dissect.target.plugins.os.unix.linux.network_managers
¶
Module Contents¶
Classes¶
Class that represents a parsing template. Linux network configuration files can be parsed according to the |
|
Class that represents a parser. This class translates the config created from a Template into a generic |
|
This class represents a Linux network managers on a given Linux based target. Detects if the network manager is |
|
This class represents a collection of available network managers on a linux target as a collection of |
Functions¶
Parse local syslog, journal and cloud init-log files for DHCP lease IPs. |
|
Attributes¶
- dissect.target.plugins.os.unix.linux.network_managers.log¶
- dissect.target.plugins.os.unix.linux.network_managers.HAS_YAML = True¶
- dissect.target.plugins.os.unix.linux.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.plugins.os.unix.linux.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.).
- name¶
- parser¶
- sections¶
- options¶
- 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.plugins.os.unix.linux.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.
- target¶
- template¶
- sections¶
- options¶
- config_globs¶
- 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.plugins.os.unix.linux.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.
- target = None¶
- parser = None¶
- config = None¶
- name¶
- config_globs¶
- detection_globs¶
- 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.
- property interface: set¶
- property ips: set¶
- property dns: set¶
- property dhcp: bool¶
- property gateway: set¶
- property netmask: set¶
- property registered: bool¶
- 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 ¶
- class dissect.target.plugins.os.unix.linux.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.
- managers = []¶
- target¶
- 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.plugins.os.unix.linux.network_managers.parse_unix_dhcp_log_messages(target: dissect.target.target.Target, iter_all: bool = False) set[str] ¶
Parse local syslog, journal and cloud init-log files for DHCP lease IPs.
- Parameters:
target – Target to discover and obtain network information from.
iter_all – Parse limited amount of journal messages (first 10000) or all of them.
- Returns:
A set of found DHCP IP addresses.
- dissect.target.plugins.os.unix.linux.network_managers.should_ignore_ip(ip: str) bool ¶
- dissect.target.plugins.os.unix.linux.network_managers.MANAGERS¶
- dissect.target.plugins.os.unix.linux.network_managers.TEMPLATES¶