From d30f2cf8dc0ed2342516f58416b13cab9a811e3d Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 23 May 2018 20:26:33 +0300 Subject: [PATCH] Update scripts --- .../monkey_island/deb-package/DEBIAN/postinst | 21 ++++++++----------- monkey/monkey_island/deb-package/DEBIAN/prerm | 2 +- monkey/monkey_island/linux/clear_db.sh | 2 +- .../monkey_island/linux/create_certificate.sh | 2 +- monkey/monkey_island/linux/install.sh | 2 +- monkey/monkey_island/linux/monkey.sh | 2 +- monkey/monkey_island/linux/run.sh | 6 +++--- .../linux/ubuntu/monkey-island.conf | 4 ++-- .../linux/ubuntu/monkey-mongo.conf | 4 ++-- .../ubuntu/systemd/monkey-island.service | 2 +- .../linux/ubuntu/systemd/monkey-mongo.service | 4 ++-- .../linux/ubuntu/systemd/start_server.sh | 4 ++-- monkey/monkey_island/windows/run_cc.bat | 4 ++-- 13 files changed, 28 insertions(+), 31 deletions(-) diff --git a/monkey/monkey_island/deb-package/DEBIAN/postinst b/monkey/monkey_island/deb-package/DEBIAN/postinst index 3fa922a01..00d3b78f1 100644 --- a/monkey/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey/monkey_island/deb-package/DEBIAN/postinst @@ -1,33 +1,30 @@ #!/bin/bash -MONKEY_FOLDER=/var/monkey_island -INSTALLATION_FOLDER=/var/monkey_island/installation -PYTHON_FOLDER=/var/monkey_island/bin/python - -cp -f ${MONKEY_FOLDER}/monkey.sh /usr/bin/monkey -chmod 755 /usr/bin/monkey +MONKEY_FOLDER=/var/monkey +INSTALLATION_FOLDER=/var/monkey/installation +PYTHON_FOLDER=/var/monkey/monkey_island/bin/python # Prepare python virtualenv pip2 install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER virtualenv -p python2.7 ${PYTHON_FOLDER} # install pip requirements -${PYTHON_FOLDER}/bin/python -m pip install -r $MONKEY_FOLDER/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER +${PYTHON_FOLDER}/bin/python -m pip install -r $MONKEY_FOLDER/monkey_island/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER # remove installation folder and unnecessary files rm -rf ${INSTALLATION_FOLDER} -rm -f ${MONKEY_FOLDER}/pip_requirements.txt +rm -f ${MONKEY_FOLDER}/monkey_island/pip_requirements.txt -cp ${MONKEY_FOLDER}/ubuntu/* /etc/init/ +cp ${MONKEY_FOLDER}/monkey_island/ubuntu/* /etc/init/ if [ -d "/etc/systemd/network" ]; then - cp ${MONKEY_FOLDER}/ubuntu/systemd/*.service /lib/systemd/system/ - chmod +x ${MONKEY_FOLDER}/ubuntu/systemd/start_server.sh + cp ${MONKEY_FOLDER}/monkey_island/ubuntu/systemd/*.service /lib/systemd/system/ + chmod +x ${MONKEY_FOLDER}/monkey_island/ubuntu/systemd/start_server.sh systemctl daemon-reload systemctl enable monkey-mongo systemctl enable monkey-island fi -${MONKEY_FOLDER}/create_certificate.sh +${MONKEY_FOLDER}/monkey_island/create_certificate.sh service monkey-island start service monkey-mongo start diff --git a/monkey/monkey_island/deb-package/DEBIAN/prerm b/monkey/monkey_island/deb-package/DEBIAN/prerm index 98557e487..69070adaf 100644 --- a/monkey/monkey_island/deb-package/DEBIAN/prerm +++ b/monkey/monkey_island/deb-package/DEBIAN/prerm @@ -8,6 +8,6 @@ rm -f /etc/init/monkey-mongo.conf [ -f "/lib/systemd/system/monkey-island.service" ] && rm -f /lib/systemd/system/monkey-island.service [ -f "/lib/systemd/system/monkey-mongo.service" ] && rm -f /lib/systemd/system/monkey-mongo.service -rm -r -f /var/monkey_island +rm -r -f /var/monkey exit 0 \ No newline at end of file diff --git a/monkey/monkey_island/linux/clear_db.sh b/monkey/monkey_island/linux/clear_db.sh index d6839ed2a..7ec819cd5 100644 --- a/monkey/monkey_island/linux/clear_db.sh +++ b/monkey/monkey_island/linux/clear_db.sh @@ -1,6 +1,6 @@ #!/bin/bash service monkey-mongo stop -cd /var/monkey_island +cd /var/monkey/monkey_island rm -rf ./db/* service monkey-mongo start diff --git a/monkey/monkey_island/linux/create_certificate.sh b/monkey/monkey_island/linux/create_certificate.sh index 32fa9756d..477440a6f 100644 --- a/monkey/monkey_island/linux/create_certificate.sh +++ b/monkey/monkey_island/linux/create_certificate.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd /var/monkey_island +cd /var/monkey/monkey_island openssl genrsa -out cc/server.key 1024 openssl req -new -key cc/server.key -out cc/server.csr -subj "/C=GB/ST=London/L=London/O=Global Security/OU=Monkey Department/CN=monkey.com" openssl x509 -req -days 366 -in cc/server.csr -signkey cc/server.key -out cc/server.crt diff --git a/monkey/monkey_island/linux/install.sh b/monkey/monkey_island/linux/install.sh index f230b58d2..d4ebfedbe 100644 --- a/monkey/monkey_island/linux/install.sh +++ b/monkey/monkey_island/linux/install.sh @@ -10,5 +10,5 @@ else fi MONKEY_FILE=monkey-linux-$ARCH -cp -f /var/monkey_island/cc/binaries/$MONKEY_FILE /tmp +cp -f /var/monkey/monkey_island/cc/binaries/$MONKEY_FILE /tmp /tmp/$MONKEY_FILE m0nk3y $@ diff --git a/monkey/monkey_island/linux/monkey.sh b/monkey/monkey_island/linux/monkey.sh index f230b58d2..d4ebfedbe 100644 --- a/monkey/monkey_island/linux/monkey.sh +++ b/monkey/monkey_island/linux/monkey.sh @@ -10,5 +10,5 @@ else fi MONKEY_FILE=monkey-linux-$ARCH -cp -f /var/monkey_island/cc/binaries/$MONKEY_FILE /tmp +cp -f /var/monkey/monkey_island/cc/binaries/$MONKEY_FILE /tmp /tmp/$MONKEY_FILE m0nk3y $@ diff --git a/monkey/monkey_island/linux/run.sh b/monkey/monkey_island/linux/run.sh index 485d6eff1..6770e2922 100644 --- a/monkey/monkey_island/linux/run.sh +++ b/monkey/monkey_island/linux/run.sh @@ -1,5 +1,5 @@ #!/bin/bash -cd /var/monkey_island/cc -/var/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey_island/db & -/var/monkey_island/bin/python/bin/python main.py \ No newline at end of file +cd /var/monkey +/var/monkey/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey/monkey_island/db & +/var/monkey/monkey_island/bin/python/bin/python monkey_island/cc/main.py \ No newline at end of file diff --git a/monkey/monkey_island/linux/ubuntu/monkey-island.conf b/monkey/monkey_island/linux/ubuntu/monkey-island.conf index 360559b31..1ded4d94a 100644 --- a/monkey/monkey_island/linux/ubuntu/monkey-island.conf +++ b/monkey/monkey_island/linux/ubuntu/monkey-island.conf @@ -7,8 +7,8 @@ respawn respawn limit unlimited script - chdir /var/monkey_island/cc - exec python main.py + chdir /var/monkey + exec python monkey_island/cc/main.py end script post-stop script diff --git a/monkey/monkey_island/linux/ubuntu/monkey-mongo.conf b/monkey/monkey_island/linux/ubuntu/monkey-mongo.conf index df9145014..cd148d877 100644 --- a/monkey/monkey_island/linux/ubuntu/monkey-mongo.conf +++ b/monkey/monkey_island/linux/ubuntu/monkey-mongo.conf @@ -7,8 +7,8 @@ respawn respawn limit unlimited script - chdir /var/monkey_island/ - exec /var/monkey_island/bin/mongodb/bin/mongod --dbpath db + chdir /var/monkey/monkey_island/ + exec /var/monkey/monkey_island/bin/mongodb/bin/mongod --dbpath db end script post-stop script diff --git a/monkey/monkey_island/linux/ubuntu/systemd/monkey-island.service b/monkey/monkey_island/linux/ubuntu/systemd/monkey-island.service index 8868dc3aa..d66de2377 100644 --- a/monkey/monkey_island/linux/ubuntu/systemd/monkey-island.service +++ b/monkey/monkey_island/linux/ubuntu/systemd/monkey-island.service @@ -5,7 +5,7 @@ After=network.target [Service] Type=simple -ExecStart=/var/monkey_island/ubuntu/systemd/start_server.sh +ExecStart=/var/monkey/monkey_island/ubuntu/systemd/start_server.sh [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/monkey/monkey_island/linux/ubuntu/systemd/monkey-mongo.service b/monkey/monkey_island/linux/ubuntu/systemd/monkey-mongo.service index 6c1fee8f8..b786e0abb 100644 --- a/monkey/monkey_island/linux/ubuntu/systemd/monkey-mongo.service +++ b/monkey/monkey_island/linux/ubuntu/systemd/monkey-mongo.service @@ -3,10 +3,10 @@ Description=Monkey Island Mongo Service After=network.target [Service] -ExecStart=/var/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey_island/db +ExecStart=/var/monkey/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey/monkey_island/db KillMode=process Restart=always -ExecStop=/var/monkey_island/bin/mongodb/bin/mongod --shutdown +ExecStop=/var/monkey/monkey_island/bin/mongodb/bin/mongod --shutdown [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh b/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh index ceeab57f4..21ba14f58 100644 --- a/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh +++ b/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh @@ -1,4 +1,4 @@ #!/bin/bash -cd /var/monkey_island/cc -/var/monkey_island/bin/python/bin/python main.py \ No newline at end of file +cd /var/monkey +/var/monkey/monkey_island/bin/python/bin/python monkey_island/cc/main.py \ No newline at end of file diff --git a/monkey/monkey_island/windows/run_cc.bat b/monkey/monkey_island/windows/run_cc.bat index c16c9fc6b..56f349c7b 100644 --- a/monkey/monkey_island/windows/run_cc.bat +++ b/monkey/monkey_island/windows/run_cc.bat @@ -1,4 +1,4 @@ @title C^&C Server -@pushd cc -@..\bin\Python27\python main.py +@pushd .. +@monkey_island\bin\Python27\python monkey_island\cc\main.py @popd \ No newline at end of file