Exemplo n.º 1
0
 private void InitializeFiles(string filename)
 {
     this.targetComputer = this.os.thisComputer;
     if (this.os.connectedComp != null)
     {
         this.targetComputer = this.os.connectedComp;
     }
     this.destFolder     = Programs.getCurrentFolder(this.os);
     this.targetFilename = filename;
     this.destFilename   = filename.Replace(".dec", "[NUMBER][EXT]");
 }
Exemplo n.º 2
0
 public MemoryForensicsExe(Rectangle location, OS operatingSystem, string[] p)
     : base(location, operatingSystem)
 {
     this.needsProxyAccess = false;
     this.name             = "MemForensics";
     this.ramCost          = 300;
     this.IdentifierName   = "MemForensics";
     if (p.Length <= 1)
     {
         this.ErrorMessage = "No file specified.";
         this.State        = MemoryForensicsExe.MemForensicsState.Error;
     }
     else
     {
         this.LoadFile(p[1], Programs.getCurrentFolder(this.os));
     }
     this.DisplayOverrideIsActive = true;
 }
Exemplo n.º 3
0
 public static MemoryForensicsExe GenerateInstanceOrNullFromArguments(Rectangle location, OS os, string[] p)
 {
     for (int index = 0; index < os.exes.Count; ++index)
     {
         MemoryForensicsExe ex = os.exes[index] as MemoryForensicsExe;
         if (ex != null)
         {
             if (p.Length > 1)
             {
                 ex.LoadFile(p[1], Programs.getCurrentFolder(os));
             }
             else
             {
                 ex.State = MemoryForensicsExe.MemForensicsState.SelectingFile;
                 ex.timeInCurrentState = 0.0f;
             }
             return((MemoryForensicsExe)null);
         }
     }
     return(new MemoryForensicsExe(location, os, p));
 }
Exemplo n.º 4
0
        private void DrawListing(Rectangle dest, SpriteBatch sb)
        {
            this.DrawHeaders(dest, sb);
            if (this.isExiting)
            {
                return;
            }
            Vector2 pos = new Vector2((float)(dest.X + 2), (float)dest.Y + 60f);

            TextItem.doFontLabel(pos, LocaleTerms.Loc("Remote"), GuiData.smallfont, new Color?(this.themeColor), (float)(this.bounds.Width - 20), 20f, false);
            pos.Y += 18f;
            sb.Draw(Utils.white, new Rectangle(this.bounds.X + 2, (int)pos.Y, this.bounds.Width - 6, 1), Utils.AddativeWhite);
            List <string> stringList1   = new List <string>();
            Folder        currentFolder = Programs.getCurrentFolder(this.os);

            for (int index = 0; index < currentFolder.files.Count; ++index)
            {
                if (ThemeManager.getThemeForDataString(currentFolder.files[index].data) != OSTheme.TerminalOnlyBlack)
                {
                    stringList1.Add(currentFolder.files[index].name);
                }
            }
            string    str = (string)null;
            string    selectedFileData = (string)null;
            Color     color            = Color.Lerp(this.os.topBarColor, Utils.AddativeWhite, 0.2f);
            int       scrollOffset     = SelectableTextList.scrollOffset;
            Rectangle rectangle1       = new Rectangle((int)pos.X, (int)pos.Y, this.bounds.Width - 6, 54);

            if (stringList1.Count > 0)
            {
                SelectableTextList.scrollOffset = this.remoteScroll;
                this.remotesSelected            = SelectableTextList.doFancyList(8139191 + this.PID, rectangle1.X, rectangle1.Y, rectangle1.Width, rectangle1.Height, stringList1.ToArray(), this.remotesSelected, new Color?(color), true);
                if (SelectableTextList.selectionWasChanged)
                {
                    this.localsSelected = -1;
                }
                this.remoteScroll = SelectableTextList.scrollOffset;
                if (this.remotesSelected >= 0)
                {
                    if (this.remotesSelected >= stringList1.Count)
                    {
                        this.remotesSelected = -1;
                    }
                    else
                    {
                        str = stringList1[this.remotesSelected];
                        selectedFileData = currentFolder.searchForFile(str).data;
                    }
                }
            }
            else
            {
                sb.Draw(Utils.white, rectangle1, Utils.VeryDarkGray);
                TextItem.doFontLabelToSize(rectangle1, "    -- " + LocaleTerms.Loc("No Valid Files") + " --    ", GuiData.smallfont, Utils.AddativeWhite, false, false);
            }
            pos.Y += (float)(rectangle1.Height + 6);
            TextItem.doFontLabel(pos, LocaleTerms.Loc("Local Theme Files"), GuiData.smallfont, new Color?(this.themeColor), (float)(this.bounds.Width - 20), 20f, false);
            pos.Y += 18f;
            sb.Draw(Utils.white, new Rectangle(this.bounds.X + 2, (int)pos.Y, this.bounds.Width - 6, 1), Utils.AddativeWhite);
            stringList1.Clear();
            List <string> stringList2 = new List <string>();
            Folder        folder1     = this.os.thisComputer.files.root.searchForFolder("sys");

            for (int index = 0; index < folder1.files.Count; ++index)
            {
                if (ThemeManager.getThemeForDataString(folder1.files[index].data) != OSTheme.TerminalOnlyBlack)
                {
                    stringList1.Add(folder1.files[index].name);
                    stringList2.Add(folder1.files[index].data);
                }
            }
            Folder folder2 = this.os.thisComputer.files.root.searchForFolder("home");

            for (int index = 0; index < folder2.files.Count; ++index)
            {
                if (ThemeManager.getThemeForDataString(folder2.files[index].data) != OSTheme.TerminalOnlyBlack)
                {
                    stringList1.Add(folder2.files[index].name);
                    stringList2.Add(folder2.files[index].data);
                }
            }
            Rectangle rectangle2 = new Rectangle((int)pos.X, (int)pos.Y, this.bounds.Width - 6, 72);

            if (stringList1.Count > 0)
            {
                SelectableTextList.scrollOffset = this.localScroll;
                this.localsSelected             = SelectableTextList.doFancyList(839192 + this.PID, rectangle2.X, rectangle2.Y, rectangle2.Width, rectangle2.Height, stringList1.ToArray(), this.localsSelected, new Color?(color), true);
                if (SelectableTextList.selectionWasChanged)
                {
                    this.remotesSelected = -1;
                }
                this.localScroll = SelectableTextList.scrollOffset;
                if (this.localsSelected >= 0)
                {
                    str = stringList1[this.localsSelected];
                    selectedFileData = stringList2[this.localsSelected];
                }
            }
            else
            {
                sb.Draw(Utils.white, rectangle2, Utils.VeryDarkGray);
                TextItem.doFontLabelToSize(rectangle2, "    -- " + LocaleTerms.Loc("No Valid Files") + " --    ", GuiData.smallfont, Utils.AddativeWhite, false, false);
            }
            SelectableTextList.scrollOffset = scrollOffset;
            pos.Y += (float)(rectangle2.Height + 2);
            Rectangle bounds = new Rectangle(this.bounds.X + 4, (int)pos.Y + 2, this.bounds.Width - 8, (int)((double)dest.Height - ((double)pos.Y - (double)dest.Y)) - 4);

            this.DrawApplyField(str, selectedFileData, bounds, sb);
        }
