/
r2-angr.py
64 lines (49 loc) · 1.32 KB
/
r2-angr.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/env python3
# Copyright (C) 2017 Chase Kanipe
"""
r2-angr
"""
import r2lang
import r2pipe
import sys
r = r2pipe.open()
session = None
initialized = False
def r2angr(_):
global session
global initialized
"""Build the plugin"""
binary = r.cmdj("ij")["core"]["file"]
def process(command):
global session
global initialized
"""Process commands here"""
if not command.startswith("m"):
return 0
if command == "mi":
sys.path.append("src/")
try:
from session import Session
session = Session(binary, r)
initialized = True
except Exception as e:
print(e)
else:
try:
if initialized:
session.run(command[1:])
else:
print("r2angr not initialized")
except Exception as e:
print(e)
# Parse arguments
#tmp = command.split(" ")
#print(str(tmp))
return 1
return {"name": "r2-angr",
"licence": "GPLv3",
"desc": "Integrates angr with radare2",
"call": process}
# Register the plugin
if not r2lang.plugin("core", r2angr):
print("An error occurred while registering r2angr")