Skip to content

Commit

Permalink
Add dns options to dc-list
Browse files Browse the repository at this point in the history
  • Loading branch information
NeffIsBack committed Jan 1, 2025
1 parent fbd4e1a commit d8e5e94
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions nxc/protocols/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from re import sub, I
from zipfile import ZipFile
from termcolor import colored
from dns import resolver

from Cryptodome.Hash import MD4
from OpenSSL.SSL import SysCallError
Expand All @@ -32,7 +33,6 @@

from nxc.config import process_secret, host_info_colors
from nxc.connection import connection
from nxc.connection import resolver
from nxc.helpers.bloodhound import add_user_bh
from nxc.logger import NXCAdapter, nxc_logger
from nxc.protocols.ldap.bloodhound import BloodHound
Expand Down Expand Up @@ -702,7 +702,11 @@ def groups(self):
def dc_list(self):
# Building the search filter
resolv = resolver.Resolver()
resolv.nameservers = [self.host]
if self.args.dns_server:
resolv.nameservers = [self.args.dns_server]
else:
resolv.nameservers = [self.host]
resolv.timeout = self.args.dns_timeout

search_filter = "(&(objectCategory=computer)(primaryGroupId=516))"
attributes = ["dNSHostName"]
Expand All @@ -721,7 +725,7 @@ def dc_list(self):
break # If a record has been found, stop checking further

try:
answers = resolv.resolve(name, record_type)
answers = resolv.resolve(name, record_type, tcp=self.args.dns_tcp)
for rdata in answers:
if record_type in ["A", "AAAA"]:
ip_address = rdata.to_text()
Expand Down

0 comments on commit d8e5e94

Please sign in to comment.