7- Generating Shellcode
Last updated
Last updated
Generating Shellcode: Once we have the information from step 5 to 6, we can generate the malicious shell code that will allow us to get the reverse shell.
We can use the tool from metasploit to generate shell code.
-p for the payload
EXITFUNC=thread make our exploit a little bit more stable
-f export the file type in C
-a for architecture x86
-b for bad characters
In case, you're working with a very limited space. Supposed you have only 200 bytes left and your payload size 351 bytes so it's not going to work because you're going to truncated at 200.
Now, we're going to create another python script and copy the shell code from kali and paste it in the python script. we need to use byte encode "b" letter in front of the payload.
"A" * 2003 get us to the EIP
\xaf\x11\x50\x62 when we get to EIP, we're going to hit this pointer address. This pointer address is jump address (break point). This value is called little endian.
overflow is the set of instruction that instruction we're providing.
\x90 * 32 is called nop and nop are padding. They stand for no operation. We're just adding a little bit of pad space. If we didn't have that our overflow wouldn't actually work. If you have limited space, you have to 8 or 16.
Finally, we go to kali machine and run listener with netcat and run the 6-shellcode.py.