Exemplo n.º 5
0
        private void DrawListing(Rectangle dest, SpriteBatch sb)
        {
            DrawHeaders(dest, sb);
            if (isExiting)
            {
                return;
            }
            var pos = new Vector2(dest.X + 2, dest.Y + 60f);

            TextItem.doFontLabel(pos, "Remote", GuiData.smallfont, themeColor, this.bounds.Width - 20, 20f);
            pos.Y += 18f;
            sb.Draw(Utils.white, new Rectangle(this.bounds.X + 2, (int)pos.Y, this.bounds.Width - 6, 1),
                    Utils.AddativeWhite);
            var list1         = new List <string>();
            var currentFolder = Programs.getCurrentFolder(os);

            for (var index = 0; index < currentFolder.files.Count; ++index)
            {
                if (ThemeManager.getThemeForDataString(currentFolder.files[index].data) != OSTheme.TerminalOnlyBlack)
                {
                    list1.Add(currentFolder.files[index].name);
                }
            }
            string str = null;
            string selectedFileData = null;
            var    color            = Color.Lerp(os.topBarColor, Utils.AddativeWhite, 0.2f);
            var    num        = SelectableTextList.scrollOffset;
            var    rectangle1 = new Rectangle((int)pos.X, (int)pos.Y, this.bounds.Width - 6, 54);

            if (list1.Count > 0)
            {
                SelectableTextList.scrollOffset = remoteScroll;
                remotesSelected = SelectableTextList.doFancyList(8139191 + PID, rectangle1.X, rectangle1.Y,
                                                                 rectangle1.Width, rectangle1.Height, list1.ToArray(), remotesSelected, color, true);
                if (SelectableTextList.selectionWasChanged)
                {
                    localsSelected = -1;
                }
                remoteScroll = SelectableTextList.scrollOffset;
                if (remotesSelected >= 0)
                {
                    if (remotesSelected >= list1.Count)
                    {
                        remotesSelected = -1;
                    }
                    else
                    {
                        str = list1[remotesSelected];
                        selectedFileData = currentFolder.searchForFile(str).data;
                    }
                }
            }
            else
            {
                sb.Draw(Utils.white, rectangle1, Utils.VeryDarkGray);
                TextItem.doFontLabelToSize(rectangle1, "    -- No Valid Files --    ", GuiData.smallfont,
                                           Utils.AddativeWhite);
            }
            pos.Y += rectangle1.Height + 6;
            TextItem.doFontLabel(pos, "Local Theme Files", GuiData.smallfont, themeColor, this.bounds.Width - 20, 20f);
            pos.Y += 18f;
            sb.Draw(Utils.white, new Rectangle(this.bounds.X + 2, (int)pos.Y, this.bounds.Width - 6, 1),
                    Utils.AddativeWhite);
            list1.Clear();
            var list2   = new List <string>();
            var folder1 = os.thisComputer.files.root.searchForFolder("sys");

            for (var index = 0; index < folder1.files.Count; ++index)
            {
                if (ThemeManager.getThemeForDataString(folder1.files[index].data) != OSTheme.TerminalOnlyBlack)
                {
                    list1.Add(folder1.files[index].name);
                    list2.Add(folder1.files[index].data);
                }
            }
            var folder2 = os.thisComputer.files.root.searchForFolder("home");

            for (var index = 0; index < folder2.files.Count; ++index)
            {
                if (ThemeManager.getThemeForDataString(folder2.files[index].data) != OSTheme.TerminalOnlyBlack)
                {
                    list1.Add(folder2.files[index].name);
                    list2.Add(folder2.files[index].data);
                }
            }
            var rectangle2 = new Rectangle((int)pos.X, (int)pos.Y, this.bounds.Width - 6, 72);

            if (list1.Count > 0)
            {
                SelectableTextList.scrollOffset = localScroll;
                localsSelected = SelectableTextList.doFancyList(839192 + PID, rectangle2.X, rectangle2.Y,
                                                                rectangle2.Width, rectangle2.Height, list1.ToArray(), localsSelected, color, true);
                if (SelectableTextList.selectionWasChanged)
                {
                    remotesSelected = -1;
                }
                localScroll = SelectableTextList.scrollOffset;
                if (localsSelected >= 0)
                {
                    str = list1[localsSelected];
                    selectedFileData = list2[localsSelected];
                }
            }
            else
            {
                sb.Draw(Utils.white, rectangle2, Utils.VeryDarkGray);
                TextItem.doFontLabelToSize(rectangle2, "    -- No Valid Files --    ", GuiData.smallfont,
                                           Utils.AddativeWhite);
            }
            SelectableTextList.scrollOffset = num;
            pos.Y += rectangle2.Height + 2;
            var bounds = new Rectangle(this.bounds.X + 4, (int)pos.Y + 2, this.bounds.Width - 8,
                                       (int)(dest.Height - (pos.Y - (double)dest.Y)) - 4);

            DrawApplyField(str, selectedFileData, bounds, sb);
        }
Exemplo n.º 6
0
        public void doTabComplete()
        {
            List <string> stringList1 = new List <string>();

            if (this.currentLine.Length == 0)
            {
                return;
            }
            int length1 = this.currentLine.IndexOf(' ');

            if (length1 >= 1)
            {
                string path = this.currentLine.Substring(length1 + 1);
                string str1 = this.currentLine.Substring(0, length1);
                if (str1.Equals("upload") || str1.Equals("up"))
                {
                    int length2 = path.LastIndexOf('/');
                    if (length2 < 0)
                    {
                        length2 = 0;
                    }
                    string str2 = path.Substring(0, length2) + "/";
                    if (str2.StartsWith("/"))
                    {
                        str2 = str2.Substring(1);
                    }
                    string str3   = path.Substring(length2 + (length2 == 0 ? 0 : 1));
                    Folder folder = Programs.getFolderAtPathAsFarAsPossible(path, this.os, this.os.thisComputer.files.root);
                    bool   flag   = false;
                    if (folder == this.os.thisComputer.files.root && str2.Length > 1)
                    {
                        flag = true;
                    }
                    if (folder == null)
                    {
                        folder = this.os.thisComputer.files.root;
                    }
                    if (!flag)
                    {
                        for (int index = 0; index < folder.folders.Count; ++index)
                        {
                            if (folder.folders[index].name.ToLower().StartsWith(str3.ToLower(), StringComparison.InvariantCultureIgnoreCase))
                            {
                                stringList1.Add(str1 + " " + str2 + folder.folders[index].name + "/");
                            }
                        }
                        for (int index = 0; index < folder.files.Count; ++index)
                        {
                            if (folder.files[index].name.ToLower().StartsWith(str3.ToLower()))
                            {
                                stringList1.Add(str1 + " " + str2 + folder.files[index].name);
                            }
                        }
                    }
                }
                else
                {
                    if (path == null || (path.Equals("") || path.Length < 1) && !str1.Equals("exe"))
                    {
                        return;
                    }
                    Folder currentFolder = Programs.getCurrentFolder(this.os);
                    for (int index = 0; index < currentFolder.folders.Count; ++index)
                    {
                        if (currentFolder.folders[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                        {
                            stringList1.Add(str1 + " " + currentFolder.folders[index].name + "/");
                        }
                    }
                    for (int index = 0; index < currentFolder.files.Count; ++index)
                    {
                        if (currentFolder.files[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                        {
                            stringList1.Add(str1 + " " + currentFolder.files[index].name);
                        }
                    }
                    if (stringList1.Count == 0)
                    {
                        for (int index = 0; index < currentFolder.files.Count; ++index)
                        {
                            if (currentFolder.files[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                            {
                                stringList1.Add(str1 + " " + currentFolder.files[index].name);
                            }
                        }
                    }
                }
            }
            else
            {
                List <string> stringList2 = new List <string>();
                stringList2.AddRange((IEnumerable <string>)ProgramList.programs);
                stringList2.AddRange((IEnumerable <string>)ProgramList.getExeList(this.os));
                for (int index = 0; index < stringList2.Count; ++index)
                {
                    if (stringList2[index].ToLower().StartsWith(this.currentLine.ToLower()))
                    {
                        stringList1.Add(stringList2[index]);
                    }
                }
            }
            if (stringList1.Count == 1)
            {
                this.currentLine = stringList1[0];
                TextBox.moveCursorToEnd(this.currentLine);
            }
            else
            {
                if (stringList1.Count <= 1)
                {
                    return;
                }
                this.os.write(this.prompt + this.currentLine);
                string str = stringList1[0];
                for (int index = 0; index < stringList1.Count; ++index)
                {
                    this.os.write(stringList1[index]);
                    for (int length2 = 0; length2 < str.Length; ++length2)
                    {
                        if (stringList1[index].Length <= length2 || (int)string.Concat((object)str[length2]).ToLowerInvariant()[0] != (int)string.Concat((object)stringList1[index][length2]).ToLowerInvariant()[0])
                        {
                            str = str.Substring(0, length2);
                            break;
                        }
                    }
                    this.currentLine = str;
                    TextBox.moveCursorToEnd(this.currentLine);
                }
            }
        }
Exemplo n.º 7
0
        public static bool ExecuteProgram(object os_object, string[] arguments)
        {
            var os       = (OS)os_object;
            var strArray = arguments;
            var flag1    = true;

            if (strArray[0].Equals("connect"))
            {
                Programs.connect(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("disconnect") || strArray[0].Equals("dc"))
            {
                Programs.disconnect(strArray, os);
            }
            else if (strArray[0].Equals("ls") || strArray[0].Equals("dir"))
            {
                Programs.ls(strArray, os);
            }
            else if (strArray[0].Equals("cd"))
            {
                Programs.cd(strArray, os);
            }
            else if (strArray[0].Equals("cd.."))
            {
                strArray = new string[2]
                {
                    "cd",
                    ".."
                };
                Programs.cd(strArray, os);
            }
            else if (strArray[0].Equals("cat") || strArray[0].Equals("less"))
            {
                Programs.cat(strArray, os);
            }
            else if (strArray[0].Equals("exe"))
            {
                Programs.execute(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("probe") || strArray[0].Equals("nmap"))
            {
                Programs.probe(strArray, os);
            }
            else if (strArray[0].Equals("scp"))
            {
                Programs.scp(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("scan"))
            {
                Programs.scan(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("rm"))
            {
                Programs.rm(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("mv"))
            {
                Programs.mv(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("ps"))
            {
                Programs.ps(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("kill"))
            {
                Programs.kill(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("reboot"))
            {
                Programs.reboot(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("openCDTray"))
            {
                Programs.opCDTray(strArray, os, true);
                flag1 = false;
            }
            else if (strArray[0].Equals("closeCDTray"))
            {
                Programs.opCDTray(strArray, os, false);
                flag1 = false;
            }
            else if (strArray[0].Equals("replace"))
            {
                Programs.replace2(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("analyze"))
            {
                Programs.analyze(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("solve"))
            {
                Programs.solve(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("clear"))
            {
                Programs.clear(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("upload") || strArray[0].Equals("up"))
            {
                Programs.upload(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("login"))
            {
                Programs.login(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("addnote"))
            {
                Programs.addNote(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals(":(){:|:&};:"))
            {
                ExecuteProgram(os, new string[1]
                {
                    "forkbomb"
                });
            }
            else if (strArray[0].Equals("append"))
            {
                var fileEntry1 = Programs.getCurrentFolder(os).searchForFile(strArray[1]);
                if (fileEntry1 != null)
                {
                    var str1 = "";
                    for (var index = 2; index < strArray.Length; ++index)
                    {
                        str1 = str1 + strArray[index] + " ";
                    }
                    var fileEntry2 = fileEntry1;
                    var str2       = fileEntry2.data + "\n" + str1;
                    fileEntry2.data = str2;
                    flag1           = true;
                    strArray[0]     = "cat";
                    for (var index = 2; index < strArray.Length; ++index)
                    {
                        strArray[index] = "";
                    }
                    Programs.cat(strArray, os);
                }
            }
            else if (strArray[0].Equals("remline"))
            {
                var fileEntry = Programs.getCurrentFolder(os).searchForFile(strArray[1]);
                if (fileEntry != null)
                {
                    var length = fileEntry.data.LastIndexOf('\n');
                    if (length < 0)
                    {
                        length = 0;
                    }
                    fileEntry.data = fileEntry.data.Substring(0, length);
                    flag1          = true;
                    strArray[0]    = "cat";
                    for (var index = 2; index < strArray.Length; ++index)
                    {
                        strArray[index] = "";
                    }
                    Programs.cat(strArray, os);
                }
            }
            else if (strArray[0].Equals("getString"))
            {
                Programs.getString(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj"))
            {
                Programs.firstTimeInit(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("chat"))
            {
                var message = "chat " + os.username + " ";
                for (var index = 1; index < strArray.Length; ++index)
                {
                    message = message + strArray[index] + " ";
                }
                if (os.multiplayer)
                {
                    os.sendMessage(message);
                }
                flag1 = false;
            }
            else if ((strArray[0].Equals("exitdemo") || strArray[0].Equals("resetdemo")) && Settings.isDemoMode)
            {
                MusicManager.transitionToSong("Music/Ambient/AmbientDrone_Clipped");
                var mainMenu = new MainMenu();
                os.ScreenManager.AddScreen(mainMenu);
                MainMenu.resetOS();
                os.ExitScreen();
                flag1 = false;
            }
            else if (strArray[0].Equals("fh") && OS.DEBUG_COMMANDS)
            {
                Programs.fastHack(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("ra") && OS.DEBUG_COMMANDS)
            {
                Programs.revealAll(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("deathseq") && OS.DEBUG_COMMANDS)
            {
                os.TraceDangerSequence.BeginTraceDangerSequence();
                flag1 = false;
            }
            else if (strArray[0].Equals("testcredits") && OS.DEBUG_COMMANDS)
            {
                os.endingSequence.IsActive = true;
                flag1 = false;
            }
            else if (strArray[0].Equals("addflag") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length < 2)
                {
                    os.write("\nFlag to add required\n");
                }
                os.Flags.AddFlag(strArray[1]);
                flag1 = false;
            }
            else if (strArray[0].Equals("addTestEmails") && OS.DEBUG_COMMANDS)
            {
                for (var index = 0; index < 4; ++index)
                {
                    ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(
                        MailServer.generateEmail(
                            string.Concat("testEmail ", index, " ", Utils.getRandomByte().ToString()), "test", "test"),
                        os.defaultUser.name);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("dscan") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length < 2)
                {
                    os.write("\nNode ID Required\n");
                }
                var flag2 = false;
                for (var index = 0; index < os.netMap.nodes.Count; ++index)
                {
                    if (os.netMap.nodes[index].idName.StartsWith(strArray[1]))
                    {
                        os.netMap.discoverNode(os.netMap.nodes[index]);
                        os.netMap.nodes[index].highlightFlashTime = 1f;
                        flag2 = true;
                        break;
                    }
                }
                if (!flag2)
                {
                    os.write("Node ID Not found");
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("testsave") && OS.DEBUG_COMMANDS ||
                     strArray[0].Equals("save!(SJN!*SNL8vAewew57WewJdwl89(*4;;;&!)@&(ak'^&#@J3KH@!*"))
            {
                os.threadedSaveExecute();
                SettingsLoader.writeStatusFile();
                flag1 = false;
            }
            else if (strArray[0].Equals("testload") && OS.DEBUG_COMMANDS)
            {
                flag1 = false;
            }
            else if (strArray[0].Equals("debug") && OS.DEBUG_COMMANDS)
            {
                var num = PortExploits.services.Count;
                if (strArray.Length > 1)
                {
                    try
                    {
                        num = Convert.ToInt32(strArray[1]);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                for (var index = 0; index < PortExploits.services.Count && index < num; ++index)
                {
                    os.thisComputer.files.root.folders[2].files.Add(
                        new FileEntry(PortExploits.crackExeData[PortExploits.portNums[index]],
                                      PortExploits.cracks[PortExploits.portNums[index]]));
                }
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[9],
                                                                              PortExploits.cracks[9]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[10],
                                                                              PortExploits.cracks[10]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[11],
                                                                              PortExploits.cracks[11]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[12],
                                                                              PortExploits.cracks[12]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[13],
                                                                              PortExploits.cracks[13]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[14],
                                                                              PortExploits.cracks[14]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[15],
                                                                              PortExploits.cracks[15]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[16],
                                                                              PortExploits.cracks[16]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[17],
                                                                              PortExploits.cracks[17]));
                os.thisComputer.files.root.folders[2].files.Add(
                    new FileEntry(PortExploits.DangerousPacemakerFirmware, "KBT_TestFirmware.dll"));
                os.Flags.AddFlag("dechead");
                os.Flags.AddFlag("decypher");
                os.Flags.AddFlag("csecBitSet01Complete");
                os.Flags.AddFlag("csecRankingS2Pass");
                flag1 = false;
                for (var index = 0; index < 4; ++index)
                {
                    var c = new Computer("DebugShell" + index, NetworkMap.generateRandomIP(),
                                         os.netMap.getRandomPosition(), 0, 2, os);
                    c.adminIP = os.thisComputer.adminIP;
                    os.netMap.nodes.Add(c);
                    os.netMap.discoverNode(c);
                }
                os.netMap.discoverNode("practiceServer");
                os.netMap.discoverNode("entropy00");
            }
            else if (strArray[0].Equals("flash") && OS.DEBUG_COMMANDS)
            {
                os.traceTracker.start(20f);
                os.warningFlash();
                flag1 = false;
                os.IncConnectionOverlay.Activate();
            }
            else if (strArray[0].Equals("testRevealNodes") && OS.DEBUG_COMMANDS)
            {
                for (var index = 0; index < os.netMap.nodes.Count; ++index)
                {
                    if (Utils.random.NextDouble() < 0.01)
                    {
                        os.netMap.discoverNode(os.netMap.nodes[index]);
                    }
                }
            }
            else if (strArray[0].Equals("dectest") && OS.DEBUG_COMMANDS)
            {
                var str1 = "this is a test message for the encrypter";
                var str2 = FileEncrypter.EncryptString(str1, "header message", "1.2.3.4.5",
                                                       "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongpass", null);
                os.write(str1);
                os.write("  ");
                os.write("  ");
                os.write(str2);
                os.write("  ");
                os.write("  ");
                os.write(
                    FileEncrypter.MakeReplacementsForDisplay(
                        FileEncrypter.DecryptString(str2,
                                                    "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongpass")[2]));
                os.write("  ");
                os.write(
                    FileEncrypter.MakeReplacementsForDisplay(FileEncrypter.DecryptString(str2, "wrongPass")[2] ==
                                                             null
                        ? "NULL"
                        : "CORRECT"));
                os.write("  ");
            }
            else if (strArray[0].Equals("test") && OS.DEBUG_COMMANDS)
            {
                HackerScriptExecuter.runScript("ThemeHack.txt", os);
            }
            else if (strArray[0].Equals("MotIsTheBest") && OS.DEBUG_COMMANDS)
            {
                os.runCommand("probe");
                os.runCommand("exe WebServerWorm 80");
                os.runCommand("exe SSHcrack 22");
                os.runCommand("exe SMTPoverflow 25");
                os.runCommand("exe FTPBounce 21");
            }
            else if (strArray[0].Equals("help") || strArray[0].Equals("Help") ||
                     (strArray[0].Equals("?") || strArray[0].Equals("man")))
            {
                var page = 0;
                if (strArray.Length > 1)
                {
                    try
                    {
                        page = Convert.ToInt32(strArray[1]);
                        if (page > Helpfile.getNumberOfPages())
                        {
                            os.write("Invalid Page Number - Displaying First Page");
                            page = 0;
                        }
                    }
                    catch (FormatException ex)
                    {
                        os.write("Invalid Page Number");
                    }
                    catch (OverflowException ex)
                    {
                        os.write("Invalid Page Number");
                    }
                }
                Helpfile.writeHelp(os, page);
                flag1 = false;
            }
            else
            {
                if (strArray[0] != "")
                {
                    var num = AttemptExeProgramExecution(os, strArray);
                    if (num == 0)
                    {
                        os.write("Execution failed");
                    }
                    else if (num < 0)
                    {
                        os.write("No Command " + strArray[0] + " - Check Syntax\n");
                    }
                }
                flag1 = false;
            }
            if (flag1)
            {
                if (!os.commandInvalid)
                {
                    os.display.command     = strArray[0];
                    os.display.commandArgs = strArray;
                    os.display.typeChanged();
                }
                else
                {
                    os.commandInvalid = false;
                }
            }
            return(flag1);
        }
Exemplo n.º 8
0
        public static bool ExecuteProgram(object os_object, string[] arguments)
        {
            OS os = (OS)os_object;

            string[] strArray = arguments;
            bool     flag1    = true;

            if (strArray[0].ToLower().Equals("connect"))
            {
                Programs.connect(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("disconnect") || strArray[0].Equals("dc"))
            {
                Programs.disconnect(strArray, os);
            }
            else if (strArray[0].Equals("ls") || strArray[0].Equals("dir"))
            {
                Programs.ls(strArray, os);
            }
            else if (strArray[0].Equals("cd"))
            {
                Programs.cd(strArray, os);
            }
            else if (strArray[0].Equals("cd.."))
            {
                strArray = new string[2] {
                    "cd", ".."
                };
                Programs.cd(strArray, os);
            }
            else if (strArray[0].Equals("cat") || strArray[0].Equals("more") || strArray[0].Equals("less"))
            {
                Programs.cat(strArray, os);
            }
            else if (strArray[0].Equals("exe"))
            {
                Programs.execute(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("probe") || strArray[0].Equals("nmap"))
            {
                Programs.probe(strArray, os);
            }
            else if (strArray[0].Equals("scp"))
            {
                Programs.scp(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("scan"))
            {
                Programs.scan(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("rm") || strArray[0].Equals("del"))
            {
                Programs.rm(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("mv"))
            {
                Programs.mv(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("ps"))
            {
                Programs.ps(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("kill") || strArray[0].Equals("pkill"))
            {
                Programs.kill(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("reboot"))
            {
                Programs.reboot(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("opencdtray"))
            {
                Programs.opCDTray(strArray, os, true);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("closecdtray"))
            {
                Programs.opCDTray(strArray, os, false);
                flag1 = false;
            }
            else if (strArray[0].Equals("replace"))
            {
                Programs.replace2(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("analyze"))
            {
                Programs.analyze(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("solve"))
            {
                Programs.solve(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("clear"))
            {
                Programs.clear(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("upload") || strArray[0].Equals("up"))
            {
                Programs.upload(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("login"))
            {
                Programs.login(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("addnote"))
            {
                Programs.addNote(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals(":(){:|:&};:"))
            {
                ProgramRunner.ExecuteProgram((object)os, new string[1]
                {
                    "forkbomb"
                });
            }
            else if (strArray[0].ToLower().Equals("append"))
            {
                flag1 = false;
                string[] quoteSeperatedArgs = Utils.GetQuoteSeperatedArgs(strArray);
                Folder   currentFolder      = Programs.getCurrentFolder(os);
                if (quoteSeperatedArgs.Length > 1)
                {
                    FileEntry fileEntry1 = currentFolder.searchForFile(quoteSeperatedArgs[1]);
                    int       num        = 2;
                    if (fileEntry1 == null)
                    {
                        fileEntry1 = currentFolder.searchForFile(os.display.commandArgs[1]);
                        if (fileEntry1 == null)
                        {
                            os.write("Usage: append [FILENAME] [LINE TO APPEND]");
                            return(flag1);
                        }
                        os.write("No filename provided");
                        os.write("Assuming active flag file \"" + fileEntry1.name + "\" For editing");
                        if (strArray.Length == 1)
                        {
                            strArray = new string[2]
                            {
                                "append",
                                fileEntry1.name
                            }
                        }
                        ;
                        else
                        {
                            strArray[1] = fileEntry1.name;
                        }
                        num = 1;
                    }
                    if (fileEntry1 != null)
                    {
                        string str1 = "";
                        for (int index = num; index < quoteSeperatedArgs.Length; ++index)
                        {
                            str1 = str1 + quoteSeperatedArgs[index] + " ";
                        }
                        FileEntry fileEntry2 = fileEntry1;
                        string    str2       = fileEntry2.data + "\n" + str1;
                        fileEntry2.data = str2;
                        flag1           = true;
                        strArray[0]     = "cat";
                        strArray[1]     = fileEntry1.name;
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            strArray[index] = "";
                        }
                        Programs.cat(strArray, os);
                    }
                }
                else
                {
                    os.write("Usage: append [FILENAME] [LINE TO APPEND]");
                    return(flag1);
                }
            }
            else if (strArray[0].Equals("remline"))
            {
                FileEntry fileEntry = Programs.getCurrentFolder(os).searchForFile(strArray[1]);
                if (fileEntry != null)
                {
                    int length = fileEntry.data.LastIndexOf('\n');
                    if (length < 0)
                    {
                        length = 0;
                    }
                    fileEntry.data = fileEntry.data.Substring(0, length);
                    flag1          = true;
                    strArray[0]    = "cat";
                    for (int index = 2; index < strArray.Length; ++index)
                    {
                        strArray[index] = "";
                    }
                    Programs.cat(strArray, os);
                }
            }
            else if (strArray[0].Equals("getString"))
            {
                Programs.getString(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("reloadtheme"))
            {
                FileEntry fileEntry = os.thisComputer.files.root.searchForFolder("sys").searchForFile("x-server.sys");
                if (fileEntry != null)
                {
                    OSTheme themeForDataString = ThemeManager.getThemeForDataString(fileEntry.data);
                    ThemeManager.switchTheme((object)os, themeForDataString);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj"))
            {
                Programs.firstTimeInit(strArray, os, false);
                flag1 = false;
            }
            else if (strArray[0].Equals("chat"))
            {
                string message = "chat " + os.username + " ";
                for (int index = 1; index < strArray.Length; ++index)
                {
                    message = message + strArray[index] + " ";
                }
                if (os.multiplayer)
                {
                    os.sendMessage(message);
                }
                flag1 = false;
            }
            else if ((strArray[0].Equals("exitdemo") || strArray[0].Equals("resetdemo")) && Settings.isDemoMode)
            {
                MusicManager.transitionToSong("Music/Ambient/AmbientDrone_Clipped");
                MainMenu mainMenu = new MainMenu();
                os.ScreenManager.AddScreen((GameScreen)mainMenu);
                MainMenu.resetOS();
                os.ExitScreen();
                OS.currentInstance = (OS)null;
                flag1 = false;
                if (Settings.MultiLingualDemo)
                {
                    LocaleActivator.ActivateLocale("zh-cn", Game1.getSingleton().Content);
                }
            }
            else if (strArray[0].Equals("fh") && OS.DEBUG_COMMANDS)
            {
                Programs.fastHack(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("ra") && OS.DEBUG_COMMANDS)
            {
                Programs.revealAll(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("deathseq") && OS.DEBUG_COMMANDS)
            {
                os.TraceDangerSequence.BeginTraceDangerSequence();
                flag1 = false;
            }
            else if (strArray[0].Equals("testcredits") && OS.DEBUG_COMMANDS)
            {
                os.endingSequence.IsActive = true;
                flag1 = false;
            }
            else if (strArray[0].Equals("addflag") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length < 2)
                {
                    os.write("\nFlag to add required\n");
                }
                os.Flags.AddFlag(strArray[1]);
                flag1 = false;
            }
            else if (strArray[0].Equals("addTestEmails") && OS.DEBUG_COMMANDS)
            {
                for (int index = 0; index < 4; ++index)
                {
                    ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(MailServer.generateEmail("testEmail " + (object)index + " " + Utils.getRandomByte().ToString(), "test", "test"), os.defaultUser.name);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("dscan") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length < 2)
                {
                    os.write("\nNode ID Required\n");
                }
                bool flag2 = false;
                for (int index = 0; index < os.netMap.nodes.Count; ++index)
                {
                    if (os.netMap.nodes[index].idName.ToLower().StartsWith(strArray[1].ToLower()))
                    {
                        os.netMap.discoverNode(os.netMap.nodes[index]);
                        os.netMap.nodes[index].highlightFlashTime = 1f;
                        flag2 = true;
                        break;
                    }
                }
                if (!flag2)
                {
                    os.write("Node ID Not found");
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("revmany") && OS.DEBUG_COMMANDS)
            {
                for (int index1 = 0; index1 < 60; ++index1)
                {
                    int index2;
                    do
                    {
                        index2 = Utils.random.Next(os.netMap.nodes.Count);
                    }while (os.netMap.nodes[index2].idName == "mainHub" || os.netMap.nodes[index2].idName == "entropy00" || os.netMap.nodes[index2].idName == "entropy01");
                    os.netMap.discoverNode(os.netMap.nodes[index2]);
                }
                os.netMap.lastAddedNode = os.thisComputer;
                os.homeAssetServerID    = "dhsDrop";
                os.homeNodeID           = "dhs";
                os.netMap.discoverNode(Programs.getComputer(os, "dhs"));
                os.netMap.discoverNode(Programs.getComputer(os, "dhsDrop"));
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("reloadext") && OS.DEBUG_COMMANDS)
            {
                if (Settings.IsInExtensionMode)
                {
                    ExtensionLoader.ReloadExtensionNodes((object)os);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("testsave") && OS.DEBUG_COMMANDS || strArray[0].Equals("save!(SJN!*SNL8vAewew57WewJdwl89(*4;;;&!)@&(ak'^&#@J3KH@!*"))
            {
                os.threadedSaveExecute(false);
                SettingsLoader.writeStatusFile();
                flag1 = false;
            }
            else if (strArray[0].Equals("testload") && OS.DEBUG_COMMANDS)
            {
                flag1 = false;
            }
            else if (strArray[0].Equals("teststrikerhack") && OS.DEBUG_COMMANDS)
            {
                os.delayer.Post(ActionDelayer.Wait(3.0), (Action)(() => MissionFunctions.runCommand(1, "triggerDLCHackRevenge")));
                flag1 = false;
            }
            else if (strArray[0].Equals("linkToCSECPostDLC") && OS.DEBUG_COMMANDS)
            {
                os.execute("dscan mainhub");
                os.allFactions.setCurrentFaction("hub", os);
                os.currentFaction.playerValue = 2;
                os.Flags.AddFlag("dlc_complete");
                os.Flags.AddFlag("dlc_csec_end_facval:0");
                MissionFunctions.runCommand(1, "addRank");
                flag1 = false;
            }
            else if (strArray[0].Equals("debug") && OS.DEBUG_COMMANDS)
            {
                int num = PortExploits.services.Count;
                if (strArray.Length > 1)
                {
                    try
                    {
                        num = Convert.ToInt32(strArray[1]);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                for (int index = 0; index < PortExploits.services.Count && index <= num; ++index)
                {
                    os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[PortExploits.portNums[index]], PortExploits.cracks[PortExploits.portNums[index]]));
                }
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[9], PortExploits.cracks[9]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[10], PortExploits.cracks[10]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[11], PortExploits.cracks[11]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[12], PortExploits.cracks[12]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[13], PortExploits.cracks[13]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[14], PortExploits.cracks[14]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[15], PortExploits.cracks[15]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[16], PortExploits.cracks[16]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[17], PortExploits.cracks[17]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[31], PortExploits.cracks[31]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[33], PortExploits.cracks[33]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[34], PortExploits.cracks[34]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[35], PortExploits.cracks[35]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[36], PortExploits.cracks[36]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[37], PortExploits.cracks[37]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[38], PortExploits.cracks[38]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[39], PortExploits.cracks[39]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[41], PortExploits.cracks[41]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[554], PortExploits.cracks[554]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[40], PortExploits.cracks[40]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.DangerousPacemakerFirmware, "KBT_TestFirmware.dll"));
                os.Flags.AddFlag("dechead");
                os.Flags.AddFlag("decypher");
                os.Flags.AddFlag("csecBitSet01Complete");
                os.Flags.AddFlag("csecRankingS2Pass");
                os.Flags.AddFlag("CSEC_Member");
                os.Flags.AddFlag("bitPathStarted");
                flag1 = false;
                for (int index = 0; index < 4; ++index)
                {
                    Computer c = new Computer("DebugShell" + (object)index, NetworkMap.generateRandomIP(), os.netMap.getRandomPosition(), 0, (byte)2, os);
                    c.adminIP = os.thisComputer.adminIP;
                    os.netMap.nodes.Add(c);
                    os.netMap.discoverNode(c);
                }
                os.netMap.discoverNode("practiceServer");
                os.netMap.discoverNode("entropy00");
            }
            else if (strArray[0].Equals("flash") && OS.DEBUG_COMMANDS)
            {
                os.traceTracker.start(40f);
                os.warningFlash();
                flag1 = false;
                os.IncConnectionOverlay.Activate();
            }
            else if (strArray[0].Equals("cycletheme") && OS.DEBUG_COMMANDS)
            {
                Action <OSTheme> ctheme = (Action <OSTheme>)(theme => ThemeManager.switchTheme((object)os, theme));
                int    next             = 1;
                double delay            = 1.2;
                Action cthemeAct        = (Action)(() =>
                {
                    ctheme((OSTheme)next);
                    next = (next + 1) % 7;
                });
                cthemeAct += (Action)(() => os.delayer.Post(ActionDelayer.Wait(delay), cthemeAct));
                cthemeAct();
            }
            else if (strArray[0].Equals("testdlc") && OS.DEBUG_COMMANDS)
            {
                MissionFunctions.runCommand(0, "demoFinalMissionEndDLC");
                flag1 = false;
            }
            else if (strArray[0].Equals("testircentries") && OS.DEBUG_COMMANDS)
            {
                DLCHubServer daemon = Programs.getComputer(os, "dhs").getDaemon(typeof(DLCHubServer)) as DLCHubServer;
                for (int index = 0; index < 100; ++index)
                {
                    daemon.IRCSystem.AddLog("Test", "Test Message\nMultiline\nMessage", (string)null);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("testirc") && OS.DEBUG_COMMANDS)
            {
                DLCHubServer daemon = Programs.getComputer(os, "dhs").getDaemon(typeof(DLCHubServer)) as DLCHubServer;
                daemon.IRCSystem.AddLog("Test", "Test Message", (string)null);
                daemon.IRCSystem.AddLog("Channel", "Test Message\nfrom channel", (string)null);
                flag1 = false;
            }
            else if (strArray[0].Equals("flashtest") && OS.DEBUG_COMMANDS)
            {
                if (!PostProcessor.dangerModeEnabled)
                {
                    PostProcessor.dangerModeEnabled         = true;
                    PostProcessor.dangerModePercentComplete = 0.5f;
                }
                else
                {
                    PostProcessor.dangerModeEnabled         = false;
                    PostProcessor.dangerModePercentComplete = 0.0f;
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("dectest") && OS.DEBUG_COMMANDS)
            {
                string str1 = "this is a test message for the encrypter";
                string str2 = FileEncrypter.EncryptString(str1, "header message", "1.2.3.4.5", "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongpass", (string)null);
                os.write(str1);
                os.write("  ");
                os.write("  ");
                os.write(str2);
                os.write("  ");
                os.write("  ");
                os.write(FileEncrypter.MakeReplacementsForDisplay(FileEncrypter.DecryptString(str2, "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongpass")[2]));
                os.write("  ");
                os.write(FileEncrypter.MakeReplacementsForDisplay(FileEncrypter.DecryptString(str2, "wrongPass")[2] == null ? "NULL" : "CORRECT"));
                os.write("  ");
            }
            else if (strArray[0].Equals("test") && OS.DEBUG_COMMANDS)
            {
                ((DLCHubServer)Programs.getComputer(os, "dhs").getDaemon(typeof(DLCHubServer))).AddMission((ActiveMission)ComputerLoader.readMission("Content/DLC/Missions/Attack/AttackMission.xml"), (string)null, false);
            }
            else if (strArray[0].Equals("testtrace") && OS.DEBUG_COMMANDS)
            {
                MissionFunctions.runCommand(1, "triggerDLCHackRevenge");
            }
            else if (strArray[0].Equals("testboot") && OS.DEBUG_COMMANDS)
            {
                os.BootAssitanceModule.IsActive = true;
                os.bootingUp     = false;
                os.canRunContent = false;
                MusicManager.stop();
            }
            else if (strArray[0].Equals("testhhbs") && OS.DEBUG_COMMANDS)
            {
                os.write(HostileHackerBreakinSequence.IsInBlockingHostileFileState((object)os) ? "BLOCKED" : "SAFE");
            }
            else if (strArray[0].Equals("printflags") && OS.DEBUG_COMMANDS)
            {
                os.write(os.Flags.GetSaveString());
            }
            else if (strArray[0].Equals("loseadmin") && OS.DEBUG_COMMANDS)
            {
                os.connectedComp.adminIP = os.connectedComp.ip;
                flag1 = false;
            }
            else if (strArray[0].Equals("runcmd") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length > 1)
                {
                    string name = strArray[1];
                    int    num  = 0;
                    if (strArray.Length > 2)
                    {
                        num = Convert.ToInt32(strArray[1]);
                    }
                    MissionFunctions.runCommand(num, name);
                }
            }
            else if (strArray[0].ToLower().Equals("runhackscript") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length > 1)
                {
                    string scriptName = strArray[1];
                    try
                    {
                        HackerScriptExecuter.runScript(scriptName, (object)os, os.thisComputer.ip, os.thisComputer.ip);
                    }
                    catch (Exception ex)
                    {
                        os.write("Error launching script " + scriptName);
                        os.write(Utils.GenerateReportFromExceptionCompact(ex));
                    }
                }
            }
            else if (strArray[0].Equals("MotIsTheBest") && OS.DEBUG_COMMANDS)
            {
                os.runCommand("probe");
                os.runCommand("exe WebServerWorm 80");
                os.runCommand("exe SSHcrack 22");
                os.runCommand("exe SMTPoverflow 25");
                os.runCommand("exe FTPBounce 21");
            }
            else if (strArray[0].Equals("help") || strArray[0].Equals("Help") || strArray[0].Equals("?") || strArray[0].Equals("man"))
            {
                int page = 0;
                if (strArray.Length > 1)
                {
                    try
                    {
                        page = Convert.ToInt32(strArray[1]);
                        if (page > Helpfile.getNumberOfPages())
                        {
                            os.write("Invalid Page Number - Displaying First Page");
                            page = 0;
                        }
                    }
                    catch (FormatException ex)
                    {
                        os.write("Invalid Page Number");
                    }
                    catch (OverflowException ex)
                    {
                        os.write("Invalid Page Number");
                    }
                }
                Helpfile.writeHelp(os, page);
                flag1 = false;
            }
            else
            {
                if (strArray[0] != "")
                {
                    int num = ProgramRunner.AttemptExeProgramExecution(os, strArray);
                    if (num == 0)
                    {
                        os.write("Execution failed");
                    }
                    else if (num < 0)
                    {
                        os.write("No Command " + strArray[0] + " - Check Syntax\n");
                    }
                }
                flag1 = false;
            }
            if (flag1)
            {
                if (!os.commandInvalid)
                {
                    os.display.command     = strArray[0];
                    os.display.commandArgs = strArray;
                    os.display.typeChanged();
                }
                else
                {
                    os.commandInvalid = false;
                }
            }
            return(flag1);
        }
Exemplo n.º 9
0
        public void doTabComplete()
        {
            var list1 = new List <string>();

            if (currentLine.Length == 0)
            {
                return;
            }
            var length1 = currentLine.IndexOf(' ');

            if (length1 >= 1)
            {
                var path = currentLine.Substring(length1 + 1);
                var str1 = currentLine.Substring(0, length1);
                if (path == null || (path.Equals("") || path.Length < 1) && !str1.Equals("exe"))
                {
                    return;
                }
                if (str1.Equals("upload") || str1.Equals("up"))
                {
                    var length2 = path.LastIndexOf('/');
                    if (length2 < 0)
                    {
                        length2 = 0;
                    }
                    var str2 = path.Substring(0, length2) + "/";
                    if (str2.StartsWith("/"))
                    {
                        str2 = str2.Substring(1);
                    }
                    var str3   = path.Substring(length2 + (length2 == 0 ? 0 : 1));
                    var folder = Programs.getFolderAtPathAsFarAsPossible(path, os, os.thisComputer.files.root) ??
                                 os.thisComputer.files.root;
                    for (var index = 0; index < folder.folders.Count; ++index)
                    {
                        if (folder.folders[index].name.StartsWith(str3, StringComparison.InvariantCultureIgnoreCase))
                        {
                            list1.Add(str1 + " " + str2 + folder.folders[index].name + "/");
                        }
                    }
                    for (var index = 0; index < folder.files.Count; ++index)
                    {
                        if (folder.files[index].name.StartsWith(str3))
                        {
                            list1.Add(str1 + " " + str2 + folder.files[index].name);
                        }
                    }
                }
                else
                {
                    var currentFolder = Programs.getCurrentFolder(os);
                    for (var index = 0; index < currentFolder.folders.Count; ++index)
                    {
                        if (currentFolder.folders[index].name.StartsWith(path,
                                                                         StringComparison.InvariantCultureIgnoreCase))
                        {
                            list1.Add(str1 + " " + currentFolder.folders[index].name + "/");
                        }
                    }
                    for (var index = 0; index < currentFolder.files.Count; ++index)
                    {
                        if (currentFolder.files[index].name.StartsWith(path, StringComparison.InvariantCultureIgnoreCase))
                        {
                            list1.Add(str1 + " " + currentFolder.files[index].name);
                        }
                    }
                    if (list1.Count == 0)
                    {
                        for (var index = 0; index < currentFolder.files.Count; ++index)
                        {
                            if (currentFolder.files[index].name.StartsWith(path,
                                                                           StringComparison.InvariantCultureIgnoreCase))
                            {
                                list1.Add(str1 + " " + currentFolder.files[index].name);
                            }
                        }
                    }
                }
            }
            else
            {
                var list2 = new List <string>();
                list2.AddRange(ProgramList.programs);
                list2.AddRange(ProgramList.getExeList(os));
                for (var index = 0; index < list2.Count; ++index)
                {
                    if (list2[index].ToLower().StartsWith(currentLine.ToLower()))
                    {
                        list1.Add(list2[index]);
                    }
                }
            }
            if (list1.Count == 1)
            {
                currentLine = list1[0];
                TextBox.moveCursorToEnd(currentLine);
            }
            else
            {
                if (list1.Count <= 1)
                {
                    return;
                }
                os.write(prompt + currentLine);
                var str = list1[0];
                for (var index = 0; index < list1.Count; ++index)
                {
                    os.write(list1[index]);
                    for (var length2 = 0; length2 < str.Length; ++length2)
                    {
                        if (list1[index].Length <= length2 || str[length2] != list1[index][length2])
                        {
                            str = str.Substring(0, length2);
                            break;
                        }
                    }
                    currentLine = str;
                    TextBox.moveCursorToEnd(currentLine);
                }
            }
        }