Python2 scripts for Stack Buffer Overflows inspired by dostackbufferoverflowgood
- msfvenom
- python2
- Immunity Debugger with mona.py
git clone https://github.com/thirdbyte/bof_scripts
cd bof_scripts
chmod +x *
- Set
RHOST
andRPORT
inconfig.py
according to the target
- Modify
config.py
to have a workingconnect
function ./1_fuzz.py
- Update
BUFT
inconfig.py
to be slightly larger than the crashed bytes
./2_find_offset.py
- Copy the mona command, paste it in Immunity Debugger & run it
- Note the EIP
OFFSET
- Modify
OFFSET
ofconfig.py
to have the value found in the previous step ./3_confirm_offset.py
ESP
should point toCCCC
. If not, keep modifyingNO_B
,NO_C
andNO_Z
inconfig.py
- Modify
config.py
and make sure that initially,BADCHARS=[0x00,0x0A]
./4_badchars.py
- Copy
bad.bin
generated to target machine - In debugger, right click on
ESP
and clickFollow in Dump
- In debugger, execute
!mona compare -a esp -f c:\path\to\bad.bin
- Again modify
config.py
to add additionalBADCHARS
- Keep on repeating this step unless no
BADCHARS
are left
OR
- Modify
config.py
and make sure that initially,BADCHARS=[0x00,0x0A]
./4_badchars.py
- In debugger, right click on
ESP
and clickFollow in Dump
- Manually review the
BADCHARS
- Again modify
config.py
to add additionalBADCHARS
- Keep on repeating this step unless no
BADCHARS
are left
./5_find_jmp_esp.py
- Copy the mona command, paste it in Immunity Debugger & run it. Alternatively, execute
!mona modules
followed by!mona find -s '\xff\xe4' -m module.dll
if the previous command does not return aJMPESP
- Note the
JMPESP
address
- Modify
JMPESP
inconfig.py
to have value found in previous step ./6_confirm_jmp_esp.py
- Observe debugger for
INT 3
in disassembler. The highlightedINT 3
should be the second instruction, followed by 2 moreINT 3
and 1INT 3
above. If a total of 4INT 3
are not visible each in a single line, then modifyNO_Z
accordingly
./7_generate_shellcode.sh
- Input
LHOST
,LPORT
andPLATFORM
./8_exploit.py
- Final Exploit Code
./compile.sh
creates a single python file namedfinal.py
for the exploit