diff --git a/monkey/monkey_island/monkey_island.ico b/monkey/monkey_island/monkey_island.ico new file mode 100644 index 000000000..0a9976256 Binary files /dev/null and b/monkey/monkey_island/monkey_island.ico differ diff --git a/monkey/monkey_island/monkey_island.spec b/monkey/monkey_island/monkey_island.spec new file mode 100644 index 000000000..342df5ab3 --- /dev/null +++ b/monkey/monkey_island/monkey_island.spec @@ -0,0 +1,93 @@ +# -*- mode: python -*- +import os +import platform + + +__author__ = 'itay.mizeretz' + +block_cipher = None + + +def main(): + a = Analysis(['cc/main.py'], + pathex=['..'], + hiddenimports=get_hidden_imports(), + hookspath=None, + runtime_hooks=None, + binaries=None, + datas=None, + excludes=None, + win_no_prefer_redirects=None, + win_private_assemblies=None, + cipher=block_cipher + ) + + a.binaries += get_binaries() + a.datas = process_datas(a.datas) + + pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + name=get_monkey_filename(), + debug=False, + strip=get_exe_strip(), + upx=True, + console=True, + icon=get_exe_icon()) + + +def is_windows(): + return platform.system().find("Windows") >= 0 + + +def is_32_bit(): + return platform.architecture()[0] == "32bit" + + +def process_datas(orig_datas): + datas = orig_datas + if is_windows(): + datas = [i for i in datas if i[0].find('Include') < 0] + return datas + + +def get_binaries(): + binaries = get_windows_only_binaries() if is_windows() else get_linux_only_binaries() + return binaries + + +def get_windows_only_binaries(): + binaries = [] + binaries += get_msvcr() + return binaries + + +def get_linux_only_binaries(): + binaries = [] + return binaries + + +def get_hidden_imports(): + return ['_cffi_backend', 'queue'] if is_windows() else ['_cffi_backend'] + + +def get_msvcr(): + return [('msvcr100.dll', os.environ['WINDIR'] + '\\system32\\msvcr100.dll', 'BINARY')] + + +def get_monkey_filename(): + return 'monkey_island.exe' if is_windows() else 'monkey_island' + + +def get_exe_strip(): + return not is_windows() + + +def get_exe_icon(): + return 'monkey_island.ico' if is_windows() else None + + +main() # We don't check if __main__ because this isn't the main script. diff --git a/monkey/monkey_island/requirements.txt b/monkey/monkey_island/requirements.txt index b8df0f5a9..0caf91c10 100644 --- a/monkey/monkey_island/requirements.txt +++ b/monkey/monkey_island/requirements.txt @@ -9,10 +9,12 @@ flask Flask-Pymongo Flask-Restful Flask-JWT -jsonschema +jsonschema==2.6.0 netifaces ipaddress enum34 pycryptodome boto3 -awscli \ No newline at end of file +awscli +cffi +PyInstaller \ No newline at end of file diff --git a/monkey/monkey_island/windows/build_pyinstaller.bat b/monkey/monkey_island/windows/build_pyinstaller.bat new file mode 100644 index 000000000..58ec101d0 --- /dev/null +++ b/monkey/monkey_island/windows/build_pyinstaller.bat @@ -0,0 +1,5 @@ +REM - Builds Monkey Island Server EXE using pyinstaller - +bin\Python27\Scripts\pyinstaller.exe -F --log-level=DEBUG --clean --upx-dir=.\bin monkey_island.spec +move /Y dist\monkey_island.exe monkey_island.exe +rmdir /S /Q build +rmdir /S /Q dist \ 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 f674376a1..c1a2fd88e 100644 --- a/monkey/monkey_island/windows/run_cc.bat +++ b/monkey/monkey_island/windows/run_cc.bat @@ -1,3 +1,4 @@ +REM - Runs Monkey Island Server using python - @title C^&C Server @pushd .. @monkey_island\bin\Python27\Scripts\python monkey_island.py diff --git a/monkey/monkey_island/windows/run_cc_exe.bat b/monkey/monkey_island/windows/run_cc_exe.bat new file mode 100644 index 000000000..a8b2cb14b --- /dev/null +++ b/monkey/monkey_island/windows/run_cc_exe.bat @@ -0,0 +1,5 @@ +REM - Runs Monkey Island Server using built pyinstaller EXE - +@title C^&C Server +@pushd .. +@monkey_island\monkey_island.exe +@popd \ No newline at end of file diff --git a/monkey/monkey_island/windows/run_mongodb.bat b/monkey/monkey_island/windows/run_mongodb.bat index ca33c22d7..970e98874 100644 --- a/monkey/monkey_island/windows/run_mongodb.bat +++ b/monkey/monkey_island/windows/run_mongodb.bat @@ -1,2 +1,3 @@ +REM - Runs MongoDB Server - @title MongoDB @bin\mongodb\mongod.exe --dbpath db \ No newline at end of file diff --git a/monkey/monkey_island/windows/run_server.bat b/monkey/monkey_island/windows/run_server.bat index a15fbcc04..ab2ad274c 100644 --- a/monkey/monkey_island/windows/run_server.bat +++ b/monkey/monkey_island/windows/run_server.bat @@ -1,4 +1,5 @@ +REM - Runs MongoDB Server & Monkey Island Server using built pyinstaller EXE - if not exist db mkdir db start windows\run_mongodb.bat -start windows\run_cc.bat +start windows\run_cc_exe.bat start https://localhost:5000 \ No newline at end of file diff --git a/monkey/monkey_island/windows/run_server_py.bat b/monkey/monkey_island/windows/run_server_py.bat new file mode 100644 index 000000000..07a587f49 --- /dev/null +++ b/monkey/monkey_island/windows/run_server_py.bat @@ -0,0 +1,5 @@ +REM - Runs MongoDB Server & Monkey Island Server using python - +if not exist db mkdir db +start windows\run_mongodb.bat +start windows\run_cc.bat +start https://localhost:5000 \ No newline at end of file