dissect.target.helpers.network_managers

Module Contents

Classes

Template

Class that represents a parsing template. Linux network configuration files can be parsed according to the

Parser

Class that represents a parser. This class translates the config created from a Template into a generic

NetworkManager

This class represents a Linux network managers on a given Linux based target. Detects if the network manager is

LinuxNetworkManager

This class represents a collection of available network managers on a linux target as a collection of

Functions

parse_unix_dhcp_log_messages

Parse local syslog, journal and cloud init-log files for DHCP lease IPs.

should_ignore_ip

Attributes

dissect.target.helpers.network_managers.log
dissect.target.helpers.network_managers.HAS_YAML = True
dissect.target.helpers.network_managers.IGNORED_IPS = ['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']
class dissect.target.helpers.network_managers.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.

Parameters:
  • name – Name of the parsing template.

  • parser – A function or object to parse a Linux network configuration file with.

  • sections – Configuration sections to look for in the specified configuration file.

  • options – Configuration options to look for in the specified configuration file (ip, dns, dhcp, etc.).

set_name(name: str) None

Sets the name of the the used parsing template to the name of the discovered network manager.

create_config(path: dissect.target.helpers.fsutil.TargetPath) dict | None

Create a network config dictionary based on the configured template and supplied path.

Parameters:

Path – Path to the to be parsed config file.

Returns:

A dictionary based on the provided configured template, else None

class dissect.target.helpers.network_managers.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

Parameters:
  • target – Target to parse the config from.

  • config_globs – Glob patterns to obtain config files from.

  • template – Template object to create a config from.

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.

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.

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.

translate(value: Any, option: str) str

Translates the passed option value name to its corrensponding generalized option name.

Returns:

Translated option name.

class dissect.target.helpers.network_managers.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.

Parameters:
  • name – Name of the network manager to detect

  • detection_globs – Glob patterns to detect network manager with.

  • config_flobs – Glob patterns to retreive possible configuration files belonging to this network manager.

property interface: set
property ips: set
property dns: set
property dhcp: bool
property gateway: set
property netmask: set
property registered: bool
detect(target: dissect.target.target.Target | None = None) bool

Detects if the network manager is active on the target

Returns:

Whether a certain network manager is detected on the target

register(target: dissect.target.target.Target, template: Template) bool

Sets the detected parsing template and target the network manager.

Parameters:
  • target – Target object to register to this NetworkManager class.

  • template – Parsing Template object to register to this NetworkManager class.

Returns:

Whether the registration process was executed succesfully.

parse() None

Parse the network configuration for this network manager.

static clean_ips(ips: Iterable) set

Clean ip values before returning them.

Parameters:

ips – Iterable of ip addresses to clean.

Returns:

Set of cleaned ip addresses.

__repr__() str

Return repr(self).

class dissect.target.helpers.network_managers.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.

Parameters:

target – Target to discover and obtain network information from.

discover() None

Discover which defined network managers are active on the target.

Registers the discovered network managers as active for parsing later on.

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.

dissect.target.helpers.network_managers.parse_unix_dhcp_log_messages(target) list[str]

Parse local syslog, journal and cloud init-log files for DHCP lease IPs.

Parameters:

target – Target to discover and obtain network information from.

Returns:

List of DHCP ip addresses.

dissect.target.helpers.network_managers.should_ignore_ip(ip: str) bool
dissect.target.helpers.network_managers.MANAGERS
dissect.target.helpers.network_managers.TEMPLATES