Skip to content

fix(mssql): handle TDS error when NTLM challenge absent and fix local-auth flow#1183

Merged
NeffIsBack merged 10 commits intoPennyw0rth:mainfrom
azoxlpf:fix/mssql-integrated-auth-tds-error-handling
Apr 6, 2026
Merged

fix(mssql): handle TDS error when NTLM challenge absent and fix local-auth flow#1183
NeffIsBack merged 10 commits intoPennyw0rth:mainfrom
azoxlpf:fix/mssql-integrated-auth-tds-error-handling

Conversation

@azoxlpf
Copy link
Copy Markdown
Contributor

@azoxlpf azoxlpf commented Mar 31, 2026

Description

Fixes #1065: when the server answers the integrated LOGIN7 with a TDS error instead of NTLM, we no longer call parse_challenge() on that data (no more crash). We log a short message and still finish host setup so SQL auth with --local-auth works. Tested against MSSQL on Debian where integrated Windows auth is not available. Parsing is minimal not a full TDS error decode just enough to avoid the exception.

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

install mssql server on debian with docker :

docker run -e "ACCEPT_EULA=Y"  -e "MSSQL_SA_PASSWORD=Password123!"  -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server:2022-latest

Screenshots (if appropriate):

Before :

image

After :

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)

@NeffIsBack NeffIsBack added the bug-fix This Pull Request fixes a bug label Mar 31, 2026
@NeffIsBack
Copy link
Copy Markdown
Member

Thanks for the bug fix PR!

@NeffIsBack
Copy link
Copy Markdown
Member

Shouldn't we properly parse the message tho? Do you know what exactly the structure is? Then we could probably just parse it with impacket.

@azoxlpf
Copy link
Copy Markdown
Contributor Author

azoxlpf commented Apr 1, 2026

Shouldn't we properly parse the message tho? Do you know what exactly the structure is? Then we could probably just parse it with impacket.

The integrated-auth failure path now pulls MsgText with Impacket’s TDS_INFO_ERROR (scan for 0xAA / 0xAB in the LOGIN7 response, full packet then the legacy [3:] slice). Dropped the manual UTF-16 heuristic. LGTM :

image

Copy link
Copy Markdown
Member

@NeffIsBack NeffIsBack left a comment

Choose a reason for hiding this comment

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

Few small formatting changes left :)

Comment thread nxc/protocols/mssql.py Outdated
Comment thread nxc/protocols/mssql.py Outdated
Comment thread nxc/protocols/mssql.py Outdated
Comment thread nxc/protocols/mssql.py
Copy link
Copy Markdown
Member

@NeffIsBack NeffIsBack left a comment

Choose a reason for hiding this comment

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

Fyi, added a NTLM:False banner as this is more accurate imo. LGTM:
Image

@NeffIsBack NeffIsBack merged commit 67d90e0 into Pennyw0rth:main Apr 6, 2026
5 checks passed
@azoxlpf azoxlpf deleted the fix/mssql-integrated-auth-tds-error-handling branch April 7, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix This Pull Request fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mssql protocol crash

2 participants