-d is ignored for database credentials (-id), regression from login rewrite

Open Beginner friendly
#1,544 0 comments 0 reactions 0 assignees View on GitHub

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

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

  1. Have a credential in the nxcdb, e.g. ID 5 = domain-a.local\\user with an NT hash.
  2. Run: nxc smb <target-in-domain-b> -id 5 -d domain-b.local
  3. The login is attempted as domain-a.local\\user, not domain-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-auth takes precedence over both -d and 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Pennyw0rth/NetExec

All issues in Pennyw0rth/NetExec

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.