Ejemplo n.º 1
0
 public static void CommandListener(CommandSentEvent e)
 {
     Command.Handler.CommandFunc f;
     if (Command.Handler.ModCommands.TryGetValue(e[0], out f))
     {
         e.IsCancelled = true;
         try
         {
             e.Disconnects = f(e.OS, e.Arguments);
         }
         catch (Exception ex)
         {
             e.OS.Write("Command {0} threw Exception:\n    {1}('{2}')", e.Arguments[0], ex.GetType().FullName, ex.Message);
             throw;
         }
     }
 }
Ejemplo n.º 2
0
        private FTPResponse SendCommand(string Command, bool CheckConnection)
        {
            // make sure we're connected
            if (CheckConnection)
            {
                CheckConnect();
            }

            // encode the command
            byte[] bytes = Encoding.ASCII.GetBytes((Command + "\r\n").ToCharArray());

            // send it
            m_cmdsocket.Send(bytes, bytes.Length, 0);

            if (CommandSentEvent != null)
            {
                foreach (FTPCommandHandler ch in CommandSentEvent.GetInvocationList())
                {
                    ch(Command);
                }
            }

            return(ReadResponse());
        }
Ejemplo n.º 3
0
 public static void OverrideCommands(CommandSentEvent e)
 {
     if (e[0].ToLower() == "probe" || e[0].ToLower() == "nmap")
     {
         e.IsCancelled = true;
         e.StateChange = CommandDisplayStateChange.Probe;
         var os = e.OS;
         int i;
         var c = os.GetCurrentComputer();
         os.WriteLine("Probing {0}...\n", c.ip);
         for (i = 0; i < 10; i++)
         {
             Thread.Sleep(80);
             os.WriteAppend(".");
         }
         os.WriteLine("\nProbe Complete - Open ports:\n").WriteLine("---------------------------------");
         if (Port.Instance.compToInst.ContainsKey(c))
         {
             foreach (var ins in Port.Instance.compToInst[c])
             {
                 os.WriteLine("Port#: {0} - {1}{2}", ins.Port.PortDisplay, ins.Port.PortName, (ins.Unlocked ? "OPEN" : ""));
                 Thread.Sleep(120);
             }
         }
         for (i = 0; i < c.ports.Count; i++)
         {
             os.WriteLine("Port#: {0} - {1}{2}", c.GetDisplayPortNumberFromCodePort(c.ports[i]),
                          PortExploits.services[c.ports[i]],
                          (c.portsOpen[i] > 0 ? " : OPEN" : ""));
             Thread.Sleep(120);
         }
         os.WriteLine("---------------------------------")
         .WriteLine("Open Ports Required for Crack : {0}", Math.Max(c.portsNeededForCrack + 1, 0));
         if (c.hasProxy)
         {
             os.WriteLine("Proxy Detected : {0}", (c.proxyActive ? "ACTIVE" : "INACTIVE"));
         }
         if (c.firewall != null)
         {
             os.WriteLine("Firewall Detected : {0}", (c.firewall.solved ? "SOLVED" : "ACTIVE"));
         }
     }
     if (e[0].ToLower() == "help" || e[0].ToLower() == "man" || e[0] == "?")
     {
         e.IsCancelled = true;
         int page = 0;
         if (e.Arguments.Count > 1)
         {
             try
             {
                 page = Convert.ToInt32(e[1]);
                 if (page > Command.Help.PageCount)
                 {
                     e.OS.WriteLine("Invalid Page Number - Displaying First Page");
                     page = 0;
                 }
             }
             catch (FormatException)
             {
                 e.OS.WriteLine("Invalid Page Number");
             }
             catch (OverflowException)
             {
                 e.OS.WriteLine("Invalid Page Number");
             }
         }
         e.OS.WriteLine(Command.Help.GetPageString(page));
         e.Disconnects = false;
     }
     if (e[0] == "exe")
     {
         e.IsCancelled = true;
         e.Disconnects = false;
         var os     = e.OS;
         var folder = os.thisComputer.files.root.searchForFolder("bin");
         os.write("Available Executables:\n");
         os.write("PortHack");
         os.write("ForkBomb");
         os.write("Shell");
         os.write("Tutorial");
         foreach (var file in folder.files)
         {
             bool alreadyHandled = false;
             var  name           = file.name.Contains(".") ? file.name.Remove(file.name.LastIndexOf('.')) : file.name;
             foreach (var num in PortExploits.exeNums)
             {
                 if (file.data == PortExploits.crackExeData[num] ||
                     file.data == PortExploits.crackExeDataLocalRNG[num])
                 {
                     os.write(name);
                     alreadyHandled = true;
                     break;
                 }
             }
             if (!alreadyHandled && Executable.Handler.IsFileDataForModExe(file.data))
             {
                 os.write(name);
             }
         }
         os.write(" ");
     }
 }
