Fixed error caused by mixing up the value of "started_on_island" with whether the current monkey is running on island.
This commit is contained in:
parent
5f28808885
commit
d2a8597903
|
@ -1,6 +1,9 @@
|
|||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from infection_monkey.config import WormConfiguration
|
||||
from infection_monkey.network.tools import is_running_on_server
|
||||
|
||||
|
||||
def get_host_from_network_location(network_location: str) -> str:
|
||||
"""
|
||||
|
@ -18,3 +21,9 @@ def remove_port(url):
|
|||
with_port = f'{parsed.scheme}://{parsed.netloc}'
|
||||
without_port = re.sub(':[0-9]+(?=$|\/)', '', with_port)
|
||||
return without_port
|
||||
|
||||
|
||||
def is_running_on_island():
|
||||
current_server_without_port = get_host_from_network_location(WormConfiguration.current_server)
|
||||
running_on_island = is_running_on_server(current_server_without_port)
|
||||
return running_on_island and WormConfiguration.depth == WormConfiguration.max_depth
|
||||
|
|
|
@ -7,7 +7,7 @@ import time
|
|||
from threading import Thread
|
||||
|
||||
import infection_monkey.tunnel as tunnel
|
||||
from common.network.network_utils import get_host_from_network_location
|
||||
from common.network.network_utils import is_running_on_island
|
||||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||
from common.utils.exceptions import (ExploitingVulnerableMachineError,
|
||||
FailedExploitationError)
|
||||
|
@ -19,8 +19,7 @@ from infection_monkey.model import DELAY_DELETE_CMD
|
|||
from infection_monkey.network.firewall import app as firewall
|
||||
from infection_monkey.network.HostFinger import HostFinger
|
||||
from infection_monkey.network.network_scanner import NetworkScanner
|
||||
from infection_monkey.network.tools import (get_interface_to_target,
|
||||
is_running_on_server)
|
||||
from infection_monkey.network.tools import get_interface_to_target
|
||||
from infection_monkey.post_breach.post_breach_handler import PostBreach
|
||||
from infection_monkey.system_info import SystemInfoCollector
|
||||
from infection_monkey.system_singleton import SystemSingleton
|
||||
|
@ -125,7 +124,7 @@ class InfectionMonkey(object):
|
|||
|
||||
self.shutdown_by_not_alive_config()
|
||||
|
||||
if self.is_started_on_island():
|
||||
if is_running_on_island():
|
||||
WormConfiguration.started_on_island = True
|
||||
ControlClient.report_start_on_island()
|
||||
ControlClient.should_monkey_run(self._opts.vulnerable_port)
|
||||
|
@ -400,10 +399,6 @@ class InfectionMonkey(object):
|
|||
self._default_server = WormConfiguration.current_server
|
||||
LOG.debug("default server set to: %s" % self._default_server)
|
||||
|
||||
def is_started_on_island(self):
|
||||
island_ip = get_host_from_network_location(self._default_server)
|
||||
return is_running_on_server(island_ip) and WormConfiguration.depth == WormConfiguration.max_depth
|
||||
|
||||
def log_arguments(self):
|
||||
arg_string = " ".join([f"{key}: {value}" for key, value in vars(self._opts).items()])
|
||||
LOG.info(f"Monkey started with arguments: {arg_string}")
|
||||
|
|
|
@ -3,10 +3,10 @@ import logging
|
|||
from common.cloud.aws.aws_instance import AwsInstance
|
||||
from common.cloud.scoutsuite_consts import PROVIDERS
|
||||
from common.common_consts.system_info_collectors_names import AWS_COLLECTOR
|
||||
from common.network.network_utils import is_running_on_island
|
||||
from infection_monkey.system_info.collectors.scoutsuite_collector.scoutsuite_collector import scan_cloud_security
|
||||
from infection_monkey.system_info.system_info_collector import \
|
||||
SystemInfoCollector
|
||||
from infection_monkey.config import WormConfiguration
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -20,7 +20,7 @@ class AwsCollector(SystemInfoCollector):
|
|||
|
||||
def collect(self) -> dict:
|
||||
logger.info("Collecting AWS info")
|
||||
if WormConfiguration.started_on_island:
|
||||
if is_running_on_island():
|
||||
logger.info("Attempting to scan AWS security with ScoutSuite.")
|
||||
scan_cloud_security(cloud_type=PROVIDERS.AWS)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue