Skip to content

Commit d4808ac

Browse files
committed
check if target is dc
1 parent 864b7ae commit d4808ac

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

nxc/protocols/smb.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,18 @@ def print_host_info(self):
314314
self.logger.display(f"{self.server_os}{f' x{self.os_arch}' if self.os_arch else ''} (name:{self.hostname}) (domain:{self.targetDomain}) ({signing}) ({smbv1})")
315315

316316
if self.args.generate_hosts_file:
317+
from impacket.dcerpc.v5 import nrpc, epm
318+
self.logger.debug("Performing authentication attempts...")
319+
isdc = False
320+
try:
321+
epm.hept_map(self.host, nrpc.MSRPC_UUID_NRPC, protocol="ncacn_ip_tcp")
322+
isdc = True
323+
except DCERPCException:
324+
self.logger.debug("Error while connecting to host: DCERPCException, which means this is probably not a DC!")
325+
317326
with open(self.args.generate_hosts_file, "a+") as host_file:
318-
host_file.write(f"{self.host} {self.hostname} {self.hostname}.{self.targetDomain}\n")
327+
host_file.write(f"{self.host} {self.hostname} {self.hostname}.{self.targetDomain} {self.targetDomain if isdc else ''}\n")
328+
self.logger.debug(f"{self.host} {self.hostname} {self.hostname}.{self.targetDomain} {self.targetDomain if isdc else ''}")
319329

320330
return self.host, self.hostname, self.targetDomain
321331

0 commit comments

Comments
 (0)