Skip to content

Commit 46f6dad

Browse files
authored
Merge branch 'main' into opsec
2 parents 9ad951c + 266c671 commit 46f6dad

4 files changed

Lines changed: 83 additions & 1 deletion

File tree

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# ❗❗❗ Before filing this bug report, MAKE SURE you have already downloaded the newest version of NetExec from GitHub and installed it! Many issues have already been reported and fixed, _especially_ if you are running the native Kali version! Please delete this line before submitting your issue if you have done so.❗❗❗
2+
13
---
24
name: Bug report
35
about: Create a report to help us improve
@@ -7,6 +9,8 @@ assignees: ''
79

810
---
911

12+
13+
1014
**Describe the bug**
1115
A clear and concise description of what the bug is.
1216

@@ -30,7 +34,7 @@ If applicable, add screenshots to help explain your problem.
3034

3135
**NetExec info**
3236
- OS: [e.g. Kali]
33-
- Version of nxc: [e.g. v1.5.2]
37+
- Version of nxc: [e.g. v1.5.2] (run nxc --version and post the _exact_ string that is output)
3438
- Installed from: apt/github/pip/docker/...? Please try with latest release before opening an issue
3539

3640
**Additional context**

nxc/modules/dump-computers.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from nxc.parsers.ldap_results import parse_result_attributes
2+
3+
4+
class NXCModule:
5+
name = "dump-computers"
6+
description = "Dumps all computers in the domain"
7+
supported_protocols = ["ldap"]
8+
opsec_safe = True
9+
multiple_hosts = False
10+
11+
def options(self, context, module_options):
12+
"""
13+
TYPE Only dump NETBIOS or FQDN instead of 'FQDN (OS Version)'
14+
OUTPUT Output to file in addition to printing to console
15+
16+
Examples
17+
--------
18+
netexec ldap $DC-IP -u $username -p $password -M dump-computers
19+
netexec ldap $DC-IP -u $username -p $password -M dump-computers -o TYPE=netbios
20+
netexec ldap $DC-IP -u $username -p $password -M dump-computers -o TYPE=fqdn
21+
netexec ldap $DC-IP -u $username -p $password -M dump-computers -o TYPE=netbios OUTPUT=<location>
22+
"""
23+
self.output_file = None
24+
self.netbios_only = False
25+
self.fqdn_only = False
26+
27+
if "OUTPUT" in module_options:
28+
self.output_file = module_options["OUTPUT"]
29+
if "TYPE" in module_options:
30+
if module_options["TYPE"].lower() == "netbios":
31+
self.netbios_only = True
32+
elif module_options["TYPE"].lower() == "fqdn":
33+
self.fqdn_only = True
34+
35+
def on_login(self, context, connection):
36+
resp = connection.search(
37+
searchFilter="(objectCategory=computer)",
38+
attributes=["dNSHostName", "operatingSystem"]
39+
)
40+
resp_parsed = parse_result_attributes(resp)
41+
42+
answers = []
43+
context.log.debug(f"Total number of records returned: {len(resp_parsed)}")
44+
45+
for item in resp_parsed:
46+
dns_host_name = item["dNSHostName"]
47+
operating_system = item.get("operatingSystem", "Unknown OS")
48+
49+
if self.netbios_only:
50+
netbios_name = dns_host_name.split(".")[0]
51+
answer = netbios_name
52+
elif self.fqdn_only:
53+
answer = dns_host_name
54+
else:
55+
answer = f"{dns_host_name} ({operating_system})"
56+
answers.append(answer)
57+
58+
context.log.success("Found the following computers:")
59+
for answer in answers:
60+
context.log.highlight(answer)
61+
62+
if self.output_file:
63+
try:
64+
with open(self.output_file, "w") as f:
65+
f.write("\n".join(answers) + "\n")
66+
context.log.success(f"Results saved to {self.output_file}")
67+
except Exception as e:
68+
context.log.error(f"Failed to write to file {self.output_file}: {e}")

nxc/modules/wcc.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def init_checks(self):
178178
ConfigCheck("CredentialGuard enabled", "Checks if CredentialGuard is enabled", checker_args=[[self, ("HKLM\\SYSTEM\\CurrentControlSet\\Control\\DeviceGuard", "EnableVirtualizationBasedSecurity", 1), ("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa", "LsaCfgFlags", 1)]]),
179179
ConfigCheck("Lsass run as PPL", "Checks if lsass runs as a protected process", checker_args=[[self, ("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa", "RunAsPPL", 1)]]),
180180
ConfigCheck("No Powershell v2", "Checks if powershell v2 is available", checker_args=[[self, ("HKLM\\SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", "PSCompatibleVersion", "2.0", not_(operator.contains))]]),
181+
ConfigCheck("LLMNR disabled", "Checks if LLMNR is disabled", checker_args=[[self, ("HKLM\\Software\\policies\\Microsoft\\Windows NT\\DNSClient", "EnableMulticast", 0)]]),
181182
ConfigCheck("LmCompatibilityLevel == 5", "Checks if LmCompatibilityLevel is set to 5", checker_args=[[self, ("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa", "LmCompatibilityLevel", 5, operator.ge)]]),
182183
ConfigCheck("NBTNS disabled", "Checks if NBTNS is disabled on all interfaces", checkers=[self.check_nbtns]),
183184
ConfigCheck("mDNS disabled", "Checks if mDNS is disabled", checker_args=[[self, ("HKLM\\SYSTEM\\CurrentControlSet\\Services\\DNScache\\Parameters", "EnableMDNS", 0)]]),
@@ -453,13 +454,21 @@ def check_wsus_running(self):
453454
return ok, reasons
454455

455456
def check_nbtns(self):
457+
adapters_key = "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e972-e325-11ce-bfc1-08002be10318}"
456458
key_name = "HKLM\\SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters\\Interfaces"
457459
subkeys = self.reg_get_subkeys(self.dce, self.connection, key_name)
458460
success = False
459461
reasons = []
460462
missing = 0
461463
nbtns_enabled = 0
464+
462465
for subkey in subkeys:
466+
# Ignore Microsoft Kernel Debug Network Adapter
467+
kdnic_key = adapters_key + "\\0000"
468+
kdnic_uuid = self.reg_query_value(self.dce, self.connection, kdnic_key, "NetCfgInstanceId")
469+
if subkey.lower() == ("Tcpip_" + kdnic_uuid).replace("\x00", "").lower():
470+
continue
471+
463472
value = self.reg_query_value(self.dce, self.connection, key_name + "\\" + subkey, "NetbiosOptions")
464473
if isinstance(value, DCERPCSessionError):
465474
if value.error_code == ERROR_OBJECT_NOT_FOUND:

tests/e2e_commands.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M subnets
210210
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M user-desc
211211
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M whoami
212212
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M pso
213+
netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M dump-computers
213214
##### WINRM
214215
netexec winrm TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS # need an extra space after this command due to regex
215216
netexec winrm TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -X ipconfig

0 commit comments

Comments
 (0)