Overview
The machinecredentials command elevates to SYSTEM, retrieves the DPAPI_SYSTEM LSA secret, decrypts machine masterkeys, and uses them to decrypt all machine-scope Credential Manager files. This reveals credentials for scheduled tasks, services, and system-level saved passwords.Machine credentials are stored in system profile directories and protected with machine-scope DPAPI, containing high-value credentials for scheduled tasks and service accounts.
Basic Usage
How It Works
1
Elevation to SYSTEM
Duplicates a SYSTEM token to elevate privileges
2
DPAPI_SYSTEM Retrieval
Retrieves the DPAPI_SYSTEM LSA secret
3
Masterkey Decryption
Decrypts all machine DPAPI masterkeys using DPAPI_SYSTEM
4
Credential Discovery
Locates machine credential files in system directories
5
Credential Decryption
Decrypts each credential file using machine masterkeys
Credential File Locations
Machine credentials are stored in:Example Output
Types of Machine Credentials Found
Scheduled Task Credentials
Scheduled Task Credentials
TargetName:
Domain:batch=TaskScheduler:Task:{GUID}- Credentials for tasks running as specific users
- Domain and local account passwords
- Service account credentials
- Automated job credentials
- Often domain admin or privileged accounts
- Used for administrative automation
- Long-lived credentials
Service Account Credentials
Service Account Credentials
Various TargetNames
- Windows service account passwords
- Application pool identities
- Background process credentials
- System service accounts
- Elevated privileges common
- Network access credentials
- Database access accounts
RDP Saved Credentials
RDP Saved Credentials
TargetName:
Domain:target=TERMSRV/HOSTNAME- Saved Remote Desktop passwords
- System-level RDP credentials
- Service account RDP access
- Jump box credentials
- Lateral movement credentials
- Administrative access
- Server-to-server connections
Network Authentication
Network Authentication
TargetName: Various network targets
- Network share credentials
- SQL Server connections
- Web service authentication
- API credentials
- Network resource access
- Database credentials
- Internal service accounts
Common Scenarios
Post-Exploitation Credential Gathering
Post-Exploitation Credential Gathering
After gaining admin access:
Scheduled Task Enumeration
Scheduled Task Enumeration
Find and correlate task credentials:
Service Account Discovery
Service Account Discovery
Identify service credentials:
Lateral Movement Preparation
Lateral Movement Preparation
Collect credentials for lateral movement:
Credential Flags
Theflags field indicates protection scope:
| Flag | Value | Description |
|---|---|---|
| CRYPTPROTECT_SYSTEM | 0x20000000 | System credential protection |
| CRYPTPROTECT_UI_FORBIDDEN | 0x1 | No UI prompts allowed |
| CRYPTPROTECT_LOCAL_MACHINE | 0x4 | Machine-scope protection |
Machine credentials typically have the
CRYPTPROTECT_SYSTEM flag (0x20000000).Scheduled Task GUID Correlation
Match credential GUIDs to tasks:Detection Considerations
Host-Based Indicators:- Elevation to SYSTEM privileges
- LSA secret retrieval (DPAPI_SYSTEM)
- Access to system profile credential directories
- Bulk credential file reading
- Token duplication activity
- Monitor SYSTEM token impersonation
- Alert on LSA secret access (DPAPI_SYSTEM)
- Track access to system credential directories
- Detect bulk credential file enumeration
- Monitor SharpDPAPI or similar tool execution
Related Commands
machinemasterkeys
Extract machine masterkeys first
machinevaults
Decrypt machine vault data
machinetriage
Comprehensive machine DPAPI triage
credentials
Decrypt user credentials
Tips
Maximizing Credential Value
Maximizing Credential Value
- Focus on scheduled task credentials (often privileged)
- Correlate task GUIDs with task details
- Test RDP credentials immediately
- Check service account privileges
- Look for domain accounts vs local
OPSEC Considerations
OPSEC Considerations
- Requires elevation (high visibility)
- SYSTEM privilege elevation generates events
- LSA secret access triggers alerts
- Consider timing and detection capabilities
- May trigger EDR behavioral detections
Troubleshooting
Troubleshooting
Access denied:
- Need Administrator privileges
- UAC may block elevation
- Security software may prevent SYSTEM access
- Try running as SYSTEM directly
- System may not have saved machine credentials
- Credentials may be in vault instead
- Check ServiceProfiles directories
- Scheduled tasks may use group policy credentials
- Some credentials may use different masterkeys
- Verify DPAPI_SYSTEM was retrieved correctly
- Check all system profile directories
Correlating with System Activity
Scheduled Tasks:Understanding Credential Context
Machine credentials are saved when:-
Scheduled Task Creation:
- Task configured to run as specific user
- Password saved in Credential Manager
- Protected with machine masterkey
-
Service Installation:
- Service configured with service account
- Credentials stored for service startup
- Machine-scope DPAPI protection
-
System-Level Operations:
- Administrative tools saving credentials
- Backup software credentials
- Monitoring tools
- Remote management tools