forked from grayhatacademy/ghidra_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArmRopFind.py
36 lines (27 loc) · 863 Bytes
/
ArmRopFind.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
# Find ARM ROP gadgets that contain a user specified instruction.
#@author fuzzywalls
#@category TNS
#@menupath TNS.Arm Rop.Find
import re
from utils import armrop, utils
utils.allowed_processors(currentProgram, 'ARM')
op1 = None
op2 = None
op3 = None
search = askString(
'ARM ROP Find', 'What instruction do you want to search for?')
try:
search = re.sub(' +', ' ', search)
mnem, operands = search.split(' ', 1)
operands = operands.replace(' ', '')
operands = operands.split(',')
op1, op2, op3 = operands + [None] * (3 - len(operands))
except ValueError:
mnem = search
if not mnem.startswith('.*'):
mnem = '.*' + mnem
print 'Searching for %s' % search
search_ins = armrop.ArmInstruction(mnem, op1, op2, op3)
arm_rop = armrop.ArmRop(currentProgram)
results = arm_rop.find_instructions([search_ins])
results.pretty_print()