Beispiel #1
0
 public static FileSystem load(XmlReader reader)
 {
     var fileSystem = new FileSystem(true);
     while (reader.Name != "filesystem")
         reader.Read();
     fileSystem.root = Folder.load(reader);
     return fileSystem;
 }
Beispiel #2
0
 public Computer(string compName, string compIP, Vector2 compLocation, int seclevel, byte compType, OS opSystem)
 {
     name = compName;
     ip = compIP;
     location = compLocation;
     type = compType;
     files = generateRandomFileSystem();
     idName = compName.Replace(" ", "_");
     os = opSystem;
     traceTime = -1f;
     securityLevel = seclevel;
     adminIP = NetworkMap.generateRandomIP();
     users = new List<UserDetail>();
     adminPass = PortExploits.getRandomPassword();
     users.Add(new UserDetail("admin", adminPass, 1));
     ports = new List<int>(seclevel);
     portsOpen = new List<byte>(seclevel);
     openPortsForSecurityLevel(seclevel);
     links = new List<int>();
     daemons = new List<Daemon>();
 }
Beispiel #3
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;
 }