Agent: Add self._default_server to monkey.py
This commit is contained in:
parent
b3bc9b2ffa
commit
18fb4e7533
|
@ -40,7 +40,7 @@ class InfectionMonkey:
|
||||||
logger.info("Monkey is initializing...")
|
logger.info("Monkey is initializing...")
|
||||||
self._singleton = SystemSingleton()
|
self._singleton = SystemSingleton()
|
||||||
self._opts = self._get_arguments(args)
|
self._opts = self._get_arguments(args)
|
||||||
# TODO Used in propagation phase to set the default server for the victim
|
self._default_server = self._opts.server
|
||||||
self._default_server_port = None
|
self._default_server_port = None
|
||||||
# TODO used in propogation phase
|
# TODO used in propogation phase
|
||||||
self._monkey_inbound_tunnel = None
|
self._monkey_inbound_tunnel = None
|
||||||
|
@ -54,6 +54,7 @@ class InfectionMonkey:
|
||||||
arg_parser.add_argument("-d", "--depth", type=int)
|
arg_parser.add_argument("-d", "--depth", type=int)
|
||||||
opts, _ = arg_parser.parse_known_args(args)
|
opts, _ = arg_parser.parse_known_args(args)
|
||||||
InfectionMonkey._log_arguments(opts)
|
InfectionMonkey._log_arguments(opts)
|
||||||
|
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -110,26 +111,25 @@ class InfectionMonkey:
|
||||||
|
|
||||||
def _connect_to_island(self):
|
def _connect_to_island(self):
|
||||||
# Sets island's IP and port for monkey to communicate to
|
# Sets island's IP and port for monkey to communicate to
|
||||||
if not self._is_default_server_set():
|
if self._current_server_is_set():
|
||||||
|
self._default_server = WormConfiguration.current_server
|
||||||
|
logger.debug("Default server set to: %s" % self._default_server)
|
||||||
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Monkey couldn't find server with {} default tunnel.".format(self._opts.tunnel)
|
"Monkey couldn't find server with {} default tunnel.".format(self._opts.tunnel)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._set_default_port()
|
self._set_default_port()
|
||||||
|
|
||||||
ControlClient.wakeup(parent=self._opts.parent)
|
ControlClient.wakeup(parent=self._opts.parent)
|
||||||
ControlClient.load_control_config()
|
ControlClient.load_control_config()
|
||||||
|
|
||||||
def _is_default_server_set(self) -> bool:
|
def _current_server_is_set(self) -> bool:
|
||||||
"""
|
if ControlClient.find_server(default_tunnel=self._opts.tunnel):
|
||||||
Sets the default server for the Monkey to communicate back to.
|
|
||||||
:return
|
|
||||||
"""
|
|
||||||
if not ControlClient.find_server(default_tunnel=self._opts.tunnel):
|
|
||||||
return False
|
|
||||||
self._opts.server = WormConfiguration.current_server
|
|
||||||
logger.debug("default server set to: %s" % self._opts.server)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _is_upgrade_to_64_needed():
|
def _is_upgrade_to_64_needed():
|
||||||
return WindowsUpgrader.should_upgrade()
|
return WindowsUpgrader.should_upgrade()
|
||||||
|
@ -172,7 +172,7 @@ class InfectionMonkey:
|
||||||
MockPuppet(),
|
MockPuppet(),
|
||||||
LegacyTelemetryMessengerAdapter(),
|
LegacyTelemetryMessengerAdapter(),
|
||||||
VictimHostFactory(),
|
VictimHostFactory(),
|
||||||
ControlChannel(self._opts.server, GUID),
|
ControlChannel(self._default_server, GUID),
|
||||||
local_network_interfaces,
|
local_network_interfaces,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class InfectionMonkey:
|
||||||
|
|
||||||
def _set_default_port(self):
|
def _set_default_port(self):
|
||||||
try:
|
try:
|
||||||
self._default_server_port = self._opts.server.split(":")[1]
|
self._default_server_port = self._default_server.split(":")[1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._default_server_port = ""
|
self._default_server_port = ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue