예제 #1
0
        public static string GetReportOnHashCodeOfEmptyStringForOtherCLRVersion()
        {
            string data1 = Utils.readEntireFile("DebugTest.txt");
            string data2 = FileEncrypter.EncryptString("test content", "headercontent", "1.1.1.1.1", "12345asdf", (string)null);

            Console.WriteLine("password 12345asdf hashes to: " + (object)(ushort)"12345asdf".GetHashCode());
            for (ushort pass = 0; (int)pass < (int)ushort.MaxValue; ++pass)
            {
                if (FileEncrypter.TestingDecryptString(data1, pass)[0].Contains("Firmware"))
                {
                    Console.WriteLine("Match Found: " + (object)pass + " is valid match, current CLR produces: " + (object)(ushort)"".GetHashCode());
                }
                else
                {
                    if ((int)pass % 1000 == 0)
                    {
                        Console.Write(".");
                    }
                    if ((int)pass % 50000 == 0)
                    {
                        Console.WriteLine("");
                    }
                }
                string[] strArray = FileEncrypter.TestingDecryptString(data2, pass);
                if (strArray[2] != null && strArray[2].Contains("test") && (strArray[4] != null && strArray[4] == "1") && strArray[5] != null && strArray[5] == "ENCODED")
                {
                    Console.WriteLine("Alt Match Found: " + (object)pass + " is valid match, current CLR produces: " + (object)(ushort)"".GetHashCode());
                }
            }
            Console.WriteLine("Operation Complete");
            return("");
        }
예제 #2
0
 public string Serialize()
 {
     return("" + this.Username + SaveAccountData.Delimiter[0] + FileEncrypter.EncryptString(this.Password, "", "", "", (string)null) + SaveAccountData.Delimiter[0] + Utils.SafeWriteDateTime(this.LastWriteTime) + SaveAccountData.Delimiter[0] + this.FileUsername);
 }
예제 #3
0
 public string Serialize()
 {
     return("" + Username + Delimiter[0] + FileEncrypter.EncryptString(Password, "", "", "", null) + Delimiter[0] +
            LastWriteTime.ToString(CultureInfo.InvariantCulture) + Delimiter[0] + FileUsername);
 }
예제 #4
0
        public static Computer LoadComputer(string filename, OS os, bool preventAddingToNetmap = false, bool preventInitDaemons = false)
        {
            PreventNetmapAdd  = preventAddingToNetmap;
            PreventDaemonInit = preventInitDaemons;

            filename = LocalizedFileLoader.GetLocalizedFilepath(filename);
            Computer result = null;
            string   themeData;

            var executor    = new EventExecutor(filename, ignoreCase: true);
            var readContent = true;

            if (filename.Contains("ExampleComputer.xml") && !Util.Extensions.CheckLabyrinths())
            {
                executor.OnRead += exec =>
                {
                    var val = Regex.Replace(exec.Reader.Value.Trim().ToLower().Replace('_', ' '), @"s/\s{2,}/ /g", "");
                    if (readContent && val == "end labyrinths only content")
                    {
                        readContent = true;
                    }
                    else if (!readContent && val == "start labyrinths only content")
                    {
                        readContent = false;
                    }
                    return(readContent);
                };
            }

            executor.AddExecutor("Computer", (exec, info) =>
            {
                var compType = info.Attributes.GetValue("type");
                result       = new Computer(
                    info.Attributes.GetValue("name", true) ?? "UNKNOWN",
                    info.Attributes.GetValue("ip", true) ?? Utility.GenerateRandomIP(),
                    os.netMap.getRandomPosition(),
                    Convert.ToInt32(info.Attributes.GetValue("security")),
                    compType?.ToLower() == "empty" ? (byte)4 : Convert.ToByte(compType),
                    os)
                {
                    idName = info.Attributes.GetValue("id") ?? "UNKNOWN",
                    AllowsDefaultBootModule = info.Attributes.GetValue("allowsDefaultBootModule")?.ToLower() != "false",
                    icon = info.Attributes.GetValue("icon")
                };
                if (result.type != 4)
                {
                    return;
                }
                var folder = result.files.root.searchForFolder("home");
                folder?.files.Clear();
                folder?.folders.Clear();
            });

            executor.AddExecutor("Computer.File", (exec, info) =>
            {
                var encodedFileStr = info.Attributes.GetValueOrDefault("name", "Data", true).HacknetFilter();
                themeData          = info.Value;
                if (string.IsNullOrEmpty(themeData))
                {
                    themeData = Utility.GenerateBinString();
                }
                themeData          = themeData.HacknetFilter();
                var folderFromPath = result.getFolderFromPath(
                    info.Attributes.GetValueOrDefault("path", "home"), true);
                if (!info.Attributes.GetBool("EduSafe", true) &&
                    (Settings.EducationSafeBuild || !Settings.EducationSafeBuild) &&
                    info.Attributes.GetBool("EduSafeOnly"))
                {
                    return;
                }
                var file = folderFromPath.searchForFile(encodedFileStr);
                if (file == null)
                {
                    folderFromPath.files.Add(new FileEntry(themeData, encodedFileStr));
                }
                else
                {
                    file.data = encodedFileStr;
                }
            }, true);

            executor.AddExecutor("Computer.EncryptedFile", (exec, info) =>
            {
                var encodedFileStr = info.Attributes.GetValueOrDefault("name", "Data", true);
                var header         = info.Attributes.GetValueOrDefault("header", "ERROR");
                var ip             = info.Attributes.GetValueOrDefault("ip", "ERROR");
                var pass           = info.Attributes.GetValueOrDefault("pass", "");
                var extension      = info.Attributes.GetValue("extension");
                var doubleAttr     = info.Attributes.GetBool("double");
                themeData          = info.Value;
                if (string.IsNullOrEmpty(themeData))
                {
                    themeData = Utility.GenerateBinString();
                }
                themeData = themeData.HacknetFilter();
                if (doubleAttr)
                {
                    themeData = FileEncrypter.EncryptString(themeData, header, ip, pass, extension);
                }
                themeData = FileEncrypter.EncryptString(themeData, header, ip, pass,
                                                        (doubleAttr ? "_LAYER2.dec" : extension));
                var folderFromPath = result.getFolderFromPath(
                    info.Attributes.GetValue("path") ?? "home", true);
                var file = folderFromPath.searchForFile(encodedFileStr);
                if (file == null)
                {
                    folderFromPath.files.Add(new FileEntry(themeData, encodedFileStr));
                }
                else
                {
                    file.data = themeData;
                }
            }, true);


            executor.AddExecutor("Computer.MemoryDumpFile", (exec, info) =>
            {
                var memoryInfo = info.Children.FirstOrDefault(e => e.Name == "Memory");
                if (memoryInfo == null)
                {
                    /* TODO: error reporting */
                }
                var memoryContents = ReplacementsCommon.LoadMemoryContents(memoryInfo);
                var fileName       = info.Attributes.GetValueOrDefault("name", "Data");
                var folderFromPath = result.getFolderFromPath(info.Attributes.GetValueOrDefault("path", "home"), true);
                var file           = folderFromPath.searchForFile(fileName);
                if (file != null)
                {
                    file.data = memoryContents.GetEncodedFileString();
                }
                else
                {
                    folderFromPath.files.Add(new FileEntry(memoryContents.GetEncodedFileString(), fileName));
                }
            }, true);

            executor.AddExecutor("Computer.Memory", (exec, info) =>
            {
                result.Memory = ReplacementsCommon.LoadMemoryContents(info);
            }, true);

            executor.AddExecutor("Computer.CustomThemeFile", (exec, info) =>
            {
                var encodedFileStr = info.Attributes.GetValueOrDefault("name", "Data", true);
                themeData          = ThemeManager.getThemeDataStringForCustomTheme(info.Attributes.GetValue("themePath"));
                themeData          = string.IsNullOrEmpty(themeData)
                    ? "DEFINITION ERROR - Theme generated incorrectly. No Custom theme found at definition path"
                    : themeData.HacknetFilter();
                var folderFromPath = result.getFolderFromPath(
                    info.Attributes.GetValueOrDefault("path", "home"), true);
                var file = folderFromPath.searchForFile(encodedFileStr);
                if (file == null)
                {
                    folderFromPath.files.Add(new FileEntry(themeData, encodedFileStr));
                }
                else
                {
                    file.data = themeData;
                }
            });

            executor.AddExecutor("Computer.Ports", (exec, info) =>
                                 ComputerLoader.loadPortsIntoComputer(info.Value, result), true);

            executor.AddExecutor("Computer.PositionNear", (exec, info) =>
            {
                var target        = info.Attributes.GetValueOrDefault("target", "");
                var position      = info.Attributes.GetInt("position", 1);
                var total         = info.Attributes.GetInt("total", 3);
                var force         = info.Attributes.GetBool("force");
                var extraDistance = MathHelper.Clamp(info.Attributes.GetFloat("extraDistance"), -1, 1);
                ComputerLoader.postAllLoadedActions += () =>
                {
                    var c = Programs.getComputer(os, target);
                    if (c != null)
                    {
                        result.location = c.location
                                          + Corporation.getNearbyNodeOffset(
                            c.location,
                            position,
                            total,
                            os.netMap,
                            extraDistance,
                            force);
                    }
                };
            });

            executor.AddExecutor("Computer.Proxy", (exec, info) =>
            {
                var time = info.Attributes.GetFloat("time", 1);
                if (time <= 0f)
                {
                    result.hasProxy    = false;
                    result.proxyActive = false;
                }
            });

            executor.AddExecutor("Computer.PortsForCrack", (exec, info) =>
            {
                var val = info.Attributes.GetInt("val", -1);
                if (val != -1)
                {
                    result.portsNeededForCrack = val - 1;
                }
            });

            executor.AddExecutor("Computer.Firewall", (exec, info) =>
            {
                var level = info.Attributes.GetInt("level", 1);
                if (level <= 0)
                {
                    result.firewall = null;
                }
                else
                {
                    var solution = info.Attributes.GetValue("solution");
                    if (solution == null)
                    {
                        result.addFirewall(level);
                    }
                    else
                    {
                        result.addFirewall(
                            level, solution, info.Attributes.GetFloat("additionalTime"));
                    }
                }
            });

            executor.AddExecutor("Computer.Link", (exec, info) =>
            {
                var linkedComp =
                    Programs.getComputer(os, info.Attributes.GetValueOrDefault("target", ""));
                if (linkedComp != null)
                {
                    result.links.Add(os.netMap.nodes.IndexOf(linkedComp));
                }
            });

            executor.AddExecutor("Computer.Dlink", (exec, info) =>
            {
                /* captures for lambda */
                var offsetComp = result;
                var linkTo     = info.Attributes.GetValueOrDefault("target", "");
                ComputerLoader.postAllLoadedActions += () =>
                {
                    var linkedComp =
                        Programs.getComputer(os, linkTo);
                    if (linkedComp != null)
                    {
                        offsetComp.links.Add(os.netMap.nodes.IndexOf(linkedComp));
                    }
                };
            });

            executor.AddExecutor("Computer.Trace", (exec, info) =>
                                 result.traceTime = info.Attributes.GetFloat("time", 1));

            executor.AddExecutor("Computer.AdminPass", (exec, info) =>
                                 result.setAdminPassword(
                                     info.Attributes.GetValue("pass", true) ?? PortExploits.getRandomPassword()));

            executor.AddExecutor("Computer.Admin", (exec, info) =>
                                 result.admin = Utility.GetAdminFromString(
                                     info.Attributes.GetValueOrDefault("type", "basic"),
                                     info.Attributes.GetBool("resetPassword", true),
                                     info.Attributes.GetBool("isSuper")
                                     ));

            executor.AddExecutor("Computer.PortRemap", (exec, info) =>
            {
                if (!string.IsNullOrWhiteSpace(info.Value))
                {
                    result.PortRemapping = PortRemappingSerializer.Deserialize(info.Value);
                }
            }, true);

            executor.AddExecutor("Computer.ExternalCounterpart", (exec, info)
                                 => result.externalCounterpart = new ExternalCounterpart(info.Attributes.GetValue("name"),
                                                                                         ExternalCounterpart.getIPForServerName(info.Attributes.GetValue("id"))));

            executor.AddExecutor("Computer.Account", (exec, info) =>
            {
                byte type      = 0;
                string typeStr = info.Attributes.GetValueOrDefault("type", "admin").ToLower(),
                password       = info.Attributes.GetValueOrDefault("password", "ERROR", true),
                username       = info.Attributes.GetValueOrDefault("username", "ERROR", true);
                switch (typeStr)
                {
                case "admin": type = 0; break;

                case "all": type = 1; break;

                case "mail": type = 2; break;

                case "missionlist": type = 3; break;

                default:
                    if (char.IsDigit(typeStr[0]))
                    {
                        byte.TryParse(typeStr, out type);
                    }
                    break;
                }
                var addUser = true;
                for (int i = 0; i < result.users.Count; i++)
                {
                    var userDetail = result.users[i];
                    if (userDetail.name == username)
                    {
                        userDetail.pass = password;
                        userDetail.type = type;
                        result.users[i] = userDetail;
                        if (username == "admin")
                        {
                            result.adminPass = password;
                        }
                        addUser = false;
                    }
                }
                if (addUser)
                {
                    result.AddUserDetail(username, password, type);
                }
            });

            executor.AddExecutor("Computer.Tracker", (exec, info) => result.HasTracker = true);

            executor.AddExecutor("Computer.MissionListingServer", (exec, info) =>
            {
                result.AddDaemon <MissionListingServer>(
                    info.Attributes.GetValueOrDefault("name", "ERROR", true),
                    info.Attributes.GetValueOrDefault("group", "ERROR", true),
                    os,
                    info.Attributes.GetBool("public"),
                    info.Attributes.GetBool("assigner"));
            });

            executor.AddExecutor("Computer.VariableMissionListingServer", (exec, info) =>
            {
                var title = info.Attributes.GetValue("title", true);
                var missionListingServer = result.AddDaemon <MissionListingServer>(
                    info.Attributes.GetValue("name", true),
                    info.Attributes.GetValue("iconPath"),
                    info.Attributes.GetValue("articleFolderPath"),
                    Utility.GetColorFromString(info.Attributes.GetValue("color"), Color.IndianRed),
                    os,
                    info.Attributes.GetBool("public"),
                    info.Attributes.GetBool("assigner")
                    );
                if (title != null)
                {
                    missionListingServer.listingTitle = title;
                }
            });

            executor.AddExecutor("Computer.MissionHubServer", (exec, info) =>
            {
                var missionPath = info.Attributes.GetValueOrDefault("missionFolderPath", "").Replace('\\', '/');
                if (!missionPath.EndsWith("/", StringComparison.InvariantCulture))
                {
                    missionPath += "/";
                }
                var hubServer = result.AddDaemon <MissionHubServer>(
                    info.Attributes.GetValue("serviceName"),
                    info.Attributes.GetValueOrDefault("groupName", "", true),
                    os
                    );
                hubServer.MissionSourceFolderPath =
                    (Settings.IsInExtensionMode
                        ? ExtensionLoader.ActiveExtensionInfo.FolderPath + "/"
                        : "Content/Missions/") + missionPath;
                hubServer.themeColor           = info.Attributes.GetColor("themeColor", Color.PaleTurquoise);
                hubServer.themeColorBackground = info.Attributes.GetColor("backgroundColor", Color.PaleTurquoise);
                hubServer.themeColorLine       = info.Attributes.GetColor("line Color", Color.PaleTurquoise);
                hubServer.allowAbandon         = info.Attributes.GetBool("allowAbandon", true);
            });

            executor.AddExecutor("Computer.MailServer", (exec, info) =>
            {
                var mailServer = result.AddDaemon <MailServer>(
                    info.Attributes.GetValueOrDefault("name", "Mail Server"),
                    os);
                mailServer.shouldGenerateJunkEmails = info.Attributes.GetBool("generateJunk", true);
                var color = info.Attributes.GetColor("color", true);
                if (color.HasValue)
                {
                    mailServer.setThemeColor(color.Value);
                }
                foreach (var emailInfo in info.Children.Where((i) => i.Name.ToLower() == "email"))
                {
                    mailServer.AddEmailToServer(
                        emailInfo.Attributes.GetValue("sender"),
                        emailInfo.Attributes.GetValue("recipient"),
                        emailInfo.Attributes.GetValue("subject"),
                        emailInfo.Value
                        );
                }
            }, true);

            executor.AddExecutor("Computer.AddEmailDaemon", (exec, info)
                                 => result.AddDaemon <AddEmailDaemon>("Final Task", os));

            executor.AddExecutor("Computer.DeathRowDatabase", (exec, info)
                                 => result.AddDaemon <DeathRowDatabaseDaemon>("Death Row Database", os));

            executor.AddExecutor("Computer.AcademicDatabase", (exec, info)
                                 => result.AddDaemon <AcademicDatabaseDaemon>("International Academic Database", os));

            executor.AddExecutor("Computer.IspSystem", (exec, info)
                                 => result.AddDaemon <ISPDaemon>(os));

            executor.AddExecutor("Computer.MessageBoard", (exec, info) =>
            {
                var messageBoardDaemon       = result.AddDaemon <MessageBoardDaemon>(os);
                messageBoardDaemon.name      = info.Attributes.GetValueOrDefault("name", "Anonymous");
                messageBoardDaemon.BoardName = messageBoardDaemon.name;
                const string content         = "Content/Missions/";
                foreach (var threadInfo in info.Children.Where((cinfo) => cinfo.Name.ToLower() == "thread"))
                {
                    var threadLoc = threadInfo.Value ?? "UNKNOWN";
                    if (threadLoc.StartsWith(content, StringComparison.InvariantCulture))
                    {
                        threadLoc = threadLoc.Substring(content.Length);
                    }
                    messageBoardDaemon.AddThread(Utils.readEntireFile(
                                                     (Settings.IsInExtensionMode ?
                                                      ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" :
                                                      content
                                                     ) + threadLoc
                                                     ));
                }
            }, true);

            executor.AddExecutor("Computer.AddAvconDemoEndDaemon", (exec, info)
                                 => result.AddDaemon <AvconDemoEndDaemon>("Demo End", os));

            executor.AddExecutor("Computer.AddWebServer", (exec, info) =>
                                 result.AddDaemon <WebServerDaemon>(
                                     info.Attributes.GetValueOrDefault("name", "Web Server"),
                                     os,
                                     info.Attributes.GetValue("url")
                                     ).registerAsDefaultBootDaemon());

            executor.AddExecutor("Computer.AddOnlineWebServer", (exec, info) =>
            {
                var webOnlineServerDaemon = result.AddDaemon <OnlineWebServerDaemon>(
                    info.Attributes.GetValueOrDefault("name", "Web Server"),
                    os);
                webOnlineServerDaemon.setURL(
                    info.Attributes.GetValueOrDefault("url", webOnlineServerDaemon.webURL));
                webOnlineServerDaemon.registerAsDefaultBootDaemon();
            });


            executor.AddExecutor("Computer.UploadServerDaemon", (exec, info) =>
            {
                var uploadServerDaemon = result.AddDaemon <UploadServerDaemon>(
                    info.Attributes.GetValueOrDefault("name", "File Upload Server"),
                    info.Attributes.GetColor("color", new Color(0, 94, 38)),
                    os,
                    info.Attributes.GetValue("folder"),
                    info.Attributes.GetBool("needsAuth")
                    );
                uploadServerDaemon.hasReturnViewButton = info.Attributes.GetBool("hasReturnViewButton");
                uploadServerDaemon.registerAsDefaultBootDaemon();
            });

            executor.AddExecutor("Computer.MedicalDatabase", (exec, info)
                                 => result.AddDaemon <MedicalDatabaseDaemon>(os));

            executor.AddExecutor("Computer.HeartMonitor", (exec, info)
                                 => result.AddDaemon <HeartMonitorDaemon>(os)
                                 .PatientID = info.Attributes.GetValueOrDefault("patient", "UNKNOWN"));

            executor.AddExecutor("Computer.PointClicker", (exec, info)
                                 => result.AddDaemon <PointClickerDaemon>("Point Clicker!", os));

            executor.AddExecutor("Computer.PorthackHeart", (exec, info)
                                 => result.AddDaemon <PorthackHeartDaemon>(os));

            executor.AddExecutor("Computer.SongChangerDaemon", (exec, info)
                                 => result.AddDaemon <SongChangerDaemon>(os));

            executor.AddExecutor("Computer.CustomConnectDisplayDaemon", (exec, info)
                                 => result.AddDaemon <CustomConnectDisplayDaemon>(os));

            executor.AddExecutor("Computer.DatabaseDaemon", (exec, info) =>
            {
                info.Name.ThrowNoLabyrinths();
                var emailAccount = info.Attributes.GetValue("AdminEmailAccount");

                var databaseColor = info.Attributes.GetColor("Color", true);
                if (!databaseColor.HasValue)
                {
                    databaseColor = os.highlightColor;
                }

                var databaseDaemon = result.AddDaemon <DatabaseDaemon>(
                    os,
                    info.Attributes.GetValueOrDefault("Name", "Database"),
                    DatabaseDaemon.GetDatabasePermissionsFromString(
                        info.Attributes.GetValueOrDefault("Permissions", "")
                        ),
                    info.Attributes.GetValue("DataType"),
                    info.Attributes.GetValueOrDefault("Foldername", "Database"),
                    databaseColor);
                if (!string.IsNullOrWhiteSpace(emailAccount))
                {
                    databaseDaemon.adminResetEmailHostID      = info.Attributes.GetValue("AdminEmailHostID");
                    databaseDaemon.adminResetPassEmailAccount = emailAccount;
                }
                if (info.Children.Count > 0)
                {
                    var dataset = databaseDaemon.GetDataset();
                    foreach (var e in info.Children)
                    {
                        if (e.Name == databaseDaemon.DataTypeIdentifier)
                        {
                            dataset.Add(new DatabaseDaemonHandler.DataInfo(e));
                        }
                    }
                }
            }, true);



            executor.AddExecutor("Computer.WhitelistAuthenticatorDaemon", (exec, info)
                                 => result.AddDaemon(
                                     new WhitelistConnectionDaemon(result, os)
            {
                RemoteSourceIP      = info.Attributes.GetValue("Remote"),
                AuthenticatesItself = info.Attributes.GetBool("SelfAuthenticating", true)
            }));


            executor.AddExecutor("Computer.MarkovTextDaemon", (exec, info)
                                 => result.AddDaemon <MarkovTextDaemon>(
                                     os,
                                     info.Attributes.GetValue("Name"),
                                     info.Attributes.GetValue("SourceFilesContentFolder")
                                     ));

            executor.AddExecutor("Computer.IrcDaemon", (exec, info) =>
            {
                var rCDaemon = result.AddDaemon <IRCDaemon>(
                    os,
                    info.Attributes.GetValueOrDefault("Remote", "IRC Server")
                    );
                rCDaemon.ThemeColor    = info.Attributes.GetColor("themeColor", new Color(184, 2, 141));
                rCDaemon.RequiresLogin = info.Attributes.GetBool("needsLogin");
                foreach (var cinfo in info.Children)
                {
                    switch (cinfo.Name.ToLower())
                    {
                    case "user":
                    case "agent":
                        var name = cinfo.Attributes.GetValue("name", true);
                        if (!string.IsNullOrWhiteSpace(name))
                        {
                            rCDaemon.UserColors.Add(name,
                                                    cinfo.Attributes.GetColor("color", Color.LightGreen));
                        }

                        break;

                    case "post":
                        var user = cinfo.Attributes.GetValue("user", true);
                        if (!string.IsNullOrWhiteSpace(user))
                        {
                            rCDaemon.StartingMessages.Add(
                                new KeyValuePair <string, string>(user, cinfo.Value?.HacknetFilter()));
                        }

                        break;
                    }
                }
            }, true);

            executor.AddExecutor("Computer.AircraftDaemon", (exec, info) =>
            {
                info.Name.ThrowNoLabyrinths();
                result.AddDaemon <AircraftDaemon>(
                    os,
                    info.Attributes.GetValue("Name"),
                    info.Attributes.GetVector2(defaultVal: Vector2.Zero),
                    info.Attributes.GetVector2("Dest", defaultVal: Vector2.One * 0.5f),
                    info.Attributes.GetFloat("Progress", 0.5f)
                    );
            });

            executor.AddExecutor("Computer.LogoCustomConnectDisplayDaemon", (exec, info)
                                 => result.AddDaemon <LogoCustomConnectDisplayDaemon>(
                                     os,
                                     info.Attributes.GetValue("logo"),
                                     info.Attributes.GetValue("title", true),
                                     info.Attributes.GetBool("overdrawLogo"),
                                     info.Attributes.GetValue("buttonAlignment")
                                     ));

            executor.AddExecutor("Computer.LogoDaemon", (exec, info)
                                 => result.AddDaemon(
                                     new LogoDaemon(
                                         result,
                                         os,
                                         result.name,
                                         info.Attributes.GetBool("ShowsTitle", true),
                                         info.Attributes.GetValue("LogoImagePath"))
            {
                TextColor = info.Attributes.GetColor("TextColor", Color.White),
                BodyText  = info.Value
            }
                                     ), true);

            executor.AddExecutor("Computer.DHSDaemon", (exec, info) =>
            {
                info.Name.ThrowNoLabyrinths();

                var groupName             = info.Attributes.GetValueOrDefault("groupName", "UNKNOWN");
                var addsFactionPoint      = info.Attributes.GetBool("addsFactionPointOnMissionComplete", true);
                var autoClearMissions     = info.Attributes.GetBool("autoClearMissionsOnPlayerComplete", true);
                var allowContractAbbandon = info.Attributes.GetBool("allowContractAbbandon");
                var themeColor            = info.Attributes.GetColor("themeColor", new Color(38, 201, 155));

                var dlcHubServer = result.AddDaemon <DLCHubServer>("DHS", groupName, os);
                dlcHubServer.AddsFactionPointForMissionCompleteion = addsFactionPoint;
                dlcHubServer.AutoClearMissionsOnSingleComplete     = autoClearMissions;
                dlcHubServer.AllowContractAbbandon = allowContractAbbandon;
                dlcHubServer.themeColor            = themeColor;

                foreach (var cinfo in info.Children.Where(v =>
                                                          v.Name.ToLower() == "user" || v.Name.ToLower() == "agent")
                         )
                {
                    var name     = cinfo.Attributes.GetValue("name", true);
                    var password = cinfo.Attributes.GetValueOrDefault("pass", "password");
                    var color    = cinfo.Attributes.GetColor("color", Color.LightGreen);
                    if (!string.IsNullOrWhiteSpace(name))
                    {
                        dlcHubServer.AddAgent(name, password, color);
                    }
                }
            }, true);

            void creditFunc(IExecutor exec, ElementInfo info)
            {
                var inputArr = new List <object>
                {
                    os,
                    info.Attributes.GetValue("Title", true),
                    info.Attributes.GetValue("ButtonText", true)
                }.Where((i) => i != null).ToArray();

                result.AddDaemon <DLCCreditsDaemon>(inputArr.ToArray())
                .ConditionalActionsToLoadOnButtonPress =
                    info.Attributes.GetValue("ConditionalActionSetToRunOnButtonPressPath");
            }

            executor.AddExecutor("Computer.DLCCredits", creditFunc);
            executor.AddExecutor("Computer.CreditsDaemon", creditFunc);

            executor.AddExecutor("Computer.FastActionHost", (exec, info)
                                 => result.AddDaemon <FastActionHost>(os, result.name));

            executor.AddExecutor("Computer.eosDevice", (exec, info)
                                 => AddEosComputer(info, result, os), true);

            HandlerListener.DaemonLoadListener(result, executor);

            foreach (var exec in ComputerLoaders)
            {
                executor.AddExecutor(exec.Key, exec.Value);
            }

            executor.OnOpenFile                   += OnOpenFile;
            executor.OnRead                       += OnRead;
            executor.OnReadElement                += OnReadElement;
            executor.OnReadEndElement             += OnReadEndElement;
            executor.OnReadDocument               += OnReadDocument;
            executor.OnReadComment                += OnReadComment;
            executor.OnReadText                   += OnReadText;
            executor.OnReadProcessingInstructions += OnReadProcessingInstructions;
            executor.OnCloseFile                  += OnCloseFile;

            executor.OnCloseFile += reader =>
            {
                if (!preventInitDaemons)
                {
                    result.initDaemons();
                }
                if (!preventAddingToNetmap)
                {
                    os.netMap.nodes.Add(result);
                }
            };

            executor.Parse();
            return(result);
        }
