예제 #1
0
def test_build_monkey_commandline():
    example_host = VictimHost(ip_addr="bla")
    example_host.set_default_server("101010")

    expected = f" -p {GUID} -s 101010 -d 0 -l /home/bla -vp 80"
    actual = build_monkey_commandline(target_host=example_host,
                                      depth=0,
                                      vulnerable_port="80",
                                      location="/home/bla")

    assert expected == actual
예제 #2
0
 def generate_victims_from_range(self, net_range):
     """
     Generates VictimHosts from a given netrange
     :param net_range: Network range object
     :return: Generator of VictimHost objects
     """
     for address in net_range:
         if not self.is_ip_scannable(address):  # check if the IP should be skipped
             continue
         if hasattr(net_range, "domain_name"):
             victim = VictimHost(address, net_range.domain_name)
         else:
             victim = VictimHost(address)
         yield victim
예제 #3
0
def test_build_monkey_execution_command():
    host = VictimHost("127.0.0.1")
    depth = 2
    executable_path = "/tmp/test-monkey"

    cmd = powershell.build_monkey_execution_command(host, depth, executable_path)

    assert f"-d {depth}" in cmd
    assert executable_path in cmd
예제 #4
0
def zerologon_exploiter_object(monkeypatch):
    def mock_report_login_attempt(**kwargs):
        return None

    host = VictimHost(IP, DOMAIN_NAME)
    obj = ZerologonExploiter(host)
    monkeypatch.setattr(obj, "dc_name", NETBIOS_NAME, raising=False)
    monkeypatch.setattr(obj, "report_login_attempt", mock_report_login_attempt)
    return obj
예제 #5
0
def powershell_exploiter(monkeypatch):
    host = VictimHost("127.0.0.1")
    pe = powershell.PowerShellExploiter(host)
    pe._config = Config(
        USER_LIST,
        PASSWORD_LIST,
        LM_HASH_LIST,
        NT_HASH_LIST,
        DROPPER_TARGET_PATH_32,
        DROPPER_TARGET_PATH_64,
    )

    monkeypatch.setattr(powershell, "AuthenticationError", TestAuthenticationError)
    monkeypatch.setattr(powershell, "is_windows_os", lambda: True)
    # It's regrettable to mock out a private method on the PowerShellExploiter instance object, but
    # it's necessary to avoid having to deal with the monkeyfs
    monkeypatch.setattr(pe, "_write_virtual_file_to_local_path", lambda: None)

    return pe
예제 #6
0
import json

import pytest

from infection_monkey.exploit.wmiexec import WmiExploiter
from infection_monkey.model.host import VictimHost
from infection_monkey.telemetry.exploit_telem import ExploitTelem


DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"
HOST = VictimHost(IP, DOMAIN_NAME)
HOST_AS_DICT = {
    "ip_addr": IP,
    "domain_name": DOMAIN_NAME,
    "os": {},
    "services": {},
    "icmp": False,
    "monkey_exe": None,
    "default_tunnel": None,
    "default_server": None,
}
EXPLOITER = WmiExploiter(HOST)
EXPLOITER_NAME = "WmiExploiter"
EXPLOITER_INFO = {
    "display_name": WmiExploiter._EXPLOITED_SERVICE,
    "started": "",
    "finished": "",
    "vulnerable_urls": [],
    "vulnerable_ports": [],
    "executed_cmds": [],
예제 #7
0
def host():
    return VictimHost(IP, DOMAIN_NAME)