Agent: Extract method _get_agent_command

This commit is contained in:
Kekoa Kaaikala 2022-10-06 14:15:52 +00:00
parent 156300e8ed
commit 2d130a0442
1 changed files with 17 additions and 12 deletions

View File

@ -56,18 +56,7 @@ class SMBExploiter(HostExploiter):
return self.exploit_result return self.exploit_result
# execute the remote dropper in case the path isn't final # execute the remote dropper in case the path isn't final
if remote_full_path.lower() != str(dest_path).lower(): cmdline = self._get_agent_command(remote_full_path, dest_path)
cmdline = DROPPER_CMDLINE_DETACHED_WINDOWS % {
"dropper_path": remote_full_path
} + build_monkey_commandline(
self.servers,
self.current_depth + 1,
str(dest_path),
)
else:
cmdline = MONKEY_CMDLINE_DETACHED_WINDOWS % {
"monkey_path": remote_full_path
} + build_monkey_commandline(self.servers, self.current_depth + 1)
smb_conn = None smb_conn = None
for str_bind_format, port in SMBExploiter.KNOWN_PROTOCOLS.values(): for str_bind_format, port in SMBExploiter.KNOWN_PROTOCOLS.values():
@ -206,3 +195,19 @@ class SMBExploiter(HostExploiter):
continue continue
return remote_full_path, SelectedCredentials(user, password, lm_hash, ntlm_hash) return remote_full_path, SelectedCredentials(user, password, lm_hash, ntlm_hash)
def _get_agent_command(self, remote_full_path: str, dest_path: PurePath) -> str:
if remote_full_path.lower() != str(dest_path).lower():
cmdline = DROPPER_CMDLINE_DETACHED_WINDOWS % {
"dropper_path": remote_full_path
} + build_monkey_commandline(
self.servers,
self.current_depth + 1,
str(dest_path),
)
else:
cmdline = MONKEY_CMDLINE_DETACHED_WINDOWS % {
"monkey_path": remote_full_path
} + build_monkey_commandline(self.servers, self.current_depth + 1)
return cmdline