Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions dissect/target/plugins/os/windows/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,13 @@ def _get_config_value(key: RegistryKey, name: str, sep: str | None = None) -> se

def _construct_interface(key: RegistryKey, ip_key: str, subnet_key: str) -> set[str]:
interface = ""

if ip := _get_config_value(key, ip_key):
interface = next(iter(ip))

if not interface:
return set()

if subnet := _get_config_value(key, subnet_key):
interface = f"{interface}/{next(iter(subnet))}"

Expand Down
19 changes: 19 additions & 0 deletions tests/plugins/os/windows/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ class MockRegVal:
},
id="OTHER empty",
),
pytest.param(
{
"NetCfgInstanceId": "TESTINGINSTANCEID",
"EnableDHCP": 1,
"DhcpIPAddress": "0.0.0.0",
"DhcpSubnetMask": "255.255.255.0",
},
{
"_NO_INTERFACES": True,
"enabled": True,
"cidr": {}, # and not {'/255.255.255.0'}
},
id="invalid cidr",
),
],
)
def test_windows_network(
Expand Down Expand Up @@ -167,6 +181,11 @@ def test_windows_network(
assert network.gateways() == expected_values.get("gateway", [])
assert network.macs() == expected_values.get("mac", [])

if expected_values.get("_NO_INTERFACES"):
with pytest.raises(StopIteration):
next(iter(network.interfaces()))
return

network_interface = next(iter(network.interfaces()))
assert network_interface.name == expected_values.get("name")
assert network_interface.type == expected_values.get("type")
Expand Down
Loading