Skip to content

Commit 25ac2e2

Browse files
committed
Update dump-computers.py
added fqdn only
1 parent 8c37f34 commit 25ac2e2

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

nxc/modules/dump-computers.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import socket
12
from nxc.logger import nxc_logger
23
from impacket.ldap.ldap import LDAPSearchError
34
from impacket.ldap.ldapasn1 import SearchResultEntry
5+
import sys
46

57
class NXCModule:
68

@@ -13,28 +15,34 @@ class NXCModule:
1315
def options(self, context, module_options):
1416
"""
1517
dump-computers: Specify dump-computers to call the module
16-
Usage:
17-
18+
Usage:
1819
>prints fqdn and version
1920
nxc ldap $DC-IP -u Username -p Password -M dump-computers
2021
2122
>prints only netbios name
2223
nxc ldap $DC-IP -u Username -p Password -M dump-computers -o NETBIOS=True
2324
25+
>prints only fqdn
26+
nxc ldap $DC-IP -u Username -p Password -M dump-computers -o FQDN=True
27+
2428
>prints fqdn and version, output to file
2529
nxc ldap $DC-IP -u Username -p Password -M dump-computers -o OUTPUT=<location>
2630
2731
>prints only netbios name, output to file
2832
nxc ldap $DC-IP -u Username -p Password -M dump-computers -o OUTPUT=<location> -o NETBIOS=True
33+
nxc ldap $DC-IP -u Username -p Password -M dump-computers -o OUTPUT=<location> -o FQDN=True
2934
3035
"""
3136
self.output_file = None
3237
self.netbios_only = False
38+
self.fqdn_only = False
3339

3440
if "OUTPUT" in module_options:
3541
self.output_file = module_options["OUTPUT"]
3642
if "NETBIOS" in module_options and module_options["NETBIOS"].lower() == "true":
3743
self.netbios_only = True
44+
if "FQDN" in module_options and module_options["FQDN"].lower() == "true":
45+
self.fqdn_only = True
3846

3947
def on_login(self, context, connection):
4048
search_filter = "(objectCategory=computer)"
@@ -65,7 +73,12 @@ def on_login(self, context, connection):
6573
operating_system = attribute["vals"][0]
6674
if dns_host_name:
6775
netbios_name = dns_host_name.split(".")[0]
68-
answer = netbios_name if self.netbios_only else f"{dns_host_name} ({operating_system})"
76+
if self.netbios_only:
77+
answer = netbios_name
78+
elif self.fqdn_only:
79+
answer = dns_host_name
80+
else:
81+
answer = f"{dns_host_name} ({operating_system})"
6982
answers.append(answer)
7083
except Exception as e:
7184
context.log.debug("Exception:", exc_info=True)

0 commit comments

Comments
 (0)