Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in windows network plugins #955

Merged
merged 14 commits into from
Nov 27, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions dissect/target/plugins/os/windows/network.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

import re
from enum import IntEnum
from functools import lru_cache
from typing import Iterator
from typing import Iterator, Optional

from dissect.util.ts import wintimestamp

Expand Down Expand Up @@ -224,11 +225,13 @@ def _try_value(subkey: RegistryKey, value: str) -> str | list | None:
return None


def _get_config_value(key: RegistryKey, name: str) -> set:
def _get_config_value(key: RegistryKey, name: str, split_char: Optional[list[str]] = None) -> set:
value = _try_value(key, name)
if not value or value in ("", "0.0.0.0", None, [], ["0.0.0.0"]):
return set()

if split_char:
split_regexp = '|'.join(re.escape(c) for c in split_char)
value = re.split(split_regexp, value)
if isinstance(value, list):
return set(value)

Expand Down Expand Up @@ -354,11 +357,11 @@ def _extract_network_device_config(self, interface_id: str) -> list[dict[str, se
dhcp_config["ip"].update(_get_config_value(key, "DhcpIPAddress"))
dhcp_config["subnetmask"].update(_get_config_value(key, "DhcpSubnetMask"))
dhcp_config["search_domain"].update(_get_config_value(key, "DhcpDomain"))
dhcp_config["dns"].update(_get_config_value(key, "DhcpNameServer"))
dhcp_config["dns"].update(_get_config_value(key, "DhcpNameServer", [" ", ","]))

# Extract static configuration from the registry
static_config["gateway"].update(_get_config_value(key, "DefaultGateway"))
static_config["dns"].update(_get_config_value(key, "NameServer"))
static_config["dns"].update(_get_config_value(key, "NameServer", [" ", ","]))
static_config["search_domain"].update(_get_config_value(key, "Domain"))
static_config["ip"].update(_get_config_value(key, "IPAddress"))
static_config["subnetmask"].update(_get_config_value(key, "SubnetMask"))
Expand Down