Skip to content

Fixing KDC_ERR_S_UNKNOWN_PRINCIPAL in case of NTLM restriction for WS2025 - #1347

Draft
XedSama wants to merge 2 commits into
Pennyw0rth:mainfrom
XedSama:fix-1312-kdc-ws2025
Draft

Fixing KDC_ERR_S_UNKNOWN_PRINCIPAL in case of NTLM restriction for WS2025#1347
XedSama wants to merge 2 commits into
Pennyw0rth:mainfrom
XedSama:fix-1312-kdc-ws2025

Conversation

@XedSama

@XedSama XedSama commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR resolves issue #1312 by adding support for the rate-limiting introduced by WS2025 to the enum_host_info and _is_dc_via_smb functions.

During the null auth at the start of the enum_host_info function, the NetBIOSTimeout exception is not handled correctly. Whilst the null_auth variable is correctly set to False, this is not the case for no_ntlm, which distorts the detection later in the function.

The ntlm_probe_failed variable effectively detects whether rate limiting is in place; it also reroutes the _is_dc_via_smb function and sets no_ntlm to true.

Finally, the aggressive check conditions for DC detection have been extended to include the use of the Kerberos flag (-k), which, in the case of rate-limiting and the NTLM protocol being disabled, still ensures accurate detection.

The quality of the PR is somewhat questionable in my opinion, but after testing, it seems to work quite well and does not introduce any regressions.

Type of change

Insert an "x" inside the brackets for relevant items (do not delete options)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Deprecation of feature or functionality
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dploot, lsassy, etc)
  • This PR was created with the assistance of AI (list what type of assistance, tool(s)/model(s) in the description)

Setup guide for the review

Server : Windows Server 2025
Additional : reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0" /v RestrictReceivingNTLMTraffic /t REG_DWORD /d 2 /f to disable NTLM traffic

Screenshots (if appropriate):

image

Checklist:

Insert an "x" inside the brackets for completed and relevant items (do not delete options)

  • I have ran Ruff against my changes (poetry: poetry run ruff check ., use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary (new modules or features are required to be added to the e2e tests)
  • If reliant on changes of third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have linked relevant sources that describes the added technique (blog posts, documentation, etc)
  • I have performed a self-review of my own code (not an AI review)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)

@XedSama

XedSama commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

I think it’s best not to use the increase_auth_timeout function for null auth and guest auth, as this would increase the detection time, even though it means we lose some visibility into these two indicators.

Comment thread nxc/protocols/smb.py
self.logger.debug("NTLM not supported")

aggressive_check = bool(self.args.generate_hosts_file or self.args.generate_krb5_file)
aggressive_check = bool(self.args.generate_hosts_file or self.args.generate_krb5_file or self.kerberos)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i don't understand or self.kerberos ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The aggressive check was only enabled when the --generate-krb5-file and --generate-hosts-file arguments were used. I think it should also be enabled when the -k/--kerberos argument is used.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's a deliberate choice to avoid noise and agressive check, it's even more important behind a proxychains

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I hadn’t actually taken Proxychains into account. As for the noise, I’m well aware of it, but it seems less of a problem to me than having to wait for a response after the 2-second rate limit. However, I think we could use the _is_dc_via_kerberos function first, before the _is_dc_via_rpc function, as the former is less noisy than the latter.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i see your point, but it could be the subject of another pr, let me check

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice ! I'll edit my PR to take this in account and not make a duplicate

@XedSama XedSama Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure what would be a good solution to accurately detect that NTLM is disabled for rate-limited WS2025. Adding increase_auth_timeout() works like a charm but it make the null probe at least 2s long, which seems very hard to accept.

@NeffIsBack

Copy link
Copy Markdown
Member

Hey everyone, what's the state of this PR? Was the original issue solved by #1351?

@XedSama

XedSama commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Not entirely, as it is still not possible to determine with certainty whether NTLM is disabled when rate limiting is in place. I won’t be able to work on it this week, but I plan to get back to it as soon as possible.

@NeffIsBack

Copy link
Copy Markdown
Member

Sounds good. Ima turn it into a draft then so I see that this is not ready for a review then. Just press the "ready for review" button if I should take a look at it.

@NeffIsBack
NeffIsBack marked this pull request as draft August 16, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants