-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.py
58 lines (43 loc) · 1.15 KB
/
plugin.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
#! /usr/bin/env python3
# Copyright (C) 2017 Chase Kanipe
"""
modality
"""
import r2lang
import r2pipe
import sys
r = r2pipe.open()
session = None
initialized = False
def modality(_):
global session
global initialized
def process(command):
global session
global initialized
if not command.startswith("M"):
return 0
binary = r.cmd("i~file").split("\n")[0].split(" ")[-1]
if not initialized:
sys.path.append("src/")
try:
from r2angr import R2ANGR
session = R2ANGR(binary, r)
initialized = True
session.load_angr()
except Exception as e:
print(e)
try:
session.run(command[1:])
except Exception as e:
print(e)
try:
return session.return_value
except:
return 1
return {"name": "r2-angr",
"licence": "GPLv3",
"desc": "Integrates angr with radare2",
"call": process}
if not r2lang.plugin("core", modality):
print("An error occurred while registering modality")