Merge pull request #1813 from guardicore/1801-fix-failure-quitting-tunnel

1801 fix failure quitting tunnel
This commit is contained in:
Mike Salvatore 2022-03-24 14:57:24 -04:00 committed by GitHub
commit 8d4edca419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 13 deletions

View File

@ -85,7 +85,7 @@ class Configuration(object):
current_server = ""
# Configuration servers to try to connect to, in this order.
command_servers = ["192.0.2.0:5000"]
command_servers = []
keep_tunnel_open_time = 60

View File

@ -87,13 +87,13 @@ class SMBExploiter(HostExploiter):
return self.exploit_result
# execute the remote dropper in case the path isn't final
if remote_full_path.lower() != dest_path.lower():
if remote_full_path.lower() != str(dest_path).lower():
cmdline = DROPPER_CMDLINE_DETACHED_WINDOWS % {
"dropper_path": remote_full_path
} + build_monkey_commandline(
self.host,
self.current_depth - 1,
dest_path,
str(dest_path),
)
else:
cmdline = MONKEY_CMDLINE_DETACHED_WINDOWS % {

View File

@ -120,13 +120,8 @@ class InfectionMonkey:
@staticmethod
def _add_default_server_to_config(default_server: str):
if default_server:
if default_server not in WormConfiguration.command_servers:
logger.debug("Added default server: %s" % default_server)
WormConfiguration.command_servers.insert(0, default_server)
else:
logger.debug(
"Default server: %s is already in command servers list" % default_server
)
def _connect_to_island(self):
# Sets island's IP and port for monkey to communicate to
@ -302,9 +297,7 @@ class InfectionMonkey:
@staticmethod
def _close_tunnel():
tunnel_address = (
ControlClient.proxies.get("https", "").replace("https://", "").split(":")[0]
)
tunnel_address = ControlClient.proxies.get("https", "").replace("http://", "").split(":")[0]
if tunnel_address:
logger.info("Quitting tunnel %s", tunnel_address)
tunnel.quit_tunnel(tunnel_address)