From 76840389e84278bdfdbf46dda0961f5c29fa44f3 Mon Sep 17 00:00:00 2001 From: Barak Hoffer Date: Sun, 11 Oct 2015 14:01:27 +0300 Subject: [PATCH] readme for build envs and c&c setup --- build_env/build_from_cc.sh | 44 +++++++++++++++++++++++ build_env/readme.txt | 71 ++++++++++++++++++++++++++++++++++++++ monkey_island/readme.txt | 38 ++++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 build_env/build_from_cc.sh create mode 100644 build_env/readme.txt create mode 100644 monkey_island/readme.txt diff --git a/build_env/build_from_cc.sh b/build_env/build_from_cc.sh new file mode 100644 index 000000000..95db3f41a --- /dev/null +++ b/build_env/build_from_cc.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +sources_path=/mnt/sources +build_path=/home/user/Code/chaos_monkey +out_path=/mnt/binaries +out_name=$1 +shift +sha=0 +update_sha() { + sha=`ls -lR --time-style=full-iso $sources_path | sha1sum` +} +update_sha +previous_sha=$sha +build() { + echo -en " building...\n\n" + rm -fR "$build_path" + mkdir "$build_path" + cp -R "$sources_path/." "$build_path" + pushd "$build_path" + chmod +x build_linux.sh + ./build_linux.sh + popd + cp -f "$build_path/dist/monkey" "$out_path/$out_name" + echo -en "\n--> resumed watching." +} +compare() { + update_sha + if [[ $sha != $previous_sha ]] ; then + echo -n "change detected," + build + previous_sha=$sha + else + echo -n . + fi +} +trap build SIGINT +trap exit SIGQUIT + +echo -e "--> Press Ctrl+C to force build, Ctrl+\\ to exit." +echo -en "--> watching \"$path\"." +while true; do + compare + sleep 1 +done \ No newline at end of file diff --git a/build_env/readme.txt b/build_env/readme.txt new file mode 100644 index 000000000..c2f1c8c3a --- /dev/null +++ b/build_env/readme.txt @@ -0,0 +1,71 @@ +How to create a monkey build environment: + +Windows: +1. Install python 2.7 + https://www.python.org/download/releases/2.7 +2. install pywin32-219.win32-py2.7.exe + http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/ +3. install VCForPython27.msi + http://www.microsoft.com/en-us/download/details.aspx?id=44266 +4. Download & Run get-pip.py + https://bootstrap.pypa.io/get-pip.py +5. Run: + setx path "%path%;C:\Python27\;C:\Python27\Scripts" + python -m pip install enum34 + python -m pip install impacket + python -m pip install PyCrypto + python -m pip install pyasn1 + python -m pip install cffi + python -m pip install twisted + python -m pip install rdpy + python -m pip install requests + python -m pip install odict + python -m pip install paramiko + python -m pip install psutil + python -m pip install PyInstaller + type > C:\Python27\Lib\site-packages\zope\__init__.py + +Linux (Tested on Ubuntu 12.04): +1. Run: + sudo apt-get update + apt-get install python-pip python-dev libffi-dev upx + sudo pip install enum34 + sudo pip install impacket + sudo pip install PyCrypto --upgrade + sudo pip install pyasn1 + sudo pip install cffi + sudo pip install zope.interface --upgrade + sudo pip install twisted + sudo pip install rdpy + sudo pip install requests --upgrade + sudo pip install odict + sudo pip install paramiko + sudo pip install psutil + sudo pip install https://github.com/pyinstaller/pyinstaller/releases/download/3.0.dev2/PyInstaller-3.0.dev2.tar.gz + sudo apt-get install winbind + +How to connect build environment to c&c: +- will auto compile the source code stored in the c&c and update the c&c binaries accordingly +Linux (Tested on Ubuntu 12.04): + 1. Setup c&c according to readme in monkey_island folder + 2. Install cifs: + sudo apt-get install cifs-utils + 3. Run: + mkdir /home/user/Code + sudo mkdir /mnt/sources + sudo mkdir /mnt/binaries + 4. Save username and password for c&c smb: + echo username= > /home/user/.smbcreds + echo password= >> /home/user/.smbcreds + (Change and according to c&c) + 5. Edit fstab: + run: sudo nano /etc/fstab + add rows: + //monkeycc/sources /mnt/sources cifs iocharset=utf-8,credentials=/home/user/.smbcreds,uid=1000 0 0 + //monkeycc/binaries /mnt/binaries cifs iocharset=utf-8,credentials=/home/user/.smbcreds,uid=1000 0 0 + 6. Remount: + sudo mount -a + 7. Check if sources exist in /mnt/sources + If not, edit hosts file - add a line in /etc/hosts with c&c ip and hostname and remount. + 8. put build_from_cc.sh in /home/user and run. + use Ctrl+C to manualy check compilation and Ctrl+\ to exit script. \ No newline at end of file diff --git a/monkey_island/readme.txt b/monkey_island/readme.txt new file mode 100644 index 000000000..9665200f3 --- /dev/null +++ b/monkey_island/readme.txt @@ -0,0 +1,38 @@ +How to setup C&C server: +On Windows: +1. Install python 2.7 + https://www.python.org/download/releases/2.7 +2. Download & Run get-pip.py + https://bootstrap.pypa.io/get-pip.py +3. Run: + setx path "%path%;C:\Python27\;C:\Python27\Scripts" + python -m pip install flask + python -m pip install Flask-Pymongo + python -m pip install Flask-Restful + python -m pip install python-dateutil + mkdir C:\MonkeyIsland\bin + mkdir C:\MonkeyIsland\db + mkdir C:\MonkeyIsland\cc\binaries +4. Put monkey binaries in C:\MonkeyIsland\cc\binaries: + monkey-linux-64 - monkey binary for linux 64bit + monkey-linux-32 - monkey binary for linux 32bit + monkey-windows-32.exe - monkey binary for windows 32bit + monkey-windows-64.exe - monkey binary for windows 64bit +4. Download MongoDb & Extract to C:\MonkeyIsland\bin\mongodb + http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-latest.zip +5. Install OpenSSL + https://slproweb.com/download/Win64OpenSSL_Light-1_0_2d.exe +6. Generate SSL Certificate, Run create_certificate.bat + +How to Connect to build environment: +1. set hostname to MONKEYCC +2. Put monkey source code at C:\Code\monkey +3. Run: + net share binaries=C:\MonkeyIsland\cc\binaries + net share sources=C:\Code\monkey\chaos_monkey +4. Run batch/sh script according to build environment readme + +How to run: +1. start run_mongodb.bat +2. start run_cc.bat +3. to clear db, run clear_db.bat \ No newline at end of file