-
Notifications
You must be signed in to change notification settings - Fork 2
/
mallory_install.sh
executable file
·183 lines (153 loc) · 5.67 KB
/
mallory_install.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
# ----------------------------------------------------------------
# This script updates a basic installation of Ubuntu (10.10 or 11.04)
# to the latest package revs, and installs the packages required
# to run the current (1.0) version of the Mallory tool.
# ----------------------------------------------------------------
# Copyright 2011 - Intrepidus Group
# ----------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------
export UPDATE_DIR=${HOME}/.mallory/update
export UPDATE_LOG=${UPDATE_DIR}/update.log
# -----------------------------------------------------------------
# functions
# -----------------------------------------------------------------
function print_header {
echo "+--------------------------------------------------------+"
echo "| MALLORY INSTALL/UPDATE SCRIPT |"
echo "+--------------------------------------------------------+"
}
function phase0 {
# create the update directory if it doesn't exist
[[ ! -d ${UPDATE_DIR} ]] && mkdir -p ${UPDATE_DIR}
print_header
echo "| Before running this script, please ensure that you've |"
echo "| configured a network interface and that the internet |"
echo "| is reachable by this virtual machine. |"
echo "+--------------------------------------------------------+"
echo "| Once you have done this (or if you already had) simply |"
echo "| rerun this script to continue the update |"
echo "+--------------------------------------------------------+"
echo "phase1" > ${UPDATE_DIR}/.next_phase
exit 0
}
function phase1 {
print_header
echo "beginning Mallory installation"
echo "updating apt package list"
sudo apt-get update |tee ${UPDATE_LOG}
echo ""
echo "upgrading OS to latest versions of installed packages"
sudo apt-get upgrade -y |tee -a ${UPDATE_LOG}
echo "installing Mallory dependencies"
sudo apt-get -y install build-essential mercurial libnetfilter-conntrack-dev libnetfilter-conntrack3 |tee -a ${UPDATE_LOG}
if [ ! -f /usr/lib/netfilter_conntrack.so.1 ]; then
sudo ln -s /usr/lib/libnetfilter_conntrack.so /usr/lib/libnetfilter_conntrack.so.1
fi
sudo apt-get -y install python-pip python-m2crypto python-qt4 pyro-gui python-netfilter python-pyasn1 |tee -a ${UPDATE_LOG}
sudo apt-get -y install python-paramiko python-twisted-web python-qt4-sql libqt4-sql-sqlite sqlite3 |tee -a ${UPDATE_LOG}
sudo easy_install pynetfilter_conntrack
echo ""
echo "enter directory you'd like Mallory to be installed to"
read -p "(default: ${HOME}/mallory)" mallorydir
if [ "$mallorydir" == "" ]; then
mallorydir="${HOME}/mallory";
fi
echo ${mallorydir} > ${UPDATE_DIR}/installdir
echo "retrieving current mallory source from bitbucket"
/usr/bin/hg clone http://bitbucket.org/IntrepidusGroup/mallory ${mallorydir}/current
echo "phase2" > ${UPDATE_DIR}/.next_phase
phase2
}
function phase2 {
print_header
echo "Mallory installation completed"
echo "To use mallory:"
echo "Open a new terminal window, cd to ${mallorydir}/current/src, then run:"
echo " sudo python ./mallory.py"
echo ""
echo "To run the mallory GUI:"
echo "Open a new terminal window cd to ${mallorydir}/current/src and run:"
echo " sudo chown $USER mallory.log"
echo " where $USER is the user you are logged in as. Then run:"
echo " python ./launchgui.py"
echo "Have fun!"
read -n1 -p "press any key to continue..."
echo "update" > ${UPDATE_DIR}/.next_phase
exit 0
}
function update {
print_header
echo "Starting Mallory Update"
if [ ! -d ${UPDATE_DIR} ]; then
echo "mallory update directory not found, quitting"
exit 1
fi
if [ ! -f ${UPDATE_DIR}/installdir ]; then
echo "mallory installation path not found"
exit 1
fi
export mallorydir=`cat ${UPDATE_DIR}/installdir`
if [ ! -d ${mallorydir} ]; then
echo "mallory installation directory doesn't exist"
exit 1
fi
echo "moving current install to archive"
if [[ -d ${mallorydir}/archive ]]; then
rm -rf ${mallorydir}/archive/*
else
mkdir ${mallorydir}/archive
fi
# Check for current and move it
# NOTE: we use 'cp -R; rm' instead of 'mv' here
# to avoid 'Directory not empty' errors
if [[ -d ${mallorydir}/current ]]; then
cp -R ${mallorydir}/current/* ${mallorydir}/archive/
fi
rm -rf ${mallorydir}/current
echo "retrieving current mallory source from bitbucket"
/usr/bin/hg clone http://bitbucket.org/IntrepidusGroup/mallory ${mallorydir}/current
echo "update" > ${UPDATE_DIR}/.next_phase
exit 0
}
# -----------------------------------------------------------------
# scriptybits
# -----------------------------------------------------------------
if [[ -f ${UPDATE_DIR}/.next_phase ]]; then
case `cat ${UPDATE_DIR}/.next_phase` in
phase0)
phase0
;;
phase1)
phase1
;;
phase2)
phase2
;;
update)
update
;;
phase4)
echo "phase4: profit!"
exit 0
;;
*)
echo "unknown update status, attempting update"
update
;;
esac
else
phase0
fi