Skip to content

Instantly share code, notes, and snippets.

@lallousx86
Created September 11, 2014 23:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lallousx86/a2b30006ba9be99cbaea to your computer and use it in GitHub Desktop.
Save lallousx86/a2b30006ba9be99cbaea to your computer and use it in GitHub Desktop.
Return the body of a ROP gadget as a string
import idaapi
import idautils
import idc
def get_rop_gadget_string(addr):
gb = []
while True:
# Decode
i = idautils.DecodeInstruction(addr)
# Get the bytes
for x in range(0, i.size):
gb.append(idc.Byte(addr))
addr += 1
if i.itype == idaapi.NN_retn:
break
return "".join(["\\x%02x" % x for x in gb])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment