Diving into stack and head memory corruption
- Run vulnerable application and attach it to Immunity Debugger
- Ensure you have a script that can normally communicate target protocol
- Perform Fuzzing on that script with a single character until application crashes
- Figure out which registers contain memory addresses that are overridden
- Figure out which registers are overridden themselves (this is only good ifit’s EIP)
- Locate the bytes at which EIP was overridden
- Ensure you have enough room to hide a payload that is your reverse shell ( 350 bytes would be perfect!)
- Determine bad characters
- Work on redirection, need to find DLL. Use mona!
- Make sure you look for at least 4 falses (first 4, hopefully 5)
- Generate payload and update your exploit code
- Exploit!
ESP points directly to the start of your payload (after execution of the ret in the function you're attacking) because you put the payload right after the 4 bytes that overwrite the return address on the stack. ret pops 4 (or 8) bytes into EIP, leaving ESP pointing to the payload that directly follows.
-
- Pattern_create / Pattern_offset
- In mona.py or in msf (.rb)
-
- Standard Shellcode requires 350-400 Bytes
- Stagers requires
-
- Need to do multiple times (breaks on bad characters)
- Stop when see FE, FF (or end non-bad chars)
-
- Locate modules without protections
- !mona modules
- Find a return address (JMP ESP)
- Does not have to be a single instruction
-
- Must match OS version (32/64)
- Different prompts based on shellcode type
- EXITFUNC = Thread
- -e (specify encoder)
-
- Different prompts
- Sometimes blank (no leading symbol)