Skip to content

Instantly share code, notes, and snippets.

@lieanu
Created July 17, 2015 03:22
Show Gist options
  • Select an option

  • Save lieanu/66c236d71d01874b44ed to your computer and use it in GitHub Desktop.

Select an option

Save lieanu/66c236d71d01874b44ed to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
import profile
from pwn import *
from pprint import pprint
def ttt4():
rop = ROP(ELF.from_assembly(
'''
pop eax; ret
pop ebx; call eax
mov ecx, ebx; ret
xchg edx, ecx; jmp eax
mov edi, edx; ret;
'''
))
context = {
'eax': 1,
'ebx': 2,
'ecx': 3,
'edx': 4
}
for r, gadgets in rop.setRegisters(context).items():
print '<setting %s>' % r
for g in gadgets:
if isinstance(g, pwnlib.rop.gadgets.Gadget):
print hex(g.address), '; '.join(g.insns)
elif isinstance(g, int): print hex(g)
else: print g
if __name__ == "__main__":
#profile.run("ttt4()", "mystats")
profile.run("ttt4()")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment