Skip to content

Added Shadow Credentials Module#1234

Open
SoftAndoWetto wants to merge 1 commit into
Pennyw0rth:mainfrom
SoftAndoWetto:feature/shadow-credentials
Open

Added Shadow Credentials Module#1234
SoftAndoWetto wants to merge 1 commit into
Pennyw0rth:mainfrom
SoftAndoWetto:feature/shadow-credentials

Conversation

@SoftAndoWetto
Copy link
Copy Markdown

Description

Adds a new LDAP module shadow-creds that automates the Shadow Credentials attack against Active Directory targets.

The module writes a key credential to the target account's msDS-KeyCredentialLink attribute via LDAP, then exports a PFX certificate for use with certipy-ad to perform PKINIT authentication and retrieve an NT hash.

Key features:

  • Auto-generates a random 24-character PFX password if one is not supplied
  • Hybrid PFX path resolution (exact path + glob fallback) to handle pywhisker suffix behaviour
  • Thin logger adapter routing pywhisker output through nxc's logger, with access-denied and user-not-found signals surfaced cleanly
  • Patches impacket's LDAPConnection.__init__ to drop the unsupported signing kwarg present in newer builds

Dependencies:

  • pywhisker (pip: pywhisker)
  • impacket

AI assistance: Initial module structure and logger adapter were drafted with assistance from Claude (Anthropic). All logic was reviewed, tested, and modified manually..


Type of change

  • 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) — requires pywhisker
  • This PR was created with the assistance of AI — Claude (Anthropic), used for initial scaffolding and comment style. Logic reviewed and tested manually.

Setup guide for the review

Local environment:

  • OS: Kali Linux (rolling)
  • Python: 3.11
  • NetExec installed via pipx / dev clone

Target:

  • Windows Server 2019 (Build 17763)
  • Domain: enclave.local
  • DC IP: tested against a local lab DC

Dependencies to install:

pip install pywhisker

To test the full module:

nxc ldap <dc_ip> -u <user> -p <pass> -M shadow-creds -o TARGET=<samaccountname>

# Authenticate with the resulting PFX
certipy-ad auth -pfx /tmp/nxc_shadow/<target>.pfx -password <auto-generated>

Note: The attacking account requires GenericWrite or GenericAll over the target, or explicit write access to msDS-KeyCredentialLink. The DC must support PKINIT (i.e. have a CA or support Windows Hello for Business key trust).


Screenshots

Success:
Success
Output:
Output

Fail:
Fail
Invalid Permissions:
Invalid Permissions
Invalid Name:
Invlaid Name


Checklist

@SoftAndoWetto
Copy link
Copy Markdown
Author

I also have a module for performing Unpac-The-Hash off of this that I am looking at add after this and am looking to create an additional third module replicating the ShadowSpray tool (Link: https://github.com/Dec0ne/ShadowSpray/) but am unsure if this is something you would want in NetExec

@NeffIsBack
Copy link
Copy Markdown
Member

Thanks for the PR, but unfortunately this is duplicate to #936

@NeffIsBack NeffIsBack added the duplicate This issue or pull request already exists label May 7, 2026
@NeffIsBack
Copy link
Copy Markdown
Member

I also have a module for performing Unpac-The-Hash off of this that I am looking at add after this and am looking to create an additional third module replicating the ShadowSpray tool (Link: https://github.com/Dec0ne/ShadowSpray/) but am unsure if this is something you would want in NetExec

Definitely looks interesting, although I would need to take a closer look at that to be able to properly say something about it. At the end, isn't at least ShadowSpray covered when we have a ShadowCredentials module?

@SoftAndoWetto
Copy link
Copy Markdown
Author

I also have a module for performing Unpac-The-Hash off of this that I am looking at add after this and am looking to create an additional third module replicating the ShadowSpray tool (Link: https://github.com/Dec0ne/ShadowSpray/) but am unsure if this is something you would want in NetExec

Definitely looks interesting, although I would need to take a closer look at that to be able to properly say something about it. At the end, isn't at least ShadowSpray covered when we have a ShadowCredentials module?

ShadowSpray works by taking 1 input account and recursively adding shadow credentials to all possible accounts and authenticating with those discovered accounts and continuing the spray
"
Login to the domain with the supplied credentials (Or use the current session).
Check that the domain functional level is 2016 (Otherwise stop since the Shadow Credentials attack won't work)
Gather a list of all the objects in the domain (users and computers) from LDAP.
For every object in the list do the following:
Try to add KeyCredential to the object's "msDS-KeyCredentialLink" attribute.
If the above is successful, use PKINIT to request a TGT using the added KeyCredential.
If the above is successful, perform an UnPACTheHash attack to reveal the user/computer NT hash.
If --RestoreShadowCred was specified: Remove the added KeyCredential (clean up after yourself...)
If --Recursive was specified: Do the same process using each of the user/computer accounts we successfully owned.
"

@SoftAndoWetto
Copy link
Copy Markdown
Author

Thanks for the PR, but unfortunately this is duplicate to #936

Apologies I didn't see this module in the latest version and didn't know it had been made. Also if needed aspects of my code can be added to the module that will come in the update as well that's completely fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants