in this post i want to learn a simple way to making shellcodes under v1nd0z operation system :D
debuggers can helping to a fast shellcoding and test our shellcodes
do you remember exe file injection method ? in this method we must be find a free code area in the exe file , we calls this area code cave .
in the code cave we can insert assembly instructions , and run it !
after inserting our codes , we must change the instruction pointer address to the beginning of our codes address
ok , i guess you understand the method that i want to use
let's go !
i want make a MessageBox shellcode that show d3c0der !
it is a simple code in assembly language :
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
MOV BYTE PTR SS:[EBP-7],64
MOV BYTE PTR SS:[EBP-6],33
MOV BYTE PTR SS:[EBP-5],63
MOV BYTE PTR SS:[EBP-4],30
MOV BYTE PTR SS:[EBP-3],64
MOV BYTE PTR SS:[EBP-2],65
MOV BYTE PTR SS:[EBP-1],72
push 0
LEA EBX,DWORD PTR SS:[EBP-7]
PUSH EBX
LEA ECX,DWORD PTR SS:[EBP-7]
PUSH ECX
push 0
MOV EAX,USER32.MessageBoxA
CALL EAX
for conversion your word ( that you want show by shellcode ) to hex , you can use this site :
http://centricle.com/tools/ascii-hex/
this is an axample of conversion the " d3c0der " word :

the codecave area :

now i insert this codes into the debugger :

the first instruction that i use is " xor eax,eax "
and this addres is : 01010D47 ( we use it for changing EIP )
take a look at the registers window , and see the instruction pointer address .

go to this address :

and replace the " push 60 " with " JMP 01010D47 "

now run the program , you can see the d3c0der message .
but there is a problem ! null bytes !
shellcodes must be free from null bytes !
wich part of our code , makes null bytes ?!
it is " push 0 "
we can use an old technique for remove null byte
by replacing " push 0 " with
xor ecx,ecx
push ecx
we can solve this problem , and our final shellcode is :
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
MOV BYTE PTR SS:[EBP-7],64
MOV BYTE PTR SS:[EBP-6],33
MOV BYTE PTR SS:[EBP-5],63
MOV BYTE PTR SS:[EBP-4],30
MOV BYTE PTR SS:[EBP-3],64
MOV BYTE PTR SS:[EBP-2],65
MOV BYTE PTR SS:[EBP-1],72
xor ecx,ecx
push ecx
LEA EBX,DWORD PTR SS:[EBP-7]
PUSH EBX
LEA ECX,DWORD PTR SS:[EBP-7]
PUSH ECX
xor ecx,ecx
push ecx
MOV EAX,USER32.MessageBoxA
CALL EAX
test it and enjoy !
good luck!
debuggers can helping to a fast shellcoding and test our shellcodes
do you remember exe file injection method ? in this method we must be find a free code area in the exe file , we calls this area code cave .
in the code cave we can insert assembly instructions , and run it !
after inserting our codes , we must change the instruction pointer address to the beginning of our codes address
ok , i guess you understand the method that i want to use
let's go !
i want make a MessageBox shellcode that show d3c0der !
it is a simple code in assembly language :
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
MOV BYTE PTR SS:[EBP-7],64
MOV BYTE PTR SS:[EBP-6],33
MOV BYTE PTR SS:[EBP-5],63
MOV BYTE PTR SS:[EBP-4],30
MOV BYTE PTR SS:[EBP-3],64
MOV BYTE PTR SS:[EBP-2],65
MOV BYTE PTR SS:[EBP-1],72
push 0
LEA EBX,DWORD PTR SS:[EBP-7]
PUSH EBX
LEA ECX,DWORD PTR SS:[EBP-7]
PUSH ECX
push 0
MOV EAX,USER32.MessageBoxA
CALL EAX
for conversion your word ( that you want show by shellcode ) to hex , you can use this site :
http://centricle.com/tools/ascii-hex/
this is an axample of conversion the " d3c0der " word :

the codecave area :

now i insert this codes into the debugger :

the first instruction that i use is " xor eax,eax "
and this addres is : 01010D47 ( we use it for changing EIP )
take a look at the registers window , and see the instruction pointer address .

go to this address :

and replace the " push 60 " with " JMP 01010D47 "

now run the program , you can see the d3c0der message .
but there is a problem ! null bytes !
shellcodes must be free from null bytes !
wich part of our code , makes null bytes ?!
it is " push 0 "
we can use an old technique for remove null byte
by replacing " push 0 " with
xor ecx,ecx
push ecx
we can solve this problem , and our final shellcode is :
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
MOV BYTE PTR SS:[EBP-7],64
MOV BYTE PTR SS:[EBP-6],33
MOV BYTE PTR SS:[EBP-5],63
MOV BYTE PTR SS:[EBP-4],30
MOV BYTE PTR SS:[EBP-3],64
MOV BYTE PTR SS:[EBP-2],65
MOV BYTE PTR SS:[EBP-1],72
xor ecx,ecx
push ecx
LEA EBX,DWORD PTR SS:[EBP-7]
PUSH EBX
LEA ECX,DWORD PTR SS:[EBP-7]
PUSH ECX
xor ecx,ecx
push ecx
MOV EAX,USER32.MessageBoxA
CALL EAX
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
unsigned char shellcode[]=
/x33/xc0/x33/xdb/x33/xc9/x33/xd2/xc6/x45/xf9/x64/xc6/x45/xfa/x33/xc6/x45/xfb/x63/xc6/x45/xfc/x30/xc6/x45/xfd/x64/xc6/x45/xfe/x65/xc6/x45/xff/x72/x33/xc9/x51/x8d/x5d/xf9/x53/x8d/x4d/xf9/x51/x33/xc9/x51/xb8/xea/x07/x45/x7e/xff/xd0
printf("Size = %d bytes\n", strlen(shellcode));
((void (*)())shellcode)();
return 0;
}
test it and enjoy !
good luck!












