:py:mod:`dissect.target.helpers.network_managers` ================================================= .. py:module:: dissect.target.helpers.network_managers Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.target.helpers.network_managers.Template dissect.target.helpers.network_managers.Parser dissect.target.helpers.network_managers.NetworkManager dissect.target.helpers.network_managers.LinuxNetworkManager Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.target.helpers.network_managers.parse_unix_dhcp_log_messages dissect.target.helpers.network_managers.should_ignore_ip Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.target.helpers.network_managers.log dissect.target.helpers.network_managers.HAS_YAML dissect.target.helpers.network_managers.IGNORED_IPS dissect.target.helpers.network_managers.MANAGERS dissect.target.helpers.network_managers.TEMPLATES .. py:data:: log .. py:data:: HAS_YAML :value: True .. py:data:: IGNORED_IPS :value: ['0.0.0.0', '127.0.0.1', '::1', '0:0:0:0:0:0:0:1', '0:0:0:0:0:0:0:0'] .. py:class:: Template(name: str, parser: Any, sections: list[str], options: list[str]) Class that represents a parsing template. Linux network configuration files can be parsed according to the options specified within this template. :param name: Name of the parsing template. :param parser: A function or object to parse a Linux network configuration file with. :param sections: Configuration sections to look for in the specified configuration file. :param options: Configuration options to look for in the specified configuration file (ip, dns, dhcp, etc.). .. py:method:: set_name(name: str) -> None Sets the name of the the used parsing template to the name of the discovered network manager. .. py:method:: create_config(path: dissect.target.helpers.fsutil.TargetPath) -> Optional[dict] Create a network config dictionary based on the configured template and supplied path. :param Path: Path to the to be parsed config file. :returns: A dictionary based on the provided configured template, else None .. py:class:: Parser(target: dissect.target.target.Target, config_globs: list[str], template: Template) Class that represents a parser. This class translates the config created from a Template into a generic configuration dictionary :param target: Target to parse the config from. :param config_globs: Glob patterns to obtain config files from. :param template: Template object to create a config from. .. py:method:: parse() -> collections.defaultdict Returns a translated dictionary of network configuration properties. :returns: Dictionary containing network configuration properties for interface, dhcp, ips, gateways, dns, and netmask. .. py:method:: translate_network_config(config_dict: dict) -> list[tuple[str, Any]] Translates a parsed network configuration property to its generalized form: :returns: List containing the translated property and its value. .. py:method:: expand_config_file_paths() -> list[dissect.target.helpers.fsutil.TargetPath] Expands all globbed config file path to discovery network configuration files. :returns: List containing the found network configuration files. .. py:method:: translate(value: Any, option: str) -> str Translates the passed option value name to its corrensponding generalized option name. :returns: Translated option name. .. py:class:: NetworkManager(name: str, detection_globs: tuple[str], config_globs: tuple[str]) This class represents a Linux network managers on a given Linux based target. Detects if the network manager is active based on available configuration files and paths. :param name: Name of the network manager to detect :param detection_globs: Glob patterns to detect network manager with. :param config_flobs: Glob patterns to retreive possible configuration files belonging to this network manager. .. py:property:: interface :type: set .. py:property:: ips :type: set .. py:property:: dns :type: set .. py:property:: dhcp :type: bool .. py:property:: gateway :type: set .. py:property:: netmask :type: set .. py:property:: registered :type: bool .. py:method:: detect(target: Optional[dissect.target.target.Target] = None) -> bool Detects if the network manager is active on the target :returns: Whether a certain network manager is detected on the target .. py:method:: register(target: dissect.target.target.Target, template: Template) -> bool Sets the detected parsing template and target the network manager. :param target: Target object to register to this NetworkManager class. :param template: Parsing Template object to register to this NetworkManager class. :returns: Whether the registration process was executed succesfully. .. py:method:: parse() -> None Parse the network configuration for this network manager. .. py:method:: clean_ips(ips: Iterable) -> set :staticmethod: Clean ip values before returning them. :param ips: Iterable of ip addresses to clean. :returns: Set of cleaned ip addresses. .. py:method:: __repr__() -> str Return repr(self). .. py:class:: LinuxNetworkManager(target: dissect.target.target.Target) This class represents a collection of available network managers on a linux target as a collection of NetworkManager objects. :param target: Target to discover and obtain network information from. .. py:method:: discover() -> None Discover which defined network managers are active on the target. Registers the discovered network managers as active for parsing later on. .. py:method:: get_config_value(attr: str) -> list[set] Return the specified value from a network configuration option. :returns: List containing the values corrensponding to that configuration option. .. py:function:: parse_unix_dhcp_log_messages(target) -> list[str] Parse local syslog, journal and cloud init-log files for DHCP lease IPs. :param target: Target to discover and obtain network information from. :returns: List of DHCP ip addresses. .. py:function:: should_ignore_ip(ip: str) -> bool .. py:data:: MANAGERS .. py:data:: TEMPLATES