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
Command Arguments
Required Arguments
| Argument | Description |
|---|---|
/target:FILE.xml | Required - Path to PSCredential CLIXML file |
Decryption Methods
- CryptUnprotectData
- Domain Backup Key
- Masterkey Mappings
- User Credentials
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
3
Import for Use
Example: Using /unprotect
Example: Using Masterkey Mappings
Example: Using Domain Backup Key
Finding PSCredential XML Files
PowerShell credential files can be anywhere, but common locations include: Script Directories:Common Scenarios
Unprivileged Execution (Recommended)
Unprivileged Execution (Recommended)
Run as the user who created the credential:Benefits:
- No LSASS access required
- No elevation needed
- Minimal detection footprint
Post-Domain Compromise
Post-Domain Compromise
After obtaining domain backup key:
Script Analysis Workflow
Script Analysis Workflow
Analyze scripts to find and decrypt credentials:
Offline/Forensic Analysis
Offline/Forensic Analysis
Analyzing copied credential files:
Why Administrators Use Credential Export
Automation Scripts
Automation Scripts
- Scheduled tasks requiring credentials
- Unattended script execution
- Service account password storage
- Database connection credentials
Configuration Management
Configuration Management
- Deployment scripts
- Configuration automation
- Batch operations
- Remote management tasks
Development/Testing
Development/Testing
- Test credentials in development
- Lab environment automation
- Demo/training scripts
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
- 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)
Related Commands
credentials
Decrypt Credential Manager files
blob
Decrypt arbitrary DPAPI blobs
masterkeys
Decrypt user masterkeys
backupkey
Retrieve domain backup key
Tips
Finding Credentials
Finding Credentials
- 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
OPSEC Considerations
OPSEC Considerations
- Prefer
/unprotectwhen 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
Troubleshooting
Troubleshooting
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
- 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
- Extract masterkey from user’s profile
- Use domain backup key for decryption
- Masterkey may have been rotated/deleted