예제 #1
0
        public static MemoryDumpDownloader GenerateInstanceOrNullFromArguments(string[] args, Rectangle location, object osObj, Computer target)
        {
            OS operatingSystem = (OS)osObj;

            if (operatingSystem.hasConnectionPermission(true))
            {
                return(new MemoryDumpDownloader(location, operatingSystem));
            }
            operatingSystem.write(LocaleTerms.Loc("Admin access required to generate memory dump"));
            return((MemoryDumpDownloader)null);
        }
예제 #2
0
 public static void cd(string[] args, OS os)
 {
     if (os.hasConnectionPermission(false))
     {
         if (args.Length >= 2)
         {
             getCurrentFolder(os);
             if (args[1].Equals("/"))
                 os.navigationPath.Clear();
             if (args[1].Equals(".."))
             {
                 if (os.navigationPath.Count > 0)
                 {
                     os.navigationPath.RemoveAt(os.navigationPath.Count - 1);
                 }
                 else
                 {
                     os.display.command = "connect";
                     os.validCommand = false;
                 }
             }
             else
             {
                 if (args[1].StartsWith("/"))
                 {
                     var folder = (os.connectedComp != null ? os.connectedComp : os.thisComputer).files.root;
                     os.navigationPath.Clear();
                 }
                 var navigationPathAtPath = getNavigationPathAtPath(args[1], os, null);
                 for (var index = 0; index < navigationPathAtPath.Count; ++index)
                 {
                     if (navigationPathAtPath[index] == -1)
                         os.navigationPath.RemoveAt(os.navigationPath.Count - 1);
                     else
                         os.navigationPath.Add(navigationPathAtPath[index]);
                 }
             }
         }
         else
             os.write("Usage: cd [WHERE TO GO or .. TO GO BACK]");
         var str1 = "";
         if (os.connectedComp != null)
             str1 = os.connectedComp.ip + "/";
         for (var index = 0; index < os.navigationPath.Count; ++index)
             str1 = str1 + getFolderAtDepth(os, index + 1).name + "/";
         var str2 = str1 + "> ";
         os.terminal.prompt = str2;
     }
     else
         os.write("Insufficient Privileges to Perform Operation");
 }
예제 #3
0
 public static void scan(string[] args, OS os)
 {
     if (args.Length > 1)
     {
         var computer = getComputer(os, args[1]);
         if (computer == null)
             return;
         os.netMap.discoverNode(computer);
         os.write("Found Terminal : " + computer.name + "@" + computer.ip);
     }
     else
     {
         var computer = os.connectedComp != null ? os.connectedComp : os.thisComputer;
         if (os.hasConnectionPermission(true))
         {
             os.write("Scanning...");
             for (var index = 0; index < computer.links.Count; ++index)
             {
                 if (!os.netMap.visibleNodes.Contains(computer.links[index]))
                     os.netMap.visibleNodes.Add(computer.links[index]);
                 os.netMap.nodes[computer.links[index]].highlightFlashTime = 1f;
                 os.write("Found Terminal : " + os.netMap.nodes[computer.links[index]].name + "@" +
                          os.netMap.nodes[computer.links[index]].ip);
                 os.netMap.lastAddedNode = os.netMap.nodes[computer.links[index]];
                 Thread.Sleep(400);
             }
             os.write("Scan Complete\n");
         }
         else
             os.write("Scanning Requires Admin Access\n");
     }
 }
예제 #4
0
 public static void upload(string[] args, OS os)
 {
     if (os.connectedComp == null || os.connectedComp == os.thisComputer)
     {
         os.write("Must be Connected to a Non-Local Host\n");
         os.write("Connect to a REMOTE host and run upload with a LOCAL filepath\n");
     }
     else if (args.Length < 2)
         os.write("Not Enough Arguments");
     else if (!os.hasConnectionPermission(false))
     {
         os.write("Insufficient user permissions to upload");
     }
     else
     {
         var folder = os.thisComputer.files.root;
         var length = args[1].LastIndexOf('/');
         if (length <= 0)
             return;
         var path = args[1].Substring(0, length);
         var folderAtPath = getFolderAtPath(path, os, os.thisComputer.files.root, false);
         if (folderAtPath == null)
         {
             os.write("Local Folder " + path + " not found.");
         }
         else
         {
             var fileName = args[1].Substring(length + 1);
             var fileEntry = folderAtPath.searchForFile(fileName);
             if (fileEntry == null)
             {
                 os.write("File " + fileName + " not found at specified filepath.");
             }
             else
             {
                 var currentFolder = getCurrentFolder(os);
                 var folderPath = os.navigationPath;
                 os.write("Uploading Local File " + fileName + "\nto Remote Folder /" + currentFolder.name);
                 var num = fileEntry.size;
                 for (var index = 0; index < num/300; ++index)
                 {
                     os.writeSingle(".");
                     OS.operationProgress = index/(float) (num/1000);
                     Thread.Sleep(200);
                 }
                 os.connectedComp.makeFile(os.thisComputer.ip, fileEntry.name, fileEntry.data, folderPath, true);
                 os.write("Transfer Complete\n");
             }
         }
     }
 }
예제 #5
0
 public static void ls(string[] args, OS os)
 {
     if (os.hasConnectionPermission(false))
     {
         var folder = getCurrentFolder(os);
         if (args.Length >= 2)
             folder = getFolderAtPath(args[1], os, null, false);
         var num = 0;
         for (var index = 0; index < folder.folders.Count; ++index)
         {
             os.write(":" + folder.folders[index].name);
             ++num;
         }
         for (var index = 0; index < folder.files.Count; ++index)
         {
             os.write(folder.files[index].name ?? "");
             ++num;
         }
         if (num != 0)
             return;
         os.write("--Folder Empty --");
     }
     else
         os.write("Insufficient Privileges to Perform Operation");
 }
예제 #6
0
 public static void opCDTray(string[] args, OS os, bool isOpen)
 {
     var computer = os.connectedComp != null ? os.connectedComp : os.thisComputer;
     if (os.hasConnectionPermission(true) || computer.ip.Equals(os.thisComputer.ip))
     {
         if (isOpen)
             computer.openCDTray(computer.ip);
         else
             computer.closeCDTray(computer.ip);
     }
     else
         os.write("Insufficient Privileges to Perform Operation");
 }
예제 #7
0
 public static void reboot(string[] args, OS os)
 {
     if (os.hasConnectionPermission(true))
     {
         var flag1 = os.connectedComp == null || os.connectedComp == os.thisComputer;
         var flag2 = false;
         if (args.Length > 1 && args[1].ToLower() == "-i")
             flag2 = true;
         if (!flag1)
             os.write("Rebooting Connected System : " + os.connectedComp.name);
         if (!flag2)
         {
             var num = 5;
             while (num > 0)
             {
                 os.write("System Reboot in ............" + num);
                 --num;
                 Thread.Sleep(1000);
             }
         }
         if (os.connectedComp == null || os.connectedComp == os.thisComputer)
             os.rebootThisComputer();
         else
             os.connectedComp.reboot(os.thisComputer.ip);
     }
     else
         os.write("Rebooting requires Admin access");
 }