Skip to content

Commit

Permalink
Merge branch '3170-remove-hard-coded-plugin' into develop
Browse files Browse the repository at this point in the history
Issue #3170
PR #3465
  • Loading branch information
mssalvatore committed Jul 7, 2023
2 parents d4d6471 + 548d503 commit f17f779
Show file tree
Hide file tree
Showing 45 changed files with 50 additions and 1,224 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
- Plugin source is now gzipped. #3392
- Allowed characters in Agent event tags. #3399
- Hard-coded Log4Shell exploiter to a plugin. #3388
- Hard-coded SSH exploiter to a plugin. #3170
- Identities and secrets can be associated when configuring credentials in the
UI. #3393

Expand Down
1 change: 0 additions & 1 deletion monkey/agent_plugins/exploiters/ssh/src/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

logger = logging.getLogger(__name__)

TRANSFER_UPDATE_RATE = 15
SSH_AUTH_TIMEOUT = LONG_REQUEST_TIMEOUT
SSH_BANNER_TIMEOUT = MEDIUM_REQUEST_TIMEOUT
SSH_EXEC_TIMEOUT = LONG_REQUEST_TIMEOUT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from pathlib import PurePath
from typing import Sequence

from common import OperatingSystem
from common.types import AgentID
from infection_monkey.exploit import IAgentOTPProvider
from infection_monkey.i_puppet import TargetHost
Expand All @@ -17,9 +16,6 @@ def build_ssh_command(
remote_agent_binary_destination_path: PurePath,
otp_provider: IAgentOTPProvider,
) -> str:
if target_host.operating_system != OperatingSystem.LINUX:
raise Exception(f"Unsupported operating system: {target_host.operating_system}")

otp = otp_provider.get_otp()
cmdline_arguments = build_monkey_commandline_parameters(
parent=agent_id, servers=servers, depth=current_depth + 1
Expand Down
2 changes: 1 addition & 1 deletion monkey/agent_plugins/exploiters/wmi/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supported_operating_systems:
target_operating_systems:
- windows
title: WMI Exploiter
version: 1.0.1
version: 1.0.2
description: Attempts a brute-force attack against WMI using known credentials.
safe: true
remediation_suggestion: >-
Expand Down
2 changes: 1 addition & 1 deletion monkey/agent_plugins/exploiters/zerologon/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supported_operating_systems:
target_operating_systems:
- windows
title: Zerologon Exploiter
version: 1.0.1
version: 1.0.2
description: >-
Exploits a privilege escalation vulnerability (CVE-2020-1472) in a Windows
server domain controller (DC) by using the Netlogon Remote Protocol (MS-NRPC).
Expand Down
13 changes: 1 addition & 12 deletions monkey/agent_plugins/exploiters/zerologon/src/HostExploiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from common.agent_events import ExploitationEvent, PropagationEvent
from common.event_queue import IAgentEventPublisher
from common.types import AgentID, Event
from common.utils.exceptions import FailedExploitationError
from infection_monkey.i_puppet import ExploiterResultData, TargetHost

from .zerologon_options import ZerologonOptions
from .zerologon_utils.exceptions import FailedExploitationError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -111,17 +111,6 @@ def _exploit_host(self) -> ExploiterResultData:
def add_vuln_url(self, url):
self.exploit_info["vulnerable_urls"].append(url)

def add_vuln_port(self, port):
self.exploit_info["vulnerable_ports"].append(port)

def add_executed_cmd(self, cmd):
"""
Appends command to exploiter's info.
:param cmd: String of executed command. e.g. 'echo Example'
"""
powershell = True if "powershell" in cmd.lower() else False
self.exploit_info["executed_cmds"].append({"cmd": cmd, "powershell": powershell})

def _publish_exploitation_event(
self,
time: float = time(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from common.utils.exceptions import FailedExploitationError
class FailedExploitationError(Exception):
"""Raise when exploiter fails instead of returning False"""


class DomainControllerNameFetchError(FailedExploitationError):
Expand Down
3 changes: 0 additions & 3 deletions monkey/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@
from .agent_registration_data import AgentRegistrationData
from .agent_signals import AgentSignals
from .agent_heartbeat import AgentHeartbeat
from .hard_coded_manifests import (
HARD_CODED_EXPLOITER_MANIFESTS,
)
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,9 @@

EXPLOITATION_OPTIONS_CONFIGURATION = ExploitationOptionsConfiguration(http_ports=HTTP_PORTS)

# Order is preserved and agent will run exploiters in this sequence
EXPLOITERS: Dict[str, Dict] = {
"SSHExploiter": {},
}

EXPLOITATION_CONFIGURATION = ExploitationConfiguration(
options=EXPLOITATION_OPTIONS_CONFIGURATION,
exploiters=EXPLOITERS,
exploiters={},
)

PROPAGATION_CONFIGURATION = PropagationConfiguration(
Expand Down
1 change: 0 additions & 1 deletion monkey/common/hard_coded_manifests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .hard_coded_exploiter_manifests import HARD_CODED_EXPLOITER_MANIFESTS
from .hard_coded_payloads_manifests import HARD_CODED_PAYLOADS_MANIFESTS

This file was deleted.

8 changes: 0 additions & 8 deletions monkey/common/utils/attack_utils.py

This file was deleted.

2 changes: 0 additions & 2 deletions monkey/common/utils/exceptions.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import logging

from common.agent_events import CredentialsStolenEvent
from infection_monkey.propagation_credentials_repository import (
ILegacyPropagationCredentialsRepository,
IPropagationCredentialsRepository,
)
from infection_monkey.propagation_credentials_repository import IPropagationCredentialsRepository

logger = logging.getLogger(__name__)

Expand All @@ -13,12 +10,9 @@ class add_stolen_credentials_to_propagation_credentials_repository:
def __init__(
self,
credentials_repository: IPropagationCredentialsRepository,
legacy_credentials_repository: ILegacyPropagationCredentialsRepository,
):
self._credentials_repository = credentials_repository
self._legacy_credentials_repository = legacy_credentials_repository

def __call__(self, event: CredentialsStolenEvent):
logger.debug(f"Adding {len(event.stolen_credentials)} to the credentials repository")
self._credentials_repository.add_credentials(event.stolen_credentials)
self._legacy_credentials_repository.add_credentials(event.stolen_credentials)
3 changes: 0 additions & 3 deletions monkey/infection_monkey/custom_types.py

This file was deleted.

168 changes: 0 additions & 168 deletions monkey/infection_monkey/exploit/HostExploiter.py

This file was deleted.

1 change: 0 additions & 1 deletion monkey/infection_monkey/exploit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
from .polymorphic_agent_binary_repository_decorator import PolymorphicAgentBinaryRepositoryDecorator
from .island_api_agent_otp_provider import IslandAPIAgentOTPProvider
from .i_agent_otp_provider import IAgentOTPProvider
from .exploiter_wrapper import ExploiterWrapper
Loading

0 comments on commit f17f779

Please sign in to comment.