forked from p15670423/monkey
Agent: Rename get_agent_dest_path to get_agent_dst_path
This commit is contained in:
parent
8ef0b44841
commit
e4a2a54c71
|
@ -12,7 +12,7 @@ import string
|
|||
import requests
|
||||
|
||||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.exploit.tools.http_tools import HTTPTools
|
||||
from infection_monkey.exploit.web_rce import WebRCE
|
||||
from infection_monkey.model import (
|
||||
|
@ -43,7 +43,7 @@ class HadoopExploiter(WebRCE):
|
|||
return self.exploit_result
|
||||
|
||||
try:
|
||||
monkey_path_on_victim = get_agent_dest_path(self.host)
|
||||
monkey_path_on_victim = get_agent_dst_path(self.host)
|
||||
except KeyError:
|
||||
return self.exploit_result
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from infection_monkey.exploit.log4shell_utils import (
|
|||
build_exploit_bytecode,
|
||||
get_log4shell_service_exploiters,
|
||||
)
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.exploit.tools.http_tools import HTTPTools
|
||||
from infection_monkey.exploit.web_rce import WebRCE
|
||||
from infection_monkey.i_puppet.i_puppet import ExploiterResultData
|
||||
|
@ -61,7 +61,7 @@ class Log4ShellExploiter(WebRCE):
|
|||
self._agent_http_server_thread = None
|
||||
|
||||
def _start_servers(self):
|
||||
target_path = get_agent_dest_path(self.host)
|
||||
target_path = get_agent_dst_path(self.host)
|
||||
|
||||
# Start http server, to serve agent to victims
|
||||
agent_http_path = self._start_agent_http_server(target_path)
|
||||
|
|
|
@ -8,7 +8,7 @@ import pymssql
|
|||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
||||
from common.utils.exceptions import FailedExploitationError
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.exploit.tools.http_tools import HTTPTools
|
||||
from infection_monkey.exploit.tools.payload_parsing import LimitedSizePayload
|
||||
from infection_monkey.i_puppet import ExploiterResultData
|
||||
|
@ -59,7 +59,7 @@ class MSSQLExploiter(HostExploiter):
|
|||
Also, don't forget to start_monkey_server() before self.upload_monkey() and
|
||||
self.stop_monkey_server() after
|
||||
"""
|
||||
monkey_path_on_victim = get_agent_dest_path(self.host)
|
||||
monkey_path_on_victim = get_agent_dst_path(self.host)
|
||||
|
||||
# Brute force to get connection
|
||||
creds = generate_identity_secret_pairs(
|
||||
|
|
|
@ -13,7 +13,7 @@ from infection_monkey.exploit.powershell_utils.powershell_client import (
|
|||
IPowerShellClient,
|
||||
PowerShellClient,
|
||||
)
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path, get_random_file_suffix
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path, get_random_file_suffix
|
||||
from infection_monkey.model import DROPPER_ARG, RUN_MONKEY, VictimHost
|
||||
from infection_monkey.utils.commands import build_monkey_commandline
|
||||
from infection_monkey.utils.environment import is_windows_os
|
||||
|
@ -134,7 +134,7 @@ class PowerShellExploiter(HostExploiter):
|
|||
raise ValueError(f"Unknown secret type {credentials.secret_type}")
|
||||
|
||||
def _execute_monkey_agent_on_victim(self):
|
||||
monkey_path_on_victim = get_agent_dest_path(self.host)
|
||||
monkey_path_on_victim = get_agent_dst_path(self.host)
|
||||
|
||||
self._copy_monkey_binary_to_victim(monkey_path_on_victim)
|
||||
logger.info("Successfully copied the monkey binary to the victim.")
|
||||
|
|
|
@ -6,7 +6,7 @@ from impacket.dcerpc.v5.scmr import DCERPCSessionError
|
|||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
||||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.exploit.tools.smb_tools import SmbTools
|
||||
from infection_monkey.model import DROPPER_CMDLINE_DETACHED_WINDOWS, MONKEY_CMDLINE_DETACHED_WINDOWS
|
||||
from infection_monkey.telemetry.attack.t1035_telem import T1035Telem
|
||||
|
@ -31,7 +31,7 @@ class SMBExploiter(HostExploiter):
|
|||
|
||||
def _exploit_host(self):
|
||||
agent_binary = self.agent_repository.get_agent_binary(self.host.os["type"])
|
||||
dest_path = get_agent_dest_path(self.host)
|
||||
dest_path = get_agent_dst_path(self.host)
|
||||
creds = generate_brute_force_combinations(self.options["credentials"])
|
||||
|
||||
for user, password, lm_hash, ntlm_hash in interruptible_iter(creds, self.interrupt):
|
||||
|
|
|
@ -9,7 +9,7 @@ from common.utils import Timer
|
|||
from common.utils.attack_utils import ScanStatus
|
||||
from common.utils.exceptions import FailedExploitationError
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.i_puppet import ExploiterResultData
|
||||
from infection_monkey.model import MONKEY_ARG
|
||||
from infection_monkey.network.tools import check_tcp_port, get_interface_to_target
|
||||
|
@ -209,7 +209,7 @@ class SSHExploiter(HostExploiter):
|
|||
self._set_interrupted()
|
||||
return self.exploit_result
|
||||
|
||||
monkey_path_on_victim = get_agent_dest_path(self.host)
|
||||
monkey_path_on_victim = get_agent_dst_path(self.host)
|
||||
|
||||
try:
|
||||
with ssh.open_sftp() as ftp:
|
||||
|
|
|
@ -14,7 +14,7 @@ AGENT_BINARY_PATH_LINUX = "/tmp/monkey"
|
|||
AGENT_BINARY_PATH_WIN64 = r"C:\Windows\temp\monkey64.exe"
|
||||
|
||||
|
||||
def get_agent_dest_path(host: VictimHost) -> PurePath:
|
||||
def get_agent_dst_path(host: VictimHost) -> PurePath:
|
||||
if host.os["type"] == "windows":
|
||||
path = PureWindowsPath(AGENT_BINARY_PATH_WIN64)
|
||||
else:
|
||||
|
|
|
@ -6,7 +6,7 @@ import traceback
|
|||
from impacket.dcerpc.v5.rpcrt import DCERPCException
|
||||
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dest_path
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.exploit.tools.smb_tools import SmbTools
|
||||
from infection_monkey.exploit.tools.wmi_tools import AccessDeniedException, WmiTools
|
||||
from infection_monkey.i_puppet import ExploiterResultData
|
||||
|
@ -74,7 +74,7 @@ class WmiExploiter(HostExploiter):
|
|||
self._set_interrupted()
|
||||
return self.exploit_result
|
||||
|
||||
target_path = get_agent_dest_path(self.host)
|
||||
target_path = get_agent_dst_path(self.host)
|
||||
|
||||
remote_full_path = SmbTools.copy_file(
|
||||
self.host,
|
||||
|
|
|
@ -6,7 +6,7 @@ from infection_monkey.exploit.tools.helpers import (
|
|||
AGENT_BINARY_PATH_LINUX,
|
||||
AGENT_BINARY_PATH_WIN64,
|
||||
RAND_SUFFIX_LEN,
|
||||
get_agent_dest_path,
|
||||
get_agent_dst_path,
|
||||
)
|
||||
|
||||
|
||||
|
@ -19,27 +19,27 @@ def _get_host(os):
|
|||
@pytest.mark.parametrize(
|
||||
"os, path", [("linux", AGENT_BINARY_PATH_LINUX), ("windows", AGENT_BINARY_PATH_WIN64)]
|
||||
)
|
||||
def test_get_agent_dest_path(os, path):
|
||||
def test_get_agent_dst_path(os, path):
|
||||
host = _get_host(os)
|
||||
rand_path = get_agent_dest_path(host)
|
||||
rand_path = get_agent_dst_path(host)
|
||||
|
||||
# Assert that filename got longer by RAND_SUFFIX_LEN and one dash
|
||||
assert len(str(rand_path)) == (len(str(path)) + RAND_SUFFIX_LEN + 1)
|
||||
|
||||
|
||||
def test_get_agent_dest_path_randomness():
|
||||
def test_get_agent_dst_path_randomness():
|
||||
host = _get_host("windows")
|
||||
|
||||
path1 = get_agent_dest_path(host)
|
||||
path2 = get_agent_dest_path(host)
|
||||
path1 = get_agent_dst_path(host)
|
||||
path2 = get_agent_dst_path(host)
|
||||
|
||||
assert path1 != path2
|
||||
|
||||
|
||||
def test_get_agent_dest_path_str_place():
|
||||
def test_get_agent_dst_path_str_place():
|
||||
host = _get_host("windows")
|
||||
|
||||
rand_path = get_agent_dest_path(host)
|
||||
rand_path = get_agent_dst_path(host)
|
||||
|
||||
assert str(rand_path).startswith(r"C:\Windows\temp\monkey")
|
||||
assert str(rand_path).endswith(".exe")
|
||||
|
|
Loading…
Reference in New Issue