Skip to content

Commit

Permalink
Support gadgets alignment options, closes JonathanSalwan#97
Browse files Browse the repository at this point in the history
  • Loading branch information
SweetVishnya committed Dec 3, 2020
1 parent ce1ba02 commit 11417ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Usage
[--rawEndian <endian>] [--re <re>] [--offset <hexaddr>]
[--ropchain] [--thumb] [--console] [--norop] [--nojop]
[--callPreceded] [--nosys] [--multibr] [--all] [--noinstr]
[--dump]
[--dump] [--silent] [--align ALIGN]

optional arguments:
-h, --help show this help message and exit
Expand All @@ -55,7 +55,7 @@ Usage
--memstr <string> Search each byte in all readable segment
--depth <nbyte> Depth for search engine (default 10)
--only <key> Only show specific instructions
--filter <key> Suppress specific instructions
--filter <key> Suppress specific mnemonics
--range <start-end> Search between two addresses (0x...-0x...)
--badbytes <byte> Rejects specific bytes in the gadget's address
--rawArch <arch> Specify an arch for a raw file
Expand All @@ -74,7 +74,8 @@ Usage
--all Disables the removal of duplicate gadgets
--noinstr Disable the gadget instructions console printing
--dump Outputs the gadget bytes

--silent Disables printing of gadgets during analysis
--align ALIGN Align gadgets addresses (in bytes)

How can I contribute ?
----------------------
Expand Down
1 change: 1 addition & 0 deletions ropgadget/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __parse(self, arguments, custom_arguments_provided=False):
parser.add_argument("--noinstr", action="store_true", help="Disable the gadget instructions console printing")
parser.add_argument("--dump", action="store_true", help="Outputs the gadget bytes")
parser.add_argument("--silent", action="store_true", help="Disables printing of gadgets during analysis")
parser.add_argument("--align", type=int, help="Align gadgets addresses (in bytes)")

self.__args = parser.parse_args(arguments)

Expand Down
2 changes: 2 additions & 0 deletions ropgadget/gadgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def __gadgetsFinding(self, section, gadgets, arch, mode):
ret = []
md = Cs(arch, mode)
for gad_op, gad_size, gad_align in gadgets:
if self.__options.align:
gad_align = self.__options.align
allRefRet = [m.start() for m in re.finditer(gad_op, opcodes)]
for ref in allRefRet:
end = ref + gad_size
Expand Down

0 comments on commit 11417ce

Please sign in to comment.