Skip to main content

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

This command requires elevation (Administrator privileges) to:
  • Elevate to SYSTEM via token duplication
  • Retrieve the DPAPI_SYSTEM LSA secret
  • Access system credential files

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

Output:

Types of Machine Credentials Found

TargetName: Domain:batch=TaskScheduler:Task:{GUID}
  • Credentials for tasks running as specific users
  • Domain and local account passwords
  • Service account credentials
  • Automated job credentials
Why Valuable:
  • Often domain admin or privileged accounts
  • Used for administrative automation
  • Long-lived credentials
Various TargetNames
  • Windows service account passwords
  • Application pool identities
  • Background process credentials
  • System service accounts
Why Valuable:
  • Elevated privileges common
  • Network access credentials
  • Database access accounts
TargetName: Domain:target=TERMSRV/HOSTNAME
  • Saved Remote Desktop passwords
  • System-level RDP credentials
  • Service account RDP access
  • Jump box credentials
Why Valuable:
  • Lateral movement credentials
  • Administrative access
  • Server-to-server connections
TargetName: Various network targets
  • Network share credentials
  • SQL Server connections
  • Web service authentication
  • API credentials
Why Valuable:
  • Network resource access
  • Database credentials
  • Internal service accounts

Common Scenarios

After gaining admin access:
Find and correlate task credentials:
Identify service credentials:
Collect credentials for lateral movement:

Credential Flags

The flags field indicates protection scope:
Machine credentials typically have the CRYPTPROTECT_SYSTEM flag (0x20000000).

Scheduled Task GUID Correlation

Match credential GUIDs to tasks:

Detection Considerations

Machine credential extraction is a high-privilege operation that should trigger security monitoring.
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
Event Log Indicators:
Defensive Monitoring:
  • 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

machinemasterkeys

Extract machine masterkeys first

machinevaults

Decrypt machine vault data

machinetriage

Comprehensive machine DPAPI triage

credentials

Decrypt user credentials

Tips

  • 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
  • Requires elevation (high visibility)
  • SYSTEM privilege elevation generates events
  • LSA secret access triggers alerts
  • Consider timing and detection capabilities
  • May trigger EDR behavioral detections
Access denied:
  • Need Administrator privileges
  • UAC may block elevation
  • Security software may prevent SYSTEM access
  • Try running as SYSTEM directly
No credentials found:
  • System may not have saved machine credentials
  • Credentials may be in vault instead
  • Check ServiceProfiles directories
  • Scheduled tasks may use group policy credentials
Partial decryption:
  • Some credentials may use different masterkeys
  • Verify DPAPI_SYSTEM was retrieved correctly
  • Check all system profile directories

Correlating with System Activity

Scheduled Tasks:
Windows Services:
Process Credentials:

Understanding Credential Context

Machine credentials are saved when:
  1. Scheduled Task Creation:
    • Task configured to run as specific user
    • Password saved in Credential Manager
    • Protected with machine masterkey
  2. Service Installation:
    • Service configured with service account
    • Credentials stored for service startup
    • Machine-scope DPAPI protection
  3. System-Level Operations:
    • Administrative tools saving credentials
    • Backup software credentials
    • Monitoring tools
    • Remote management tools