Skip to content

fix(mssql): handle NoneType in rid_brute when SUSER_SNAME returns NULL - #1534

Closed
JordaoMbambu wants to merge 1 commit into
Pennyw0rth:mainfrom
JordaoMbambu:fix/mssql-rid-brute-nonetype
Closed

JordaoMbambu wants to merge 1 commit into
Pennyw0rth:mainfrom
JordaoMbambu:fix/mssql-rid-brute-nonetype

Conversation

@JordaoMbambu

Copy link
Copy Markdown

Description

Fixes #1533

When running --rid-brute against an MSSQL target using a SQL login (not a Windows/domain account), NetExec crashes with AttributeError: 'NoneType' object has no attribute 'split' at mssql.py:480.

The root cause: SUSER_SNAME() returns NULL for RIDs that don't resolve to any account. Python receives this as None (not the string "NULL"), so the existing if username == "NULL": continue check never matches, and the code reaches line 480 where .split("\\") is called on None → crash.

The fix adds a null check before splitting: if username is None or doesn't contain a backslash, return it as-is instead of crashing.

No dependencies required.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This PR was created with the assistance of AI (Claude Sonnet 4.6 via claude.ai , used to write professionally and identify the root cause. Code review and validation were conducted manually.)

Setup guide for the review

Target: Windows Server 2022, MSSQL (SQL Server 2019 RTM 15.0.2000)

How to trigger the bug:

  1. Connect to an MSSQL instance using a pure SQL login (not a Windows/domain account)
  2. Run: nxc mssql <IP> --local-auth -u <sql_user> -p <password> --rid-brute
  3. The first RIDs (0-499) return NULL from SUSER_SNAME() → crash at mssql.py:480

After the fix:

  • Unresolved RIDs are skipped cleanly
  • Domain users are enumerated correctly from RID 500+

Screenshots

Before: crash on first NULL RID:

verbose_error

The fix in mssql.py:

before_after_changing

After : NULL RIDs skipped, brute force continues:

None

After with | grep -v None domain users enumerated correctly:

rid_brute_working

Checklist

  • I have ran Ruff against my changes
  • I have added or updated the tests/e2e_commands.txt file if necessary
  • 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
  • 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)

@mpgn

mpgn commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR! This is already fixed on main by #1295: rid_brute() skips None before the split (mssql.py#L487-L488), so this check is never reached. Your traceback (split on line 480) comes from an older nxc build (f6b0896) that predates this fix, so updating your nxc install is enough. I think we can close this PR and #1533.

@NeffIsBack

Copy link
Copy Markdown
Member

@mpgn you are right, completely missed that. Closing now

@JordaoMbambu

Copy link
Copy Markdown
Author

Thanks @mpgn and @NeffIsBack, makes sense!

FYI I did check I was on the latest version, I'm on the Exegol free image which says it's up to date. Turns out it was built just before #1295 got merged, so the fix isn't in there yet. Might be worth knowing if other Exegol users report the same thing.

Really appreciate you both taking the time to look into it, even though it ended up being a duplicate :)

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.

[MSSQL] rid_brute crashes with AttributeError when SUSER_SNAME returns NULL (SQL login)

3 participants