-d is ignored for database credentials (-id), regression from login rewrite
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- authentication, security
Research direction
Read query_db_creds() in nxc/connection.py (around lines 340-346), then compare it with parse_credentials() in the same file and with the removed logic under git show 9d158f84. Restore the three branches: -d overrides the DB domain, --local-auth overrides both, and an empty DB domain falls back to the target domain. Done when nxc smb <target> -id 5 -d other.local authenticates as other.local\user, covered by a unit test on the credential-building path.
Written by the indexing model from the issue text.
Description
Describe the bug
When credentials are pulled from the database with -id, the -d / --domain flag is ignored. Each credential is always tried against the domain stored in its DB row, so you can no longer reuse a stored user/hash against a different domain with something like -id 5 -d other.local.
This used to work. The old CrackMapExec login loop overrode the DB domain before authenticating:
if not domain:
domain = self.domain
if self.args.local_auth:
domain = self.domain
elif self.args.domain:
domain = self.args.domain
Commit 9d158f84 ("Reimplement get_credentials for login", April 2023) moved DB credential handling into query_db_creds() and dropped these branches. query_db_creds() now appends the DB domain as-is:
https://github.com/Pennyw0rth/NetExec/blob/89d25017/nxc/connection.py#L340-L346
Credentials given with -u are unaffected because parse_credentials() still falls back to self.args.domain.
To Reproduce
- Have a credential in the nxcdb, e.g. ID 5 =
domain-a.local\\userwith an NT hash. - Run:
nxc smb <target-in-domain-b> -id 5 -d domain-b.local - The login is attempted as
domain-a.local\\user, notdomain-b.local\\user.
Expected behavior
-d overrides the domain stored with DB credentials, as it did before the login rewrite. The removed code also had two related behaviors that are likely worth restoring together:
--local-authtakes precedence over both-dand the DB domain.- A DB credential with an empty domain falls back to the target's domain.
Workaround
Pass the secret directly instead of using -id: -u user -H <hash> -d domain-b.local.
NetExec info
- OS: macOS 27.3
- Version of nxc: 1.5.1 - Yippie-Ki-Yay - cd599504 - 540
- Installed from: github. Code path also confirmed unchanged on current main (89d25017).
Additional context
The root cause was identified by reading the code and git history (with AI assistance), and the regression commit was confirmed with git show 9d158f84. Happy to submit a PR restoring the override logic with a unit test.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 803
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 23
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Pennyw0rth/NetExec
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Pennyw0rth/NetExec#1542 ·
Maintainers usually reply within 1 day
-
dependencies
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Pennyw0rth/NetExec#1198 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 22/100
Pennyw0rth/NetExec#1502 · 1 reaction ·
Maintainers usually reply within 1 day
-
Speed improvements tracking (load time, exec waits, Kerberos)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 5/5 Over a week Newbie friendliness 12/100
Pennyw0rth/NetExec#1478 ·
Maintainers usually reply within 1 day
-
Users-export flag does not honor active-users flagPossibly taken @H1DroZz claimed this 287 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 32/100
Pennyw0rth/NetExec#1458 · 3 comments ·
Maintainers usually reply within 1 day
All issues in Pennyw0rth/NetExec
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
ActivityWatch/docs#223 ·
-
[Bug]: OpenCode v2 skips an assistant message that gains text after an earlier capturePossibly taken @jianyx1 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
volcengine/OpenViking#8354 ·
Maintainers usually reply within 1 day
-
comp/tools P2 tool/skills type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#159541 ·
Maintainers usually reply within 1 day
-
bot-triaged module: correctness (silent) module: cpu module: empty tensor module: loss triage review
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
request-theme
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
LizardByte/ThemerrDB#10167 · 1 comment ·