Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SystemDPAPIdump.py example #1137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clavoillotte
Copy link

This PR adds a new example, SystemDPAPIdump.py, which automates extraction of DPAPI credentials for the SYSTEM user on a remote host.

Currently it extracts and decrypts DPAPI credentials files (used by the task scheduler, amongst others) and SCCM client credentials (following @gentilkiwi's publication and implementation), using a combination of WMI (SCCM), SMB client (retrieve files) and remote registry (retrieve DPAPI keys) features from the library.

Process:

  • list and retrieve SCCM client secrets using WMI
  • list and retrieve DPAPI credential files from the SYSTEM user profile using SMB
  • parse retrieved credentials to obtain a list of masterkeys required for decryption
  • retrieve required masterkey files using SMB
  • dumps LSA Secrets to obtain dpapi_userkey (unless provided with -userkey, e.g. when previously obtained)
  • cleanup (end of remote operations)
  • decrypt masterkeys using dpapi_userkey
  • decrypt credentials/secrets using masterkeys

Has some error management to attempt cleanup even if something goes wrong, and tries to not perform unneeded operations.
Reuses code from secretsdump.py, wmiquery.py, dpapi.py, and smbclient.py.

@mpgn
Copy link
Contributor

mpgn commented Aug 3, 2021

Hello,

Quick question, why SYSTEM instead of the current user used to log to the target ? My idea, the probability of using DPAPI is more in favor of the user instead of SYSTEM no ?

Sorry, it was about SCCM, my bad :)

@clavoillotte
Copy link
Author

Hi,

The initial use case for this script was dumping scheduled tasks credentials, which are stored in the SYSTEM user profile. I added SCCM when gentilkiwi published his code as the requirements are close enough.
The idea was to dump what we can remotely with only local admin access and no code execution, but if you also have user credentials (or are willing to execute code on that host), you could certainly do something similar with user secrets as well.

@alexisbalbachan alexisbalbachan added the low Low priority item label Feb 2, 2023
GeisericII added a commit to ThePorgs/impacket that referenced this pull request Jun 3, 2024
Mercury0 added a commit to Mercury0/impacket that referenced this pull request Sep 11, 2024
Automates extraction of DPAPI credentials for SYSTEM user on remote host.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low Low priority item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants