Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTH Fix for Group Enumeration with SMB #563

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nxc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ def parse_credentials(self):
else:
secret.append(password)
cred_type.append("plaintext")

# Some libraries will be confused by a bare NT hash - pad such a hash
# with a placeholder LM: prefix.
def pad_lm(ntlm_hash):
if len(ntlm_hash) == 32:
lm_hash = "aad3b435b51404eeaad3b435b51404ee"
ntlm_hash = lm_hash + ":" + ntlm_hash
return ntlm_hash

# Parse NTLM-hashes
if hasattr(self.args, "hash") and self.args.hash:
Expand All @@ -431,13 +439,15 @@ def parse_credentials(self):
self.logger.fail(f"Invalid NTLM hash length on line {(i + 1)} (len {len(line)}): {line}")
continue
else:
line = pad_lm(line)
secret.append(line)
cred_type.append("hash")
else:
if len(ntlm_hash) != 32 and len(ntlm_hash) != 65:
self.logger.fail(f"Invalid NTLM hash length {len(ntlm_hash)}, authentication not sent")
exit(1)
else:
ntlm_hash = pad_lm(ntlm_hash)
secret.append(ntlm_hash)
cred_type.append("hash")
self.logger.debug(secret)
Expand Down