Agent: Convert PingScanData to dataclass

This commit is contained in:
Kekoa Kaaikala 2022-09-26 17:48:27 +00:00
parent 6f095eb0c1
commit dd5b796bfe
2 changed files with 9 additions and 6 deletions

View File

@ -5,6 +5,7 @@ from dataclasses import dataclass
from enum import Enum
from typing import Dict, Iterable, Mapping, Optional, Sequence
from common import OperatingSystem
from common.credentials import Credentials
from infection_monkey.model import VictimHost
@ -31,7 +32,12 @@ class ExploiterResultData:
error_message: str = ""
PingScanData = namedtuple("PingScanData", ["response_received", "os"])
@dataclass
class PingScanData:
response_received: bool
os: Optional[OperatingSystem]
PortScanData = namedtuple("PortScanData", ["port", "status", "banner", "service"])
FingerprintData = namedtuple("FingerprintData", ["os_type", "os_version", "services"])
PostBreachData = namedtuple("PostBreachData", ["display_name", "command", "result"])

View File

@ -78,11 +78,8 @@ def _process_ping_command_output(ping_command_output: str) -> PingScanData:
# match at all if the group isn't found or the contents of the group are not only digits.
ttl = int(ttl_match.group(1))
operating_system = None
if ttl <= LINUX_TTL:
operating_system = OperatingSystem.LINUX
else: # as far we we know, could also be OSX/BSD, but lets handle that when it comes up.
operating_system = OperatingSystem.WINDOWS
# could also be OSX/BSD, but lets handle that when it comes up.
operating_system = OperatingSystem.LINUX if ttl <= LINUX_TTL else OperatingSystem.WINDOWS
return PingScanData(True, operating_system)