Source code for expliot_finder.vulnerability_scanner.captured_sensitive_target_info
"""Module that's store all detected sensitive information by 'vulnerability scanner' scanners."""
__all__ = ("CapturedSensitiveInfo",)
from dataclasses import dataclass, field
from typing import Any, Iterator, Optional
[docs]@dataclass(kw_only=True, slots=True)
class CapturedSensitiveInfo:
"""Stores detected vulnerability information about the chosen target during the scan.
This is an example of information stored by this class after scanning a
first 200 ports in target with the IP address '192.168.0.1':
.. code-block:: python
{
'ip_v4': '192.168.0.1',
'os_name': 'Linux',
'mac_address': 'D8-0D-17-XX-XX-XX',
'mac_vendor_name': 'TP-LINK TECHNOLOGIES CO.,LTD.',
'ports_services': [
PortService(
port_number=22,
service_name='ssh',
service_version='SSH-2.0-dropbear_2011.54'
),
PortService(
port_number=80,
service_name='http',
service_version='Unknown'
)
]
}
Attributes:
ip_v4:
IP address(version 4) of the selected target to scan.
os_name:
Detected OS used by target.
mac_address:
Detected MAC address used by target.
mac_vendor_name:
Detected vendor name of MAC used by target.
ports_services:
Open ports, services running on those open ports and versions of
those services that's were detected in the chosen target.
.. automethod:: __iter__
"""
ip_v4: str
os_name: Optional[str] = ""
mac_address: Optional[str] = ""
mac_vendor_name: Optional[str] = ""
ports_services: list = field(default_factory=list)
[docs] def __iter__(self) -> Iterator[tuple[str, str | list[Any]]]:
"""Allow transforming dataclass into dictionary.
Sometimes in the code, a dict will be more useful than a dataclass, so
that's why __iter__ method has been implemented.
Returns:
A dictionary with the captured confidential information of the
selected target to scan.
"""
yield "ip_v4", self.ip_v4
if self.os_name:
yield "os_name", self.os_name
if self.mac_address:
yield "mac_address", self.mac_address
if self.mac_vendor_name:
yield "mac_vendor_name", self.mac_vendor_name
if self.ports_services:
yield "ports_services", self.ports_services