Created
September 11, 2014 23:34
-
-
Save lallousx86/a2b30006ba9be99cbaea to your computer and use it in GitHub Desktop.
Return the body of a ROP gadget as a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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