Esempio n. 1
0
 private void ResetAccessPassword()
 {
     this.AdminEmailResetHasHappened = true;
     try
     {
         MailServer daemon = (MailServer)Programs.getComputer(this.os, this.adminResetEmailHostID).getDaemon(typeof(MailServer));
         string     userTo = this.adminResetPassEmailAccount;
         if (this.adminResetPassEmailAccount.Contains("@"))
         {
             userTo = this.adminResetPassEmailAccount.Substring(0, this.adminResetPassEmailAccount.IndexOf("@"));
         }
         string str = ((int)Utils.getRandomLetter()).ToString() + (object)Utils.getRandomLetter() + (object)Utils.getRandomNumberChar() + (object)Utils.getRandomLetter() + (object)Utils.getRandomNumberChar();
         this.comp.adminPass = str;
         this.comp.adminIP   = this.comp.ip;
         for (int index = 0; index < this.comp.users.Count; ++index)
         {
             if (this.comp.users[index].name.ToLower() == "admin")
             {
                 UserDetail user = this.comp.users[index];
                 user.pass = str;
                 this.comp.users[index] = user;
             }
         }
         string body = string.Format(Utils.readEntireFile("Content/DLC/Docs/DatabasePasswordResetEmail.txt"), (object)this.name, (object)str);
         daemon.addMail(MailServer.generateEmail(string.Format("{0} Password Reset", (object)this.name), body, "AdminBot"), userTo);
         this.passwordResetMessage = "Password Reset Complete";
     }
     catch (Exception ex)
     {
         this.passwordResetMessage = "CRITICAL RESET ERROR\n" + ex.ToString();
     }
 }
 private void SendReportEmail(FileMedicalRecord record, string emailAddress)
 {
     try
     {
         var mail = MailServer.generateEmail("MedicalRecord - " + record.Lastname + "_" + record.Firstname,
                                             record.ToEmailString(), "*****@*****.**");
         var userTo = emailAddress;
         if (emailAddress.Contains('@'))
         {
             userTo = emailAddress.Substring(0, emailAddress.IndexOf('@'));
         }
         var computer = Programs.getComputer(os, "jmail");
         if (computer == null)
         {
             return;
         }
         var mailServer = (MailServer)computer.getDaemon(typeof(MailServer));
         if (mailServer == null)
         {
             return;
         }
         mailServer.addMail(mail, userTo);
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 3
0
        public void addMail(string mail, string userTo)
        {
            for (int index = 0; index < this.responders.Count; ++index)
            {
                this.responders[index].mailReceived(mail, userTo);
            }
            Folder folder = (Folder)null;

            for (int index = 0; index < this.accounts.folders.Count; ++index)
            {
                if (this.accounts.folders[index].name.Equals(userTo))
                {
                    folder = this.accounts.folders[index].folders[0];
                    break;
                }
            }
            if (folder != null)
            {
                folder.files.Insert(0, new FileEntry(mail, MailServer.getSubject(mail)));
            }
            else
            {
                throw new NullReferenceException("User " + userTo + " has no valid mail account on this mail server :" + this.comp.idName + ". Check account type and name matching!");
            }
        }
Esempio n. 4
0
 public void sendEmail(OS os)
 {
     if (!this.willSendEmail)
     {
         return;
     }
     ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(MailServer.generateEmail(this.email.subject, this.email.body, this.email.sender, this.email.attachments), os.defaultUser.name);
 }
Esempio n. 5
0
        private void CompleteAndReturnToMenu()
        {
            this.os.Flags.AddFlag("Victory");
            Programs.disconnect(new string[0], this.os);
            Computer computer = Programs.getComputer(this.os, "porthackHeart");

            this.os.netMap.visibleNodes.Remove(this.os.netMap.nodes.IndexOf(computer));
            computer.disabled = true;
            computer.daemons.Clear();
            computer.ip = NetworkMap.generateRandomIP();
            this.os.terminal.inputLocked = false;
            this.os.ram.inputLocked      = false;
            this.os.netMap.inputLocked   = false;
            this.os.DisableTopBarButtons = false;
            this.os.canRunContent        = true;
            this.IsActive = false;
            ComputerLoader.loadMission("Content/Missions/CreditsMission.xml", false);
            this.os.threadedSaveExecute(false);
            MediaPlayer.IsRepeating = true;
            MusicManager.playSongImmediatley("Music\\Bit(Ending)");
            if (Settings.isPirateBuild)
            {
                this.os.delayer.Post(ActionDelayer.Wait(15.0), (Action)(() =>
                {
                    try
                    {
                        ComputerLoader.loadMission("Content/Missions/CreditsMission_p.xml", false);
                    }
                    catch (Exception ex)
                    {
                    }
                }));
            }
            if (!Settings.sendsDLC1PromoEmailAtEnd)
            {
                return;
            }
            this.os.delayer.Post(ActionDelayer.Wait(30.0), (Action)(() =>
            {
                try
                {
                    string body = Utils.readEntireFile("Content/LocPost/DLCMessage.txt");
                    string subject = "Labyrinths";
                    string sender = "Matt Trobbiani";
                    string email = MailServer.generateEmail(subject, body, sender);
                    MailServer daemon = this.os.netMap.mailServer.getDaemon(typeof(MailServer)) as MailServer;
                    if (daemon == null)
                    {
                        return;
                    }
                    daemon.addMail(email, this.os.defaultUser.name);
                }
                catch (Exception ex)
                {
                }
            }));
        }
Esempio n. 6
0
        public static string generateEmail(string subject, string body, string sender, List <string> attachments)
        {
            string str = MailServer.generateEmail(subject, body, sender) + MailServer.emailSplitDelimiter;

            for (int index = 0; index < attachments.Count; ++index)
            {
                str = str + attachments[index] + MailServer.emailSplitDelimiter;
            }
            return(str);
        }
Esempio n. 7
0
 public ActiveMission(List<MisisonGoal> _goals, string next, MailServer.EMailData _email)
 {
     goals = _goals;
     nextMission = next;
     email = _email;
     endFunctionValue = -1;
     endFunctionName = "";
     postingTitle = postingBody = "";
     reloadGoalsSourceFile = "Missions/BitMissionIntro.xml";
 }
Esempio n. 8
0
        public static void UpdateAlertIcon(object osobj)
        {
            OS     os = (OS)osobj;
            string flagStartingWith1 = os.Flags.GetFlagStartingWith("_changeAlertIconType:");
            string flagStartingWith2 = os.Flags.GetFlagStartingWith("_changeAlertIconTarget:");

            if (flagStartingWith1 == null || flagStartingWith2 == null)
            {
                return;
            }
            string   str = flagStartingWith1.Substring("_changeAlertIconType:".Length);
            string   ip_Or_ID_or_Name = flagStartingWith2.Substring("_changeAlertIconTarget:".Length);
            Computer computer         = Programs.getComputer(os, ip_Or_ID_or_Name);

            switch (str.ToLower())
            {
            case "mail":
                MailServer daemon1 = (MailServer)computer.getDaemon(typeof(MailServer));
                bool       flag    = false;
                for (int index = 0; index < daemon1.comp.users.Count; ++index)
                {
                    if (daemon1.comp.users[index].name == os.defaultUser.name)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    throw new FormatException("Mail server " + ip_Or_ID_or_Name + " does not have a user account for the player!\nA mail server must have a player account to be used as the alert icon");
                }
                os.mailicon.UpdateTargetServer(daemon1);
                os.ShowDLCAlertsIcon = false;
                break;

            case "irc":
                IRCDaemon daemon2 = (IRCDaemon)computer.getDaemon(typeof(IRCDaemon));
                os.ShowDLCAlertsIcon = true;
                os.hubServerAlertsIcon.UpdateTarget((object)daemon2, (object)daemon2.comp);
                break;

            case "irchub":
                DLCHubServer daemon3 = (DLCHubServer)computer.getDaemon(typeof(DLCHubServer));
                os.ShowDLCAlertsIcon = true;
                os.hubServerAlertsIcon.UpdateTarget((object)daemon3, (object)daemon3.comp);
                break;

            case "board":
                MessageBoardDaemon daemon4 = (MessageBoardDaemon)computer.getDaemon(typeof(MessageBoardDaemon));
                os.ShowDLCAlertsIcon = true;
                os.hubServerAlertsIcon.UpdateTarget((object)daemon4, (object)daemon4.comp);
                break;
            }
        }
Esempio n. 9
0
        public void addJunkEmails(Folder f)
        {
            if (!MailServer.shouldGenerateJunk)
            {
                return;
            }
            int num = Utils.random.Next(10);

            for (int index = 0; index < num; ++index)
            {
                f.files.Add(new FileEntry(MailServer.generateEmail("Re: Junk", BoatMail.JunkEmail, "admin@" + this.comp.name), "Re:_Junk#" + (object)OS.currentElapsedTime));
            }
        }
Esempio n. 10
0
 public void UpdateTargetServer(MailServer server)
 {
     if (this.targetServer != null)
     {
         this.targetServer.removeResponder((MailResponder)this);
     }
     else
     {
         (this.os.netMap.mailServer.daemons[0] as MailServer).removeResponder((MailResponder)this);
     }
     this.targetServer = server;
     this.targetServer.addResponder((MailResponder)this);
 }
Esempio n. 11
0
        public void contractAbbandoned(object osIn)
        {
            OS os = (OS)osIn;

            if (this.PlayerLosesValueOnAbandon)
            {
                this.playerValue -= 10;
                if (this.playerValue < 0)
                {
                    this.playerValue = 0;
                }
            }
            string email = MailServer.generateEmail(LocaleTerms.Loc("Contract Abandoned"), string.Format(Utils.readEntireFile("Content/LocPost/ContractAbandonedEmail.txt"), (object)this.getRank(), (object)this.getMaxRank(), (object)this.name), this.name + " ReplyBot");

            ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(email, os.defaultUser.name);
        }
Esempio n. 12
0
 public static void AddEmailToServer(this Hacknet.MailServer server,
                                     string sender   = null,
                                     string recip    = null,
                                     string subject  = null,
                                     string body     = null,
                                     bool dontFilter = false)
 {
     sender  = dontFilter ? sender ?? "UNKNOWN" : ComputerLoader.filter(sender ?? "UNKNOWN");
     recip   = dontFilter || recip == null ? recip : ComputerLoader.filter(recip);
     subject = dontFilter ? subject ?? "UNKNOWN" : ComputerLoader.filter(subject ?? "UNKNOWN");
     body    = dontFilter ? body ?? "UNKNOWN" : ComputerLoader.filter(body ?? "UNKNOWN");
     if (recip != null)
     {
         server.AddMailToServer(recip, Hacknet.MailServer.generateEmail(subject, body, sender));
     }
 }
Esempio n. 13
0
        public void contractAbbandoned(object osIn)
        {
            var os = (OS)osIn;

            if (PlayerLosesValueOnAbandon)
            {
                playerValue -= 10;
                if (playerValue < 0)
                {
                    playerValue = 0;
                }
            }
            var mail = MailServer.generateEmail("Contract Abandoned",
                                                "Agent,\nYou have abandoned your current contract, and as such are no longer eligable to complete it.\n" +
                                                "You are now free to accept further contracts from the contact database.\n" +
                                                "\nYour Current Ranking is " + getRank() + " of " + getMaxRank() + ".\n" + "\nThankyou,\n -" +
                                                name, name + " ReplyBot");

            ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(mail, os.defaultUser.name);
        }
Esempio n. 14
0
        public void connectToMail()
        {
            if (this.os.terminal.preventingExecution)
            {
                return;
            }
            if (!this.os.netMap.visibleNodes.Contains(this.os.netMap.nodes.IndexOf(this.os.netMap.mailServer)))
            {
                this.os.netMap.discoverNode(this.os.netMap.mailServer);
            }
            MailServer mailServer = (MailServer)this.os.netMap.mailServer.daemons[0];

            if (this.targetServer != null)
            {
                mailServer = this.targetServer;
            }
            this.os.connectedComp        = mailServer.comp;
            this.os.terminal.prompt      = this.os.connectedComp.ip + "@> ";
            mailServer.comp.userLoggedIn = true;
            this.os.display.command      = mailServer.name;
            mailServer.viewInbox(this.os.defaultUser);
            this.mailUnchecked = false;
        }
Esempio n. 15
0
 private void AddSentEmailRecordFileForMissionCompletion(ActiveMission mission, List <string> additionalDetails)
 {
     try
     {
         Folder folder = this.userFolder.searchForFolder("sent");
         string body   = mission.email.subject + " completed.";
         if (additionalDetails != null && additionalDetails.Count > 0)
         {
             body += "\nRequested Details:\n";
             for (int index = 0; index < additionalDetails.Count; ++index)
             {
                 body = body + additionalDetails[index] + "\n";
             }
         }
         string    email     = MailServer.generateEmail(mission.email.subject + " : Complete", body, this.user.name + "@" + this.comp.name);
         string    subject   = MailServer.getSubject(email);
         FileEntry fileEntry = new FileEntry(email, subject);
         folder.files.Add(fileEntry);
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 16
0
 public static void runCommand(int value, string name)
 {
     assertOS();
     if (name.Equals("addRank"))
     {
         os.currentFaction.addValue(value, os);
         var mail = MailServer.generateEmail("Contract Successful",
             "Congratulations,\nThe client of your recent contract has reported a success, and is pleased with your work.\n" +
             "You are now free to accept further contracts from the contact database.\n" +
             "\nYour Current Ranking is " + os.currentFaction.getRank() + " of " +
             os.currentFaction.getMaxRank() + ".\n" + "\nThankyou,\n -" + os.currentFaction.name,
             os.currentFaction.name + " ReplyBot");
         ((MailServer) os.netMap.mailServer.getDaemon(typeof (MailServer))).addMail(mail, os.defaultUser.name);
     }
     else if (name.StartsWith("addFlags:"))
     {
         foreach (
             var flag in
                 name.Substring("addFlags:".Length)
                     .Split(Utils.commaDelim, StringSplitOptions.RemoveEmptyEntries))
             os.Flags.AddFlag(flag);
     }
     if (name.Equals("triggerThemeHackRevenge"))
         os.delayer.Post(ActionDelayer.Wait(5.0), () =>
         {
             var mail = MailServer.generateEmail("Are you Kidding me?",
                 "Seriously?\n\n" +
                 "You think you can just f**k with my stuff and leave without consequence? Did you think I wouldn't notice?\n" +
                 "\nDid you think I wouldn't FIND you!?\n" +
                 "\nYou're a pathetic scrit kiddie, you couldn't hack a f*****g honeypot without your precious buttons and scrollbars.\n" +
                 "\nSay goodbye to your x-server, idiot." + "\n\nNaix", "*****@*****.**");
             ((MailServer) os.netMap.mailServer.getDaemon(typeof (MailServer))).addMail(mail, os.defaultUser.name);
             os.delayer.Post(ActionDelayer.Wait(24.0), () =>
             {
                 try
                 {
                     HackerScriptExecuter.runScript("ThemeHack.txt", os);
                 }
                 catch (Exception ex)
                 {
                     if (!Settings.recoverFromErrorsSilently)
                         throw ex;
                     os.write("CAUTION: UNSYNDICATED OUTSIDE CONNECTION ATTEMPT");
                     os.write("RECOVERED FROM CONNECTION SUBTERFUGE SUCCESSFULLY");
                     Console.WriteLine("Critical error loading hacker script - aborting");
                 }
             });
         });
     else if (name.Equals("changeSong"))
     {
         switch (value)
         {
             case 2:
                 MusicManager.transitionToSong("Music\\The_Quickening");
                 break;
             case 3:
                 MusicManager.transitionToSong("Music\\TheAlgorithm");
                 break;
             case 4:
                 MusicManager.transitionToSong("Music\\Ryan3");
                 break;
             case 5:
                 MusicManager.transitionToSong("Music\\Bit(Ending)");
                 break;
             case 6:
                 MusicManager.transitionToSong("Music\\Rico_Puestel-Roja_Drifts_By");
                 break;
             case 7:
                 MusicManager.transitionToSong("Music\\out_run_the_wolves");
                 break;
             case 8:
                 MusicManager.transitionToSong("Music\\Irritations");
                 break;
             case 9:
                 MusicManager.transitionToSong("Music\\Broken_Boy");
                 break;
             case 10:
                 MusicManager.transitionToSong("Music\\Ryan10");
                 break;
             case 11:
                 MusicManager.transitionToSong("Music\\tetrameth");
                 break;
             default:
                 MusicManager.transitionToSong("Music\\Revolve");
                 break;
         }
     }
     else if (name.Equals("entropyEndMissionSetup"))
     {
         runCommand(3, "changeSong");
         var comp1 = findComp("corp0#IS");
         var comp2 = findComp("corp0#MF");
         var comp3 = findComp("corp0#BU");
         var fileEntry1 = new FileEntry(Computer.generateBinaryString(5000), "HacknetOS.rar");
         var fileEntry2 = new FileEntry(Computer.generateBinaryString(4000), "HacknetOS_Data.xnb");
         var fileEntry3 = new FileEntry(Computer.generateBinaryString(4000), "HacknetOS_Content.xnb");
         var folder1 = comp1.files.root.folders[2];
         folder1.files.Add(fileEntry1);
         folder1.files.Add(fileEntry2);
         folder1.files.Add(fileEntry3);
         var folder2 = comp2.files.root.folders[2];
         folder2.files.Add(fileEntry1);
         folder2.files.Add(fileEntry2);
         folder2.files.Add(fileEntry3);
         var fileEntry4 = new FileEntry(fileEntry1.data, fileEntry1.name + "_backup");
         var fileEntry5 = new FileEntry(fileEntry2.data, fileEntry2.name + "_backup");
         var fileEntry6 = new FileEntry(fileEntry3.data, fileEntry3.name + "_backup");
         var folder3 = comp3.files.root.folders[2];
         folder3.files.Add(fileEntry4);
         folder3.files.Add(fileEntry5);
         folder3.files.Add(fileEntry6);
         comp1.traceTime = Computer.BASE_TRACE_TIME*7.5f;
         comp3.traceTime = Computer.BASE_TRACE_TIME*7.5f;
         comp2.traceTime = Computer.BASE_TRACE_TIME*7.5f;
         comp2.portsNeededForCrack = 3;
         comp1.portsNeededForCrack = 2;
         comp3.portsNeededForCrack = 2;
         var folder4 = findComp("entropy01").files.root.folders[2];
         folder4.files.Add(new FileEntry(PortExploits.crackExeData[25], "SMTPoverflow.exe"));
         folder4.files.Add(new FileEntry(PortExploits.crackExeData[80], "WebServerWorm.exe"));
     }
     else if (name.Equals("entropyAddSMTPCrack"))
     {
         var f = findComp("entropy01").files.root.folders[2];
         f.files.Add(new FileEntry(PortExploits.crackExeData[25],
             Utils.GetNonRepeatingFilename("SMTPoverflow", ".exe", f)));
         os.saveGame();
     }
     else if (name.Equals("transitionToBitMissions"))
     {
         if (Settings.isDemoMode)
         {
             runCommand(6, "changeSong");
             if (Settings.isPressBuildDemo)
                 ComputerLoader.loadMission("Content/Missions/Demo/PressBuild/DemoMission01.xml");
             else
                 ComputerLoader.loadMission("Content/Missions/Demo/AvconDemo.xml");
         }
         else
             ComputerLoader.loadMission("Content/Missions/BitMission0.xml");
     }
     else if (name.Equals("entropySendCSECInvite"))
         os.delayer.Post(ActionDelayer.Wait(6.0),
             () => ComputerLoader.loadMission("Content/Missions/MainHub/Intro/Intro01.xml"));
     else if (name.Equals("hubBitSetComplete01"))
     {
         os.delayer.Post(ActionDelayer.Wait(4.0), () => runCommand(1, "addRank"));
         runCommand(3, "changeSong");
         os.Flags.AddFlag("csecBitSet01Complete");
     }
     else if (name.Equals("enTechEnableOfflineBackup"))
     {
         var computer = Programs.getComputer(os, "EnTechOfflineBackup");
         Programs.getComputer(os, "EnTechMainframe").links.Add(os.netMap.nodes.IndexOf(computer));
         os.Flags.AddFlag("VaporSequencerEnabled");
         var folder1 = findComp("mainHubAssets").files.root.searchForFolder("bin");
         var folder2 = folder1.searchForFolder("Sequencer");
         if (folder2 == null)
         {
             folder2 = new Folder("Sequencer");
             folder1.folders.Add(folder2);
         }
         if (folder2.searchForFile("Sequencer.exe") != null)
             return;
         folder2.files.Add(new FileEntry(PortExploits.crackExeData[17], "Sequencer.exe"));
     }
     else if (name.Equals("rudeNaixResponse"))
         AchievementsManager.Unlock("rude_response", false);
     else if (name.Equals("assignPlayerToHubServerFaction"))
     {
         os.allFactions.setCurrentFaction("hub", os);
         var computer = Programs.getComputer(os, "mainHub");
         var missionHubServer = (MissionHubServer) computer.getDaemon(typeof (MissionHubServer));
         var userDetail = new UserDetail(os.defaultUser.name, "reptile", 3);
         computer.addNewUser(computer.ip, userDetail);
         missionHubServer.addUser(userDetail);
         os.homeNodeID = "mainHub";
         os.homeAssetServerID = "mainHubAssets";
         runCommand(3, "changeSong");
         os.Flags.AddFlag("CSEC_Member");
         AchievementsManager.Unlock("progress_csec", false);
     }
     else if (name.Equals("assignPlayerToEntropyFaction"))
     {
         runCommand(6, "changeSong");
         AchievementsManager.Unlock("progress_entropy", false);
     }
     else if (name.Equals("assignPlayerToLelzSec"))
     {
         os.homeNodeID = "lelzSecHub";
         os.homeAssetServerID = "lelzSecHub";
         os.Flags.AddFlag("LelzSec_Member");
         AchievementsManager.Unlock("progress_lelz", false);
     }
     else if (name.Equals("lelzSecVictory"))
         AchievementsManager.Unlock("secret_path_complete", false);
     else if (name.Equals("demoFinalMissionEnd"))
     {
         os.exes.Clear();
         PostProcessor.EndingSequenceFlashOutActive = true;
         PostProcessor.EndingSequenceFlashOutPercentageComplete = 1f;
         MusicManager.stop();
         os.delayer.Post(ActionDelayer.Wait(0.2),
             () => os.content.Load<SoundEffect>("Music/Ambient/spiral_gauge_down").Play());
         os.delayer.Post(ActionDelayer.Wait(3.0), () =>
         {
             PostProcessor.dangerModeEnabled = false;
             PostProcessor.dangerModePercentComplete = 0.0f;
             os.ExitScreen();
             os.ScreenManager.AddScreen(new DemoEndScreen());
         });
     }
     else if (name.Equals("demoFinalMissionStart"))
     {
         os.Flags.AddFlag("DemoSequencerEnabled");
         MusicManager.transitionToSong("Music/Ambient/dark_drone_008");
     }
     else if (name.Equals("CSECTesterGameWorldSetup"))
     {
         for (var index = 0; index < PortExploits.services.Count && index < 4; ++index)
             os.thisComputer.files.root.folders[2].files.Add(
                 new FileEntry(PortExploits.crackExeData[PortExploits.portNums[index]],
                     PortExploits.cracks[PortExploits.portNums[index]]));
         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.delayer.Post(ActionDelayer.Wait(0.2), () =>
         {
             os.allFactions.setCurrentFaction("entropy", os);
             os.currentMission = null;
             os.netMap.discoverNode(Programs.getComputer(os, "entropy00"));
             os.netMap.discoverNode(Programs.getComputer(os, "entropy01"));
         });
     }
     else if (name.Equals("EntropyFastFowardSetup"))
     {
         os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[22],
             PortExploits.cracks[22]));
         os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[21],
             PortExploits.cracks[21]));
         for (var index = 0; index < 3; ++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.delayer.Post(ActionDelayer.Wait(0.2), () =>
         {
             os.allFactions.setCurrentFaction("entropy", os);
             os.currentMission = null;
             os.netMap.discoverNode(Programs.getComputer(os, "entropy00"));
             os.netMap.discoverNode(Programs.getComputer(os, "entropy01"));
             var computer = Programs.getComputer(os, "entropy01");
             var userDetail = computer.users[0];
             userDetail.known = true;
             computer.users[0] = userDetail;
             os.allFactions.factions[os.allFactions.currentFaction].playerValue = 2;
             os.delayer.Post(ActionDelayer.Wait(0.2), () =>
             {
                 os.Flags.AddFlag("eosPathStarted");
                 ComputerLoader.loadMission(
                     "Content/Missions/Entropy/StartingSet/eosMissions/eosIntroDelayer.xml");
             });
         });
     }
     else if (name.Equals("CSECFastFowardSetup"))
     {
         os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[22],
             PortExploits.cracks[22]));
         os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[21],
             PortExploits.cracks[21]));
         for (var index = 0; index < 3; ++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.delayer.Post(ActionDelayer.Wait(0.2), () =>
         {
             runCommand(0, "assignPlayerToHubServerFaction");
             os.currentMission = null;
             os.netMap.discoverNode(Programs.getComputer(os, "mainHub"));
             os.netMap.discoverNode(Programs.getComputer(os, "mainHubAssets"));
             var computer = Programs.getComputer(os, "mainHubAssets");
             var userDetail = computer.users[0];
             userDetail.known = true;
             computer.users[0] = userDetail;
         });
     }
     else if (name.Equals("csecAddTraceKill"))
     {
         var folder = findComp("mainHubAssets").files.root.searchForFolder("bin");
         var f = folder.searchForFolder("TK");
         if (f == null)
         {
             f = new Folder("TK");
             folder.folders.Add(f);
         }
         f.files.Add(
             new FileEntry(
                 FileEncrypter.EncryptString(PortExploits.crackExeData[12], "Vapor Trick Enc.", "NULL", "dx122DX",
                     ".exe"), Utils.GetNonRepeatingFilename("TraceKill", ".dec", f)));
         os.Flags.AddFlag("bitPathStarted");
         runCommand(10, "changeSong");
     }
     else if (name.Equals("junebugComplete"))
     {
         var computer = Programs.getComputer(os, "pacemaker01");
         if (computer != null)
         {
             var heartMonitorDaemon = (HeartMonitorDaemon) computer.getDaemon(typeof (HeartMonitorDaemon));
             if (heartMonitorDaemon != null)
                 heartMonitorDaemon.ForceStopBeepSustainSound();
         }
         runCommand(1, "addRank");
     }
     else if (name.Equals("eosIntroMissionSetup"))
     {
         findComp("entropy01")
             .files.root.searchForFolder("bin")
             .files.Add(new FileEntry(PortExploits.crackExeData[13], "eosDeviceScan.exe"));
         os.delayer.Post(ActionDelayer.Wait(8.0), () =>
         {
             var mail = MailServer.generateEmail("Fwd: eOS Stuff",
                 Utils.readEntireFile("Content/Post/eosScannerMail.txt"), "vtfx", new List<string>(new string[1]
                 {
                     "note#%#eOS Security Basics#%#" +
                     ("1: Get admin access to a computer that you suspect has an eOS device sync'd to it\n" +
                      "2: Run eosdevicescanner.exe\nto scan for paired devices and automatically open connection ports\n" +
                      "3: connect to the revealed device\n" +
                      "3: login with\nuser: \"admin\"\npassword: \"alpine\"\n\n" +
                      "The password is the same for all eOS devices!")
                 }));
             ((MailServer) os.netMap.mailServer.getDaemon(typeof (MailServer))).addMail(mail, os.defaultUser.name);
         });
         runCommand(4, "changeSong");
         os.saveGame();
     }
     else
     {
         if (!name.Equals("eosIntroEndFunc"))
             return;
         runCommand(1, "addRank");
         var missionListingServer =
             (MissionListingServer) findComp("entropy00").getDaemon(typeof (MissionListingServer));
         var list = os.branchMissions;
         var m =
             (ActiveMission)
                 ComputerLoader.readMission(
                     "Content/Missions/Entropy/StartingSet/eosMissions/eosAddedMission.xml");
         missionListingServer.addMisison(m);
         os.branchMissions = list;
     }
 }
Esempio n. 17
0
        public static Computer load(XmlReader reader, OS os)
        {
            while (reader.Name != "computer")
            {
                reader.Read();
            }
            reader.MoveToAttribute("name");
            var compName = reader.ReadContentAsString();

            reader.MoveToAttribute("ip");
            var compIP = reader.ReadContentAsString();

            reader.MoveToAttribute("type");
            var compType = (byte)reader.ReadContentAsInt();

            reader.MoveToAttribute("spec");
            var str1 = reader.ReadContentAsString();

            reader.MoveToAttribute("id");
            var    str2 = reader.ReadContentAsString();
            string str3 = null;

            if (reader.MoveToAttribute("devices"))
            {
                str3 = reader.ReadContentAsString();
            }
            string str4 = null;

            if (reader.MoveToAttribute("icon"))
            {
                str4 = reader.ReadContentAsString();
            }
            while (reader.Name != "location")
            {
                reader.Read();
            }
            reader.MoveToAttribute("x");
            var x = reader.ReadContentAsFloat();

            reader.MoveToAttribute("y");
            var y = reader.ReadContentAsFloat();

            while (reader.Name != "security")
            {
                reader.Read();
            }
            reader.MoveToAttribute("level");
            var seclevel = reader.ReadContentAsInt();

            reader.MoveToAttribute("traceTime");
            var num1 = reader.ReadContentAsFloat();

            reader.MoveToAttribute("portsToCrack");
            var num2 = reader.ReadContentAsInt();

            reader.MoveToAttribute("adminIP");
            var str5 = reader.ReadContentAsString();
            var time = -1f;

            if (reader.MoveToAttribute("proxyTime"))
            {
                time = reader.ReadContentAsFloat();
            }
            while (reader.Name != "admin")
            {
                reader.Read();
            }
            reader.MoveToAttribute("type");
            var str6 = reader.ReadContentAsString();

            reader.MoveToAttribute("resetPass");
            var flag1 = reader.ReadContentAsBoolean();

            reader.MoveToAttribute("isSuper");
            var           flag2         = reader.ReadContentAsBoolean();
            Administrator administrator = null;

            switch (str6)
            {
            case "fast":
                administrator = new FastBasicAdministrator();
                break;

            case "basic":
                administrator = new BasicAdministrator();
                break;
            }
            if (administrator != null)
            {
                administrator.ResetsPassword = flag1;
            }
            if (administrator != null)
            {
                administrator.IsSuper = flag2;
            }
            while (reader.Name != "links")
            {
                reader.Read();
            }
            var      strArray = reader.ReadElementContentAsString().Split();
            Firewall firewall = null;

            while (reader.Name != "portsOpen" && reader.Name != "firewall")
            {
                reader.Read();
            }
            if (reader.Name == "firewall")
            {
                firewall = Firewall.load(reader);
            }
            while (reader.Name != "portsOpen")
            {
                reader.Read();
            }
            var portsList = reader.ReadElementContentAsString();
            var computer  = new Computer(compName, compIP, new Vector2(x, y), seclevel, compType, os);

            computer.firewall = firewall;
            computer.admin    = administrator;
            if (time > 0.0)
            {
                computer.addProxy(time);
            }
            else
            {
                computer.hasProxy    = false;
                computer.proxyActive = false;
            }
            while (reader.Name != "users")
            {
                reader.Read();
            }
            computer.users.Clear();
            while (!(reader.Name == "users") || reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.Name == "user")
                {
                    var userDetail = UserDetail.loadUserDetail(reader);
                    if (userDetail.name.ToLower() == "admin")
                    {
                        computer.adminPass = userDetail.pass;
                    }
                    computer.users.Add(userDetail);
                }
                reader.Read();
            }
            while (reader.Name != "daemons")
            {
                reader.Read();
            }
            reader.Read();
            while (!(reader.Name == "daemons") || reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.Name == "MailServer")
                {
                    reader.MoveToAttribute("name");
                    var name       = reader.ReadContentAsString();
                    var mailServer = new MailServer(computer, name, os);
                    computer.daemons.Add(mailServer);
                    if (reader.MoveToAttribute("color"))
                    {
                        var newThemeColor = Utils.convertStringToColor(reader.ReadContentAsString());
                        mailServer.setThemeColor(newThemeColor);
                    }
                }
                else if (reader.Name == "MissionListingServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName = reader.ReadContentAsString();
                    reader.MoveToAttribute("group");
                    var group = reader.ReadContentAsString();
                    reader.MoveToAttribute("public");
                    var _isPublic = reader.ReadContentAsString().ToLower().Equals("true");
                    reader.MoveToAttribute("assign");
                    var _isAssigner          = reader.ReadContentAsString().ToLower().Equals("true");
                    var missionListingServer = new MissionListingServer(computer, serviceName, group, os, _isPublic,
                                                                        _isAssigner);
                    computer.daemons.Add(missionListingServer);
                }
                else if (reader.Name == "AddEmailServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName    = reader.ReadContentAsString();
                    var addEmailDaemon = new AddEmailDaemon(computer, serviceName, os);
                    computer.daemons.Add(addEmailDaemon);
                }
                else if (reader.Name == "MessageBoard")
                {
                    reader.MoveToAttribute("name");
                    var str7 = reader.ReadContentAsString();
                    var messageBoardDaemon = new MessageBoardDaemon(computer, os);
                    messageBoardDaemon.name = str7;
                    computer.daemons.Add(messageBoardDaemon);
                }
                else if (reader.Name == "WebServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName = reader.ReadContentAsString();
                    reader.MoveToAttribute("url");
                    var pageFileLocation = reader.ReadContentAsString();
                    var webServerDaemon  = new WebServerDaemon(computer, serviceName, os, pageFileLocation);
                    computer.daemons.Add(webServerDaemon);
                }
                else if (reader.Name == "OnlineWebServer")
                {
                    reader.MoveToAttribute("name");
                    var serviceName = reader.ReadContentAsString();
                    reader.MoveToAttribute("url");
                    var url = reader.ReadContentAsString();
                    var onlineWebServerDaemon = new OnlineWebServerDaemon(computer, serviceName, os);
                    onlineWebServerDaemon.setURL(url);
                    computer.daemons.Add(onlineWebServerDaemon);
                }
                else if (reader.Name == "AcademicDatabse")
                {
                    reader.MoveToAttribute("name");
                    var serviceName            = reader.ReadContentAsString();
                    var academicDatabaseDaemon = new AcademicDatabaseDaemon(computer, serviceName, os);
                    computer.daemons.Add(academicDatabaseDaemon);
                }
                else if (reader.Name == "MissionHubServer")
                {
                    var missionHubServer = new MissionHubServer(computer, "unknown", "unknown", os);
                    computer.daemons.Add(missionHubServer);
                }
                else if (reader.Name == "DeathRowDatabase")
                {
                    var rowDatabaseDaemon = new DeathRowDatabaseDaemon(computer, "Death Row Database", os);
                    computer.daemons.Add(rowDatabaseDaemon);
                }
                else if (reader.Name == "MedicalDatabase")
                {
                    var medicalDatabaseDaemon = new MedicalDatabaseDaemon(computer, os);
                    computer.daemons.Add(medicalDatabaseDaemon);
                }
                else if (reader.Name == "HeartMonitor")
                {
                    var str7 = "UNKNOWN";
                    if (reader.MoveToAttribute("patient"))
                    {
                        str7 = reader.ReadContentAsString();
                    }
                    computer.daemons.Add(new HeartMonitorDaemon(computer, os)
                    {
                        PatientID = str7
                    });
                }
                else if (reader.Name.Equals("PointClicker"))
                {
                    var pointClickerDaemon = new PointClickerDaemon(computer, "Point Clicker!", os);
                    computer.daemons.Add(pointClickerDaemon);
                }
                else if (reader.Name.Equals("ispSystem"))
                {
                    var ispDaemon = new ISPDaemon(computer, os);
                    computer.daemons.Add(ispDaemon);
                }
                else if (reader.Name.Equals("porthackheart"))
                {
                    var porthackHeartDaemon = new PorthackHeartDaemon(computer, os);
                    computer.daemons.Add(porthackHeartDaemon);
                }
                else if (reader.Name.Equals("SongChangerDaemon"))
                {
                    var songChangerDaemon = new SongChangerDaemon(computer, os);
                    computer.daemons.Add(songChangerDaemon);
                }
                else if (reader.Name == "UploadServerDaemon")
                {
                    string str7;
                    var    input       = str7 = "";
                    var    foldername  = str7;
                    var    serviceName = str7;
                    if (reader.MoveToAttribute("name"))
                    {
                        serviceName = reader.ReadContentAsString();
                    }
                    if (reader.MoveToAttribute("foldername"))
                    {
                        foldername = reader.ReadContentAsString();
                    }
                    if (reader.MoveToAttribute("color"))
                    {
                        input = reader.ReadContentAsString();
                    }
                    var needsAuthentication = false;
                    if (reader.MoveToAttribute("needsAuh"))
                    {
                        needsAuthentication = reader.ReadContentAsBoolean();
                    }
                    var themeColor = Color.White;
                    if (input != "")
                    {
                        themeColor = Utils.convertStringToColor(input);
                    }
                    var uploadServerDaemon = new UploadServerDaemon(computer, serviceName, themeColor, os, foldername,
                                                                    needsAuthentication);
                    computer.daemons.Add(uploadServerDaemon);
                }
                reader.Read();
            }
            computer.files               = FileSystem.load(reader);
            computer.traceTime           = num1;
            computer.portsNeededForCrack = num2;
            computer.adminIP             = str5;
            computer.idName              = str2;
            computer.icon = str4;
            computer.attatchedDeviceIDs = str3;
            for (var index = 0; index < strArray.Length; ++index)
            {
                if (strArray[index] != "")
                {
                    computer.links.Add(Convert.ToInt32(strArray[index]));
                }
            }
            if (portsList.Length > 0)
            {
                ComputerLoader.loadPortsIntoComputer(portsList, computer);
            }
            if (str1 == "mail")
            {
                os.netMap.mailServer = computer;
            }
            else if (str1 == "player")
            {
                os.thisComputer = computer;
            }
            return(computer);
        }
Esempio n. 18
0
 public static Computer load(XmlReader reader, OS os)
 {
     while (reader.Name != "computer")
         reader.Read();
     reader.MoveToAttribute("name");
     var compName = reader.ReadContentAsString();
     reader.MoveToAttribute("ip");
     var compIP = reader.ReadContentAsString();
     reader.MoveToAttribute("type");
     var compType = (byte) reader.ReadContentAsInt();
     reader.MoveToAttribute("spec");
     var str1 = reader.ReadContentAsString();
     reader.MoveToAttribute("id");
     var str2 = reader.ReadContentAsString();
     string str3 = null;
     if (reader.MoveToAttribute("devices"))
         str3 = reader.ReadContentAsString();
     string str4 = null;
     if (reader.MoveToAttribute("icon"))
         str4 = reader.ReadContentAsString();
     while (reader.Name != "location")
         reader.Read();
     reader.MoveToAttribute("x");
     var x = reader.ReadContentAsFloat();
     reader.MoveToAttribute("y");
     var y = reader.ReadContentAsFloat();
     while (reader.Name != "security")
         reader.Read();
     reader.MoveToAttribute("level");
     var seclevel = reader.ReadContentAsInt();
     reader.MoveToAttribute("traceTime");
     var num1 = reader.ReadContentAsFloat();
     reader.MoveToAttribute("portsToCrack");
     var num2 = reader.ReadContentAsInt();
     reader.MoveToAttribute("adminIP");
     var str5 = reader.ReadContentAsString();
     var time = -1f;
     if (reader.MoveToAttribute("proxyTime"))
         time = reader.ReadContentAsFloat();
     while (reader.Name != "admin")
         reader.Read();
     reader.MoveToAttribute("type");
     var str6 = reader.ReadContentAsString();
     reader.MoveToAttribute("resetPass");
     var flag1 = reader.ReadContentAsBoolean();
     reader.MoveToAttribute("isSuper");
     var flag2 = reader.ReadContentAsBoolean();
     Administrator administrator = null;
     switch (str6)
     {
         case "fast":
             administrator = new FastBasicAdministrator();
             break;
         case "basic":
             administrator = new BasicAdministrator();
             break;
     }
     if (administrator != null)
         administrator.ResetsPassword = flag1;
     if (administrator != null)
         administrator.IsSuper = flag2;
     while (reader.Name != "links")
         reader.Read();
     var strArray = reader.ReadElementContentAsString().Split();
     Firewall firewall = null;
     while (reader.Name != "portsOpen" && reader.Name != "firewall")
         reader.Read();
     if (reader.Name == "firewall")
         firewall = Firewall.load(reader);
     while (reader.Name != "portsOpen")
         reader.Read();
     var portsList = reader.ReadElementContentAsString();
     var computer = new Computer(compName, compIP, new Vector2(x, y), seclevel, compType, os);
     computer.firewall = firewall;
     computer.admin = administrator;
     if (time > 0.0)
     {
         computer.addProxy(time);
     }
     else
     {
         computer.hasProxy = false;
         computer.proxyActive = false;
     }
     while (reader.Name != "users")
         reader.Read();
     computer.users.Clear();
     while (!(reader.Name == "users") || reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.Name == "user")
         {
             var userDetail = UserDetail.loadUserDetail(reader);
             if (userDetail.name.ToLower() == "admin")
                 computer.adminPass = userDetail.pass;
             computer.users.Add(userDetail);
         }
         reader.Read();
     }
     while (reader.Name != "daemons")
         reader.Read();
     reader.Read();
     while (!(reader.Name == "daemons") || reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.Name == "MailServer")
         {
             reader.MoveToAttribute("name");
             var name = reader.ReadContentAsString();
             var mailServer = new MailServer(computer, name, os);
             computer.daemons.Add(mailServer);
             if (reader.MoveToAttribute("color"))
             {
                 var newThemeColor = Utils.convertStringToColor(reader.ReadContentAsString());
                 mailServer.setThemeColor(newThemeColor);
             }
         }
         else if (reader.Name == "MissionListingServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             reader.MoveToAttribute("group");
             var group = reader.ReadContentAsString();
             reader.MoveToAttribute("public");
             var _isPublic = reader.ReadContentAsString().ToLower().Equals("true");
             reader.MoveToAttribute("assign");
             var _isAssigner = reader.ReadContentAsString().ToLower().Equals("true");
             var missionListingServer = new MissionListingServer(computer, serviceName, group, os, _isPublic,
                 _isAssigner);
             computer.daemons.Add(missionListingServer);
         }
         else if (reader.Name == "AddEmailServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             var addEmailDaemon = new AddEmailDaemon(computer, serviceName, os);
             computer.daemons.Add(addEmailDaemon);
         }
         else if (reader.Name == "MessageBoard")
         {
             reader.MoveToAttribute("name");
             var str7 = reader.ReadContentAsString();
             var messageBoardDaemon = new MessageBoardDaemon(computer, os);
             messageBoardDaemon.name = str7;
             computer.daemons.Add(messageBoardDaemon);
         }
         else if (reader.Name == "WebServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             reader.MoveToAttribute("url");
             var pageFileLocation = reader.ReadContentAsString();
             var webServerDaemon = new WebServerDaemon(computer, serviceName, os, pageFileLocation);
             computer.daemons.Add(webServerDaemon);
         }
         else if (reader.Name == "OnlineWebServer")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             reader.MoveToAttribute("url");
             var url = reader.ReadContentAsString();
             var onlineWebServerDaemon = new OnlineWebServerDaemon(computer, serviceName, os);
             onlineWebServerDaemon.setURL(url);
             computer.daemons.Add(onlineWebServerDaemon);
         }
         else if (reader.Name == "AcademicDatabse")
         {
             reader.MoveToAttribute("name");
             var serviceName = reader.ReadContentAsString();
             var academicDatabaseDaemon = new AcademicDatabaseDaemon(computer, serviceName, os);
             computer.daemons.Add(academicDatabaseDaemon);
         }
         else if (reader.Name == "MissionHubServer")
         {
             var missionHubServer = new MissionHubServer(computer, "unknown", "unknown", os);
             computer.daemons.Add(missionHubServer);
         }
         else if (reader.Name == "DeathRowDatabase")
         {
             var rowDatabaseDaemon = new DeathRowDatabaseDaemon(computer, "Death Row Database", os);
             computer.daemons.Add(rowDatabaseDaemon);
         }
         else if (reader.Name == "MedicalDatabase")
         {
             var medicalDatabaseDaemon = new MedicalDatabaseDaemon(computer, os);
             computer.daemons.Add(medicalDatabaseDaemon);
         }
         else if (reader.Name == "HeartMonitor")
         {
             var str7 = "UNKNOWN";
             if (reader.MoveToAttribute("patient"))
                 str7 = reader.ReadContentAsString();
             computer.daemons.Add(new HeartMonitorDaemon(computer, os)
             {
                 PatientID = str7
             });
         }
         else if (reader.Name.Equals("PointClicker"))
         {
             var pointClickerDaemon = new PointClickerDaemon(computer, "Point Clicker!", os);
             computer.daemons.Add(pointClickerDaemon);
         }
         else if (reader.Name.Equals("ispSystem"))
         {
             var ispDaemon = new ISPDaemon(computer, os);
             computer.daemons.Add(ispDaemon);
         }
         else if (reader.Name.Equals("porthackheart"))
         {
             var porthackHeartDaemon = new PorthackHeartDaemon(computer, os);
             computer.daemons.Add(porthackHeartDaemon);
         }
         else if (reader.Name.Equals("SongChangerDaemon"))
         {
             var songChangerDaemon = new SongChangerDaemon(computer, os);
             computer.daemons.Add(songChangerDaemon);
         }
         else if (reader.Name == "UploadServerDaemon")
         {
             string str7;
             var input = str7 = "";
             var foldername = str7;
             var serviceName = str7;
             if (reader.MoveToAttribute("name"))
                 serviceName = reader.ReadContentAsString();
             if (reader.MoveToAttribute("foldername"))
                 foldername = reader.ReadContentAsString();
             if (reader.MoveToAttribute("color"))
                 input = reader.ReadContentAsString();
             var needsAuthentication = false;
             if (reader.MoveToAttribute("needsAuh"))
                 needsAuthentication = reader.ReadContentAsBoolean();
             var themeColor = Color.White;
             if (input != "")
                 themeColor = Utils.convertStringToColor(input);
             var uploadServerDaemon = new UploadServerDaemon(computer, serviceName, themeColor, os, foldername,
                 needsAuthentication);
             computer.daemons.Add(uploadServerDaemon);
         }
         reader.Read();
     }
     computer.files = FileSystem.load(reader);
     computer.traceTime = num1;
     computer.portsNeededForCrack = num2;
     computer.adminIP = str5;
     computer.idName = str2;
     computer.icon = str4;
     computer.attatchedDeviceIDs = str3;
     for (var index = 0; index < strArray.Length; ++index)
     {
         if (strArray[index] != "")
             computer.links.Add(Convert.ToInt32(strArray[index]));
     }
     if (portsList.Length > 0)
         ComputerLoader.loadPortsIntoComputer(portsList, computer);
     if (str1 == "mail")
         os.netMap.mailServer = computer;
     else if (str1 == "player")
         os.thisComputer = computer;
     return computer;
 }
Esempio n. 19
0
 public static object loadComputer(string filename)
 {
     var rdr = XmlReader.Create(TitleContainer.OpenStream(filename));
     var str1 = "UNKNOWN";
     var compName = "UNKNOWN";
     string str2 = null;
     var seclevel = 0;
     byte compType = 1;
     var flag1 = true;
     var compIP = NetworkMap.generateRandomIP();
     while (rdr.Name != "Computer")
         rdr.Read();
     if (rdr.MoveToAttribute("id"))
         str1 = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("name"))
         compName = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("security"))
         seclevel = rdr.ReadContentAsInt();
     if (rdr.MoveToAttribute("type"))
         compType = (byte) rdr.ReadContentAsInt();
     if (rdr.MoveToAttribute("ip"))
         compIP = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("icon"))
         str2 = rdr.ReadContentAsString();
     if (rdr.MoveToAttribute("allowsDefaultBootModule"))
         flag1 = rdr.ReadContentAsBoolean();
     var computer1 = new Computer(compName, compIP, os.netMap.getRandomPosition(), seclevel, compType, os);
     computer1.idName = str1;
     computer1.AllowsDefaultBootModule = flag1;
     computer1.icon = str2;
     if (computer1.type == 4)
     {
         var folder = computer1.files.root.searchForFolder("home");
         if (folder != null)
         {
             folder.files.Clear();
             folder.folders.Clear();
         }
     }
     while (rdr.Name != "Computer")
     {
         if (rdr.Name.Equals("file"))
         {
             var path = !rdr.MoveToAttribute("path") ? "home" : rdr.ReadContentAsString();
             var str3 = filter(!rdr.MoveToAttribute("name") ? "Data" : rdr.ReadContentAsString());
             var num = (int) rdr.MoveToContent();
             var s = rdr.ReadElementContentAsString();
             if (s.Equals(""))
                 s = Computer.generateBinaryString(500);
             var dataEntry = filter(s);
             var folderFromPath = computer1.getFolderFromPath(path, true);
             if (folderFromPath.searchForFile(str3) != null)
                 folderFromPath.searchForFile(str3).data = dataEntry;
             else
                 folderFromPath.files.Add(new FileEntry(dataEntry, str3));
         }
         if (rdr.Name.Equals("encryptedFile"))
         {
             var flag2 = false;
             var path = !rdr.MoveToAttribute("path") ? "home" : rdr.ReadContentAsString();
             var s1 = !rdr.MoveToAttribute("name") ? "Data" : rdr.ReadContentAsString();
             var header = !rdr.MoveToAttribute("header") ? "ERROR" : rdr.ReadContentAsString();
             var ipLink = !rdr.MoveToAttribute("ip") ? "ERROR" : rdr.ReadContentAsString();
             var pass = !rdr.MoveToAttribute("pass") ? "" : rdr.ReadContentAsString();
             var fileExtension = !rdr.MoveToAttribute("extension") ? null : rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("double"))
                 flag2 = rdr.ReadContentAsBoolean();
             var str3 = filter(s1);
             var num = (int) rdr.MoveToContent();
             var s2 = rdr.ReadElementContentAsString();
             if (s2.Equals(""))
                 s2 = Computer.generateBinaryString(500);
             var data = filter(s2);
             if (flag2)
                 data = FileEncrypter.EncryptString(data, header, ipLink, pass, fileExtension);
             var dataEntry = FileEncrypter.EncryptString(data, header, ipLink, pass,
                 flag2 ? "_LAYER2.dec" : fileExtension);
             var folderFromPath = computer1.getFolderFromPath(path, true);
             if (folderFromPath.searchForFile(str3) != null)
                 folderFromPath.searchForFile(str3).data = dataEntry;
             else
                 folderFromPath.files.Add(new FileEntry(dataEntry, str3));
         }
         else if (rdr.Name.Equals("ports"))
         {
             var num = (int) rdr.MoveToContent();
             loadPortsIntoComputer(rdr.ReadElementContentAsString(), computer1);
         }
         else if (rdr.Name.Equals("positionNear"))
         {
             var ip_Or_ID_or_Name = "";
             if (rdr.MoveToAttribute("target"))
                 ip_Or_ID_or_Name = rdr.ReadContentAsString();
             var num = 0;
             var total = 3;
             if (rdr.MoveToAttribute("position"))
                 num = rdr.ReadContentAsInt();
             var positionNumber = num + 1;
             if (rdr.MoveToAttribute("total"))
                 total = rdr.ReadContentAsInt();
             var computer2 = Programs.getComputer(os, ip_Or_ID_or_Name);
             if (computer2 != null)
                 computer1.location = computer2.location +
                                      Corporation.getNearbyNodeOffset(computer2.location, positionNumber, total,
                                          os.netMap);
         }
         else if (rdr.Name.Equals("proxy"))
         {
             var num = 1f;
             if (rdr.MoveToAttribute("time"))
                 num = rdr.ReadContentAsFloat();
             if (num > 0.0)
             {
                 computer1.addProxy(Computer.BASE_PROXY_TICKS*num);
             }
             else
             {
                 computer1.hasProxy = false;
                 computer1.proxyActive = false;
             }
         }
         else if (rdr.Name.Equals("portsForCrack"))
         {
             var num = -1;
             if (rdr.MoveToAttribute("val"))
                 num = rdr.ReadContentAsInt();
             if (num != -1)
                 computer1.portsNeededForCrack = num - 1;
         }
         else if (rdr.Name.Equals("firewall"))
         {
             var level = 1;
             if (rdr.MoveToAttribute("level"))
                 level = rdr.ReadContentAsInt();
             if (level > 0)
             {
                 string solution = null;
                 var additionalTime = 0.0f;
                 if (rdr.MoveToAttribute("solution"))
                     solution = rdr.ReadContentAsString();
                 if (rdr.MoveToAttribute("additionalTime"))
                     additionalTime = rdr.ReadContentAsFloat();
                 if (solution != null)
                     computer1.addFirewall(level, solution, additionalTime);
                 else
                     computer1.addFirewall(level);
             }
             else
                 computer1.firewall = null;
         }
         else if (rdr.Name.Equals("link"))
         {
             var ip_Or_ID_or_Name = "";
             if (rdr.MoveToAttribute("target"))
                 ip_Or_ID_or_Name = rdr.ReadContentAsString();
             var computer2 = Programs.getComputer(os, ip_Or_ID_or_Name);
             if (computer2 != null)
                 computer1.links.Add(os.netMap.nodes.IndexOf(computer2));
         }
         else if (rdr.Name.Equals("dlink"))
         {
             var comp = "";
             if (rdr.MoveToAttribute("target"))
                 comp = rdr.ReadContentAsString();
             var local = computer1;
             postAllLoadedActions += () =>
             {
                 var computer2 = Programs.getComputer(os, comp);
                 if (computer2 == null)
                     return;
                 local.links.Add(os.netMap.nodes.IndexOf(computer2));
             };
         }
         else if (rdr.Name.Equals("trace"))
         {
             var num = 1f;
             if (rdr.MoveToAttribute("time"))
                 num = rdr.ReadContentAsFloat();
             computer1.traceTime = num;
         }
         else if (rdr.Name.Equals("adminPass"))
         {
             string newPass = null;
             if (rdr.MoveToAttribute("pass"))
                 newPass = rdr.ReadContentAsString();
             if (newPass == null)
                 newPass = PortExploits.getRandomPassword();
             computer1.setAdminPassword(newPass);
         }
         else if (rdr.Name.Equals("admin"))
         {
             var str3 = "basic";
             var flag2 = true;
             var flag3 = false;
             if (rdr.MoveToAttribute("type"))
                 str3 = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("resetPassword"))
                 flag2 = rdr.ReadContentAsBoolean();
             if (rdr.MoveToAttribute("isSuper"))
                 flag3 = rdr.ReadContentAsBoolean();
             switch (str3)
             {
                 case "fast":
                     computer1.admin = new FastBasicAdministrator();
                     break;
                 default:
                     computer1.admin = new BasicAdministrator();
                     break;
             }
             computer1.admin.ResetsPassword = flag2;
             computer1.admin.IsSuper = flag3;
         }
         else if (rdr.Name.Equals("ExternalCounterpart"))
         {
             var serverName = "";
             var idName = "";
             if (rdr.MoveToAttribute("id"))
                 serverName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("name"))
                 idName = rdr.ReadContentAsString();
             var externalCounterpart = new ExternalCounterpart(idName,
                 ExternalCounterpart.getIPForServerName(serverName));
             computer1.externalCounterpart = externalCounterpart;
         }
         else if (rdr.Name.Equals("account"))
         {
             byte accountType = 0;
             string s1;
             var s2 = s1 = "ERROR";
             if (rdr.MoveToAttribute("username"))
                 s2 = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("password"))
                 s1 = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("type"))
                 accountType = (byte) rdr.ReadContentAsInt();
             var user = filter(s2);
             var password = filter(s1);
             var flag2 = false;
             for (var index = 0; index < computer1.users.Count; ++index)
             {
                 var userDetail = computer1.users[index];
                 if (userDetail.name.Equals(user))
                 {
                     userDetail.pass = password;
                     userDetail.type = accountType;
                     computer1.users[index] = userDetail;
                     if (user.Equals("admin"))
                         computer1.adminPass = password;
                     flag2 = true;
                 }
             }
             if (!flag2)
             {
                 var userDetail = new UserDetail(user, password, accountType);
                 computer1.users.Add(userDetail);
             }
         }
         else if (rdr.Name.Equals("missionListingServer"))
         {
             var flag2 = false;
             var _isPublic = false;
             string serviceName;
             var group = serviceName = "ERROR";
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("group"))
                 group = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("assigner"))
                 flag2 = rdr.ReadContentAsBoolean();
             if (rdr.MoveToAttribute("public"))
                 _isPublic = rdr.ReadContentAsBoolean();
             computer1.daemons.Add(new MissionListingServer(computer1, serviceName, group, os, _isPublic, false)
             {
                 missionAssigner = flag2
             });
         }
         else if (rdr.Name.Equals("mailServer"))
         {
             var name = "Mail Server";
             if (rdr.MoveToAttribute("name"))
                 name = rdr.ReadContentAsString();
             var ms = new MailServer(computer1, name, os);
             if (rdr.MoveToAttribute("color"))
                 ms.setThemeColor(Utils.convertStringToColor(rdr.ReadContentAsString()));
             while (!(rdr.Name == "mailServer") || rdr.IsStartElement())
             {
                 if (rdr.Name == "email")
                 {
                     var sender = "UNKNOWN";
                     string str3 = null;
                     var subject = "UNKNOWN";
                     if (rdr.MoveToAttribute("sender"))
                         sender = rdr.ReadContentAsString();
                     if (rdr.MoveToAttribute("recipient"))
                         str3 = rdr.ReadContentAsString();
                     if (rdr.MoveToAttribute("subject"))
                         subject = rdr.ReadContentAsString();
                     var num = (int) rdr.MoveToContent();
                     var body = rdr.ReadElementContentAsString();
                     if (str3 != null)
                     {
                         var email = MailServer.generateEmail(subject, body, sender);
                         var recp = str3;
                         ms.setupComplete += () => ms.addMail(email, recp);
                     }
                 }
                 rdr.Read();
             }
             computer1.daemons.Add(ms);
         }
         else if (rdr.Name.Equals("addEmailDaemon"))
         {
             var addEmailDaemon = new AddEmailDaemon(computer1, "Final Task", os);
             computer1.daemons.Add(addEmailDaemon);
         }
         else if (rdr.Name.Equals("deathRowDatabase"))
         {
             var rowDatabaseDaemon = new DeathRowDatabaseDaemon(computer1, "Death Row Database", os);
             computer1.daemons.Add(rowDatabaseDaemon);
         }
         else if (rdr.Name.Equals("ispSystem"))
         {
             var ispDaemon = new ISPDaemon(computer1, os);
             computer1.daemons.Add(ispDaemon);
         }
         else if (rdr.Name.Equals("messageBoard"))
         {
             var messageBoardDaemon = new MessageBoardDaemon(computer1, os);
             var str3 = "Anonymous";
             if (rdr.MoveToAttribute("name"))
                 str3 = rdr.ReadContentAsString();
             messageBoardDaemon.name = str3;
             while (!(rdr.Name == "messageBoard") || rdr.IsStartElement())
             {
                 if (rdr.Name == "thread")
                 {
                     var num = (int) rdr.MoveToContent();
                     var filename1 = rdr.ReadElementContentAsString();
                     if (filename1 != null)
                         messageBoardDaemon.AddThread(Utils.readEntireFile(filename1));
                 }
                 rdr.Read();
             }
             computer1.daemons.Add(messageBoardDaemon);
         }
         else if (rdr.Name.Equals("addAvconDemoEndDaemon"))
         {
             var avconDemoEndDaemon = new AvconDemoEndDaemon(computer1, "Demo End", os);
             computer1.daemons.Add(avconDemoEndDaemon);
         }
         else if (rdr.Name.Equals("addWebServer"))
         {
             var serviceName = "Web Server";
             string pageFileLocation = null;
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("url"))
                 pageFileLocation = rdr.ReadContentAsString();
             var webServerDaemon = new WebServerDaemon(computer1, serviceName, os, pageFileLocation);
             webServerDaemon.registerAsDefaultBootDaemon();
             computer1.daemons.Add(webServerDaemon);
         }
         else if (rdr.Name.Equals("addOnlineWebServer"))
         {
             var serviceName = "Web Server";
             string url = null;
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("url"))
                 url = rdr.ReadContentAsString();
             var onlineWebServerDaemon = new OnlineWebServerDaemon(computer1, serviceName, os);
             if (url != null)
                 onlineWebServerDaemon.setURL(url);
             onlineWebServerDaemon.registerAsDefaultBootDaemon();
             computer1.daemons.Add(onlineWebServerDaemon);
         }
         else if (rdr.Name.Equals("uploadServerDaemon"))
         {
             var serviceName = "File Upload Server";
             string foldername = null;
             var input = "0,94,38";
             var needsAuthentication = false;
             if (rdr.MoveToAttribute("name"))
                 serviceName = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("folder"))
                 foldername = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("color"))
                 input = rdr.ReadContentAsString();
             if (rdr.MoveToAttribute("needsAuth"))
                 needsAuthentication = rdr.ReadContentAsString().ToLower() == "true";
             var themeColor = Utils.convertStringToColor(input);
             var uploadServerDaemon = new UploadServerDaemon(computer1, serviceName, themeColor, os, foldername,
                 needsAuthentication);
             uploadServerDaemon.registerAsDefaultBootDaemon();
             computer1.daemons.Add(uploadServerDaemon);
         }
         else if (rdr.Name.Equals("MedicalDatabase"))
         {
             var medicalDatabaseDaemon = new MedicalDatabaseDaemon(computer1, os);
             computer1.daemons.Add(medicalDatabaseDaemon);
         }
         else if (rdr.Name.Equals("HeartMonitor"))
         {
             var str3 = "UNKNOWN";
             if (rdr.MoveToAttribute("patient"))
                 str3 = rdr.ReadContentAsString();
             computer1.daemons.Add(new HeartMonitorDaemon(computer1, os)
             {
                 PatientID = str3
             });
         }
         else if (rdr.Name.Equals("PointClicker"))
         {
             var pointClickerDaemon = new PointClickerDaemon(computer1, "Point Clicker!", os);
             computer1.daemons.Add(pointClickerDaemon);
         }
         else if (rdr.Name.Equals("PorthackHeart"))
         {
             var porthackHeartDaemon = new PorthackHeartDaemon(computer1, os);
             computer1.daemons.Add(porthackHeartDaemon);
         }
         else if (rdr.Name.Equals("SongChangerDaemon"))
         {
             var songChangerDaemon = new SongChangerDaemon(computer1, os);
             computer1.daemons.Add(songChangerDaemon);
         }
         else if (rdr.Name.Equals("eosDevice"))
             EOSComp.AddEOSComp(rdr, computer1, os);
         rdr.Read();
     }
     computer1.initDaemons();
     os.netMap.nodes.Add(computer1);
     return computer1;
 }
