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.network.info import check_internet_access, local_ips
|
||||||
from infection_monkey.transport.http import HTTPConnectProxy
|
from infection_monkey.transport.http import HTTPConnectProxy
|
||||||
from infection_monkey.transport.tcp import TcpProxy
|
from infection_monkey.transport.tcp import TcpProxy
|
||||||
from infection_monkey.utils.exceptions.planned_shutdown_exception import PlannedShutdownException
|
|
||||||
|
|
||||||
requests.packages.urllib3.disable_warnings()
|
requests.packages.urllib3.disable_warnings()
|
||||||
|
|
||||||
|
@ -401,10 +400,8 @@ class ControlClient(object):
|
||||||
and ControlClient.can_island_see_port(vulnerable_port)
|
and ControlClient.can_island_see_port(vulnerable_port)
|
||||||
and WormConfiguration.started_on_island
|
and WormConfiguration.started_on_island
|
||||||
):
|
):
|
||||||
raise PlannedShutdownException(
|
return False
|
||||||
"Monkey shouldn't run on current machine "
|
|
||||||
"(it will be exploited later with more depth)."
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -125,7 +125,12 @@ class InfectionMonkey(object):
|
||||||
if is_running_on_island():
|
if is_running_on_island():
|
||||||
WormConfiguration.started_on_island = True
|
WormConfiguration.started_on_island = True
|
||||||
ControlClient.report_start_on_island()
|
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():
|
if firewall.is_enabled():
|
||||||
firewall.add_firewall_rule()
|
firewall.add_firewall_rule()
|
||||||
|
|
Loading…
Reference in New Issue