Update scripts

This commit is contained in:
Itay Mizeretz 2018-05-23 20:26:33 +03:00
parent a594bd11c2
commit d30f2cf8dc
13 changed files with 28 additions and 31 deletions

View File

@ -1,33 +1,30 @@
#!/bin/bash #!/bin/bash
MONKEY_FOLDER=/var/monkey_island MONKEY_FOLDER=/var/monkey
INSTALLATION_FOLDER=/var/monkey_island/installation INSTALLATION_FOLDER=/var/monkey/installation
PYTHON_FOLDER=/var/monkey_island/bin/python PYTHON_FOLDER=/var/monkey/monkey_island/bin/python
cp -f ${MONKEY_FOLDER}/monkey.sh /usr/bin/monkey
chmod 755 /usr/bin/monkey
# Prepare python virtualenv # Prepare python virtualenv
pip2 install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER pip2 install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER
virtualenv -p python2.7 ${PYTHON_FOLDER} virtualenv -p python2.7 ${PYTHON_FOLDER}
# install pip requirements # 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 # remove installation folder and unnecessary files
rm -rf ${INSTALLATION_FOLDER} 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 if [ -d "/etc/systemd/network" ]; then
cp ${MONKEY_FOLDER}/ubuntu/systemd/*.service /lib/systemd/system/ cp ${MONKEY_FOLDER}/monkey_island/ubuntu/systemd/*.service /lib/systemd/system/
chmod +x ${MONKEY_FOLDER}/ubuntu/systemd/start_server.sh chmod +x ${MONKEY_FOLDER}/monkey_island/ubuntu/systemd/start_server.sh
systemctl daemon-reload systemctl daemon-reload
systemctl enable monkey-mongo systemctl enable monkey-mongo
systemctl enable monkey-island systemctl enable monkey-island
fi fi
${MONKEY_FOLDER}/create_certificate.sh ${MONKEY_FOLDER}/monkey_island/create_certificate.sh
service monkey-island start service monkey-island start
service monkey-mongo start service monkey-mongo start

View File

@ -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-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 [ -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 exit 0

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
service monkey-mongo stop service monkey-mongo stop
cd /var/monkey_island cd /var/monkey/monkey_island
rm -rf ./db/* rm -rf ./db/*
service monkey-mongo start service monkey-mongo start

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
cd /var/monkey_island cd /var/monkey/monkey_island
openssl genrsa -out cc/server.key 1024 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 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 openssl x509 -req -days 366 -in cc/server.csr -signkey cc/server.key -out cc/server.crt

View File

@ -10,5 +10,5 @@ else
fi fi
MONKEY_FILE=monkey-linux-$ARCH 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 $@ /tmp/$MONKEY_FILE m0nk3y $@

View File

@ -10,5 +10,5 @@ else
fi fi
MONKEY_FILE=monkey-linux-$ARCH 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 $@ /tmp/$MONKEY_FILE m0nk3y $@

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
cd /var/monkey_island/cc cd /var/monkey
/var/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey_island/db & /var/monkey/monkey_island/bin/mongodb/bin/mongod --quiet --dbpath /var/monkey/monkey_island/db &
/var/monkey_island/bin/python/bin/python main.py /var/monkey/monkey_island/bin/python/bin/python monkey_island/cc/main.py

View File

@ -7,8 +7,8 @@ respawn
respawn limit unlimited respawn limit unlimited
script script
chdir /var/monkey_island/cc chdir /var/monkey
exec python main.py exec python monkey_island/cc/main.py
end script end script
post-stop script post-stop script

View File

@ -7,8 +7,8 @@ respawn
respawn limit unlimited respawn limit unlimited
script script
chdir /var/monkey_island/ chdir /var/monkey/monkey_island/
exec /var/monkey_island/bin/mongodb/bin/mongod --dbpath db exec /var/monkey/monkey_island/bin/mongodb/bin/mongod --dbpath db
end script end script
post-stop script post-stop script

View File

@ -5,7 +5,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/var/monkey_island/ubuntu/systemd/start_server.sh ExecStart=/var/monkey/monkey_island/ubuntu/systemd/start_server.sh
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -3,10 +3,10 @@ Description=Monkey Island Mongo Service
After=network.target After=network.target
[Service] [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 KillMode=process
Restart=always Restart=always
ExecStop=/var/monkey_island/bin/mongodb/bin/mongod --shutdown ExecStop=/var/monkey/monkey_island/bin/mongodb/bin/mongod --shutdown
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
cd /var/monkey_island/cc cd /var/monkey
/var/monkey_island/bin/python/bin/python main.py /var/monkey/monkey_island/bin/python/bin/python monkey_island/cc/main.py

View File

@ -1,4 +1,4 @@
@title C^&C Server @title C^&C Server
@pushd cc @pushd ..
@..\bin\Python27\python main.py @monkey_island\bin\Python27\python monkey_island\cc\main.py
@popd @popd