admin utils kinda working?
This commit is contained in:
parent
5dbfd8fd3d
commit
4e02eda1b1
|
@ -0,0 +1,9 @@
|
|||
namespace Client.Models
|
||||
{
|
||||
abstract class AdminTask
|
||||
{
|
||||
public abstract string TaskName { get; }
|
||||
public abstract string Desc { get; }
|
||||
public abstract string AdminUtilExec(string[] opts);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ namespace Client.Models
|
|||
|
||||
public static readonly List<Util> _utils = new List<Util>();
|
||||
public static readonly List<Task> _opts = new List<Task>();
|
||||
public static readonly List<AdminTask> _adminTask = new List<AdminTask>();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace Client.Utils.ClientUtils
|
|||
} else { throw new AtlasException($"[*] Usage: ByteConvert [isRemote] [filePath] <timeout> <retryCount>\n"); }
|
||||
|
||||
try {
|
||||
if (opts.Length > 3) { Timeout = Int32.Parse(opts[3]); }
|
||||
if (opts.Length > 3 && opts.Length <= 5) { retryCount = Int32.Parse(opts[4]); }
|
||||
if (opts.Length > 3) { Timeout = Int32.Parse(opts[3]); }
|
||||
if (opts.Length > 3 && opts.Length <= 5) { retryCount = Int32.Parse(opts[4]); }
|
||||
} catch (FormatException) { throw new AtlasException($"[*] Usage: ByteConvert [isRemote] [filePath] <timeout> <retryCount>\n"); }
|
||||
|
||||
if (!isRemote) {
|
||||
|
|
|
@ -15,21 +15,17 @@ namespace Client.Utils
|
|||
StringBuilder _out = new StringBuilder();
|
||||
|
||||
if (_utils.Count == 0) { Init.UtilInit(); }
|
||||
if (_opts.Count == 0 ) { Init.OptInit(); }
|
||||
if (_adminTask.Count == 0) { Init.AdminUtilInit(); }
|
||||
|
||||
_out.AppendLine("\nClient Utils\n____________\n");
|
||||
foreach (Models.Util cmd in _utils){ _out.AppendLine($"{cmd.UtilName,-25} {cmd.Desc}"); }
|
||||
|
||||
// separate based on usage
|
||||
/* ie
|
||||
* ImplantUtils
|
||||
* ------------
|
||||
* xyz
|
||||
*
|
||||
* ListenerUtils
|
||||
* -------------
|
||||
* xyz
|
||||
*
|
||||
* etc
|
||||
*/
|
||||
_out.AppendLine("\nImplant Tasks\n_____________\n");
|
||||
foreach (Models.Task cmd in _opts) { _out.AppendLine($"{cmd.TaskName, -25} {cmd.Desc}"); }
|
||||
|
||||
_out.AppendLine("\nImplant Admin Tasks\n___________________\n");
|
||||
foreach(Models.AdminTask cmd in _adminTask) { _out.AppendLine($"{cmd.TaskName,-25} {cmd.Desc}"); }
|
||||
|
||||
return _out.ToString();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils
|
||||
{
|
||||
class Cd : Models.AdminTask
|
||||
{
|
||||
private string newDir { get; set; }
|
||||
|
||||
public override string TaskName => "Cd";
|
||||
|
||||
public override string Desc => "Change directory";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: Cd [Path]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: Cd [Path]\n"); }
|
||||
if(CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
newDir = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, newDir);
|
||||
|
||||
} catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils
|
||||
{
|
||||
class Getuid : Models.AdminTask
|
||||
{
|
||||
public override string TaskName => "Getuid";
|
||||
|
||||
public override string Desc => "Fetch user id of user running implant process";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts != null && !(opts.Length > 1)) { throw new AtlasException($"[*] Usage: Getuid\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName);
|
||||
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Ls : Models.AdminTask
|
||||
{
|
||||
private string path { get; set; }
|
||||
public override string TaskName => "Ls";
|
||||
|
||||
public override string Desc => "list the contents of the current directory";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: Ls [Path]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: Ls [Path]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
path = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, path);
|
||||
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Mkdir : Models.AdminTask
|
||||
{
|
||||
private string newDir { get; set; }
|
||||
public override string TaskName => "MkDir";
|
||||
|
||||
public override string Desc => "Create a directory";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: MkDir [newDir]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: Mkdir [newDir]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
newDir = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, newDir);
|
||||
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Mkfile : Models.AdminTask
|
||||
{
|
||||
private string newFile { get; set; }
|
||||
public override string TaskName => "MkFile";
|
||||
|
||||
public override string Desc => "Create a file";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: MkFile [newFile]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: MkDir [newFile]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
newFile = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, newFile);
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Ps : Models.AdminTask
|
||||
{
|
||||
public override string TaskName => "Ps";
|
||||
|
||||
public override string Desc => "View all currently running processes";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts != null && opts.Length > 1) { throw new AtlasException($"[*] Usage: Ps\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName);
|
||||
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Pwd : Models.AdminTask
|
||||
{
|
||||
public override string TaskName => "Pwd";
|
||||
|
||||
public override string Desc => "returns the current directory";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (opts != null && opts.Length > 1) { throw new AtlasException($"[*] Usage: Pwd\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName);
|
||||
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Rmdir : Models.AdminTask
|
||||
{
|
||||
private string targetDir { get; set; }
|
||||
public override string TaskName => "RmDir";
|
||||
|
||||
public override string Desc => "Removes a directory";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: RmDir [targetDir]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: RmDir [targetDir]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
targetDir = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, targetDir);
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Rmfile : Models.AdminTask
|
||||
{
|
||||
private string targetDir { get; set; }
|
||||
public override string TaskName => "RmFile";
|
||||
|
||||
public override string Desc => "Removes a file";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: RmDir [targetDir]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: RmDir [targetDir]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
targetDir = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, targetDir);
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ using Client.Models;
|
|||
using static System.Console;
|
||||
|
||||
using static Client.Models.Client;
|
||||
using System.Text;
|
||||
|
||||
namespace Client.Utils
|
||||
{
|
||||
|
@ -36,20 +37,29 @@ namespace Client.Utils
|
|||
public static void Action(string input) {
|
||||
try
|
||||
{
|
||||
|
||||
if (input is "") { throw new AtlasException(""); }
|
||||
|
||||
String[] opts = null;
|
||||
string _out = null;
|
||||
|
||||
if (_utils.Count == 0) { Init.UtilInit(); }
|
||||
if(_adminTask.Count == 0) { Init.AdminUtilInit(); }
|
||||
|
||||
Models.Util util = _utils.FirstOrDefault(u => u.UtilName.Equals(input.Split(' ')[0], StringComparison.InvariantCultureIgnoreCase));
|
||||
if (input is "") { WriteLine(); return; }
|
||||
if (util is null) { WriteLine($"[-] Util {input} is invalid"); return; }
|
||||
|
||||
Models.AdminTask admutil = _adminTask.FirstOrDefault(u => u.TaskName.Equals(input.Split(' ')[0], StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if (util is null && admutil is null) { throw new AtlasException($"[-] Util {input} is invalid"); }
|
||||
|
||||
if(input.Contains(' ')) { opts = input.Split(' '); }
|
||||
|
||||
string _out = util.UtilExecute(opts);
|
||||
if(util is null) { _out = admutil.AdminUtilExec(opts); }
|
||||
else { _out = util.UtilExecute(opts); }
|
||||
|
||||
WriteLine(_out);
|
||||
} catch (NotImplementedException) { WriteLine($"[-] Util {input} not yet implemented"); }
|
||||
catch (AtlasException e) { WriteLine(e.Message); }
|
||||
catch (Exception e) { WriteLine($"{e}"); }
|
||||
|
||||
}
|
||||
|
@ -128,6 +138,40 @@ namespace Client.Utils
|
|||
var assemStr = Convert.ToBase64String(assemBytes);
|
||||
return assemStr;
|
||||
}
|
||||
|
||||
public static string sendAdminUtil(string taskName, string args)
|
||||
{
|
||||
var sendData = JSONOps.PackTaskData(taskName, args);
|
||||
|
||||
var tasksendOut = Comms.comms.SendPOST($"{TeamServerAddr}/Implants/{CurrentImplant}", sendData).TrimStart('[').TrimEnd(']');
|
||||
var taskId = JSONOps.ReturnTaskID(tasksendOut);
|
||||
WriteLine($"Task {taskId.Id} Initialized");
|
||||
Thread.Sleep(3000);
|
||||
|
||||
var taskOut = Comms.comms.SendGET($"{TeamServerAddr}/Implants/{CurrentImplant}/tasks/{taskId.Id}");
|
||||
var taskOutrecv = JSONOps.ReturnTaskData(taskOut);
|
||||
WriteLine($"Task {taskId.Id} Complete\n");
|
||||
Thread.Sleep(1000);
|
||||
|
||||
return taskOutrecv.TaskOut;
|
||||
}
|
||||
|
||||
public static string sendAdminUtil(string taskName)
|
||||
{
|
||||
var sendData = JSONOps.PackTaskData(taskName, null);
|
||||
|
||||
var tasksendOut = Comms.comms.SendPOST($"{TeamServerAddr}/Implants/{CurrentImplant}", sendData).TrimStart('[').TrimEnd(']');
|
||||
var taskId = JSONOps.ReturnTaskID(tasksendOut);
|
||||
WriteLine($"Task {taskId.Id} Initialized");
|
||||
Thread.Sleep(3000);
|
||||
|
||||
var taskOut = Comms.comms.SendGET($"{TeamServerAddr}/Implants/{CurrentImplant}/tasks/{taskId.Id}");
|
||||
var taskOutrecv = JSONOps.ReturnTaskData(taskOut);
|
||||
WriteLine($"Task {taskId.Id} Complete\n");
|
||||
Thread.Sleep(1000);
|
||||
|
||||
return taskOutrecv.TaskOut;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JSONOps {
|
||||
|
@ -161,6 +205,15 @@ namespace Client.Utils
|
|||
return JsonConvert.SerializeObject(send, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeNonAscii });
|
||||
}
|
||||
|
||||
|
||||
public static string PackTaskData(string taskName, string args)
|
||||
{
|
||||
var send = new Classes.TaskSend { Command = taskName, Args = args };
|
||||
|
||||
return JsonConvert.SerializeObject(send, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeNonAscii });
|
||||
}
|
||||
|
||||
|
||||
public static Classes.TaskSendOut ReturnTaskID(string taskresp) {
|
||||
return JsonConvert.DeserializeObject<Classes.TaskSendOut>(taskresp);
|
||||
}
|
||||
|
@ -179,6 +232,19 @@ namespace Client.Utils
|
|||
|
||||
static class Init
|
||||
{
|
||||
public static void AdminUtilInit()
|
||||
{
|
||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
|
||||
{
|
||||
if (type.IsSubclassOf(typeof(Models.AdminTask)))
|
||||
{
|
||||
Models.AdminTask function = Activator.CreateInstance(type) as Models.AdminTask;
|
||||
_adminTask.Add(function);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void OptInit()
|
||||
{
|
||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
|
||||
|
|
|
@ -42,9 +42,13 @@ namespace Implant
|
|||
public static void HandleTask(ImplantTask task) {
|
||||
var command = _commands.FirstOrDefault(cmd => cmd.Name.Equals(task.Command, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (command is null) { return; }
|
||||
|
||||
var _out = command.Execute(task);
|
||||
SendTaskOut(task.Id, _out);
|
||||
try
|
||||
{
|
||||
var _out = command.Execute(task);
|
||||
SendTaskOut(task.Id, _out);
|
||||
} catch (Exception e) {
|
||||
SendTaskOut(task.Id, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void HandleTasks(IEnumerable<ImplantTask> tasks) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using Implant.Models;
|
||||
using Implant.Utils;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
|
@ -11,26 +13,18 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
// pass args as string and convert to array here. i.e "cd /idk/" <- take [1] and set to path,
|
||||
// same for basic utils like ls, mkdir, rmdir, pwd, etc.
|
||||
|
||||
/*
|
||||
var opts = ImplantOptionUtils.ReturnMethod(task);
|
||||
var args = ImplantOptionUtils.ParseArgs(task.Args);
|
||||
|
||||
foreach (var opt in opts)
|
||||
try
|
||||
{
|
||||
foreach(var _params in args.Params)
|
||||
{
|
||||
if ((_params.OptionName.ToLower() is "path")
|
||||
&& (_params.OptionName.ToLower() == opt.GetPropertyValue("Name").ToString().ToLower())){
|
||||
path = _params.OptionValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
path = task.Args;
|
||||
|
||||
return path;
|
||||
if (path is null || path == ""){
|
||||
path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
}
|
||||
|
||||
Directory.SetCurrentDirectory(path);
|
||||
|
||||
return $"[*] Path set to {Directory.GetCurrentDirectory()}";
|
||||
} catch (DirectoryNotFoundException) { return $"{path} is not a valid path"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Principal;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Getuid
|
||||
class Getuid : ImplantCommands
|
||||
{
|
||||
public override string Name => "Getuid";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
return WindowsIdentity.GetCurrent().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Ls
|
||||
class Ls : ImplantCommands
|
||||
{
|
||||
private string targetPath { get; set; }
|
||||
public override string Name => "Ls";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
targetPath = task.Args;
|
||||
|
||||
StringBuilder _out = new StringBuilder();
|
||||
|
||||
if (targetPath is null || targetPath == ""){
|
||||
targetPath = Directory.GetCurrentDirectory();
|
||||
}
|
||||
|
||||
var dirs = Directory.GetDirectories(targetPath);
|
||||
foreach(var dir in dirs){
|
||||
var dirData = new DirectoryInfo(dir);
|
||||
_out.AppendLine($"{dirData.Name}");
|
||||
}
|
||||
|
||||
var files = Directory.GetFiles(targetPath);
|
||||
foreach (var file in files) {
|
||||
var fileData = new FileInfo(file);
|
||||
_out.AppendLine($"{fileData.Name} {fileData.Length}");
|
||||
}
|
||||
|
||||
return _out.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Mkdir
|
||||
class Mkdir : ImplantCommands
|
||||
{
|
||||
private string dirPath { get; set; }
|
||||
public override string Name => "MkDir";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
dirPath = task.Args;
|
||||
|
||||
Directory.CreateDirectory(dirPath);
|
||||
|
||||
if (Directory.Exists(dirPath)) { return $"[*] {dirPath} created"; }
|
||||
return $"[-] Failed to create {dirPath}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Mkfile
|
||||
internal class Mkfile : ImplantCommands
|
||||
{
|
||||
private string filePath { get; set; }
|
||||
public override string Name => "MkFile";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
filePath = task.Args;
|
||||
|
||||
File.Create(filePath);
|
||||
|
||||
if(File.Exists(filePath)) { return $"[*] {filePath} created"; }
|
||||
return $"[-] Failed to create {filePath}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Ps
|
||||
class Ps : ImplantCommands
|
||||
{
|
||||
public override string Name => "Ps";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
|
||||
StringBuilder _out = new StringBuilder();
|
||||
|
||||
_out.AppendLine($"{"PID", -15} {"ProcName", -35} {"SessionId",-45}");
|
||||
_out.AppendLine($"{"---", -15} {"--------", -35} {"---------",-45}");
|
||||
|
||||
var procs = Process.GetProcesses();
|
||||
|
||||
foreach(var proc in procs){
|
||||
_out.AppendLine($"{proc.Id, -15} {proc.ProcessName, -35} {proc.SessionId, -45}");
|
||||
}
|
||||
|
||||
return _out.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Pwd
|
||||
internal class Pwd : ImplantCommands
|
||||
{
|
||||
public override string Name => "Pwd";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
return Directory.GetCurrentDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Rmdir
|
||||
internal class Rmdir : ImplantCommands
|
||||
{
|
||||
private string targetDir { get; set; }
|
||||
|
||||
public override string Name => "RmDir";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
targetDir = task.Args;
|
||||
|
||||
DirectoryInfo dirData = new DirectoryInfo(targetDir);
|
||||
|
||||
foreach(FileInfo cFile in dirData.GetFiles()) { cFile.Delete(); }
|
||||
foreach(DirectoryInfo dir in dirData.GetDirectories()) { dir.Delete(true); }
|
||||
|
||||
if(!(dirData.Exists)) { return $"[*] {targetDir} removed"; }
|
||||
return $"[-] Failed to remove {targetDir}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
internal class Rmfile
|
||||
internal class Rmfile : ImplantCommands
|
||||
{
|
||||
private string targetFile { get; set; }
|
||||
public override string Name => "RmFile";
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
targetFile = task.Args;
|
||||
|
||||
File.Delete(targetFile);
|
||||
|
||||
if(!(File.Exists(targetFile))) { return $"[*] {targetFile} removed"; }
|
||||
return $"[-] Failed to remove {targetFile}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue