Skip to content

Commit b38f668

Browse files
committed
Rewrite mallory_install.sh
The old script depended too heavily on it running smoothly - unlikely, when run on a modern Linux distribution. This script now only installs the dependencies and gives helpful information to the user; updating the repo should be done manually through git pull. Overall: easier to debug, safer to run, less junk files generated.
1 parent 8e76e10 commit b38f668

1 file changed

Lines changed: 30 additions & 144 deletions

File tree

mallory_install.sh

Lines changed: 30 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,33 @@
11
#!/bin/bash
2-
# ----------------------------------------------------------------
3-
# This script updates a basic installation of Ubuntu (10.10 or 11.04)
4-
# to the latest package revs, and installs the packages required
5-
# to run the current (1.0) version of the Mallory tool.
6-
# ----------------------------------------------------------------
7-
# Copyright 2011 - Intrepidus Group
8-
# ----------------------------------------------------------------
9-
# This program is free software: you can redistribute it and/or modify
10-
# it under the terms of the GNU General Public License as published by
11-
# the Free Software Foundation, either version 3 of the License, or
12-
# (at your option) any later version.
13-
#
14-
# This program is distributed in the hope that it will be useful,
15-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17-
# GNU General Public License for more details.
18-
#
19-
# You should have received a copy of the GNU General Public License
20-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21-
# ----------------------------------------------------------------
2+
echo -e "Latest supported Debian-based releases are Ubuntu 18.04 (Bionic) or Debian 10 (Buster).\nOnly Python 2 is supported.\nThis script assumes the use of apt package manager.\nIt is recommended to install mallory in a virtual machine.\nThis script was tested on ubuntu; there may be a variance in package names between distributions."
3+
echo
4+
echo "The script will now install/update dependencies using apt and pip. (safe to rerun)"
5+
read -p "Press any key to continue, or ctrl+c to exit: " -n 1 -r
6+
echo
227

238
set -e
24-
export UPDATE_DIR=${HOME}/.mallory/update
25-
export UPDATE_LOG=${UPDATE_DIR}/update.log
26-
27-
# -----------------------------------------------------------------
28-
# functions
29-
# -----------------------------------------------------------------
30-
function print_header {
31-
echo "+--------------------------------------------------------+"
32-
echo "| MALLORY INSTALL/UPDATE SCRIPT |"
33-
echo "+--------------------------------------------------------+"
34-
}
35-
36-
function phase0 {
37-
# create the update directory if it doesn't exist
38-
mkdir -p ${UPDATE_DIR}
39-
print_header
40-
echo "| Before running this script, please ensure that you've |"
41-
echo "| configured a network interface and that the internet |"
42-
echo "| is reachable by this virtual machine. |"
43-
echo "+--------------------------------------------------------+"
44-
echo "| Once you have done this (or if you already had) simply |"
45-
echo "| rerun this script to continue the update |"
46-
echo "+--------------------------------------------------------+"
47-
echo "phase1" > ${UPDATE_DIR}/.next_phase
48-
exit 0
49-
}
50-
51-
function phase1 {
52-
print_header
53-
echo "beginning Mallory installation"
54-
echo "updating apt package list"
55-
sudo apt-get update |tee ${UPDATE_LOG}
56-
echo ""
57-
58-
echo "upgrading OS to latest versions of installed packages"
59-
sudo apt-get upgrade -y |tee -a ${UPDATE_LOG}
60-
61-
echo "installing Mallory dependencies"
62-
sudo apt-get -y install build-essential libnetfilter-conntrack-dev libnetfilter-conntrack3 |tee -a ${UPDATE_LOG}
63-
if [ ! -f /usr/lib/netfilter_conntrack.so.1 ]; then
64-
sudo ln -s /usr/lib/libnetfilter_conntrack.so /usr/lib/libnetfilter_conntrack.so.1
65-
fi
66-
sudo apt-get -y install python-pip git python-m2crypto python-qt4 pyro-gui python-netfilter python-pyasn1 python-pil python-ipy|tee -a ${UPDATE_LOG}
67-
sudo apt-get -y install python-paramiko python-twisted-web python-qt4-sql libqt4-sql-sqlite sqlite3 |tee -a ${UPDATE_LOG}
68-
sudo pip install pynetfilter_conntrack
69-
echo ""
70-
71-
echo "enter directory you'd like Mallory to be installed to"
72-
read -p "(default: ${HOME}/mallory)" mallorydir
73-
74-
if [ "$mallorydir" == "" ]; then
75-
mallorydir="${HOME}/mallory";
76-
fi
77-
mkdir -p $mallorydir
78-
echo ${mallorydir} > ${UPDATE_DIR}/installdir
79-
echo "retrieving current mallory source from bitbucket"
80-
/usr/bin/git clone https://github.com/intrepidusgroup/mallory ${mallorydir}/current
81-
82-
echo "phase2" > ${UPDATE_DIR}/.next_phase
83-
phase2
84-
}
85-
86-
87-
function phase2 {
88-
print_header
89-
echo "Mallory installation completed"
90-
echo "To use mallory:"
91-
echo "Open a new terminal window, cd to ${mallorydir}/current/src, then run:"
92-
echo " sudo python ./mallory.py"
93-
echo ""
94-
echo "To run the mallory GUI:"
95-
echo "Open a new terminal window cd to ${mallorydir}/current/src and run:"
96-
echo " sudo chown $USER mallory.log"
97-
echo " where $USER is the user you are logged in as. Then run:"
98-
echo " python ./launchgui.py"
99-
echo "Have fun!"
100-
read -n1 -p "press any key to continue..."
101-
102-
echo "update" > ${UPDATE_DIR}/.next_phase
103-
exit 0
104-
}
105-
106-
function update {
107-
echo 'Please cd into ${mallorydir}/current and update manually with "git pull"'
108-
echo "If you want to rerun this script please clean ~/.mallory/update"
109-
exit 0
110-
}
111-
112-
113-
# -----------------------------------------------------------------
114-
# scriptybits
115-
# -----------------------------------------------------------------
116-
117-
if [[ -f ${UPDATE_DIR}/.next_phase ]]; then
118-
case `cat ${UPDATE_DIR}/.next_phase` in
119-
phase0)
120-
phase0
121-
;;
122-
123-
phase1)
124-
phase1
125-
;;
126-
127-
phase2)
128-
phase2
129-
;;
130-
131-
update)
132-
update
133-
;;
134-
135-
phase4)
136-
echo "phase4: profit!"
137-
exit 0
138-
;;
139-
140-
*)
141-
echo "unknown update status, attempting update"
142-
update
143-
;;
144-
esac
145-
else
146-
phase0
147-
fi
9+
set -x
10+
sudo apt-get update
11+
12+
sudo apt-get install build-essential libnetfilter-conntrack-dev git python-pip python-m2crypto python-qt4 pyro-gui python-netfilter python-pyasn1 python-pil python-ipy python-paramiko python-twisted-web python-qt4-sql libqt4-sql-sqlite sqlite3 python --no-install-recommends
13+
14+
sudo -H pip2 install pynetfilter_conntrack
15+
set +x
16+
17+
echo
18+
echo 'Installation complete.'
19+
echo
20+
echo "If you haven't already, install the Mallory repo by running in a directory of your choosing:"
21+
echo
22+
echo " /usr/bin/git clone https://github.com/Tokarak/mallory"
23+
echo
24+
echo 'In the repo, src/mallory.py has the core functionality of mallory. src/launchgui.py can launch the gui WHILE src/mallory.py is already running.'
25+
echo 'It is recommended to run the gui on your virtual machine using ssh with X11 forwarding (ssh -X ...) instead of installing a bulky desktop. To enable X11forwarding on your VM:'
26+
echo " sudo apt install xauth"
27+
echo 'Search "X11Forwarding" online to learn more.'
28+
echo
29+
echo 'Notice: if you get a "cannot open shared object file" error on running the script, please see:'
30+
echo 'https://web.archive.org/web/20131007182424/http://intrepidusgroup.com/insight/2013/07/getting-mallory-to-run-in-modern-versions-of-ubuntu/'
31+
echo "Script end."
32+
echo
33+
exit 0

0 commit comments

Comments
 (0)