Ejemplo n.º 4
0
 public static void OverrideFirstTimeInit(CommandSentEvent e)
 {
     if (Extension.Handler.ActiveInfo != null &&
         e[0] == "FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj")
     {
         var os    = e.OS;
         var num   = Settings.isConventionDemo ? 80 : 200;
         var num2  = Settings.isConventionDemo ? 150 : 300;
         var doTut = e[1] == "StartTutorial";
         if (doTut)
         {
             os.display.visible    = false;
             os.ram.visible        = false;
             os.netMap.visible     = false;
             os.terminal.visible   = true;
             os.mailicon.isEnabled = false;
             if (os.hubServerAlertsIcon != null)
             {
                 os.hubServerAlertsIcon.IsEnabled = false;
             }
         }
         if (Settings.debugCommandsEnabled && GuiData.getKeyboadState().IsKeyDown(Keys.LeftAlt))
         {
             num2 = (num = 1);
         }
         Programs.typeOut("Initializing .", os, 50);
         Programs.doDots(7, num + 100, os);
         Programs.typeOut("Loading modules.", os, 50);
         Programs.doDots(5, num, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         Programs.typeOut("Loading nodes.", os, 50);
         Programs.doDots(5, num, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         Programs.typeOut("Reticulating splines.", os, 50);
         Programs.doDots(5, num - 50, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         if (os.crashModule.BootLoadErrors.Length > 0)
         {
             Programs.typeOut("\n------ " + LocaleTerms.Loc("BOOT ERRORS DETECTED") + " ------", os, 50);
             Utility.HaltThread(200);
             var array = os.crashModule.BootLoadErrors.Split(Utils.newlineDelim, StringSplitOptions.RemoveEmptyEntries);
             for (int i = 0; i < array.Length; i++)
             {
                 Programs.typeOut(array[i], os, 50);
                 Utility.HaltThread(100, true);
             }
             Programs.typeOut("---------------------------------\n", os, 50);
             Utility.HaltThread(200, true);
         }
         Programs.typeOut("\n--Initialization Complete--\n", os, 50);
         GuiData.getFilteredKeys();
         os.inputEnabled = true;
         Utility.HaltThread(num2 + 100);
         if (!doTut)
         {
             Programs.typeOut(LocaleTerms.Loc("For A Command List, type \"help\""), os, 50);
             Utility.HaltThread(num2 + 100);
         }
         os.write("");
         Utility.HaltThread(num2);
         os.write("");
         Utility.HaltThread(num2);
         os.write("");
         Utility.HaltThread(num2);
         os.write("\n");
         if (doTut)
         {
             os.write(LocaleTerms.Loc("Launching Tutorial..."));
             os.launchExecutable("Tutorial.exe", PortExploits.crackExeData[1], -1, null, null);
             Settings.initShowsTutorial = false;
             AdvancedTutorial advancedTutorial = null;
             for (int i = 0; i < os.exes.Count; i++)
             {
                 advancedTutorial = (os.exes[i] as AdvancedTutorial);
                 if (advancedTutorial != null)
                 {
                     break;
                 }
             }
             if (advancedTutorial != null)
             {
                 advancedTutorial.CanActivateFirstStep = false;
             }
             int num3 = 100;
             for (int i = 0; i < num3; i++)
             {
                 double num4 = (double)i / num3;
                 if (Utils.random.NextDouble() < num4)
                 {
                     os.ram.visible      = true;
                     os.netMap.visible   = false;
                     os.terminal.visible = false;
                 }
                 else
                 {
                     os.ram.visible      = false;
                     os.netMap.visible   = false;
                     os.terminal.visible = true;
                 }
                 Utility.HaltThread(16, true);
             }
             os.ram.visible      = true;
             os.netMap.visible   = false;
             os.terminal.visible = false;
             if (advancedTutorial != null)
             {
                 advancedTutorial.CanActivateFirstStep = true;
             }
         }
         else
         {
             os.runCommand("connect " + os.thisComputer.ip);
             if (doTut && !OS.WillLoadSave && !os.Flags.HasFlag("ExtensionFirstBootComplete"))
             {
                 ExtensionLoader.SendStartingEmailForActiveExtensionNextFrame(os);
                 float num5 = 2.2f;
                 var   num3 = (int)(60f * num5);
                 for (int i = 0; i < num3; i++)
                 {
                     double num4 = (double)i / num3;
                     os.ram.visible     = (Utils.random.NextDouble() < num4);
                     os.netMap.visible  = (Utils.random.NextDouble() < num4);
                     os.display.visible = (Utils.random.NextDouble() < num4);
                     Utility.HaltThread(16, true);
                 }
                 os.terminal.visible    = true;
                 os.display.visible     = true;
                 os.netMap.visible      = true;
                 os.ram.visible         = true;
                 os.terminal.visible    = true;
                 os.display.inputLocked = false;
                 os.netMap.inputLocked  = false;
                 os.ram.inputLocked     = false;
                 os.Flags.AddFlag("ExtensionFirstBootComplete");
             }
         }
         Utility.HaltThread(500, true);
         if (wasRecursed)
         {
             os.ram.visible         = true;
             os.ram.inputLocked     = false;
             os.display.visible     = true;
             os.display.inputLocked = false;
             os.netMap.visible      = true;
             os.netMap.inputLocked  = false;
         }
         else if (doTut)
         {
             os.ram.visible         = true;
             os.ram.inputLocked     = false;
             os.display.visible     = true;
             os.display.inputLocked = false;
             os.netMap.visible      = true;
             os.netMap.inputLocked  = false;
         }
         else if (!os.ram.visible)
         {
             wasRecursed = true;
             OverrideFirstTimeInit(e);
         }
     }
 }
Ejemplo n.º 5
0
 public static void CommandListener(CommandSentEvent e)
 {
     Logger.Info("command {0}", string.Join(" ", e.Arguments));
 }