-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathROPfinder.py
executable file
·51 lines (38 loc) · 981 Bytes
/
ROPfinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/python2.7
from r2pipe import open
from sys import argv
if len(argv) < 2:
print "usage:"
print "\t"+argv[0]+" <filename>"
exit(1)
r2 = open(argv[1])
r2.cmd("s entry0")
laddr = 0x0
caddr = 0x1
cmds = 3
condition = ""
def controll(ds):
global condition
global cmds
for i in range(0,cmds):
try:
if condition in ds[i][u'disasm']:
return True
except KeyError:
break
return False
while caddr != laddr:
ds = r2.cmdj("pdj "+str(cmds))
laddr = caddr
caddr = ds[0][u'offset']
try:
if "ret" in ds[cmds - 1][u'disasm']:
if controll(ds):
print " ----------------- "+hex(caddr)+" ------------------"
for i in range(0,cmds):
print ds[i][u'disasm']
print "----------------------------------------------------"
print
except KeyError:
pass
r2.cmd("s +1")