2022-07-18 23:59:14 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2022-03-11 23:00:25 +00:00
|
|
|
from datetime import datetime
|
2023-09-14 21:07:15 +00:00
|
|
|
from nxc.helpers.logger import write_log
|
2022-03-11 23:00:25 +00:00
|
|
|
import json
|
|
|
|
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2023-09-17 20:20:40 +00:00
|
|
|
class NXCModule:
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
2023-05-02 15:17:59 +00:00
|
|
|
Uses WMI to extract network connections, used to find multi-homed hosts.
|
|
|
|
Module by @fang0654
|
2022-03-11 23:00:25 +00:00
|
|
|
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
2022-03-11 23:00:25 +00:00
|
|
|
|
2023-05-02 15:17:59 +00:00
|
|
|
name = "get_netconnections"
|
|
|
|
description = "Uses WMI to query network connections."
|
2023-09-01 13:49:57 +00:00
|
|
|
supported_protocols = ["smb", "wmi"]
|
2023-05-02 15:17:59 +00:00
|
|
|
opsec_safe = True
|
2022-03-11 23:00:25 +00:00
|
|
|
multiple_hosts = True
|
|
|
|
|
|
|
|
def options(self, context, module_options):
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
2022-03-11 23:00:25 +00:00
|
|
|
No options
|
2023-04-07 16:40:48 +00:00
|
|
|
"""
|
2022-03-11 23:00:25 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def on_admin_login(self, context, connection):
|
|
|
|
data = []
|
2023-05-08 18:39:36 +00:00
|
|
|
cards = connection.wmi(f"select DNSDomainSuffixSearchOrder, IPAddress from win32_networkadapterconfiguration")
|
2023-08-23 04:23:28 +00:00
|
|
|
if cards:
|
|
|
|
for c in cards:
|
|
|
|
if c["IPAddress"].get("value"):
|
|
|
|
context.log.success(f"IP Address: {c['IPAddress']['value']}\tSearch Domain: {c['DNSDomainSuffixSearchOrder']['value']}")
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2023-08-23 04:23:28 +00:00
|
|
|
data.append(cards)
|
2022-03-11 23:00:25 +00:00
|
|
|
|
2023-08-30 03:43:02 +00:00
|
|
|
log_name = "network-connections-{}-{}.log".format(connection.host, datetime.now().strftime("%Y-%m-%d_%H%M%S"))
|
2022-03-11 23:00:25 +00:00
|
|
|
write_log(json.dumps(data), log_name)
|
2023-09-14 21:07:15 +00:00
|
|
|
context.log.display(f"Saved raw output to ~/.nxc/logs/{log_name}")
|