Skip to content

Commit

Permalink
Add ability to dump bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
sirusdv committed Sep 11, 2015
1 parent 2162b27 commit d2f5307
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ropgadget/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def __parse(self, arguments, custom_arguments_provided=False):
parser.add_argument("--nosys", action="store_true", help="Disable SYS search engine")
parser.add_argument("--multibr", action="store_true", help="Enable multiple branch gadgets")
parser.add_argument("--all", action="store_true", help="Disables the removal of duplicate gadgets")
parser.add_argument("--dump", action="store_true", help="Outputs the gadget bytes")

self.__args = parser.parse_args(arguments)

if self.__args.version:
Expand Down
7 changes: 6 additions & 1 deletion ropgadget/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import cmd
import os
import re
import codecs
import ropgadget.rgutils as rgutils
import sqlite3

Expand Down Expand Up @@ -79,7 +80,11 @@ def __lookingForGadgets(self):
for gadget in self.__gadgets:
vaddr = gadget["vaddr"]
insts = gadget["gadget"]
print(("0x%08x" %(vaddr) if arch == CS_MODE_32 else "0x%016x" %(vaddr)) + " : %s" %(insts))
bytes = gadget["bytes"]
bytesStr = " //" + bytes.encode('hex') if self.__options.dump else ""

print(("0x%08x" %(vaddr) if arch == CS_MODE_32 else "0x%016x" %(vaddr)) + " : %s" %(insts) + bytesStr)

print("\nUnique gadgets found: %d" %(len(self.__gadgets)))
return True

Expand Down

0 comments on commit d2f5307

Please sign in to comment.