-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.sh
executable file
·163 lines (132 loc) · 4.11 KB
/
setup.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
if [ "$1" == "--clean" ]; then
rm -rf keystone keystone_repo LIEF lief.so r2pipe
exit 1
fi
###
## 0. Prereq
#
if [ -z "$PYTHON_VER" ]; then
echo "[!] Before continuing change/declare the 'PYTHON_VER' env var to the version of python which you intend to build on (refer to gdb python api version)"
exit 1
fi
if [ -z "`which unzip`" ]; then
echo "[!] 'unzip' is no present, install it before continuing"
exit 1
fi
if [ -z "`which cmake`" ]; then
echo "[!] 'cmake' is no present, install it before continuing"
exit 1
fi
if [ -z "`which readelf`" ]; then
echo "[!] 'readelf' is no present, install it before continuing"
exit 1
fi
if [ -z "`which radare2`" ]; then
echo "[!] 'radare2' is no present, install it before continuing"
echo ""
echo "wget https://github.com/radareorg/radare2/releases/download/5.5.0/radare2_5.5.0_amd64.deb"
echo "dpkg -i ./radare2_5.5.0_amd64.deb"
echo ""
echo "Set file '~/.radare2rc' as"
# Show comments at right of disassembly if they fit in screen
echo "e asm.cmt.right=true"
# Shows pseudocode in disassembly. Eg mov eax, str.ok = > eax = str.ok
#echo "e asm.pseudo = true"
# Solarized theme
echo "eco solarized"
echo "e scr.utf8 = true"
echo ""
exit 1
fi
if [ -z "`which virtualenv`" ]; then
echo "[!] Install: 'sudo apt-get install ${PYTHON_VER}-distutils ${PYTHON_VER}-setuptools virtualenv'"
echo ""
exit 1
fi
if [ ! -f .gdbinit-gef.py ]; then
wget -O ./.gdbinit-gef.py -q https://gef.blah.cat/py
fi
###
## 1. Instal keystone python module
#
if [ ! -d keystone_repo ]; then
echo "[!] 'keystone' is no present ... installing it now (only on current folder)"
if [ -z "$KEYSTONE_VER" ]; then
echo "[!] Before continuing the variable 'KEYSTONE_VER' should be declared (e.g export KEYSTONE_VER=\"0.9.2\") ...quit"
exit 1
fi
wget https://github.com/keystone-engine/keystone/archive/refs/tags/${KEYSTONE_VER}.zip
unzip ${KEYSTONE_VER}.zip
rm ${KEYSTONE_VER}.zip
mv keystone-${KEYSTONE_VER} keystone_repo
cd keystone_repo/bindings/python
$PYTHON_VER setup.py build
cd ../../..
mv keystone_repo/bindings/python/keystone .
fi
###
## 2. Check LIEF
#
#if [ ! -f lief.so ]; then
# echo "[!] 'LIEF' is no present ... installing it now (only on current folder)"
#
# wget https://github.com/lief-project/LIEF/archive/refs/tags/${LIEF_VER}.zip
# unzip ${LIEF_VER}.zip
# rm ${LIEF_VER}.zip
#
# mv LIEF-${LIEF_VER} LIEF
# cd LIEF
# $PYTHON_VER setup.py build
#
# if [ $? != 0 ]; then
# echo "[!] error while building LIEF module"
# echo " \---> Run 'sudo apt-get install ${PYTHON_VER}-distutils ${PYTHON_VER}-setuptools'"
# exit
# fi
#
# cd ..
# mv LIEF/build/lief.so .
#
#fi
#if [ ! -d keystone ]; then
# echo "[!] 'keystone' is no present ... installing it now (only on current folder)"
# rm -rf object_virtualenv; mkdir object_virtualenv && virtualenv --python=$PYTHON_VER object_virtualenv &&\
# source object_virtualenv/bin/activate &&\
# pip install keystone &&\
# deactivate
#
# find -name keystone -type d | while read x; do
# mv "$x" keystone
# done
#
# rm -rf object_virtualenv
#fi
if [ ! -f lief.so ]; then
echo "[!] 'LIEF' is no present ... installing it now (only on current folder)"
rm -rf object_virtualenv; mkdir object_virtualenv && virtualenv --python=$PYTHON_VER object_virtualenv &&\
source object_virtualenv/bin/activate &&\
pip install lief==${LIEF_VER} &&\
deactivate
find -name "lief*.so" -type f | while read x; do
mv "$x" lief.so
done
rm -rf object_virtualenv
fi
if [ ! -d r2pipe ]; then
echo "[!] 'r2pipe' is no present ... installing it now (only on current folder)"
rm -rf object_virtualenv; mkdir object_virtualenv && virtualenv --python=$PYTHON_VER object_virtualenv &&\
source object_virtualenv/bin/activate &&\
pip install r2pipe &&\
deactivate
find -name r2pipe -type d | while read x; do
mv "$x" r2pipe
done
rm -rf object_virtualenv
fi
echo "[+] All requirements are met"
echo ""
echo "Now we need to declare env 'GDBLEED_HOME', you can do it like so:"
echo "echo \"export GDBLEED_HOME=$PWD\" >> ~/.bashrc"
echo "export GDBLEED_HOME=$PWD"
echo "[+] Done!"