From 243a0ba961d80b5898f054adb405c6bf88c23280 Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Wed, 24 Apr 2019 15:16:28 +0300 Subject: [PATCH 1/5] chmod +x install_mongo --- monkey/monkey_island/linux/install_mongo.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 monkey/monkey_island/linux/install_mongo.sh diff --git a/monkey/monkey_island/linux/install_mongo.sh b/monkey/monkey_island/linux/install_mongo.sh old mode 100644 new mode 100755 From 467e43aa1a5e4cbd85ffa046a5fca8706b2bae5c Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Wed, 24 Apr 2019 14:16:38 +0300 Subject: [PATCH 2/5] Added PyCharm ignore inspection to PyInstaller import and updated gitignore --- .gitignore | 3 ++- monkey/infection_monkey/main.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 63de45992..772829801 100644 --- a/.gitignore +++ b/.gitignore @@ -82,4 +82,5 @@ MonkeyZoo/* !MonkeyZoo/config.tf !MonkeyZoo/MonkeyZooDocs.pdf - +# vim swap files +*.swp diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index d12414eae..6e06d4aa6 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -13,7 +13,8 @@ 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 infection_monkey.post_breach # dummy import for pyinstaller +# noinspection PyUnresolvedReferences +import infection_monkey.post_breach # dummy import for pyinstaller __author__ = 'itamar' @@ -23,7 +24,7 @@ LOG_CONFIG = {'version': 1, 'disable_existing_loggers': False, 'formatters': {'standard': { 'format': '%(asctime)s [%(process)d:%(thread)d:%(levelname)s] %(module)s.%(funcName)s.%(lineno)d: %(message)s'}, - }, + }, 'handlers': {'console': {'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'standard'}, @@ -70,7 +71,8 @@ def main(): print("Loaded Configuration: %r" % WormConfiguration.as_dict()) # Make sure we're not in a machine that has the kill file - kill_path = os.path.expandvars(WormConfiguration.kill_file_path_windows) if sys.platform == "win32" else WormConfiguration.kill_file_path_linux + kill_path = os.path.expandvars( + WormConfiguration.kill_file_path_windows) if sys.platform == "win32" else WormConfiguration.kill_file_path_linux if os.path.exists(kill_path): print("Kill path found, finished run") return True From cfbf14fd67d4b10dc1b9c01165d0ce0929353d7d Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Wed, 8 May 2019 13:50:23 +0300 Subject: [PATCH 3/5] Update aws_instance.py --- monkey/common/cloud/aws_instance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/common/cloud/aws_instance.py b/monkey/common/cloud/aws_instance.py index 748bd8d04..ea6a10df7 100644 --- a/monkey/common/cloud/aws_instance.py +++ b/monkey/common/cloud/aws_instance.py @@ -30,14 +30,14 @@ class AwsInstance(object): self.region = self._parse_region( urllib2.urlopen(AWS_LATEST_METADATA_URI_PREFIX + 'meta-data/placement/availability-zone').read()) except urllib2.URLError as e: - logger.error("Failed init of AwsInstance while getting metadata: {}".format(e.message)) + logger.warning("Failed init of AwsInstance while getting metadata: {}".format(e.message)) try: self.account_id = self._extract_account_id( urllib2.urlopen( AWS_LATEST_METADATA_URI_PREFIX + 'dynamic/instance-identity/document', timeout=2).read()) except urllib2.URLError as e: - logger.error("Failed init of AwsInstance while getting dynamic instance data: {}".format(e.message)) + logger.warning("Failed init of AwsInstance while getting dynamic instance data: {}".format(e.message)) @staticmethod def _parse_region(region_url_response): From 861750be5bbba2cc75baaac3f26e69a9dae8c02f Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 9 May 2019 12:23:44 +0300 Subject: [PATCH 4/5] Struts2 ignores certificate errors, updated schema --- monkey/infection_monkey/exploit/struts2.py | 3 ++- monkey/monkey_island/cc/services/config_schema.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/exploit/struts2.py b/monkey/infection_monkey/exploit/struts2.py index 18f3d3a7e..b32ab1e6f 100644 --- a/monkey/infection_monkey/exploit/struts2.py +++ b/monkey/infection_monkey/exploit/struts2.py @@ -7,6 +7,7 @@ import urllib2 import httplib import unicodedata import re +import ssl import logging from infection_monkey.exploit.web_rce import WebRCE @@ -47,7 +48,7 @@ class Struts2Exploiter(WebRCE): headers = {'User-Agent': 'Mozilla/5.0'} request = urllib2.Request(url, headers=headers) try: - return urllib2.urlopen(request).geturl() + return urllib2.urlopen(request, context=ssl._create_unverified_context()).geturl() except urllib2.URLError: LOG.error("Can't reach struts2 server") return False diff --git a/monkey/monkey_island/cc/services/config_schema.py b/monkey/monkey_island/cc/services/config_schema.py index 382b591db..7b6f4f8e5 100644 --- a/monkey/monkey_island/cc/services/config_schema.py +++ b/monkey/monkey_island/cc/services/config_schema.py @@ -250,8 +250,9 @@ SCHEMA = { "default": [ ], "description": - "List of IPs/subnets the monkey should scan." - " Examples: \"192.168.0.1\", \"192.168.0.5-192.168.0.20\", \"192.168.0.5/24\"" + "List of IPs/subnets/hosts the monkey should scan." + " Examples: \"192.168.0.1\", \"192.168.0.5-192.168.0.20\", \"192.168.0.5/24\"," + " \"printer.example\"" } } }, From b86ab2a940e894e9ee78aaabb780193de9907f11 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 9 May 2019 16:29:05 +0300 Subject: [PATCH 5/5] MongoDB installation script added --- deployment_scripts/deploy_linux.sh | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/deployment_scripts/deploy_linux.sh b/deployment_scripts/deploy_linux.sh index 176c2e4fc..81d6e6732 100644 --- a/deployment_scripts/deploy_linux.sh +++ b/deployment_scripts/deploy_linux.sh @@ -89,25 +89,8 @@ kernel=`uname -m` linux_dist=`lsb_release -a 2> /dev/null` # If a user haven't installed mongo manually check if we can install it with our script -if [[ ! -f "$MONGO_BIN_PATH/mongod" ]] && { [[ ${kernel} != "x86_64" ]] || \ - { [[ ${linux_dist} != *"Debian"* ]] && [[ ${linux_dist} != *"Ubuntu"* ]]; }; }; then - echo "Script does not support your operating system for mongodb installation. - Reference monkey island readme and install it manually" - exit 1 -fi - -# Download mongo -if [[ ! -f "$MONGO_BIN_PATH/mongod" ]]; then - log_message "Downloading mongodb" - if [[ ${linux_dist} == *"Debian"* ]]; then - wget -c -N -O "/tmp/mongo.tgz" ${MONGO_DEBIAN_URL} - elif [[ ${linux_dist} == *"Ubuntu"* ]]; then - wget -c -N -O "/tmp/mongo.tgz" ${MONGO_UBUNTU_URL} - fi - tar --strip 2 --wildcards -C ${MONGO_BIN_PATH} -zxvf /tmp/mongo.tgz mongo*/bin/* || handle_error -else - log_message "Mongo db already installed" -fi +log_message "Installing MongoDB" +${ISLAND_PATH}/linux/install_mongo.sh ${MONGO_BIN_PATH} || handle_error log_message "Installing openssl" sudo apt-get install openssl