You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
575 B
30 lines
575 B
5 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
from sys import argv
|
||
|
from struct import unpack
|
||
|
|
||
|
gadgets = {}
|
||
|
|
||
|
for line in open("ropgadgets.txt"):
|
||
|
split = line.split("-")
|
||
|
if len(split) < 2:
|
||
|
continue
|
||
|
|
||
|
addr = int(split[0][1:], 16)
|
||
|
cmd = "-".join(split[1:]).strip()
|
||
|
gadgets[addr] = cmd
|
||
|
|
||
|
mem = open("fools.dump", "rb").read()
|
||
|
|
||
|
addr = int(argv[1], 0)
|
||
|
|
||
|
while True:
|
||
|
gadget = unpack("<H", mem[addr:addr+2])[0]
|
||
|
if gadget in gadgets:
|
||
|
print(" ", gadgets[gadget])
|
||
|
else:
|
||
|
print(" dw $%04X" % gadget)
|
||
|
if gadget == 0x1708:
|
||
|
break
|
||
|
addr += 2
|