Skip to main content

Overview

The ps command decrypts exported PowerShell PSCredential objects stored in CLIXML format. These files contain DPAPI-encrypted passwords that PowerShell administrators use to store credentials in scripts.
PowerShell’s Export-CLIXML saves PSCredential objects with passwords encrypted using DPAPI, making them portable between sessions but tied to the user account.

Basic Usage

The /target:FILE.xml parameter is required for the ps command. You must specify which credential XML file to decrypt.

Command Arguments

Required Arguments

Decryption Methods

This method works without masterkeys if run from the user context who exported the credential. No LSASS access required!
The /server argument is not applicable to the ps command since you must specify a specific target file.

How PowerShell Credential Export Works

When administrators export PowerShell credentials:
1

Create PSCredential

2

Export to XML

This saves the credential with DPAPI-encrypted password
3

Import for Use

Only works for the user who exported it

Example: Using /unprotect

Output:

Example: Using Masterkey Mappings

Output:

Example: Using Domain Backup Key

Output:

Finding PSCredential XML Files

PowerShell credential files can be anywhere, but common locations include: Script Directories:
Search Commands:
Script Analysis:

Common Scenarios

After obtaining domain backup key:
Analyze scripts to find and decrypt credentials:
Analyzing copied credential files:

Why Administrators Use Credential Export

  • Scheduled tasks requiring credentials
  • Unattended script execution
  • Service account password storage
  • Database connection credentials
  • Deployment scripts
  • Configuration automation
  • Batch operations
  • Remote management tasks
  • Test credentials in development
  • Lab environment automation
  • Demo/training scripts
Storing credentials in CLIXML is convenient but insecure. They’re only as protected as the user’s account.

Detection Considerations

Host-Based Indicators:
  • Reading PowerShell CLIXML files
  • Non-PowerShell processes accessing .xml credential files
  • Enumeration of script directories
  • Pattern matching for PSCredential XML structure
Defensive Monitoring:
  • Monitor access to common script directories
  • Alert on CLIXML file access by suspicious processes
  • Track credential export operations (Export-CLIXML)
  • Detect bulk XML file enumeration
  • Monitor for LSASS access (when not using /unprotect)
PowerShell Logging:

credentials

Decrypt Credential Manager files

blob

Decrypt arbitrary DPAPI blobs

masterkeys

Decrypt user masterkeys

backupkey

Retrieve domain backup key

Tips

  • Search common script directories
  • Look for .ps1 files using Import-CLIXML
  • Check scheduled tasks for PowerShell scripts
  • Examine automation frameworks (Jenkins, Azure DevOps)
  • Review configuration management tools
  • Prefer /unprotect when running as target user
  • Target specific files to avoid bulk enumeration
  • Redirect output to file with /consoleoutfile
  • Clean up temporary files after use
  • Avoid triggering PowerShell logging
Decryption fails with /unprotect:
  • Must run from user context who exported credential
  • Try using masterkeys or backup key instead
  • Verify you’re running as correct user
  • File may be corrupted or invalid format
Invalid XML format:
  • File may not be a PSCredential export
  • Could be different type of XML
  • Verify file contents include DPAPI blob
  • Check for SecureString element in XML
Masterkey GUID not found:
  • Extract masterkey from user’s profile
  • Use domain backup key for decryption
  • Masterkey may have been rotated/deleted