Esempio n. 20
0
 public static string generateEmail(string subject, string body, string sender)
 {
     return("0" + MailServer.emailSplitDelimiter + MailServer.cleanString(sender) + MailServer.emailSplitDelimiter + MailServer.cleanString(subject) + MailServer.emailSplitDelimiter + MailServer.minimalCleanString(body));
 }
Esempio n. 21
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);
        }
Esempio n. 22
0
        public void doLoginDisplay(Rectangle bounds, SpriteBatch sb)
        {
            int num1 = bounds.X + 20;
            int num2 = bounds.Y + 100;

            string[] strArray = this.os.displayCache.Split(new string[1] {
                "#$#$#$$#$&$#$#$#$#"
            }, StringSplitOptions.None);
            string text1 = "";
            string text2 = "";
            int    num3  = -1;
            int    num4  = 0;

            if (strArray[0].Equals("loginData"))
            {
                text1 = !(strArray[1] != "") ? this.os.terminal.currentLine : strArray[1];
                if (strArray.Length > 2)
                {
                    num4  = 1;
                    text2 = strArray[2];
                    if (text2.Equals(""))
                    {
                        for (int index = 0; index < this.os.terminal.currentLine.Length; ++index)
                        {
                            text2 += "*";
                        }
                    }
                    else
                    {
                        string str = "";
                        for (int index = 0; index < text2.Length; ++index)
                        {
                            str += "*";
                        }
                        text2 = str;
                    }
                }
                if (strArray.Length > 3)
                {
                    num4 = 2;
                    num3 = Convert.ToInt32(strArray[3]);
                }
            }
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = bounds.X + 2;
            tmpRect.Y      = num2;
            tmpRect.Height = 200;
            tmpRect.Width  = bounds.Width - 4;
            sb.Draw(Utils.white, tmpRect, num3 == 0 ? this.os.lockedColor : this.os.indentBackgroundColor);
            if (num3 != 0 && num3 != -1)
            {
                for (int index1 = 0; index1 < this.comp.users.Count; ++index1)
                {
                    if (this.comp.users[index1].name.Equals(text1))
                    {
                        this.user = this.comp.users[index1];
                        for (int index2 = 0; index2 < this.accounts.folders.Count; ++index2)
                        {
                            if (this.accounts.folders[index2].name.Equals(this.user.name))
                            {
                                this.userFolder = this.accounts.folders[index2];
                                break;
                            }
                        }
                        break;
                    }
                }
                this.state = 3;
            }
            tmpRect.Height = 22;
            int     num5    = num2 + 30;
            Vector2 vector2 = TextItem.doMeasuredLabel(new Vector2((float)num1, (float)num5), LocaleTerms.Loc("Login") + " ", new Color?(this.textColor));

            if (num3 == 0)
            {
                int num6 = num1 + (int)vector2.X;
                TextItem.doLabel(new Vector2((float)num6, (float)num5), LocaleTerms.Loc("Failed"), new Color?(this.os.brightLockedColor));
                num1 = num6 - (int)vector2.X;
            }
            int num7 = num5 + 60;

            if (num4 == 0)
            {
                tmpRect.Y = num7;
                sb.Draw(Utils.white, tmpRect, this.os.subtleTextColor);
            }
            sb.DrawString(GuiData.smallfont, LocaleTerms.Loc("username") + " :", new Vector2((float)num1, (float)num7), this.textColor);
            int num8 = num1 + 100;

            sb.DrawString(GuiData.smallfont, text1, new Vector2((float)num8, (float)num7), this.textColor);
            int num9  = num8 - 100;
            int num10 = num7 + 30;

            if (num4 == 1)
            {
                tmpRect.Y = num10;
                sb.Draw(Utils.white, tmpRect, this.os.subtleTextColor);
            }
            sb.DrawString(GuiData.smallfont, LocaleTerms.Loc("password") + " :", new Vector2((float)num9, (float)num10), this.textColor);
            int num11 = num9 + 100;

            sb.DrawString(GuiData.smallfont, text2, new Vector2((float)num11, (float)num10), this.textColor);
            int y1 = num10 + 30;
            int x  = num11 - 100;

            if (num3 != -1)
            {
                if (Button.doButton(12345, x, y1, 70, 30, LocaleTerms.Loc("Back"), new Color?(this.os.indentBackgroundColor)))
                {
                    this.state = 0;
                }
                if (!Button.doButton(123456, x + 75, y1, 70, 30, LocaleTerms.Loc("Retry"), new Color?(this.os.indentBackgroundColor)))
                {
                    return;
                }
                this.os.displayCache = "";
                this.os.execute("login");
                do
                {
                    ;
                }while (this.os.displayCache.Equals(""));
                this.os.display.command = this.name;
            }
            else
            {
                int y2 = y1 + 65;
                for (int index = 0; index < this.comp.users.Count; ++index)
                {
                    if (this.comp.users[index].known && MailServer.validUser(this.comp.users[index].type))
                    {
                        if (Button.doButton(123457 + index, x, y2, 300, 25, "User: "******" Pass: " + this.comp.users[index].pass, new Color?(this.os.darkBackgroundColor)))
                        {
                            this.forceLogin(this.comp.users[index].name, this.comp.users[index].pass);
                        }
                        y2 += 27;
                    }
                }
            }
        }
Esempio n. 23
0
        public static void runCommand(int value, string name)
        {
            MissionFunctions.assertOS();
            if (name.ToLower().Trim() == "none")
            {
                return;
            }
            if (name.Equals("addRank"))
            {
                if (!OS.TestingPassOnly || MissionFunctions.os.currentFaction != null)
                {
                    MissionFunctions.os.currentFaction.addValue(value, (object)MissionFunctions.os);
                    string email = MailServer.generateEmail(LocaleTerms.Loc("Contract Successful"), string.Format(Utils.readEntireFile("Content/LocPost/MissionCompleteEmail.txt"), (object)MissionFunctions.os.currentFaction.getRank(), (object)MissionFunctions.os.currentFaction.getMaxRank(), (object)MissionFunctions.os.currentFaction.name), MissionFunctions.os.currentFaction.name + " ReplyBot");
                    ((MailServer)MissionFunctions.os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(email, MissionFunctions.os.defaultUser.name);
                }
                else if (OS.DEBUG_COMMANDS && MissionFunctions.os.currentFaction == null)
                {
                    MissionFunctions.os.write("----------");
                    MissionFunctions.os.write("----------");
                    MissionFunctions.os.write("ERROR IN FUNCTION 'addRank'");
                    MissionFunctions.os.write("Player is not assigned to a faction, so rank cannot be added!");
                    MissionFunctions.os.write("Make sure you have assigned a player a faction with the 'SetFaction' function before using this!");
                    MissionFunctions.os.write("----------");
                    MissionFunctions.os.write("----------");
                }
            }
            else if (name.Equals("addRankSilent"))
            {
                if (OS.TestingPassOnly && MissionFunctions.os.currentFaction == null)
                {
                    return;
                }
                MissionFunctions.os.currentFaction.addValue(value, (object)MissionFunctions.os);
            }
            else if (name.StartsWith("addFlags:"))
            {
                foreach (string flag in name.Substring("addFlags:".Length).Split(Utils.commaDelim, StringSplitOptions.RemoveEmptyEntries))
                {
                    MissionFunctions.os.Flags.AddFlag(flag);
                }
                CustomFaction currentFaction = MissionFunctions.os.currentFaction as CustomFaction;
                if (currentFaction == null)
                {
                    return;
                }
                currentFaction.CheckForAllCustomActionsToRun((object)MissionFunctions.os);
            }
            else if (name.StartsWith("removeFlags:"))
            {
                string[] strArray = name.Substring("removeFlags:".Length).Split(Utils.commaDelim, StringSplitOptions.RemoveEmptyEntries);
                for (int index = 0; index < strArray.Length; ++index)
                {
                    if (MissionFunctions.os.Flags.HasFlag(strArray[index]))
                    {
                        MissionFunctions.os.Flags.RemoveFlag(strArray[index]);
                    }
                }
                CustomFaction currentFaction = MissionFunctions.os.currentFaction as CustomFaction;
                if (currentFaction == null)
                {
                    return;
                }
                currentFaction.CheckForAllCustomActionsToRun((object)MissionFunctions.os);
            }
            else if (name.StartsWith("setFaction:"))
            {
                string newFaction = name.Substring("setFaction:".Length);
                bool   flag       = false;
                foreach (KeyValuePair <string, Faction> faction in MissionFunctions.os.allFactions.factions)
                {
                    if (faction.Value.idName.ToLower() == newFaction.ToLower())
                    {
                        MissionFunctions.os.allFactions.setCurrentFaction(newFaction, MissionFunctions.os);
                        flag = true;
                        break;
                    }
                }
                if (!flag && OS.TestingPassOnly)
                {
                    throw new NullReferenceException("Faction " + newFaction + "not found for setFaction action!");
                }
            }
            else if (name.StartsWith("loadConditionalActions:"))
            {
                RunnableConditionalActions.LoadIntoOS(name.Substring("loadConditionalActions:".Length), (object)MissionFunctions.os);
            }
            else if (name.Equals("triggerThemeHackRevenge"))
            {
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(5.0), (Action)(() =>
                {
                    string email = MailServer.generateEmail(LocaleTerms.Loc("Are you Kidding me?"), Utils.readEntireFile("Content/LocPost/NaixEmail.txt"), "*****@*****.**");
                    ((MailServer)MissionFunctions.os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(email, MissionFunctions.os.defaultUser.name);
                    MissionFunctions.os.delayer.Post(ActionDelayer.Wait(24.0), (Action)(() =>
                    {
                        try
                        {
                            HackerScriptExecuter.runScript("HackerScripts/ThemeHack.txt", (object)MissionFunctions.os, (string)null, (string)null);
                        }
                        catch (Exception ex)
                        {
                            if (!Settings.recoverFromErrorsSilently)
                            {
                                throw ex;
                            }
                            MissionFunctions.os.write("CAUTION: UNSYNDICATED OUTSIDE CONNECTION ATTEMPT");
                            MissionFunctions.os.write("RECOVERED FROM CONNECTION SUBTERFUGE SUCCESSFULLY");
                            Console.WriteLine("Critical error loading hacker script - aborting");
                        }
                    }));
                }));
            }
            else if (name.Equals("changeSong"))
            {
                switch (value)
                {
                case 2:
                    MusicManager.transitionToSong("Music\\The_Quickening");
                    break;

                case 3:
                    MusicManager.transitionToSong("Music\\TheAlgorithm");
                    break;

                case 4:
                    MusicManager.transitionToSong("Music\\Ryan3");
                    break;

                case 5:
                    MusicManager.transitionToSong("Music\\Bit(Ending)");
                    break;

                case 6:
                    MusicManager.transitionToSong("Music\\Rico_Puestel-Roja_Drifts_By");
                    break;

                case 7:
                    MusicManager.transitionToSong("Music\\out_run_the_wolves");
                    break;

                case 8:
                    MusicManager.transitionToSong("Music\\Irritations");
                    break;

                case 9:
                    MusicManager.transitionToSong("Music\\Broken_Boy");
                    break;

                case 10:
                    MusicManager.transitionToSong("Music\\Ryan10");
                    break;

                case 11:
                    MusicManager.transitionToSong("Music\\tetrameth");
                    break;

                default:
                    MusicManager.transitionToSong("Music\\Revolve");
                    break;
                }
            }
            else if (name.Equals("entropyEndMissionSetup"))
            {
                MissionFunctions.runCommand(3, "changeSong");
                Computer  comp1      = MissionFunctions.findComp("corp0#IS");
                Computer  comp2      = MissionFunctions.findComp("corp0#MF");
                Computer  comp3      = MissionFunctions.findComp("corp0#BU");
                FileEntry fileEntry1 = new FileEntry(Computer.generateBinaryString(5000), "HacknetOS.rar");
                FileEntry fileEntry2 = new FileEntry(Computer.generateBinaryString(4000), "HacknetOS_Data.xnb");
                FileEntry fileEntry3 = new FileEntry(Computer.generateBinaryString(4000), "HacknetOS_Content.xnb");
                Folder    folder1    = comp1.files.root.folders[2];
                folder1.files.Add(fileEntry1);
                folder1.files.Add(fileEntry2);
                folder1.files.Add(fileEntry3);
                Folder folder2 = comp2.files.root.folders[2];
                folder2.files.Add(fileEntry1);
                folder2.files.Add(fileEntry2);
                folder2.files.Add(fileEntry3);
                FileEntry fileEntry4 = new FileEntry(fileEntry1.data, fileEntry1.name + "_backup");
                FileEntry fileEntry5 = new FileEntry(fileEntry2.data, fileEntry2.name + "_backup");
                FileEntry fileEntry6 = new FileEntry(fileEntry3.data, fileEntry3.name + "_backup");
                Folder    folder3    = comp3.files.root.folders[2];
                folder3.files.Add(fileEntry4);
                folder3.files.Add(fileEntry5);
                folder3.files.Add(fileEntry6);
                comp1.traceTime           = Computer.BASE_TRACE_TIME * 7.5f;
                comp3.traceTime           = Computer.BASE_TRACE_TIME * 7.5f;
                comp2.traceTime           = Computer.BASE_TRACE_TIME * 7.5f;
                comp2.portsNeededForCrack = 3;
                comp1.portsNeededForCrack = 2;
                comp3.portsNeededForCrack = 2;
                Folder folder4 = MissionFunctions.findComp("entropy01").files.root.folders[2];
                folder4.files.Add(new FileEntry(PortExploits.crackExeData[25], "SMTPoverflow.exe"));
                folder4.files.Add(new FileEntry(PortExploits.crackExeData[80], "WebServerWorm.exe"));
            }
            else if (name.Equals("entropyAddSMTPCrack"))
            {
                Folder folder = MissionFunctions.findComp("entropy01").files.root.folders[2];
                bool   flag   = false;
                for (int index = 0; index < folder.files.Count; ++index)
                {
                    if (folder.files[index].data == PortExploits.crackExeData[25] || folder.files[index].name == "SMTPoverflow.exe")
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    folder.files.Add(new FileEntry(PortExploits.crackExeData[25], Utils.GetNonRepeatingFilename("SMTPoverflow", ".exe", folder)));
                }
                MissionFunctions.os.Flags.AddFlag("ThemeHackTransitionAssetsAdded");
            }
            else if (name.Equals("transitionToBitMissions"))
            {
                if (Settings.isDemoMode)
                {
                    MissionFunctions.runCommand(6, "changeSong");
                    if (Settings.isPressBuildDemo)
                    {
                        ComputerLoader.loadMission("Content/Missions/Demo/PressBuild/DemoMission01.xml", false);
                    }
                    else
                    {
                        ComputerLoader.loadMission("Content/Missions/Demo/AvconDemo.xml", false);
                    }
                }
                else
                {
                    ComputerLoader.loadMission("Content/Missions/BitMission0.xml", false);
                }
            }
            else if (name.Equals("entropySendCSECInvite"))
            {
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(6.0), (Action)(() => ComputerLoader.loadMission("Content/Missions/MainHub/Intro/Intro01.xml", false)));
            }
            else if (name.Equals("hubBitSetComplete01"))
            {
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(4.0), (Action)(() => MissionFunctions.runCommand(1, "addRank")));
                MissionFunctions.runCommand(3, "changeSong");
                MissionFunctions.os.Flags.AddFlag("csecBitSet01Complete");
            }
            else if (name.Equals("enTechEnableOfflineBackup"))
            {
                Programs.getComputer(MissionFunctions.os, "EnTechOfflineBackup");
                MissionFunctions.os.Flags.AddFlag("VaporSequencerEnabled");
                Folder folder1 = MissionFunctions.findComp("mainHubAssets").files.root.searchForFolder("bin");
                Folder folder2 = folder1.searchForFolder("Sequencer");
                if (folder2 == null)
                {
                    folder2 = new Folder("Sequencer");
                    folder1.folders.Add(folder2);
                }
                if (folder2.searchForFile("Sequencer.exe") != null)
                {
                    return;
                }
                folder2.files.Add(new FileEntry(PortExploits.crackExeData[17], "Sequencer.exe"));
            }
            else if (name.Equals("rudeNaixResponse"))
            {
                AchievementsManager.Unlock("rude_response", false);
            }
            else if (name.Equals("assignPlayerToHubServerFaction"))
            {
                MissionFunctions.os.allFactions.setCurrentFaction("hub", MissionFunctions.os);
                Computer         computer   = Programs.getComputer(MissionFunctions.os, "mainHub");
                MissionHubServer daemon     = (MissionHubServer)computer.getDaemon(typeof(MissionHubServer));
                UserDetail       userDetail = new UserDetail(MissionFunctions.os.defaultUser.name, "reptile", (byte)3);
                computer.addNewUser(computer.ip, userDetail);
                daemon.addUser(userDetail);
                MissionFunctions.os.homeNodeID        = "mainHub";
                MissionFunctions.os.homeAssetServerID = "mainHubAssets";
                MissionFunctions.runCommand(3, "changeSong");
                MissionFunctions.os.Flags.AddFlag("CSEC_Member");
                AchievementsManager.Unlock("progress_csec", false);
                if (!MissionFunctions.os.HasLoadedDLCContent || !Settings.EnableDLC || MissionFunctions.os.Flags.HasFlag("dlc_complete"))
                {
                    return;
                }
                daemon.AddMissionToListings("Content/DLC/Missions/BaseGameConnectors/Missions/CSEC_DLCConnectorIntro.xml", 1);
            }
            else if (name.Equals("assignPlayerToEntropyFaction"))
            {
                MissionFunctions.runCommand(6, "changeSong");
                MissionFunctions.os.homeNodeID        = "entropy00";
                MissionFunctions.os.homeAssetServerID = "entropy01";
                AchievementsManager.Unlock("progress_entropy", false);
            }
            else if (name.Equals("assignPlayerToLelzSec"))
            {
                MissionFunctions.os.homeNodeID        = "lelzSecHub";
                MissionFunctions.os.homeAssetServerID = "lelzSecHub";
                MissionFunctions.os.Flags.AddFlag("LelzSec_Member");
                AchievementsManager.Unlock("progress_lelz", false);
            }
            else if (name.Equals("lelzSecVictory"))
            {
                AchievementsManager.Unlock("secret_path_complete", false);
            }
            else if (name.Equals("demoFinalMissionEnd"))
            {
                MissionFunctions.os.exes.Clear();
                PostProcessor.EndingSequenceFlashOutActive             = true;
                PostProcessor.EndingSequenceFlashOutPercentageComplete = 1f;
                MusicManager.stop();
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.2), (Action)(() => MissionFunctions.os.content.Load <SoundEffect>("Music/Ambient/spiral_gauge_down").Play()));
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(3.0), (Action)(() =>
                {
                    PostProcessor.dangerModeEnabled = false;
                    PostProcessor.dangerModePercentComplete = 0.0f;
                    MissionFunctions.os.ExitScreen();
                    MissionFunctions.os.ScreenManager.AddScreen((GameScreen) new DemoEndScreen());
                }));
            }
            else if (name.Equals("demoFinalMissionEndDLC"))
            {
                if (!Settings.isDemoMode)
                {
                    return;
                }
                MissionFunctions.os.exes.Clear();
                PostProcessor.EndingSequenceFlashOutActive             = true;
                PostProcessor.EndingSequenceFlashOutPercentageComplete = 1f;
                MusicManager.stop();
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.0), (Action)(() => MissionFunctions.os.content.Load <SoundEffect>("SFX/BrightFlash").Play()));
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.4), (Action)(() => MissionFunctions.os.content.Load <SoundEffect>("SFX/TraceKill").Play()));
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(1.6), (Action)(() =>
                {
                    MusicManager.playSongImmediatley("DLC/Music/DreamHead");
                    PostProcessor.dangerModeEnabled = false;
                    PostProcessor.dangerModePercentComplete = 0.0f;
                    MissionFunctions.os.ScreenManager.AddScreen((GameScreen) new DemoEndScreen()
                    {
                        StopsMusic = false,
                        IsDLCDemoScreen = true
                    });
                    MissionFunctions.os.ExitScreen();
                }));
            }
            else if (name.Equals("demoFinalMissionStart"))
            {
                MissionFunctions.os.Flags.AddFlag("DemoSequencerEnabled");
                MusicManager.transitionToSong("Music/Ambient/dark_drone_008");
            }
            else if (name.Equals("CSECTesterGameWorldSetup"))
            {
                for (int index = 0; index < PortExploits.services.Count && index < 4; ++index)
                {
                    MissionFunctions.os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[PortExploits.portNums[index]], PortExploits.cracks[PortExploits.portNums[index]]));
                }
                for (int index = 0; index < 4; ++index)
                {
                    Computer c = new Computer("DebugShell" + (object)index, NetworkMap.generateRandomIP(), MissionFunctions.os.netMap.getRandomPosition(), 0, (byte)2, MissionFunctions.os);
                    c.adminIP = MissionFunctions.os.thisComputer.adminIP;
                    MissionFunctions.os.netMap.nodes.Add(c);
                    MissionFunctions.os.netMap.discoverNode(c);
                }
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.2), (Action)(() =>
                {
                    MissionFunctions.os.allFactions.setCurrentFaction("entropy", MissionFunctions.os);
                    MissionFunctions.os.currentMission = (ActiveMission)null;
                    MissionFunctions.os.netMap.discoverNode(Programs.getComputer(MissionFunctions.os, "entropy00"));
                    MissionFunctions.os.netMap.discoverNode(Programs.getComputer(MissionFunctions.os, "entropy01"));
                }));
            }
            else if (name.Equals("EntropyFastFowardSetup"))
            {
                MissionFunctions.os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[22], PortExploits.cracks[22]));
                MissionFunctions.os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[21], PortExploits.cracks[21]));
                for (int index = 0; index < 3; ++index)
                {
                    Computer c = new Computer("DebugShell" + (object)index, NetworkMap.generateRandomIP(), MissionFunctions.os.netMap.getRandomPosition(), 0, (byte)2, MissionFunctions.os);
                    c.adminIP = MissionFunctions.os.thisComputer.adminIP;
                    MissionFunctions.os.netMap.nodes.Add(c);
                    MissionFunctions.os.netMap.discoverNode(c);
                }
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.2), (Action)(() =>
                {
                    MissionFunctions.os.allFactions.setCurrentFaction("entropy", MissionFunctions.os);
                    MissionFunctions.os.currentMission = (ActiveMission)null;
                    MissionFunctions.os.netMap.discoverNode(Programs.getComputer(MissionFunctions.os, "entropy00"));
                    MissionFunctions.os.netMap.discoverNode(Programs.getComputer(MissionFunctions.os, "entropy01"));
                    Computer computer = Programs.getComputer(MissionFunctions.os, "entropy01");
                    UserDetail user = computer.users[0];
                    user.known = true;
                    computer.users[0] = user;
                    MissionFunctions.os.allFactions.factions[MissionFunctions.os.allFactions.currentFaction].playerValue = 2;
                    MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.2), (Action)(() =>
                    {
                        MissionFunctions.os.Flags.AddFlag("eosPathStarted");
                        ComputerLoader.loadMission("Content/Missions/Entropy/StartingSet/eosMissions/eosIntroDelayer.xml", false);
                    }));
                }));
            }
            else if (name.Equals("CSECFastFowardSetup"))
            {
                MissionFunctions.os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[22], PortExploits.cracks[22]));
                MissionFunctions.os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[21], PortExploits.cracks[21]));
                for (int index = 0; index < 3; ++index)
                {
                    Computer c = new Computer("DebugShell" + (object)index, NetworkMap.generateRandomIP(), MissionFunctions.os.netMap.getRandomPosition(), 0, (byte)2, MissionFunctions.os);
                    c.adminIP = MissionFunctions.os.thisComputer.adminIP;
                    MissionFunctions.os.netMap.nodes.Add(c);
                    MissionFunctions.os.netMap.discoverNode(c);
                }
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(0.2), (Action)(() =>
                {
                    MissionFunctions.runCommand(0, "assignPlayerToHubServerFaction");
                    MissionFunctions.os.currentMission = (ActiveMission)null;
                    MissionFunctions.os.netMap.discoverNode(Programs.getComputer(MissionFunctions.os, "mainHub"));
                    MissionFunctions.os.netMap.discoverNode(Programs.getComputer(MissionFunctions.os, "mainHubAssets"));
                    Computer computer = Programs.getComputer(MissionFunctions.os, "mainHubAssets");
                    UserDetail user = computer.users[0];
                    user.known = true;
                    computer.users[0] = user;
                }));
            }
            else if (name.Equals("csecAddTraceKill"))
            {
                Folder folder = MissionFunctions.findComp("mainHubAssets").files.root.searchForFolder("bin");
                Folder f      = folder.searchForFolder("TK");
                if (f == null)
                {
                    f = new Folder("TK");
                    folder.folders.Add(f);
                }
                f.files.Add(new FileEntry(FileEncrypter.EncryptString(PortExploits.crackExeData[12], "Vapor Trick Enc.", "NULL", "dx122DX", ".exe"), Utils.GetNonRepeatingFilename("TraceKill", ".dec", f)));
                MissionFunctions.os.Flags.AddFlag("bitPathStarted");
                MissionFunctions.runCommand(10, "changeSong");
            }
            else if (name.Equals("junebugComplete"))
            {
                Computer computer = Programs.getComputer(MissionFunctions.os, "pacemaker01");
                if (computer != null)
                {
                    HeartMonitorDaemon daemon = (HeartMonitorDaemon)computer.getDaemon(typeof(HeartMonitorDaemon));
                    if (daemon != null)
                    {
                        daemon.ForceStopBeepSustainSound();
                    }
                }
                MissionFunctions.runCommand(1, "addRank");
            }
            else if (name.Equals("eosIntroMissionSetup"))
            {
                MissionFunctions.findComp("entropy01").files.root.searchForFolder("bin").files.Add(new FileEntry(PortExploits.crackExeData[13], "eosDeviceScan.exe"));
                MissionFunctions.os.delayer.Post(ActionDelayer.Wait(8.0), (Action)(() =>
                {
                    string email = MailServer.generateEmail("Fwd: eOS Stuff", Utils.readEntireFile("Content/Post/eosScannerMail.txt"), "vtfx", new List <string>((IEnumerable <string>) new string[1] {
                        "note#%#" + LocaleTerms.Loc("eOS Security Basics") + "#%#" + Utils.readEntireFile("Content/LocPost/eOSNote.txt")
                    }));
                    ((MailServer)MissionFunctions.os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(email, MissionFunctions.os.defaultUser.name);
                    MissionFunctions.os.saveGame();
                }));
                MissionFunctions.runCommand(4, "changeSong");
                MissionFunctions.os.saveGame();
            }
            else if (name.Equals("eosIntroEndFunc"))
            {
                MissionFunctions.runCommand(1, "addRank");
                MissionListingServer daemon         = (MissionListingServer)MissionFunctions.findComp("entropy00").getDaemon(typeof(MissionListingServer));
                List <ActiveMission> branchMissions = MissionFunctions.os.branchMissions;
                ActiveMission        m = (ActiveMission)ComputerLoader.readMission("Content/Missions/Entropy/StartingSet/eosMissions/eosAddedMission.xml");
                daemon.addMisison(m, false);
                MissionFunctions.os.branchMissions = branchMissions;
            }
            else if (name.Equals("changeSongDLC"))
            {
                switch (value)
                {
                case 2:
                    MusicManager.transitionToSong("DLC\\Music\\snidelyWhiplash");
                    break;

                case 3:
                    MusicManager.transitionToSong("DLC\\Music\\Slow_Motion");
                    break;

                case 4:
                    MusicManager.transitionToSong("DLC\\Music\\World_Chase");
                    break;

                case 5:
                    MusicManager.transitionToSong("DLC\\Music\\HOME_Resonance");
                    break;

                case 6:
                    MusicManager.transitionToSong("DLC\\Music\\Remi_Finale");
                    break;

                case 7:
                    MusicManager.transitionToSong("DLC\\Music\\RemiDrone");
                    break;

                case 8:
                    MusicManager.transitionToSong("DLC\\Music\\DreamHead");
                    break;

                case 9:
                    MusicManager.transitionToSong("DLC\\Music\\Userspacelike");
                    break;

                case 10:
                    MusicManager.transitionToSong("DLC\\Music\\CrashTrack");
                    break;

                default:
                    MusicManager.transitionToSong("DLC\\Music\\Remi2");
                    break;
                }
            }
            else if (name.Equals("scanAndStartDLCVenganceHack"))
            {
                Computer comp = MissionFunctions.findComp("dAttackTarget");
                if (comp == null)
                {
                    return;
                }
                Folder folder = comp.files.root.searchForFolder("log");
                bool   flag   = false;
                for (int index = 0; index < folder.files.Count; ++index)
                {
                    if (folder.files[index].data.Contains(MissionFunctions.os.thisComputer.ip))
                    {
                        SARunFunction saRunFunction = new SARunFunction()
                        {
                            DelayHost = "dhs", FunctionName = "triggerDLCHackRevenge", FunctionValue = 1
                        };
                        ((DLCHubServer)Programs.getComputer(MissionFunctions.os, "dhs").getDaemon(typeof(DLCHubServer))).DelayedActions.AddAction((SerializableAction)saRunFunction, 16f);
                        break;
                    }
                }
                if (!flag)
                {
                    MissionFunctions.runCommand(4, "changeSongDLC");
                }
            }
            else if (name.Equals("triggerDLCHackRevenge"))
            {
                try
                {
                    HackerScriptExecuter.runScript("DLC/ActionScripts/Hackers/SystemHack.txt", (object)MissionFunctions.os, (string)null, (string)null);
                }
                catch (Exception ex)
                {
                    if (!Settings.recoverFromErrorsSilently)
                    {
                        throw ex;
                    }
                    MissionFunctions.os.write("CAUTION: UNSYNDICATED OUTSIDE CONNECTION ATTEMPT");
                    MissionFunctions.os.write("RECOVERED FROM CONNECTION SUBTERFUGE SUCCESSFULLY");
                    Console.WriteLine("Critical error loading hacker script - aborting\r\n" + Utils.GenerateReportFromException(ex));
                }
            }
            else if (name.Equals("activateAircraftStatusOverlay"))
            {
                MissionFunctions.os.AircraftInfoOverlay.Activate();
                MissionFunctions.os.AircraftInfoOverlay.IsMonitoringDLCEndingCases = true;
            }
            else if (name.Equals("activateAircraftStatusOverlayLabyrinthsMonitoring"))
            {
                MissionFunctions.os.AircraftInfoOverlay.IsMonitoringDLCEndingCases = true;
            }
            else if (name.Equals("deActivateAircraftStatusOverlay"))
            {
                MissionFunctions.os.AircraftInfoOverlay.IsActive = false;
                MissionFunctions.os.AircraftInfoOverlay.IsMonitoringDLCEndingCases = false;
                MissionFunctions.os.Flags.AddFlag("AircraftInfoOverlayDeactivated");
            }
            else if (name.Equals("defAttackAircraft"))
            {
                Computer computer = Programs.getComputer(MissionFunctions.os, "dair_crash");
                Folder   folder   = computer.files.root.searchForFolder("FlightSystems");
                for (int index = 0; index < folder.files.Count; ++index)
                {
                    if (folder.files[index].name == "747FlightOps.dll")
                    {
                        folder.files.RemoveAt(index);
                        break;
                    }
                }
                ((AircraftDaemon)computer.getDaemon(typeof(AircraftDaemon))).StartReloadFirmware();
                if (MissionFunctions.os.AircraftInfoOverlay.IsActive)
                {
                    return;
                }
                MissionFunctions.os.AircraftInfoOverlay.Activate();
                MissionFunctions.os.AircraftInfoOverlay.IsMonitoringDLCEndingCases = true;
            }
            else if (name.Equals("playAirlineCrashSongSequence"))
            {
                MusicManager.playSongImmediatley("DLC\\Music\\Remi_Finale");
                MediaPlayer.IsRepeating = false;
            }
            else if (name.Equals("flashUI"))
            {
                MissionFunctions.os.warningFlash();
            }
            else if (name.Equals("addRankSilent"))
            {
                MissionFunctions.os.currentFaction.addValue(value, (object)MissionFunctions.os);
            }
            else if (name.StartsWith("addRankFaction:"))
            {
                string str = name.Substring("addRankFaction:".Length);
                foreach (KeyValuePair <string, Faction> faction in MissionFunctions.os.allFactions.factions)
                {
                    if (faction.Value.idName.ToLower() == str.ToLower())
                    {
                        faction.Value.addValue(value, (object)MissionFunctions.os);
                        break;
                    }
                }
            }
            else if (name.StartsWith("setHubServer:"))
            {
                string str = name.Substring("setHubServer:".Length);
                MissionFunctions.os.homeNodeID = str;
            }
            else if (name.StartsWith("setAssetServer:"))
            {
                string str = name.Substring("setAssetServer:".Length);
                MissionFunctions.os.homeAssetServerID = str;
            }
            else if (name.StartsWith("playCustomSong:"))
            {
                string songName = Utils.GetFileLoadPrefix() + name.Substring("playCustomSong:".Length);
                if (songName.EndsWith(".ogg"))
                {
                    songName = songName.Substring(0, songName.Length - ".ogg".Length);
                }
                if (songName.StartsWith("Content"))
                {
                    songName = songName.Substring("Content/".Length);
                }
                else if (songName.StartsWith("Extensions"))
                {
                    songName = "../" + songName;
                }
                MusicManager.transitionToSong(songName);
            }
            else if (name.StartsWith("playCustomSongImmediatley:"))
            {
                string songname = Utils.GetFileLoadPrefix() + name.Substring("playCustomSongImmediatley:".Length);
                if (songname.EndsWith(".ogg"))
                {
                    songname = songname.Substring(0, songname.Length - ".ogg".Length);
                }
                if (songname.StartsWith("Content"))
                {
                    songname = songname.Substring("Content/".Length);
                }
                else if (songname.StartsWith("Extensions"))
                {
                    songname = "../" + songname;
                }
                MusicManager.playSongImmediatley(songname);
            }
            else
            {
                if (OS.TestingPassOnly && !string.IsNullOrWhiteSpace(name))
                {
                    throw new FormatException("No Command Function " + name);
                }
                if (MissionFunctions.ReportErrorInCommand != null)
                {
                    MissionFunctions.ReportErrorInCommand("No command found for \"" + name + "\" with value \"" + (object)value + "\"");
                }
            }
        }
Esempio n. 24
0
 public static void AddMailToServer(this Hacknet.MailServer server, string recip, string mail)
 => server.setupComplete = () => server.addMail(mail, recip);
Esempio n. 25
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);
        }