Skip to content

Commit 3e39874

Browse files
authored
Merge pull request Pennyw0rth#712 from Pennyw0rth/neff-fix-asreproast-anon
Enable asreproast with anonymous ldap logins
2 parents 9d3f34e + 10e7c62 commit 3e39874

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

nxc/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,14 @@ def parse_credentials(self):
416416
with open(ntlm_hash) as ntlm_hash_file:
417417
for i, line in enumerate(ntlm_hash_file):
418418
line = line.strip()
419-
if len(line) != 32 and len(line) != 65:
419+
if len(line) != 32 and len(line) != 65 and len(line) != 0:
420420
self.logger.fail(f"Invalid NTLM hash length on line {(i + 1)} (len {len(line)}): {line}")
421421
continue
422422
else:
423423
secret.append(line)
424424
cred_type.append("hash")
425425
else:
426-
if len(ntlm_hash) != 32 and len(ntlm_hash) != 65:
426+
if len(ntlm_hash) != 32 and len(ntlm_hash) != 65 and len(ntlm_hash) != 0:
427427
self.logger.fail(f"Invalid NTLM hash length {len(ntlm_hash)}, authentication not sent")
428428
exit(1)
429429
else:

nxc/protocols/ldap.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
364364
if nthash:
365365
self.nthash = nthash
366366

367-
if self.password == "" and self.args.asreproast:
367+
if self.username and self.password == "" and self.args.asreproast:
368368
hash_tgt = KerberosAttacks(self).get_tgt_asroast(self.username)
369369
if hash_tgt:
370370
self.logger.highlight(f"{hash_tgt}")
@@ -483,7 +483,7 @@ def plaintext_login(self, domain, username, password):
483483
self.password = password
484484
self.domain = domain
485485

486-
if self.password == "" and self.args.asreproast:
486+
if self.username and self.password == "" and self.args.asreproast:
487487
hash_tgt = KerberosAttacks(self).get_tgt_asroast(self.username)
488488
if hash_tgt:
489489
self.logger.highlight(f"{hash_tgt}")
@@ -574,7 +574,7 @@ def hash_login(self, domain, username, ntlm_hash):
574574
self.username = username
575575
self.domain = domain
576576

577-
if self.hash == "" and self.args.asreproast:
577+
if self.username and self.hash == "" and self.args.asreproast:
578578
hash_tgt = KerberosAttacks(self).get_tgt_asroast(self.username)
579579
if hash_tgt:
580580
self.logger.highlight(f"{hash_tgt}")
@@ -875,7 +875,7 @@ def resolve_and_display_hostname(name, domain_name=None):
875875
trust_direction = int(trust["trustDirection"])
876876
trust_type = int(trust["trustType"])
877877
trust_attributes = int(trust["trustAttributes"])
878-
878+
879879
# See: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/e9a2d23c-c31e-4a6f-88a0-6646fdb51a3c
880880
trust_attribute_flags = {
881881
0x1: "Non-Transitive",
@@ -965,9 +965,6 @@ def active_users(self):
965965
self.logger.highlight(f"{user.get('sAMAccountName', ''):<30}{pwd_last_set:<20}{user.get('badPwdCount', ''):<9}{user.get('description', '')}")
966966

967967
def asreproast(self):
968-
if self.password == "" and self.nthash == "" and not self.kerberos:
969-
return False
970-
971968
# Building the search filter
972969
search_filter = f"(&(UserAccountControl:1.2.840.113556.1.4.803:={UF_DONT_REQUIRE_PREAUTH})(!(UserAccountControl:1.2.840.113556.1.4.803:={UF_ACCOUNTDISABLE}))(!(objectCategory=computer)))"
973970
resp = self.search(search_filter, attributes=["sAMAccountName"], sizeLimit=0)

0 commit comments

Comments
 (0)