forked from ReFirmLabs/binwalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deps.sh
executable file
·146 lines (130 loc) · 3.93 KB
/
deps.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
#!/bin/bash
REQUIRED_UTILS="wget tar python"
APTCMD="apt-get"
YUMCMD="yum"
APT_CANDIDATES="git build-essential libqt4-opengl mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsprogs cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev"
PYTHON2_APT_CANDIDATES="python-lzma python-pip python-opengl python-qt4 python-qt4-gl python-numpy python-scipy"
PYTHON3_APT_CANDIDATES="python3-pip python3-opengl python3-pyqt4 python3-pyqt4.qtopengl python3-numpy python3-scipy"
PYTHON3_YUM_CANDIDATES=""
YUM_CANDIDATES="git gcc gcc-c++ make openssl-devel qtwebkit-devel qt-devel gzip bzip2 tar arj p7zip p7zip-plugins cabextract squashfs-tools zlib zlib-devel lzo lzo-devel xz xz-compat-libs xz-libs xz-devel xz-lzma-compat python-backports-lzma lzip pyliblzma perl-Compress-Raw-Lzma"
PYTHON2_YUM_CANDIDATES="python-pip python-opengl python-qt4 numpy python-numdisplay numpy-2f python-Bottleneck scipy"
APT_CANDIDATES="$APT_CANDIDATES $PYTHON2_APT_CANDIDATES"
YUM_CANDIDATES="$YUM_CANDIDATES $PYTHON2_YUM_CANDIDATES"
PIP_COMMANDS="pip"
# Check for root privileges
if [ $UID -eq 0 ]
then
SUDO=""
else
SUDO="sudo"
REQUIRED_UTILS="sudo $REQUIRED_UTILS"
fi
function install_sasquatch
{
git clone https://github.com/devttys0/sasquatch
(cd sasquatch && make && $SUDO make install)
$SUDO rm -rf sasquatch
}
function install_jefferson
{
$SUDO pip install cstruct
git clone https://github.com/sviehb/jefferson
(cd jefferson && $SUDO python2 setup.py install)
$SUDO rm -rf jefferson
}
function install_unstuff
{
mkdir -p /tmp/unstuff
cd /tmp/unstuff
wget -O - http://my.smithmicro.com/downloads/files/stuffit520.611linux-i386.tar.gz | tar -zxv
$SUDO cp bin/unstuff /usr/local/bin/
cd -
rm -rf /tmp/unstuff
}
function install_pip_package
{
PACKAGE="$1"
for PIP_COMMAND in $PIP_COMMANDS
do
$SUDO $PIP_COMMAND install $PACKAGE
done
}
function find_path
{
FILE_NAME="$1"
echo -ne "checking for $FILE_NAME..."
which $FILE_NAME > /dev/null
if [ $? -eq 0 ]
then
echo "yes"
return 0
else
echo "no"
return 1
fi
}
# Make sure the user really wants to do this
echo ""
echo "WARNING: This script will download and install all required and optional dependencies for binwalk."
echo " This script has only been tested on, and is only intended for, Debian based systems."
echo " Some dependencies are downloaded via unsecure (HTTP) protocols."
echo " This script requires internet access."
echo " This script requires root privileges."
echo ""
echo -n "Continue [y/N]? "
read YN
if [ "$(echo "$YN" | grep -i -e 'y' -e 'yes')" == "" ]
then
echo "Quitting..."
exit 1
fi
# Check to make sure we have all the required utilities installed
NEEDED_UTILS=""
for UTIL in $REQUIRED_UTILS
do
find_path $UTIL
if [ $? -eq 1 ]
then
NEEDED_UTILS="$NEEDED_UTILS $UTIL"
fi
done
# Check for supported package managers and set the PKG_* envars appropriately
find_path $APTCMD
if [ $? -eq 1 ]
then
find_path $YUMCMD
if [ $? -eq 1 ]
then
NEEDED_UTILS="$NEEDED_UTILS $APTCMD/$YUMCMD"
else
PKGCMD="$YUMCMD"
PKGCMD_OPTS="-y install"
PKG_CANDIDATES="$YUM_CANDIDATES"
PKG_PYTHON3_CANDIDATES="$PYTHON3_YUM_CANDIDATES"
fi
else
PKGCMD="$APTCMD"
PKGCMD_OPTS="install -y"
PKG_CANDIDATES="$APT_CANDIDATES"
PKG_PYTHON3_CANDIDATES="$PYTHON3_APT_CANDIDATES"
fi
if [ "$NEEDED_UTILS" != "" ]
then
echo "Please install the following required utilities: $NEEDED_UTILS"
exit 1
fi
# Check to see if we should install modules for python3 as well
find_path python3
if [ $? -eq 0 ]
then
PKG_CANDIDATES="$PKG_CANDIDATES $PKG_PYTHON3_CANDIDATES"
PIP_COMMANDS="pip3 $PIP_COMMANDS"
fi
# Do the install(s)
cd /tmp
sudo $PKGCMD $PKGCMD_OPTS $PKG_CANDIDTES
install_pip_package pyqtgraph
install_pip_package capstone
install_sasquatch
install_jefferson
install_unstuff