blob: cba53e71a78e8c8e4ece9171e1ee6c23f962e9d0 (
plain)
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
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/env python
#
# Thanks to @withzombies for letting us adapt his script
#
import sys
from os import path
from os import stat
from site import getsitepackages
try:
import binaryninja
print "Binary Ninja API Installed"
sys.exit(0)
except ImportError:
pass
if sys.platform == "linux":
userpath = path.expanduser("~/.binaryninja")
lastrun = path.join(userpath, "lastrun")
if path.isfile(lastrun):
lastrunpath = open(lastrun).read().strip()
api_path = path.join(path.dirname(lastrun), "python")
else:
print "Running on linux, but ~/.binaryninja/lastrun does not exist"
sys.exit(0)
elif sys.platform == "darwin":
api_path = "/Applications/Binary Ninja.app/Contents/Resources/python"
else:
# Windows
api_path = "r'C:\Program Files\Vector35\BinaryNinja\python'"
def validate_path(path):
try:
stat(path)
except OSError:
return False
old_path = sys.path
sys.path.append(path)
try:
from binaryninja import core_version
except ImportError:
sys.path = old_path
return False
return True
while not validate_path(api_path):
print "Binary Ninja not found. Please provide the path to Binary " + \
"Ninja's install directory"
sys.stdout.write("[{}] ".format(api_path))
new_path = sys.stdin.readline().strip()
if len(new_path) == 0:
print "Invalid path"
continue
if not new_path.endswith('python'):
new_path = path.join(new_path, 'python')
api_path = new_path
from binaryninja import core_version
print "Found Binary Ninja core version: {}".format(core_version)
install_path = getsitepackages()[0]
binaryninja_pth_path = path.join(install_path, 'binaryninja.pth')
open(binaryninja_pth_path, 'wb').write(api_path)
print "Binary Ninja API installed using {}".format(binaryninja_pth_path)
|