-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/1.8.0 fix deb python version #609
Changes from 13 commits
7bab9a0
c72ed36
5c6b9c4
ef5694e
7488dea
41f4f3f
bd2edee
8907a01
90f9f69
305d15c
b95646c
f1de8e8
9d889aa
9687b22
592fd88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# See the "Depends" field of the control file for what packages this scripts depends on. | ||
# Here are the explanations for the current deps: | ||
# Dependency - Why is it required | ||
## openssl - Server certificate generation | ||
## python3.7-dev - Server runtime | ||
## python3.7-venv - For creating virtual env to install all the server pip deps (don't want to pollute system python) | ||
## python3-venv - python3.7-venv doesn't work without it since you need ensure-pip | ||
## build-essential - for compiling python dependencies that don't come in a pre-compiled wheel, like `netifaces` | ||
|
||
echo "Installing Monkey Island (Infection Monkey server)..." | ||
|
||
MONKEY_FOLDER=/var/monkey | ||
INSTALLATION_FOLDER=/var/monkey/monkey_island/installation | ||
PYTHON_FOLDER=/var/monkey/monkey_island/bin/python | ||
PYTHON_VERSION=python3.7 | ||
|
||
# Prepare python virtualenv | ||
pip3 install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER | ||
python3 -m virtualenv -p python3 ${PYTHON_FOLDER} | ||
|
||
# install pip requirements | ||
# This is using the apt package `python3.7-venv` which is listed in the `control` file as a dependency. | ||
# See https://packages.debian.org/stable/python/python3.7-venv | ||
echo "Using $(command -v $PYTHON_VERSION) as the base for virtualenv creation" | ||
$PYTHON_VERSION -m venv ${PYTHON_FOLDER} | ||
# shellcheck disable=SC1090 | ||
source ${PYTHON_FOLDER}/bin/activate | ||
|
||
echo "Installing Python dependencies using $(command -v pip)..." | ||
# First, make sure that pip is updated | ||
${PYTHON_FOLDER}/bin/python -m pip install --upgrade pip | ||
# Then install the dependecies from the pre-downloaded whl and tar.gz file | ||
${PYTHON_FOLDER}/bin/python -m pip install -r $MONKEY_FOLDER/monkey_island/requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER | ||
|
||
deactivate | ||
|
||
# remove installation folder and unnecessary files | ||
rm -rf ${INSTALLATION_FOLDER} | ||
rm -f ${MONKEY_FOLDER}/monkey_island/requirements.txt | ||
|
||
echo "Installing mongodb..." | ||
${MONKEY_FOLDER}/monkey_island/install_mongo.sh ${MONKEY_FOLDER}/monkey_island/bin/mongodb | ||
|
||
if [ -d "/etc/systemd/network" ]; then | ||
|
@@ -25,11 +47,17 @@ if [ -d "/etc/systemd/network" ]; then | |
systemctl enable monkey-island | ||
fi | ||
|
||
${MONKEY_FOLDER}/monkey_island/create_certificate.sh ${MONKEY_FOLDER}/monkey_island/ | ||
echo "Creating server certificate..." | ||
${MONKEY_FOLDER}/monkey_island/create_certificate.sh ${MONKEY_FOLDER}/monkey_island/cc | ||
|
||
echo "Starting services..." | ||
service monkey-island start | ||
service monkey-mongo start | ||
|
||
echo Monkey Island installation ended | ||
echo "" | ||
echo "Monkey Island installation ended." | ||
echo "The server should be accessible soon via https://<server_ip>:5000/" | ||
echo "To check the Island's status, run 'sudo service monkey-island status'" | ||
echo "" | ||
|
||
exit 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,21 @@ | |
|
||
server_root=${1:-"./cc"} | ||
|
||
echo "Creating server cetificate. Server root: $server_root" | ||
# We override the RANDFILE determined by default openssl.cnf | ||
# This is a known issue with the current version of openssl on Ubuntu 18.04 - once they release | ||
# a new version, we can delete this command. See | ||
# https://github.com/openssl/openssl/commit/0f58220973a02248ca5c69db59e615378467b9c8#diff-8ce6aaad88b10ed2b3b4592fd5c8e03a | ||
# for more details. | ||
dd bs=1024 count=2 </dev/urandom >~/.rnd | ||
chmod 666 ~/.rnd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if you don't have permissions to ~ or if the file exists? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user which runs ./create_cert will have access to their own ~ folder in enough of the cases that I'm willing to leave this in. No other workaround that doesn't involve carrying openssl with us or messing with worse things in the system that I could fine. |
||
|
||
echo "Generating key in $server_root/server.key" | ||
openssl genrsa -out "$server_root"/server.key 2048 | ||
echo "Generating csr in $server_root/server.csr" | ||
openssl req -new -key "$server_root"/server.key -out "$server_root"/server.csr -subj "/C=GB/ST=London/L=London/O=Global Security/OU=Monkey Department/CN=monkey.com" | ||
echo "Generating certificate in $server_root/server.crt" | ||
openssl x509 -req -days 366 -in "$server_root"/server.csr -signkey "$server_root"/server.key -out $server_root/server.crt | ||
|
||
# Shove some new random data into the file to override the original seed. | ||
dd bs=1024 count=2 </dev/urandom >~/.rnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you ran source above, why are you fully qualifying your python command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
592fd88