예제 #5
0
        static ContentLoader()
        {
            EventManager.onPluginUnload += OnPluginUnload;

            executor.RegisterExecutor("Computer", (exec, info) =>
            {
                var typeString = info.Attributes.GetString("type", "1");
                byte type;
                if (!byte.TryParse(typeString, out type))
                {
                    if (typeString.ToLowerInvariant() == "empty")
                    {
                        type = 4;
                    }
                    else
                    {
                        throw new FormatException("Invalid computer type");
                    }
                }

                comp = new Computer(
                    info.Attributes.GetString("name", "UNKNOWN").Filter(),
                    info.Attributes.GetString("ip", NetworkMap.generateRandomIP()).Filter(),
                    os.netMap.getRandomPosition(),
                    info.Attributes.GetInt("security"),
                    type,
                    os
                    )
                {
                    idName = info.Attributes.GetString("id", "UNKNOWN").Filter(),
                    AllowsDefaultBootModule = info.Attributes.GetBool("allowsDefaultBootModule", true),
                    icon = info.Attributes.GetString("icon", null)
                };
                holder.Comp = comp;

                if (type == 4)
                {
                    var home = comp.files.root.searchForFolder("home");
                    if (home != null)
                    {
                        home.folders.Clear();
                        home.files.Clear();
                    }
                }
            });
            executor.RegisterExecutor("Computer.file", (exec, info) =>
            {
                var path     = info.Attributes.GetString("path", "home");
                var name     = info.Attributes.GetString("name", "Data").Filter();
                var contents = (info.Content ?? Computer.generateBinaryString(500)).Filter();
                var eduSafe  = info.Attributes.GetBool("EduSafe", true);
                var eduOnly  = info.Attributes.GetBool("EduSafeOnly");

                if ((!eduSafe && Settings.EducationSafeBuild) || (eduOnly && Settings.EducationSafeBuild))
                {
                    return;
                }

                var folder   = comp.getFolderFromPath(path, true);
                var existing = folder.searchForFile(name);
                if (existing != null)
                {
                    existing.data = contents;
                }
                else
                {
                    folder.files.Add(new FileEntry(contents, name));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.encryptedFile", (exec, info) =>
            {
                var path      = info.Attributes.GetString("path", "home");
                var name      = info.Attributes.GetString("name", "Data").Filter();
                var contents  = (info.Content ?? Computer.generateBinaryString(500)).Filter();
                var header    = info.Attributes.GetString("header", "ERROR");
                var sourceIP  = info.Attributes.GetString("ip", "ERROR");
                var password  = info.Attributes.GetString("pass");
                var extension = info.Attributes.GetString("extension", null);
                var isDouble  = info.Attributes.GetBool("double");

                var encryptedText = FileEncrypter.EncryptString(
                    contents,
                    header,
                    sourceIP,
                    password,
                    extension
                    );
                if (isDouble)
                {
                    encryptedText = FileEncrypter.EncryptString(
                        encryptedText,
                        header,
                        sourceIP,
                        password,
                        "_LAYER2.dec"
                        );
                }

                var folder   = comp.getFolderFromPath(path, true);
                var existing = folder.searchForFile(name);
                if (existing != null)
                {
                    existing.data = encryptedText;
                }
                else
                {
                    folder.files.Add(new FileEntry(encryptedText, name));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.memoryDumpFile", (exec, info) =>
            {
                var path     = info.Attributes.GetString("path", "home");
                var name     = info.Attributes.GetString("name", "Data").Filter();
                var contents = ReplacementsCommon.LoadMemoryContents(info).GetEncodedFileString();

                var folder   = comp.getFolderFromPath(path, true);
                var existing = folder.searchForFile(name);
                if (existing != null)
                {
                    existing.data = contents;
                }
                else
                {
                    folder.files.Add(new FileEntry(contents, name));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.customthemefile", (exec, info) =>
            {
                var path     = info.Attributes.GetString("path", "home");
                var name     = info.Attributes.GetString("name", "Data").Filter();
                var contents = ThemeManager.getThemeDataStringForCustomTheme(info.Attributes.GetOrThrow("themePath", "Invalid theme path for customthemefile"));
                if (contents == null)
                {
                    throw new FormatException("Invalid theme path for customthemefile");
                }

                var folder   = comp.getFolderFromPath(path, true);
                var existing = folder.searchForFile(name);
                if (existing != null)
                {
                    existing.data = contents;
                }
                else
                {
                    folder.files.Add(new FileEntry(contents, name));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.positionNear", (exec, info) =>
            {
                var nearNodeId    = info.Attributes.GetString("target");
                var position      = info.Attributes.GetInt("position") + 1;
                var total         = info.Attributes.GetInt("total", 3);
                var force         = info.Attributes.GetBool("force");
                var extraDistance = Math.Max(-1f, Math.Min(1f, info.Attributes.GetFloat("extraDistance")));

                var sourceComp = comp;
                var origOs     = os;

                ComputerLoader.postAllLoadedActions += () =>
                {
                    var nearNode = Programs.getComputer(os, nearNodeId);
                    if (nearNode != null)
                    {
                        sourceComp.location = nearNode.location + Corporation.getNearbyNodeOffset(nearNode.location, position, total, origOs.netMap, extraDistance, force);
                    }
                };
            });
            executor.RegisterExecutor("Computer.proxy", (exec, info) =>
            {
                var time = info.Attributes.GetFloat("time", 1f);
                if (time > 0f)
                {
                    comp.addProxy(Computer.BASE_PROXY_TICKS * time);
                }
                else
                {
                    comp.hasProxy    = false;
                    comp.proxyActive = false;
                }
            });
            executor.RegisterExecutor("Computer.portsForCrack", (exec, info) =>
            {
                var num = info.Attributes.GetInt("val", -1);
                if (num != -1)
                {
                    comp.portsNeededForCrack = num - 1;
                }
            });
            executor.RegisterExecutor("Computer.firewall", (exec, info) =>
            {
                var level = info.Attributes.GetInt("level", 1);
                if (level > 0)
                {
                    if (info.Attributes.TryGetValue("solution", out var solution))
                    {
                        comp.addFirewall(level, solution, info.Attributes.GetFloat("additionalTime"));
                    }
                    else
                    {
                        comp.addFirewall(level);
                    }
                }
                else
                {
                    comp.firewall = null;
                }
            });
            executor.RegisterExecutor("Computer.link", (exec, info) =>
            {
                var linked = Programs.getComputer(os, info.Attributes.GetString("target"));
                if (linked != null)
                {
                    comp.links.Add(os.netMap.nodes.IndexOf(linked));
                }
            });
            executor.RegisterExecutor("Computer.dlink", (exec, info) =>
            {
                var linked = info.Attributes.GetString("target");
                var source = comp;
                var origOS = os;

                ComputerLoader.postAllLoadedActions += () =>
                {
                    var linkedNode = Programs.getComputer(os, linked);
                    if (linkedNode != null)
                    {
                        source.links.Add(origOS.netMap.nodes.IndexOf(linkedNode));
                    }
                };
            });
            executor.RegisterExecutor("Computer.trace", (exec, info) =>
            {
                comp.traceTime = info.Attributes.GetFloat("time", 1f);
            });
            executor.RegisterExecutor("Computer.adminPass", (exec, info) =>
            {
                comp.setAdminPassword(info.Attributes.GetString("pass", PortExploits.getRandomPassword()));
            });
            executor.RegisterExecutor("Computer.admin", (exec, info) => AdministratorManager.LoadAdministrator(info, comp, os));
            executor.RegisterExecutor("Computer.ports", (exec, info) =>
            {
                PortManager.LoadPortsFromStringVanilla(comp, info.Content);
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.portRemap", (exec, info) =>
            {
                PortManager.LoadPortRemapsFromStringVanilla(comp, info.Content);
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.PFPorts", (exec, info) =>
            {
                if (info.Children.Count != 0)
                {
                    PortManager.LoadPortsFromChildren(comp, info.Children, info.Attributes.GetBool("replace"));
                }
                else
                {
                    PortManager.LoadPortsFromString(comp, info.Content, info.Attributes.GetBool("replace"));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.ExternalCounterpart", (exec, info) =>
            {
                comp.externalCounterpart = new ExternalCounterpart(info.Attributes.GetString("name"), ExternalCounterpart.getIPForServerName(info.Attributes.GetString("id")));
            });
            executor.RegisterExecutor("Computer.account", (exec, info) =>
            {
                var username   = info.Attributes.GetString("username", "ERROR").Filter();
                var pass       = info.Attributes.GetString("password", "ERROR").Filter();
                var typeString = info.Attributes.GetString("type").ToLower();
                byte type      = 0;
                switch (typeString)
                {
                case "admin":
                    type = 0;
                    break;

                case "all":
                    type = 1;
                    break;

                case "mail":
                    type = 2;
                    break;

                case "missionlist":
                    type = 3;
                    break;

                default:
                    type = info.Attributes.GetByte("type", 0);
                    break;
                }

                var noneExists = true;
                for (int i = 0; i < comp.users.Count; i++)
                {
                    var user = comp.users[i];
                    if (user.name == username)
                    {
                        user.pass = pass;
                        user.type = type;

                        comp.users[i] = user;

                        if (username == "admin")
                        {
                            comp.adminPass = pass;
                        }

                        noneExists = false;
                    }
                }

                if (noneExists)
                {
                    comp.users.Add(new UserDetail(username, pass, type));
                }
            });
            executor.RegisterExecutor("Computer.tracker", (exec, info) => comp.HasTracker = true);
            executor.RegisterExecutor("Computer.missionListingServer", (exec, info) =>
            {
                comp.daemons.Add(new MissionListingServer(
                                     comp,
                                     info.Attributes.GetString("name", "ERROR"),
                                     info.Attributes.GetString("group", "ERROR"),
                                     os,
                                     info.Attributes.GetBool("public")
                                     )
                {
                    missionAssigner = info.Attributes.GetBool("assigner")
                });
            });
            executor.RegisterExecutor("Computer.variableMissionListingServer", (exec, info) =>
            {
                comp.daemons.Add(new MissionListingServer(
                                     comp,
                                     info.Attributes.GetString("name", null).Filter(),
                                     info.Attributes.GetString("iconPath", null),
                                     info.Attributes.GetString("articleFolderPath", null),
                                     info.Attributes.GetColor("color", Color.IndianRed).Value,
                                     os,
                                     info.Attributes.GetBool("public"),
                                     info.Attributes.GetBool("assigner")
                                     )
                {
                    listingTitle = info.Attributes.GetString("title", null)
                });
            });
            executor.RegisterExecutor("Computer.missionHubServer", (exec, info) =>
            {
                var missionPath = ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + info.Attributes.GetString("missionFolderPath", null);
                missionPath     = missionPath.Replace("\\", "/");
                if (!missionPath.EndsWith("/"))
                {
                    missionPath += "/";
                }

                comp.daemons.Add(new MissionHubServer(
                                     comp,
                                     info.Attributes.GetString("serviceName", null),
                                     info.Attributes.GetString("groupName", null).Filter(),
                                     os
                                     )
                {
                    MissionSourceFolderPath = missionPath,
                    themeColor           = info.Attributes.GetColor("themeColor", Color.PaleTurquoise).Value,
                    themeColorBackground = info.Attributes.GetColor("backgroundColor", Color.PaleTurquoise).Value,
                    themeColorLine       = info.Attributes.GetColor("lineColor", Color.PaleTurquoise).Value,
                    allowAbandon         = info.Attributes.GetBool("allowAbandon", true)
                });
            });
            executor.RegisterExecutor("Computer.mailServer", (exec, info) =>
            {
                var ms = new MailServer(
                    comp,
                    info.Attributes.GetString("name", "Mail Server"),
                    os
                    )
                {
                    shouldGenerateJunkEmails = info.Attributes.GetBool("generateJunk", true),
                };

                var color = info.Attributes.GetColor("color", null);
                if (color != null)
                {
                    ms.setThemeColor(color.Value);
                }

                foreach (var emailInfo in info.Children.Where(x => x.Name == "email"))
                {
                    var sender  = emailInfo.Attributes.GetString("sender", "UNKNOWN").Filter();
                    var subject = emailInfo.Attributes.GetString("subject", "UNKNOWN").Filter();
                    var content = (emailInfo.Content ?? "UNKNOWN").Filter();
                    if (emailInfo.Attributes.TryGetValue("recipient", out var recp))
                    {
                        recp             = recp.Filter();
                        var email        = MailServer.generateEmail(subject, content, sender);
                        ms.setupComplete = (System.Action)Delegate.Combine(ms.setupComplete, (System.Action)(() =>
                        {
                            ms.addMail(email, recp);
                        }));
                    }
                }

                comp.daemons.Add(ms);
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.addEmailDaemon", (exec, info) =>
            {
                comp.daemons.Add(new AddEmailDaemon(comp, "Final Task", os));
            });
            executor.RegisterExecutor("Computer.deathRowDatabase", (exec, info) =>
            {
                comp.daemons.Add(new DeathRowDatabaseDaemon(comp, "Death Row Database", os));
            });
            executor.RegisterExecutor("Computer.academicDatabase", (exec, info) =>
            {
                comp.daemons.Add(new AcademicDatabaseDaemon(comp, "International Academic Database", os));
            });
            executor.RegisterExecutor("Computer.ispSystem", (exec, info) =>
            {
                comp.daemons.Add(new ISPDaemon(comp, os));
            });
            executor.RegisterExecutor("Computer.messageBoard", (exec, info) =>
            {
                var messageBoard = new MessageBoardDaemon(comp, os)
                {
                    name      = info.Attributes.GetString("name", "Anonymous"),
                    BoardName = info.Attributes.GetString("name", "Anonymous")
                };

                foreach (var message in info.Children.Where(x => x.Name == "thread"))
                {
                    var path = message.Content ?? "UNKNOWN";
                    if (Settings.IsInExtensionMode)
                    {
                        path = ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" + path;
                    }
                    else if (!path.StartsWith("Content/Missions/"))
                    {
                        path = "Content/Missions/" + path;
                    }

                    messageBoard.AddThread(Utils.readEntireFile(path));
                }

                comp.daemons.Add(messageBoard);
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.addAvconDemoEndDaemon", (exec, info) =>
            {
                comp.daemons.Add(new AvconDemoEndDaemon(comp, "Demo End", os));
            });
            executor.RegisterExecutor("Computer.addWebServer", (exec, info) =>
            {
                var webServer = new WebServerDaemon(
                    comp,
                    info.Attributes.GetString("name", "Web Server"),
                    os,
                    info.Attributes.GetOrThrow("url", "addWebServer requires a url")
                    );
                webServer.registerAsDefaultBootDaemon();
                comp.daemons.Add(webServer);
            });
            executor.RegisterExecutor("Computer.addOnlineWebServer", (exec, info) =>
            {
                var onlineWebServer = new OnlineWebServerDaemon(
                    comp,
                    info.Attributes.GetString("name", "Web Server"),
                    os
                    );
                if (info.Attributes.TryGetValue("url", out var url))
                {
                    onlineWebServer.setURL(url);
                }
                onlineWebServer.registerAsDefaultBootDaemon();
                comp.daemons.Add(onlineWebServer);
            });
            executor.RegisterExecutor("Computer.uploadServerDaemon", (exec, info) =>
            {
                var uploadServer = new UploadServerDaemon(
                    comp,
                    info.Attributes.GetString("name", "File Upload Server"),
                    info.Attributes.GetColor("color", new Color(0, 94, 38)).Value,
                    os,
                    info.Attributes.GetString("folder", null),
                    info.Attributes.GetBool("needsAuth")
                    )
                {
                    hasReturnViewButton = info.Attributes.GetBool("hasReturnViewButton")
                };

                uploadServer.registerAsDefaultBootDaemon();
                comp.daemons.Add(uploadServer);
            });
            executor.RegisterExecutor("Computer.MedicalDatabase", (exec, info) =>
            {
                comp.daemons.Add(new MedicalDatabaseDaemon(comp, os));
            });
            executor.RegisterExecutor("Computer.HeartMonitor", (exec, info) =>
            {
                comp.daemons.Add(new HeartMonitorDaemon(comp, os)
                {
                    PatientID = info.Attributes.GetString("patient", "UNKNOWN")
                });
            });
            executor.RegisterExecutor("Computer.PointClicker", (exec, info) =>
            {
                comp.daemons.Add(new PointClickerDaemon(comp, "Point Clicker!", os));
            });
            executor.RegisterExecutor("Computer.SongChangerDaemon", (exec, info) =>
            {
                comp.daemons.Add(new SongChangerDaemon(comp, os));
            });
            executor.RegisterExecutor("Computer.DHSDaemon", (exec, info) =>
            {
                if (!DLC1SessionUpgrader.HasDLC1Installed)
                {
                    throw new NotSupportedException("Labyrinths DLC must be installed for DHSDaemon!");
                }

                var dlcHub = new DLCHubServer(
                    comp,
                    "DHS",
                    info.Attributes.GetString("groupName", "UNKNOWN"),
                    os
                    )
                {
                    AddsFactionPointForMissionCompleteion = info.Attributes.GetBool("addsFactionPointOnMissionComplete", true),
                    AutoClearMissionsOnSingleComplete     = info.Attributes.GetBool("autoClearMissionsOnPlayerComplete", true),
                    AllowContractAbbandon = info.Attributes.GetBool("allowContractAbbandon"),
                    themeColor            = info.Attributes.GetColor("themeColor", new Color(38, 201, 155)).Value
                };

                foreach (var userInfo in info.Children.Where(x => x.Name.ToLower() == "user" || x.Name.ToLower() == "agent"))
                {
                    if (userInfo.Attributes.TryGetValue("name", out var name))
                    {
                        dlcHub.AddAgent(
                            name.Filter(),
                            userInfo.Attributes.GetString("pass", "password").Filter(),
                            userInfo.Attributes.GetColor("color", Color.LightGreen).Value
                            );
                    }
                }

                comp.daemons.Add(dlcHub);
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.CustomConnectDisplayDaemon", (exec, info) =>
            {
                comp.daemons.Add(new CustomConnectDisplayDaemon(comp, os));
            });
            executor.RegisterExecutor("Computer.DatabaseDaemon", (exec, info) =>
            {
                if (!DLC1SessionUpgrader.HasDLC1Installed)
                {
                    throw new NotSupportedException("Labyrinths DLC must be installed for DatabaseDaemon!");
                }

                comp.daemons.Add(new DatabaseDaemon(
                                     comp,
                                     os,
                                     info.Attributes.GetString("Name", "Database"),
                                     DatabaseDaemon.GetDatabasePermissionsFromString(info.Attributes.GetString("Permissions")),
                                     info.Attributes.GetString("DataType", null),
                                     info.Attributes.GetString("Foldername", null),
                                     info.Attributes.GetColor("Color")
                                     )
                {
                    adminResetEmailHostID      = info.Attributes.GetString("AdminEmailHostID", null),
                    adminResetPassEmailAccount = info.Attributes.GetString("AdminEmailAccount"),
                    Dataset = info.Children.Count == 0 ? null : info.Children.Cast <object>().ToList()
                });
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.WhitelistAuthenticatorDaemon", (exec, info) =>
            {
                comp.daemons.Add(new WhitelistConnectionDaemon(comp, os)
                {
                    RemoteSourceIP      = info.Attributes.GetString("Remote", null),
                    AuthenticatesItself = info.Attributes.GetBool("SelfAuthenticating", true)
                });
            });
            executor.RegisterExecutor("Computer.MarkovTextDaemon", (exec, info) =>
            {
                comp.daemons.Add(new MarkovTextDaemon(
                                     comp,
                                     os,
                                     info.Attributes.GetString("Name", null),
                                     info.Attributes.GetString("SourceFilesContentFolder", null)
                                     ));
            });
            executor.RegisterExecutor("Computer.IRCDaemon", (exec, info) =>
            {
                var irc = new IRCDaemon(comp, os, info.Attributes.GetString("name", "IRC Server"))
                {
                    ThemeColor    = info.Attributes.GetColor("themeColor", new Color(184, 2, 141)).Value,
                    RequiresLogin = info.Attributes.GetBool("needsLogin", false)
                };

                foreach (var child in info.Children)
                {
                    switch (child.Name.ToLower())
                    {
                    case "user":
                    case "agent":
                        if (child.Attributes.TryGetValue("name", out var name))
                        {
                            irc.UserColors.Add(name.Filter(), child.Attributes.GetColor("color", Color.LightGreen).Value);
                        }
                        break;

                    case "post":
                        if (child.Content != null && child.Attributes.TryGetValue("user", out var user))
                        {
                            irc.StartingMessages.Add(new KeyValuePair <string, string>(user.Filter(), child.Content.Filter()));
                        }
                        break;
                    }
                }

                comp.daemons.Add(irc);
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.AircraftDaemon", (exec, info) =>
            {
                if (!DLC1SessionUpgrader.HasDLC1Installed)
                {
                    throw new NotSupportedException("Labrinths DLC has to be installed for aircraft daemon!");
                }

                comp.daemons.Add(new AircraftDaemon(
                                     comp,
                                     os,
                                     info.Attributes.GetString("Name", null),
                                     info.Attributes.GetVector("OriginX", "OriginY", Vector2.Zero).Value,
                                     info.Attributes.GetVector("DestX", "DestY", Vector2.One * 0.5f).Value,
                                     info.Attributes.GetFloat("Progress", 0.5f)
                                     ));
            });
            executor.RegisterExecutor("Computer.LogoCustomConnectDisplayDaemon", (exec, info) =>
            {
                comp.daemons.Add(new LogoCustomConnectDisplayDaemon(
                                     comp,
                                     os,
                                     info.Attributes.GetString("logo", null),
                                     info.Attributes.GetString("title", null),
                                     info.Attributes.GetBool("overdrawLogo"),
                                     info.Attributes.GetString("buttonAlignment", null)
                                     ));
            });
            executor.RegisterExecutor("Computer.LogoDaemon", (exec, info) =>
            {
                comp.daemons.Add(new LogoDaemon(
                                     comp,
                                     os,
                                     comp.name,
                                     info.Attributes.GetBool("ShowsTitle", true),
                                     info.Attributes.GetString("LogoImagePath", null)
                                     )
                {
                    TextColor = info.Attributes.GetColor("TextColor", Color.White).Value,
                    BodyText  = info.Content
                });
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.DLCCredits", (exec, info) =>
            {
                DLCCreditsDaemon credits;
                string title, text = null;
                if (info.Attributes.TryGetValue("Title", out title) || info.Attributes.TryGetValue("ButtonText", out text))
                {
                    credits = new DLCCreditsDaemon(comp, os, title.Filter(), text.Filter());
                }
                else
                {
                    credits = new DLCCreditsDaemon(comp, os);
                }

                credits.ConditionalActionsToLoadOnButtonPress = info.Attributes.GetString("ConditionalActionSetToRunOnButtonPressPath", null);
                comp.daemons.Add(credits);
            });
            executor.RegisterExecutor("Computer.CreditsDaemon", (exec, info) =>
            {
                DLCCreditsDaemon credits;
                string title, text = null;
                if (info.Attributes.TryGetValue("Title", out title) || info.Attributes.TryGetValue("ButtonText", out text))
                {
                    credits = new DLCCreditsDaemon(comp, os, title.Filter(), text.Filter());
                }
                else
                {
                    credits = new DLCCreditsDaemon(comp, os);
                }

                credits.ConditionalActionsToLoadOnButtonPress = info.Attributes.GetString("ConditionalActionSetToRunOnButtonPressPath", null);
                comp.daemons.Add(credits);
            });
            executor.RegisterExecutor("Computer.FastActionHost", (exec, info) =>
            {
                comp.daemons.Add(new FastActionHost(comp, os, comp.name));
            });
            executor.RegisterExecutor("Computer.PorthackHeart", (exec, info) =>
            {
                comp.daemons.Add(new PorthackHeartDaemon(comp, os));
            });
            executor.RegisterExecutor("Computer.Memory", (exec, info) => comp.Memory = ReplacementsCommon.LoadMemoryContents(info), ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.eosDevice", (exec, info) =>
            {
                eos = new Computer(
                    info.Attributes.GetString("name", "Unregistered eOS Device"),
                    NetworkMap.generateRandomIP(),
                    os.netMap.getRandomPosition(),
                    0,
                    5,
                    os
                    )
                {
                    idName              = info.Attributes.GetString("id", comp.idName + "_eos"),
                    icon                = info.Attributes.GetString("icon", "ePhone"),
                    location            = comp.location + Corporation.getNearbyNodeOffset(comp.location, Utils.random.Next(12), 12, os.netMap),
                    portsNeededForCrack = 2
                };

                PortManager.LoadPortsFromStringVanilla(eos, "22,3659");
                eos.setAdminPassword(info.Attributes.GetString("passOverride", "alpine"));

                EOSComp.GenerateEOSFilesystem(eos);
                if (info.Attributes.GetBool("empty", false))
                {
                    var apps = eos.files.root.searchForFolder("eos").searchForFolder("apps");
                    apps?.folders.Clear();
                    apps?.files.Clear();
                }

                os.netMap.nodes.Add(eos);

                if (comp.attatchedDeviceIDs != null)
                {
                    comp.attatchedDeviceIDs += ",";
                }
                comp.attatchedDeviceIDs += eos.idName;
            });
            executor.RegisterExecutor("Computer.eosDevice.note", (exec, info) =>
            {
                var noteFile    = info.Attributes.GetString("filename", null);
                var content     = info.Content.TrimStart().Filter();
                var notesFolder = eos.files.root.searchForFolder("eos").searchForFolder("notes");

                if (noteFile == null)
                {
                    var firstNewline = content.IndexOf('\n');
                    if (firstNewline == -1)
                    {
                        firstNewline = content.Length;
                    }
                    noteFile = content.Substring(0, firstNewline);
                    if (noteFile.Length > 50)
                    {
                        noteFile = noteFile.Substring(0, 47) + "...";
                    }
                }
                notesFolder.files.Add(new FileEntry(content, noteFile));
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("Computer.eosDevice.mail", (exec, info) =>
            {
                var username   = info.Attributes.GetString("username", null);
                var password   = info.Attributes.GetString("pass", null);
                var mailFolder = eos.files.root.searchForFolder("eos").searchForFolder("mail");

                mailFolder.files.Add(new FileEntry(
                                         $"MAIL ACCOUNT : {username}\nAccount   :{username}\nPassword :{password}\nLast Sync :{DateTime.Now.ToString()}\n\n{Computer.generateBinaryString(512)}",
                                         username + ".act"
                                         ));
            });
            executor.RegisterExecutor("Computer.eosDevice.file", (exec, info) =>
            {
                eos.getFolderFromPath(info.Attributes.GetString("path", "home")).files.Add(new FileEntry(
                                                                                               (info.Content ?? "").Filter().TrimStart(),
                                                                                               info.Attributes.GetString("name", null)
                                                                                               ));
            }, ParseOption.ParseInterior);
        }