Skip to content

Overhaul ntlm.py for Spec-Aligned Hash Extraction#23

Merged
MatrixEditor merged 24 commits intoMatrixEditor:masterfrom
StrongWind1:update/ntlm
Mar 8, 2026
Merged

Overhaul ntlm.py for Spec-Aligned Hash Extraction#23
MatrixEditor merged 24 commits intoMatrixEditor:masterfrom
StrongWind1:update/ntlm

Conversation

@StrongWind1
Copy link
Copy Markdown
Contributor

Resolves #22

What Changed

NTLM_AUTH_to_hashcat_formats() — replaces NTLM_AUTH_to_hashcat_format(). Returns list[tuple[str, str]] with all crackable hashes from a single Type 3 message. Addresses issues 1–4 from the tracking issue.

NTLM_AUTH_CreateChallenge() — removed NTLMSSP_AV_TIME from AV_PAIRS, added disable_ntlmv2 parameter, added SEAL/ALWAYS_SIGN echo, added ESS/LM_KEY exclusivity enforcement. Addresses issues 5–8.

Configuration — renamed ntlm_challangentlm_challenge, replaced ntlm_ess with ntlm_disable_ess (inverted polarity), added ntlm_disable_ntlmv2. Challenge parser now supports hex:/ascii: prefixes with backward-compatible auto-detection. Addresses issue 9.

_compute_dummy_lm_responses() — new helper that pre-computes the two known dummy LM responses per challenge for filtering.

NTLM_report_auth() — updated to iterate over all returned hashes and write each as a separate database entry.

Documentation — ~500 lines added: module-level docstring with handshake diagram, NumPy-style function docstrings, inline spec references, hashcat format token layouts.

Output

No change to hashcat format strings — the same mode 5500 and 5600 lines are produced, now with additional LMv2 companion hashes captured and bad entries filtered out. All output is directly consumable by modes 5500, 5600, 27000, and 27100.

@StrongWind1 StrongWind1 changed the title Overhaul ntlm.py for Spec-Aligned Hash Extraction [WiP] Overhaul ntlm.py for Spec-Aligned Hash Extraction Feb 25, 2026
@StrongWind1
Copy link
Copy Markdown
Contributor Author

This is a WiP. I confirmed this code works for Vista, Windows 10, and Server 2022 with all LmCompatibilityLevel set from 0 to 5. I will be doing more testing on all Windows OS before asking to merge.

I am trying to test with XP but it is failing due to smb.py not supporting it. See #24
I want to ensure this PR has feature parity with everything from Responder.

@MatrixEditor MatrixEditor added Type - Enhancement Protocol: NTLM Errors/Features related to NTLM labels Feb 25, 2026
@StrongWind1
Copy link
Copy Markdown
Contributor Author

cleaned up the code further. more testing still needed

@StrongWind1 StrongWind1 marked this pull request as ready for review March 5, 2026 05:50
@StrongWind1 StrongWind1 changed the title [WiP] Overhaul ntlm.py for Spec-Aligned Hash Extraction Overhaul ntlm.py for Spec-Aligned Hash Extraction Mar 5, 2026
@StrongWind1
Copy link
Copy Markdown
Contributor Author

Hello @MatrixEditor, This PR is ready for a review. There is some additional work on the SMB server side of things but NTLM is done and compliant.

Key improvements in the PR include:

  • Correct NTLM Versioning: Now uses payload length as the sole, reliable discriminator between NTLMv1 and NTLMv2.
  • Multi-Hash Extraction: The new NTLM_AUTH_to_hashcat_formats() correctly extracts both the NTLMv2 hash and its LMv2 companion from a single AUTHENTICATE_MESSAGE.
  • Intelligent Filtering: Actively filters out "dummy" hashes and duplicates to reduce capture noise.
  • Maximized LMv2 Capture: By omitting MsvAvTimestamp from the challenge, modern Windows clients will now correctly send the LMv2 response.
  • Configuration Overhaul: Added disable_ntlmv2 and inverted disable_ess for more explicit control over protocol negotiation.

The changes have been tested with smbclient across its various NTLMSSP options and all tests are passing. All captured hashes with smbclient crack with hashcat.

@MatrixEditor MatrixEditor self-requested a review March 5, 2026 10:00
@MatrixEditor
Copy link
Copy Markdown
Owner

MatrixEditor commented Mar 6, 2026

Hi, @StrongWind1 ,

thank you so much for reworking the NTLM core of Dementor. I will get back to the review as soon as possible, so a new version can be finalized.

@StrongWind1
Copy link
Copy Markdown
Contributor Author

Hi @MatrixEditor ,

Please see this comment for a clearer overview of the changes and improvements in this PR, along with the reasoning behind them.

#22 (comment)

Copy link
Copy Markdown
Owner

@MatrixEditor MatrixEditor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @StrongWind1,

I've finished the review - only minimal comments, nothing huge. If you want to apply additional changes before merging this request, please so let me know.

Comment thread docs/source/compat.rst Outdated
Comment thread pyproject.toml Outdated
Comment thread docs/source/compat.rst Outdated
Comment thread docs/source/compat.rst Outdated
Comment thread dementor/protocols/ntlm.py
Comment thread dementor/protocols/ntlm.py Outdated
Comment thread dementor/protocols/ntlm.py Outdated
Comment thread dementor/protocols/ntlm.py Outdated
Comment thread dementor/protocols/ntlm.py Outdated
Comment thread dementor/protocols/ntlm.py Outdated
@StrongWind1
Copy link
Copy Markdown
Contributor Author

Let me know if you any other comments!

Copy link
Copy Markdown
Owner

@MatrixEditor MatrixEditor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Will be merged if you have no further additions.

@StrongWind1
Copy link
Copy Markdown
Contributor Author

No further additions for now! Go ahead and merge.

@MatrixEditor MatrixEditor merged commit f63df54 into MatrixEditor:master Mar 8, 2026
@StrongWind1 StrongWind1 deleted the update/ntlm branch March 9, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Protocol: NTLM Errors/Features related to NTLM Type - Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overhaul ntlm.py, Spec-Aligned Hash Extraction and Additional Improvements

2 participants