forked from p15670423/monkey
Merge pull request #2339 from guardicore/2260-more-mypy-fixes
2260 more mypy fixes
This commit is contained in:
commit
a89d76a4c5
|
@ -35,6 +35,7 @@ bcrypt = "==3.2.2"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
ldap3 = "*"
|
ldap3 = "*"
|
||||||
|
mypy = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.7"
|
python_version = "3.7"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "5e9fbd68544462c51d9b31787a43522f1e39978044952717a42de8aee1844917"
|
"sha256": "f9abf32c9cb2724beb6b120c657d79fde001468eeab93775dc0fc31bf6eaa3d9"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -243,7 +243,7 @@
|
||||||
"sha256:0f7569a4a6ff151958b64304071d370daa3243d15941a7beedf0c9fe5105603e",
|
"sha256:0f7569a4a6ff151958b64304071d370daa3243d15941a7beedf0c9fe5105603e",
|
||||||
"sha256:a851e51367fb93e9e1361732c1d60dab63eff98712e503ea7d92e6eccb109b4f"
|
"sha256:a851e51367fb93e9e1361732c1d60dab63eff98712e503ea7d92e6eccb109b4f"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6' and python_version < '4.0'",
|
"markers": "python_version >= '3.6' and python_version < '4'",
|
||||||
"version": "==2.2.1"
|
"version": "==2.2.1"
|
||||||
},
|
},
|
||||||
"egg-timer": {
|
"egg-timer": {
|
||||||
|
@ -1040,6 +1040,42 @@
|
||||||
],
|
],
|
||||||
"version": "==2.9.1"
|
"version": "==2.9.1"
|
||||||
},
|
},
|
||||||
|
"mypy": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:02ef476f6dcb86e6f502ae39a16b93285fef97e7f1ff22932b657d1ef1f28655",
|
||||||
|
"sha256:0d054ef16b071149917085f51f89555a576e2618d5d9dd70bd6eea6410af3ac9",
|
||||||
|
"sha256:19830b7dba7d5356d3e26e2427a2ec91c994cd92d983142cbd025ebe81d69cf3",
|
||||||
|
"sha256:1f7656b69974a6933e987ee8ffb951d836272d6c0f81d727f1d0e2696074d9e6",
|
||||||
|
"sha256:23488a14a83bca6e54402c2e6435467a4138785df93ec85aeff64c6170077fb0",
|
||||||
|
"sha256:23c7ff43fff4b0df93a186581885c8512bc50fc4d4910e0f838e35d6bb6b5e58",
|
||||||
|
"sha256:25c5750ba5609a0c7550b73a33deb314ecfb559c350bb050b655505e8aed4103",
|
||||||
|
"sha256:2ad53cf9c3adc43cf3bea0a7d01a2f2e86db9fe7596dfecb4496a5dda63cbb09",
|
||||||
|
"sha256:3fa7a477b9900be9b7dd4bab30a12759e5abe9586574ceb944bc29cddf8f0417",
|
||||||
|
"sha256:40b0f21484238269ae6a57200c807d80debc6459d444c0489a102d7c6a75fa56",
|
||||||
|
"sha256:4b21e5b1a70dfb972490035128f305c39bc4bc253f34e96a4adf9127cf943eb2",
|
||||||
|
"sha256:5a361d92635ad4ada1b1b2d3630fc2f53f2127d51cf2def9db83cba32e47c856",
|
||||||
|
"sha256:77a514ea15d3007d33a9e2157b0ba9c267496acf12a7f2b9b9f8446337aac5b0",
|
||||||
|
"sha256:855048b6feb6dfe09d3353466004490b1872887150c5bb5caad7838b57328cc8",
|
||||||
|
"sha256:9796a2ba7b4b538649caa5cecd398d873f4022ed2333ffde58eaf604c4d2cb27",
|
||||||
|
"sha256:98e02d56ebe93981c41211c05adb630d1d26c14195d04d95e49cd97dbc046dc5",
|
||||||
|
"sha256:b793b899f7cf563b1e7044a5c97361196b938e92f0a4343a5d27966a53d2ec71",
|
||||||
|
"sha256:d1ea5d12c8e2d266b5fb8c7a5d2e9c0219fedfeb493b7ed60cd350322384ac27",
|
||||||
|
"sha256:d2022bfadb7a5c2ef410d6a7c9763188afdb7f3533f22a0a32be10d571ee4bbe",
|
||||||
|
"sha256:d3348e7eb2eea2472db611486846742d5d52d1290576de99d59edeb7cd4a42ca",
|
||||||
|
"sha256:d744f72eb39f69312bc6c2abf8ff6656973120e2eb3f3ec4f758ed47e414a4bf",
|
||||||
|
"sha256:ef943c72a786b0f8d90fd76e9b39ce81fb7171172daf84bf43eaf937e9f220a9",
|
||||||
|
"sha256:f2899a3cbd394da157194f913a931edfd4be5f274a88041c9dc2d9cdcb1c315c"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==0.971"
|
||||||
|
},
|
||||||
|
"mypy-extensions": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
|
||||||
|
"sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
|
||||||
|
],
|
||||||
|
"version": "==0.4.3"
|
||||||
|
},
|
||||||
"pyasn1": {
|
"pyasn1": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359",
|
"sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359",
|
||||||
|
@ -1057,6 +1093,52 @@
|
||||||
"sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3"
|
"sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3"
|
||||||
],
|
],
|
||||||
"version": "==0.4.8"
|
"version": "==0.4.8"
|
||||||
|
},
|
||||||
|
"tomli": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",
|
||||||
|
"sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"
|
||||||
|
],
|
||||||
|
"markers": "python_version < '3.11'",
|
||||||
|
"version": "==2.0.1"
|
||||||
|
},
|
||||||
|
"typed-ast": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:0261195c2062caf107831e92a76764c81227dae162c4f75192c0d489faf751a2",
|
||||||
|
"sha256:0fdbcf2fef0ca421a3f5912555804296f0b0960f0418c440f5d6d3abb549f3e1",
|
||||||
|
"sha256:183afdf0ec5b1b211724dfef3d2cad2d767cbefac291f24d69b00546c1837fb6",
|
||||||
|
"sha256:211260621ab1cd7324e0798d6be953d00b74e0428382991adfddb352252f1d62",
|
||||||
|
"sha256:267e3f78697a6c00c689c03db4876dd1efdfea2f251a5ad6555e82a26847b4ac",
|
||||||
|
"sha256:2efae9db7a8c05ad5547d522e7dbe62c83d838d3906a3716d1478b6c1d61388d",
|
||||||
|
"sha256:370788a63915e82fd6f212865a596a0fefcbb7d408bbbb13dea723d971ed8bdc",
|
||||||
|
"sha256:39e21ceb7388e4bb37f4c679d72707ed46c2fbf2a5609b8b8ebc4b067d977df2",
|
||||||
|
"sha256:3e123d878ba170397916557d31c8f589951e353cc95fb7f24f6bb69adc1a8a97",
|
||||||
|
"sha256:4879da6c9b73443f97e731b617184a596ac1235fe91f98d279a7af36c796da35",
|
||||||
|
"sha256:4e964b4ff86550a7a7d56345c7864b18f403f5bd7380edf44a3c1fb4ee7ac6c6",
|
||||||
|
"sha256:639c5f0b21776605dd6c9dbe592d5228f021404dafd377e2b7ac046b0349b1a1",
|
||||||
|
"sha256:669dd0c4167f6f2cd9f57041e03c3c2ebf9063d0757dc89f79ba1daa2bfca9d4",
|
||||||
|
"sha256:6778e1b2f81dfc7bc58e4b259363b83d2e509a65198e85d5700dfae4c6c8ff1c",
|
||||||
|
"sha256:683407d92dc953c8a7347119596f0b0e6c55eb98ebebd9b23437501b28dcbb8e",
|
||||||
|
"sha256:79b1e0869db7c830ba6a981d58711c88b6677506e648496b1f64ac7d15633aec",
|
||||||
|
"sha256:7d5d014b7daa8b0bf2eaef684295acae12b036d79f54178b92a2b6a56f92278f",
|
||||||
|
"sha256:98f80dee3c03455e92796b58b98ff6ca0b2a6f652120c263efdba4d6c5e58f72",
|
||||||
|
"sha256:a94d55d142c9265f4ea46fab70977a1944ecae359ae867397757d836ea5a3f47",
|
||||||
|
"sha256:a9916d2bb8865f973824fb47436fa45e1ebf2efd920f2b9f99342cb7fab93f72",
|
||||||
|
"sha256:c542eeda69212fa10a7ada75e668876fdec5f856cd3d06829e6aa64ad17c8dfe",
|
||||||
|
"sha256:cf4afcfac006ece570e32d6fa90ab74a17245b83dfd6655a6f68568098345ff6",
|
||||||
|
"sha256:ebd9d7f80ccf7a82ac5f88c521115cc55d84e35bf8b446fcd7836eb6b98929a3",
|
||||||
|
"sha256:ed855bbe3eb3715fca349c80174cfcfd699c2f9de574d40527b8429acae23a66"
|
||||||
|
],
|
||||||
|
"markers": "python_version < '3.8'",
|
||||||
|
"version": "==1.5.4"
|
||||||
|
},
|
||||||
|
"typing-extensions": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02",
|
||||||
|
"sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==4.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import threading
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, Iterable, List, Mapping, Sequence
|
from typing import Dict, Iterable, Mapping, Optional, Sequence
|
||||||
|
|
||||||
from common.credentials import Credentials
|
from common.credentials import Credentials
|
||||||
from infection_monkey.model import VictimHost
|
from infection_monkey.model import VictimHost
|
||||||
|
@ -26,8 +26,8 @@ class ExploiterResultData:
|
||||||
propagation_success: bool = False
|
propagation_success: bool = False
|
||||||
interrupted: bool = False
|
interrupted: bool = False
|
||||||
os: str = ""
|
os: str = ""
|
||||||
info: Mapping = None
|
info: Optional[Mapping] = None
|
||||||
attempts: Iterable = None
|
attempts: Optional[Iterable] = None
|
||||||
error_message: str = ""
|
error_message: str = ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class IPuppet(metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def scan_tcp_ports(
|
def scan_tcp_ports(
|
||||||
self, host: str, ports: List[int], timeout: float = 3
|
self, host: str, ports: Sequence[int], timeout: float = 3
|
||||||
) -> Dict[int, PortScanData]:
|
) -> Dict[int, PortScanData]:
|
||||||
"""
|
"""
|
||||||
Scans a list of TCP ports on a remote host
|
Scans a list of TCP ports on a remote host
|
||||||
|
@ -125,6 +125,7 @@ class IPuppet(metaclass=abc.ABCMeta):
|
||||||
name: str,
|
name: str,
|
||||||
host: VictimHost,
|
host: VictimHost,
|
||||||
current_depth: int,
|
current_depth: int,
|
||||||
|
servers: Sequence[str],
|
||||||
options: Dict,
|
options: Dict,
|
||||||
interrupt: threading.Event,
|
interrupt: threading.Event,
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
|
@ -134,6 +135,7 @@ class IPuppet(metaclass=abc.ABCMeta):
|
||||||
:param str name: The name of the exploiter to run
|
:param str name: The name of the exploiter to run
|
||||||
:param VictimHost host: A VictimHost object representing the target to exploit
|
:param VictimHost host: A VictimHost object representing the target to exploit
|
||||||
:param int current_depth: The current propagation depth
|
:param int current_depth: The current propagation depth
|
||||||
|
:param servers: List of socket addresses for victim to connect back to
|
||||||
:param Dict options: A dictionary containing options that modify the behavior of the
|
:param Dict options: A dictionary containing options that modify the behavior of the
|
||||||
exploiter
|
exploiter
|
||||||
:param threading.Event interrupt: A threading.Event object that signals the exploit to stop
|
:param threading.Event interrupt: A threading.Event object that signals the exploit to stop
|
||||||
|
|
|
@ -8,7 +8,6 @@ from typing import Callable, Dict, Sequence
|
||||||
from common.agent_configuration.agent_sub_configurations import (
|
from common.agent_configuration.agent_sub_configurations import (
|
||||||
NetworkScanConfiguration,
|
NetworkScanConfiguration,
|
||||||
PluginConfiguration,
|
PluginConfiguration,
|
||||||
ScanTargetConfiguration,
|
|
||||||
)
|
)
|
||||||
from infection_monkey.i_puppet import (
|
from infection_monkey.i_puppet import (
|
||||||
FingerprintData,
|
FingerprintData,
|
||||||
|
@ -35,7 +34,7 @@ class IPScanner:
|
||||||
def scan(
|
def scan(
|
||||||
self,
|
self,
|
||||||
addresses_to_scan: Sequence[NetworkAddress],
|
addresses_to_scan: Sequence[NetworkAddress],
|
||||||
options: ScanTargetConfiguration,
|
options: NetworkScanConfiguration,
|
||||||
results_callback: Callback,
|
results_callback: Callback,
|
||||||
stop: Event,
|
stop: Event,
|
||||||
):
|
):
|
||||||
|
|
|
@ -2,7 +2,7 @@ import logging
|
||||||
from ipaddress import IPv4Interface
|
from ipaddress import IPv4Interface
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from threading import Event
|
from threading import Event
|
||||||
from typing import List, Sequence
|
from typing import List, Mapping, Sequence
|
||||||
|
|
||||||
from common.agent_configuration import (
|
from common.agent_configuration import (
|
||||||
ExploitationConfiguration,
|
ExploitationConfiguration,
|
||||||
|
@ -26,6 +26,7 @@ from infection_monkey.telemetry.scan_telem import ScanTelem
|
||||||
from infection_monkey.utils.threading import create_daemon_thread
|
from infection_monkey.utils.threading import create_daemon_thread
|
||||||
|
|
||||||
from . import Exploiter, IPScanner, IPScanResults
|
from . import Exploiter, IPScanner, IPScanResults
|
||||||
|
from .ip_scan_results import FingerprinterName, Port
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
@ -149,8 +150,12 @@ class Propagator:
|
||||||
victim_host.os["type"] = ping_scan_data.os
|
victim_host.os["type"] = ping_scan_data.os
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_tcp_scan_results(victim_host: VictimHost, port_scan_data: PortScanData):
|
def _process_tcp_scan_results(
|
||||||
for psd in filter(lambda psd: psd.status == PortStatus.OPEN, port_scan_data.values()):
|
victim_host: VictimHost, port_scan_data: Mapping[Port, PortScanData]
|
||||||
|
):
|
||||||
|
for psd in filter(
|
||||||
|
lambda scan_data: scan_data.status == PortStatus.OPEN, port_scan_data.values()
|
||||||
|
):
|
||||||
victim_host.services[psd.service] = {}
|
victim_host.services[psd.service] = {}
|
||||||
victim_host.services[psd.service]["display_name"] = "unknown(TCP)"
|
victim_host.services[psd.service]["display_name"] = "unknown(TCP)"
|
||||||
victim_host.services[psd.service]["port"] = psd.port
|
victim_host.services[psd.service]["port"] = psd.port
|
||||||
|
@ -158,7 +163,9 @@ class Propagator:
|
||||||
victim_host.services[psd.service]["banner"] = psd.banner
|
victim_host.services[psd.service]["banner"] = psd.banner
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_fingerprinter_results(victim_host: VictimHost, fingerprint_data: FingerprintData):
|
def _process_fingerprinter_results(
|
||||||
|
victim_host: VictimHost, fingerprint_data: Mapping[FingerprinterName, FingerprintData]
|
||||||
|
):
|
||||||
for fd in fingerprint_data.values():
|
for fd in fingerprint_data.values():
|
||||||
# TODO: This logic preserves the existing behavior prior to introducing IMaster and
|
# TODO: This logic preserves the existing behavior prior to introducing IMaster and
|
||||||
# IPuppet, but it is possibly flawed. Different fingerprinters may detect
|
# IPuppet, but it is possibly flawed. Different fingerprinters may detect
|
||||||
|
|
|
@ -2,7 +2,7 @@ import logging
|
||||||
import socket
|
import socket
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
from typing import Dict, Iterable, Iterator, Mapping, MutableMapping, Optional, Tuple
|
from typing import Dict, Iterable, Iterator, Optional
|
||||||
|
|
||||||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
||||||
from common.network.network_utils import address_to_ip_port
|
from common.network.network_utils import address_to_ip_port
|
||||||
|
@ -26,13 +26,15 @@ logger = logging.getLogger(__name__)
|
||||||
# practical purposes. Revisit this if it's not.
|
# practical purposes. Revisit this if it's not.
|
||||||
NUM_FIND_SERVER_WORKERS = 32
|
NUM_FIND_SERVER_WORKERS = 32
|
||||||
|
|
||||||
|
IslandAPISearchResults = Dict[str, Optional[IIslandAPIClient]]
|
||||||
|
|
||||||
|
|
||||||
def find_available_island_apis(
|
def find_available_island_apis(
|
||||||
servers: Iterable[str], island_api_client_factory: AbstractIslandAPIClientFactory
|
servers: Iterable[str], island_api_client_factory: AbstractIslandAPIClientFactory
|
||||||
) -> Mapping[str, Optional[IIslandAPIClient]]:
|
) -> IslandAPISearchResults:
|
||||||
server_list = list(servers)
|
server_list = list(servers)
|
||||||
server_iterator = ThreadSafeIterator(server_list.__iter__())
|
server_iterator = ThreadSafeIterator(server_list.__iter__())
|
||||||
server_results: Dict[str, Tuple[bool, IIslandAPIClient]] = {}
|
server_results: IslandAPISearchResults = {}
|
||||||
|
|
||||||
run_worker_threads(
|
run_worker_threads(
|
||||||
_find_island_server,
|
_find_island_server,
|
||||||
|
@ -46,17 +48,17 @@ def find_available_island_apis(
|
||||||
|
|
||||||
def _find_island_server(
|
def _find_island_server(
|
||||||
servers: Iterator[str],
|
servers: Iterator[str],
|
||||||
server_status: MutableMapping[str, Optional[IIslandAPIClient]],
|
server_results: IslandAPISearchResults,
|
||||||
island_api_client_factory: AbstractIslandAPIClientFactory,
|
island_api_client_factory: AbstractIslandAPIClientFactory,
|
||||||
):
|
):
|
||||||
with suppress(StopIteration):
|
with suppress(StopIteration):
|
||||||
server = next(servers)
|
server = next(servers)
|
||||||
server_status[server] = _check_if_island_server(server, island_api_client_factory)
|
server_results[server] = _check_if_island_server(server, island_api_client_factory)
|
||||||
|
|
||||||
|
|
||||||
def _check_if_island_server(
|
def _check_if_island_server(
|
||||||
server: str, island_api_client_factory: AbstractIslandAPIClientFactory
|
server: str, island_api_client_factory: AbstractIslandAPIClientFactory
|
||||||
) -> IIslandAPIClient:
|
) -> Optional[IIslandAPIClient]:
|
||||||
logger.debug(f"Trying to connect to server: {server}")
|
logger.debug(f"Trying to connect to server: {server}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -2,7 +2,7 @@ import itertools
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
from ipaddress import IPv4Interface
|
from ipaddress import IPv4Interface
|
||||||
from typing import Dict, List
|
from typing import Dict, List, Sequence
|
||||||
|
|
||||||
from common.network.network_range import InvalidNetworkRangeError, NetworkRange
|
from common.network.network_range import InvalidNetworkRangeError, NetworkRange
|
||||||
from infection_monkey.network import NetworkAddress
|
from infection_monkey.network import NetworkAddress
|
||||||
|
@ -14,10 +14,10 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def compile_scan_target_list(
|
def compile_scan_target_list(
|
||||||
local_network_interfaces: List[IPv4Interface],
|
local_network_interfaces: Sequence[IPv4Interface],
|
||||||
ranges_to_scan: List[str],
|
ranges_to_scan: Sequence[str],
|
||||||
inaccessible_subnets: List[str],
|
inaccessible_subnets: Sequence[str],
|
||||||
blocklisted_ips: List[str],
|
blocklisted_ips: Sequence[str],
|
||||||
enable_local_network_scan: bool,
|
enable_local_network_scan: bool,
|
||||||
) -> List[NetworkAddress]:
|
) -> List[NetworkAddress]:
|
||||||
scan_targets = _get_ips_from_subnets_to_scan(ranges_to_scan)
|
scan_targets = _get_ips_from_subnets_to_scan(ranges_to_scan)
|
||||||
|
|
|
@ -3,7 +3,7 @@ import select
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from typing import Collection, Iterable, Mapping, Tuple
|
from typing import Collection, Dict, Iterable, Mapping, Tuple
|
||||||
|
|
||||||
from common.utils import Timer
|
from common.utils import Timer
|
||||||
from infection_monkey.i_puppet import PortScanData, PortStatus
|
from infection_monkey.i_puppet import PortScanData, PortStatus
|
||||||
|
@ -17,7 +17,7 @@ EMPTY_PORT_SCAN = {-1: PortScanData(-1, PortStatus.CLOSED, None, None)}
|
||||||
|
|
||||||
def scan_tcp_ports(
|
def scan_tcp_ports(
|
||||||
host: str, ports_to_scan: Collection[int], timeout: float
|
host: str, ports_to_scan: Collection[int], timeout: float
|
||||||
) -> Mapping[int, PortScanData]:
|
) -> Dict[int, PortScanData]:
|
||||||
try:
|
try:
|
||||||
return _scan_tcp_ports(host, ports_to_scan, timeout)
|
return _scan_tcp_ports(host, ports_to_scan, timeout)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Ransomware:
|
||||||
self._send_telemetry(filepath, False, str(ex))
|
self._send_telemetry(filepath, False, str(ex))
|
||||||
|
|
||||||
def _send_telemetry(self, filepath: Path, success: bool, error: str):
|
def _send_telemetry(self, filepath: Path, success: bool, error: str):
|
||||||
encryption_attempt = FileEncryptionTelem(str(filepath), success, error)
|
encryption_attempt = FileEncryptionTelem(filepath, success, error)
|
||||||
self._telemetry_messenger.send_telemetry(encryption_attempt)
|
self._telemetry_messenger.send_telemetry(encryption_attempt)
|
||||||
|
|
||||||
@interruptible_function(msg="Received a stop signal, skipping leave readme")
|
@interruptible_function(msg="Received a stop signal, skipping leave readme")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from typing import Dict, Iterable, List, Sequence
|
from typing import Dict, Iterable, Sequence
|
||||||
|
|
||||||
from common.common_consts.timeouts import CONNECTION_TIMEOUT
|
from common.common_consts.timeouts import CONNECTION_TIMEOUT
|
||||||
from common.credentials import Credentials
|
from common.credentials import Credentials
|
||||||
|
@ -18,7 +18,7 @@ from infection_monkey.model import VictimHost
|
||||||
|
|
||||||
from .plugin_registry import PluginRegistry
|
from .plugin_registry import PluginRegistry
|
||||||
|
|
||||||
EMPTY_FINGERPRINT = PingScanData(False, None)
|
EMPTY_FINGERPRINT = FingerprintData(None, None, [])
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class Puppet(IPuppet):
|
||||||
return network_scanning.ping(host, timeout)
|
return network_scanning.ping(host, timeout)
|
||||||
|
|
||||||
def scan_tcp_ports(
|
def scan_tcp_ports(
|
||||||
self, host: str, ports: List[int], timeout: float = CONNECTION_TIMEOUT
|
self, host: str, ports: Sequence[int], timeout: float = CONNECTION_TIMEOUT
|
||||||
) -> Dict[int, PortScanData]:
|
) -> Dict[int, PortScanData]:
|
||||||
return network_scanning.scan_tcp_ports(host, ports, timeout)
|
return network_scanning.scan_tcp_ports(host, ports, timeout)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class FileEncryptionTelem(BatchableTelemMixin, IBatchableTelem, BaseTelem):
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self._telemetry_entries.append({"path": filepath, "success": success, "error": error})
|
self._telemetry_entries.append({"path": str(filepath), "success": success, "error": error})
|
||||||
|
|
||||||
telem_category = TelemCategoryEnum.FILE_ENCRYPTION
|
telem_category = TelemCategoryEnum.FILE_ENCRYPTION
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ sphinx = "*" # Used in documentation
|
||||||
sphinx_rtd_theme = "*"
|
sphinx_rtd_theme = "*"
|
||||||
sphinx_autodoc_typehints = "*"
|
sphinx_autodoc_typehints = "*"
|
||||||
types-python-dateutil = "*"
|
types-python-dateutil = "*"
|
||||||
|
mypy = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.7"
|
python_version = "3.7"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "0cacab24c5242c8a27fa9ee3c7e91117f26234dd952d3e25bc7d5b1cf34cffff"
|
"sha256": "c56ab34713e019905e46de9a084df9d3fa77adbd5ac48723223cbf06c45d0f3e"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -72,11 +72,11 @@
|
||||||
},
|
},
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:43dadad18a7f168740e66944e4fa82c6611848ff9056ad910f8f7a3e46ab89e0",
|
"sha256:36973885b9542e6bd01dea287b2b4b3b21236307c56324fcc3f1160f2d655ed5",
|
||||||
"sha256:cffdcd380919da6137f76633531a5817e3a9f268575c128249fb637e4f9e73fb"
|
"sha256:e232343de1ab72c2aa521b625c80f699e356830fd0e2c620b465b304b17b0516"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==2022.6.15.1"
|
"version": "==2022.9.14"
|
||||||
},
|
},
|
||||||
"cffi": {
|
"cffi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
||||||
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==2.1.1"
|
"version": "==2.1.1"
|
||||||
},
|
},
|
||||||
"click": {
|
"click": {
|
||||||
|
@ -352,11 +352,11 @@
|
||||||
},
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
|
"sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
|
||||||
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
|
"sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.5'",
|
"markers": "python_version >= '3.5'",
|
||||||
"version": "==3.3"
|
"version": "==3.4"
|
||||||
},
|
},
|
||||||
"importlib-metadata": {
|
"importlib-metadata": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -588,11 +588,11 @@
|
||||||
},
|
},
|
||||||
"pyjwt": {
|
"pyjwt": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:72d1d253f32dbd4f5c88eaf1fdc62f3a19f676ccbadb9dbc5d07e951b2b26daf",
|
"sha256:8d82e7087868e94dd8d7d418e5088ce64f7daab4b36db654cbaedb46f9d1ca80",
|
||||||
"sha256:d42908208c699b3b973cbeb01a969ba6a96c821eefb1c5bfe4c390c01d67abba"
|
"sha256:e77ab89480905d86998442ac5788f35333fa85f65047a534adc38edf3c88fc3b"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_version >= '3.7'",
|
||||||
"version": "==2.4.0"
|
"version": "==2.5.0"
|
||||||
},
|
},
|
||||||
"pymongo": {
|
"pymongo": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -815,7 +815,7 @@
|
||||||
"sha256:7a6f4c4d1fdb9a2b640244008e142cbc2cd3ae34b386584ef044dd0f27101971",
|
"sha256:7a6f4c4d1fdb9a2b640244008e142cbc2cd3ae34b386584ef044dd0f27101971",
|
||||||
"sha256:95c58c194ce657a5f4fb0b9e60a84968c808888aed628cd98ab8771fe1db98ed"
|
"sha256:95c58c194ce657a5f4fb0b9e60a84968c808888aed628cd98ab8771fe1db98ed"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==0.5.2"
|
"version": "==0.5.2"
|
||||||
},
|
},
|
||||||
"semantic-version": {
|
"semantic-version": {
|
||||||
|
@ -847,7 +847,7 @@
|
||||||
"sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02",
|
"sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02",
|
||||||
"sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"
|
"sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.7'",
|
"markers": "python_version < '3.8'",
|
||||||
"version": "==4.3.0"
|
"version": "==4.3.0"
|
||||||
},
|
},
|
||||||
"urllib3": {
|
"urllib3": {
|
||||||
|
@ -1000,18 +1000,18 @@
|
||||||
},
|
},
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:43dadad18a7f168740e66944e4fa82c6611848ff9056ad910f8f7a3e46ab89e0",
|
"sha256:36973885b9542e6bd01dea287b2b4b3b21236307c56324fcc3f1160f2d655ed5",
|
||||||
"sha256:cffdcd380919da6137f76633531a5817e3a9f268575c128249fb637e4f9e73fb"
|
"sha256:e232343de1ab72c2aa521b625c80f699e356830fd0e2c620b465b304b17b0516"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==2022.6.15.1"
|
"version": "==2022.9.14"
|
||||||
},
|
},
|
||||||
"charset-normalizer": {
|
"charset-normalizer": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
||||||
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==2.1.1"
|
"version": "==2.1.1"
|
||||||
},
|
},
|
||||||
"click": {
|
"click": {
|
||||||
|
@ -1126,11 +1126,11 @@
|
||||||
},
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
|
"sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
|
||||||
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
|
"sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.5'",
|
"markers": "python_version >= '3.5'",
|
||||||
"version": "==3.3"
|
"version": "==3.4"
|
||||||
},
|
},
|
||||||
"imagesize": {
|
"imagesize": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -1232,6 +1232,35 @@
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==3.23.0"
|
"version": "==3.23.0"
|
||||||
},
|
},
|
||||||
|
"mypy": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:02ef476f6dcb86e6f502ae39a16b93285fef97e7f1ff22932b657d1ef1f28655",
|
||||||
|
"sha256:0d054ef16b071149917085f51f89555a576e2618d5d9dd70bd6eea6410af3ac9",
|
||||||
|
"sha256:19830b7dba7d5356d3e26e2427a2ec91c994cd92d983142cbd025ebe81d69cf3",
|
||||||
|
"sha256:1f7656b69974a6933e987ee8ffb951d836272d6c0f81d727f1d0e2696074d9e6",
|
||||||
|
"sha256:23488a14a83bca6e54402c2e6435467a4138785df93ec85aeff64c6170077fb0",
|
||||||
|
"sha256:23c7ff43fff4b0df93a186581885c8512bc50fc4d4910e0f838e35d6bb6b5e58",
|
||||||
|
"sha256:25c5750ba5609a0c7550b73a33deb314ecfb559c350bb050b655505e8aed4103",
|
||||||
|
"sha256:2ad53cf9c3adc43cf3bea0a7d01a2f2e86db9fe7596dfecb4496a5dda63cbb09",
|
||||||
|
"sha256:3fa7a477b9900be9b7dd4bab30a12759e5abe9586574ceb944bc29cddf8f0417",
|
||||||
|
"sha256:40b0f21484238269ae6a57200c807d80debc6459d444c0489a102d7c6a75fa56",
|
||||||
|
"sha256:4b21e5b1a70dfb972490035128f305c39bc4bc253f34e96a4adf9127cf943eb2",
|
||||||
|
"sha256:5a361d92635ad4ada1b1b2d3630fc2f53f2127d51cf2def9db83cba32e47c856",
|
||||||
|
"sha256:77a514ea15d3007d33a9e2157b0ba9c267496acf12a7f2b9b9f8446337aac5b0",
|
||||||
|
"sha256:855048b6feb6dfe09d3353466004490b1872887150c5bb5caad7838b57328cc8",
|
||||||
|
"sha256:9796a2ba7b4b538649caa5cecd398d873f4022ed2333ffde58eaf604c4d2cb27",
|
||||||
|
"sha256:98e02d56ebe93981c41211c05adb630d1d26c14195d04d95e49cd97dbc046dc5",
|
||||||
|
"sha256:b793b899f7cf563b1e7044a5c97361196b938e92f0a4343a5d27966a53d2ec71",
|
||||||
|
"sha256:d1ea5d12c8e2d266b5fb8c7a5d2e9c0219fedfeb493b7ed60cd350322384ac27",
|
||||||
|
"sha256:d2022bfadb7a5c2ef410d6a7c9763188afdb7f3533f22a0a32be10d571ee4bbe",
|
||||||
|
"sha256:d3348e7eb2eea2472db611486846742d5d52d1290576de99d59edeb7cd4a42ca",
|
||||||
|
"sha256:d744f72eb39f69312bc6c2abf8ff6656973120e2eb3f3ec4f758ed47e414a4bf",
|
||||||
|
"sha256:ef943c72a786b0f8d90fd76e9b39ce81fb7171172daf84bf43eaf937e9f220a9",
|
||||||
|
"sha256:f2899a3cbd394da157194f913a931edfd4be5f274a88041c9dc2d9cdcb1c315c"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==0.971"
|
||||||
|
},
|
||||||
"mypy-extensions": {
|
"mypy-extensions": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
|
"sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
|
||||||
|
@ -1518,7 +1547,7 @@
|
||||||
"sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02",
|
"sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02",
|
||||||
"sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"
|
"sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.7'",
|
"markers": "python_version < '3.8'",
|
||||||
"version": "==4.3.0"
|
"version": "==4.3.0"
|
||||||
},
|
},
|
||||||
"urllib3": {
|
"urllib3": {
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import infection_monkey.payload.ransomware.ransomware_builder as ransomware_builder
|
import infection_monkey.payload.ransomware.ransomware_builder as ransomware_builder
|
||||||
from monkey.common.agent_configuration.default_agent_configuration import RANSOMWARE_OPTIONS
|
from common.agent_configuration.default_agent_configuration import RANSOMWARE_OPTIONS
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from monkey.infection_monkey.network.relay import (
|
from infection_monkey.network.relay import (
|
||||||
RELAY_CONTROL_MESSAGE_REMOVE_FROM_WAITLIST,
|
RELAY_CONTROL_MESSAGE_REMOVE_FROM_WAITLIST,
|
||||||
RelayConnectionHandler,
|
RelayConnectionHandler,
|
||||||
RelayUserHandler,
|
RelayUserHandler,
|
||||||
|
|
|
@ -3,7 +3,7 @@ from time import sleep
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from monkey.infection_monkey.network.relay import RelayUserHandler
|
from infection_monkey.network.relay import RelayUserHandler
|
||||||
|
|
||||||
USER_ADDRESS = IPv4Address("0.0.0.0")
|
USER_ADDRESS = IPv4Address("0.0.0.0")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from monkey.infection_monkey.network.relay import SocketsPipe
|
from infection_monkey.network.relay import SocketsPipe
|
||||||
|
|
||||||
|
|
||||||
def test_sockets_pipe__name_increments():
|
def test_sockets_pipe__name_increments():
|
||||||
|
|
|
@ -3,9 +3,9 @@ import json
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from infection_monkey.exploit.sshexec import SSHExploiter
|
from infection_monkey.exploit.sshexec import SSHExploiter
|
||||||
|
from infection_monkey.i_puppet.i_puppet import ExploiterResultData
|
||||||
from infection_monkey.model.host import VictimHost
|
from infection_monkey.model.host import VictimHost
|
||||||
from infection_monkey.telemetry.exploit_telem import ExploitTelem
|
from infection_monkey.telemetry.exploit_telem import ExploitTelem
|
||||||
from monkey.infection_monkey.i_puppet.i_puppet import ExploiterResultData
|
|
||||||
|
|
||||||
DOMAIN_NAME = "domain-name"
|
DOMAIN_NAME = "domain-name"
|
||||||
IP = "0.0.0.0"
|
IP = "0.0.0.0"
|
||||||
|
|
Loading…
Reference in New Issue