Exemple #1
0
        public FileSystem generateRandomFileSystem()
        {
            var fileSystem = new FileSystem();

            if (type != 5)
            {
                var num1 = Utils.random.Next(6);
                for (var index1 = 0; index1 < num1; ++index1)
                {
                    var    num2 = 0;
                    string str1;
                    do
                    {
                        str1 = (num2 > 10 ? "AA" : "") + generateFolderName(Utils.random.Next(100));
                        ++num2;
                    } while (fileSystem.root.folders[0].searchForFolder(str1) != null);
                    var folder = new Folder(str1);
                    var num3   = Utils.random.Next(3);
                    for (var index2 = 0; index2 < num3; ++index2)
                    {
                        if (Utils.random.NextDouble() > 0.8)
                        {
                            var    num4 = 0;
                            string str2;
                            do
                            {
                                str2 = generateFileName(Utils.random.Next(300));
                                ++num4;
                                if (num4 > 3)
                                {
                                    str2 = (Utils.getRandomChar() + Utils.getRandomChar()).ToString() + str2;
                                }
                            } while (folder.searchForFile(str2) != null);
                            folder.files.Add(
                                new FileEntry(
                                    Utils.flipCoin()
                                        ? generateFileData(Utils.random.Next(500))
                                        : generateBinaryString(500), str2));
                        }
                        else
                        {
                            var fileEntry = new FileEntry();
                            var str2      = fileEntry.name;
                            while (folder.searchForFile(fileEntry.name) != null)
                            {
                                fileEntry.name = Utils.getRandomChar().ToString() + (int)Utils.getRandomChar() +
                                                 str2;
                            }
                            folder.files.Add(fileEntry);
                        }
                    }
                    fileSystem.root.folders[0].folders.Add(folder);
                }
            }
            else
            {
                fileSystem.root.folders.Insert(0, EOSComp.GenerateEOSFolder());
            }
            return(fileSystem);
        }
Exemple #2
0
 public static void GenerateEOSFilesystem(Computer device)
 {
     if (device.files.root.searchForFolder("eos") != null)
     {
         return;
     }
     device.files.root.folders.Insert(0, EOSComp.GenerateEOSFolder());
 }
Exemple #3
0
        public static void AddEOSComp(XmlReader rdr, Computer compAttatchedTo, object osObj)
        {
            OS     os       = (OS)osObj;
            string compName = "Unregistered eOS Device";
            string str1     = compAttatchedTo.idName + "_eos";
            bool   flag     = false;

            if (rdr.MoveToAttribute("name"))
            {
                compName = ComputerLoader.filter(rdr.ReadContentAsString());
            }
            if (rdr.MoveToAttribute("id"))
            {
                str1 = rdr.ReadContentAsString();
            }
            if (rdr.MoveToAttribute("empty"))
            {
                flag = rdr.ReadContentAsString().ToLower() == "true";
            }
            string newPass = "******";

            if (rdr.MoveToAttribute("passOverride"))
            {
                newPass = rdr.ReadContentAsString();
            }
            Computer device = new Computer(compName, NetworkMap.generateRandomIP(), os.netMap.getRandomPosition(), 0, (byte)5, os);

            device.idName = str1;
            string str2 = "ePhone";

            if (rdr.MoveToAttribute("icon"))
            {
                str2 = rdr.ReadContentAsString();
            }
            device.icon     = str2;
            device.location = compAttatchedTo.location + Corporation.getNearbyNodeOffset(compAttatchedTo.location, Utils.random.Next(12), 12, os.netMap, 0.0f, false);
            device.setAdminPassword(newPass);
            ComputerLoader.loadPortsIntoComputer("22,3659", (object)device);
            device.portsNeededForCrack = 2;
            EOSComp.GenerateEOSFilesystem(device);
            rdr.Read();
            Folder folder1 = device.files.root.searchForFolder("eos");
            Folder folder2 = folder1.searchForFolder("notes");
            Folder folder3 = folder1.searchForFolder("mail");

            while (!(rdr.Name == "eosDevice") || rdr.IsStartElement())
            {
                if (rdr.Name.ToLower() == "note" && rdr.IsStartElement())
                {
                    string nameEntry = (string)null;
                    if (rdr.MoveToAttribute("filename"))
                    {
                        nameEntry = ComputerLoader.filter(rdr.ReadContentAsString());
                    }
                    int    content   = (int)rdr.MoveToContent();
                    string dataEntry = ComputerLoader.filter(rdr.ReadElementContentAsString().TrimStart());
                    if (nameEntry == null)
                    {
                        int length = dataEntry.IndexOf("\n");
                        if (length == -1)
                        {
                            length = dataEntry.IndexOf("\n");
                        }
                        if (length == -1)
                        {
                            length = dataEntry.Length;
                        }
                        string str3 = dataEntry.Substring(0, length);
                        if (str3.Length > 50)
                        {
                            str3 = str3.Substring(0, 47) + "...";
                        }
                        nameEntry = str3.Replace(" ", "_").Replace(":", "").ToLower().Trim() + ".txt";
                    }
                    FileEntry fileEntry = new FileEntry(dataEntry, nameEntry);
                    folder2.files.Add(fileEntry);
                }
                if (rdr.Name.ToLower() == "mail" && rdr.IsStartElement())
                {
                    string str3 = (string)null;
                    string str4 = (string)null;
                    if (rdr.MoveToAttribute("username"))
                    {
                        str3 = ComputerLoader.filter(rdr.ReadContentAsString());
                    }
                    if (rdr.MoveToAttribute("pass"))
                    {
                        str4 = ComputerLoader.filter(rdr.ReadContentAsString());
                    }
                    string dataEntry = "MAIL ACCOUNT : " + str3 + "\nAccount   :" + str3 + "\nPassword :"******"\nLast Sync :" + DateTime.Now.ToString() + "\n\n" + Computer.generateBinaryString(512);
                    string nameEntry = str3 + ".act";
                    folder3.files.Add(new FileEntry(dataEntry, nameEntry));
                }
                if (rdr.Name.ToLower() == "file" && rdr.IsStartElement())
                {
                    string nameEntry = (string)null;
                    if (rdr.MoveToAttribute("name"))
                    {
                        nameEntry = rdr.ReadContentAsString();
                    }
                    string path = "home";
                    if (rdr.MoveToAttribute("path"))
                    {
                        path = rdr.ReadContentAsString();
                    }
                    int    content   = (int)rdr.MoveToContent();
                    string dataEntry = ComputerLoader.filter(rdr.ReadElementContentAsString()).TrimStart();
                    device.getFolderFromPath(path, true).files.Add(new FileEntry(dataEntry, nameEntry));
                }
                rdr.Read();
                if (rdr.EOF)
                {
                    break;
                }
            }
            if (flag)
            {
                Folder folder4 = folder1.searchForFolder("apps");
                if (folder4 != null)
                {
                    folder4.files.Clear();
                    folder4.folders.Clear();
                }
            }
            os.netMap.nodes.Add(device);
            ComputerLoader.postAllLoadedActions += (Action)(() => device.links.Add(os.netMap.nodes.IndexOf(compAttatchedTo)));
            if (compAttatchedTo.attatchedDeviceIDs != null)
            {
                compAttatchedTo.attatchedDeviceIDs += ",";
            }
            compAttatchedTo.attatchedDeviceIDs += device.idName;
        }