forked from p15670423/monkey
Agent: Return boolean from "should_monkey_run()"
A function named "should_monkey_run()" should let you know whether or not monkey should run. Before this commit, the function was responsible for flow control, as it raised a PlannedShutdownException, resulting in the shutdown of the monkey agent.
This commit is contained in:
parent
72f77b7d29
commit
ce492d25f4
|
@ -22,7 +22,6 @@ from infection_monkey.config import GUID, WormConfiguration
|
|||
from infection_monkey.network.info import check_internet_access, local_ips
|
||||
from infection_monkey.transport.http import HTTPConnectProxy
|
||||
from infection_monkey.transport.tcp import TcpProxy
|
||||
from infection_monkey.utils.exceptions.planned_shutdown_exception import PlannedShutdownException
|
||||
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
|
||||
|
@ -401,10 +400,8 @@ class ControlClient(object):
|
|||
and ControlClient.can_island_see_port(vulnerable_port)
|
||||
and WormConfiguration.started_on_island
|
||||
):
|
||||
raise PlannedShutdownException(
|
||||
"Monkey shouldn't run on current machine "
|
||||
"(it will be exploited later with more depth)."
|
||||
)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -125,7 +125,12 @@ class InfectionMonkey(object):
|
|||
if is_running_on_island():
|
||||
WormConfiguration.started_on_island = True
|
||||
ControlClient.report_start_on_island()
|
||||
ControlClient.should_monkey_run(self._opts.vulnerable_port)
|
||||
|
||||
if not ControlClient.should_monkey_run(self._opts.vulnerable_port):
|
||||
raise PlannedShutdownException(
|
||||
"Monkey shouldn't run on current machine "
|
||||
"(it will be exploited later with more depth)."
|
||||
)
|
||||
|
||||
if firewall.is_enabled():
|
||||
firewall.add_firewall_rule()
|
||||
|
|
Loading…
Reference in New Issue