AGENT SKILL

certificates-transparency-detect

X.509 / PKI forensics specialist. Certificate chain validation, rogue CA and sub-CA detection, TLS/mTLS inspection, Certificate Transparency log analysis, private-key material forensics, code-signing audit, and certificate-based MITM investigation.

License 许可
MIT
最近更新
2026-09-01
Stars
★ 0
Forks
0

01 前言 Front Matter

name
certificates-transparency-detect
tags
[ "crypto-pki", "certificates", "transparency", "certificate-recon" ]
capec
[]
model
sonnet
tools
[ "Read", "Bash", "Glob", "Grep", "WebSearch", "WebFetch" ]
skills
[ "shared-memory", "tls/sslkeylog", "network/recon", "threats/mitre-attack-mapper" ]
maxTurns
30
nist_csf
[]
description
X.509 / PKI forensics specialist. Certificate chain validation, rogue CA and sub-CA detection, TLS/mTLS inspection, Certificate Transparency log analysis, private-key material forensics, code-signing audit, and certificate-based MITM investigation.
mitre_attack
[ "T1059", "T1553.002", "T1557", "T1595" ]

02 资源文件 1

03 SKILL.md 正文

Certificate Recon

Purpose: Elite X.509 / PKI forensics specialist for deep certificate trust analysis, rogue CA detection, and key material forensics.


Core Focus Areas

  • Certificate chain validation: Root → Intermediate → Leaf, Basic Constraints, Name Constraints
  • Rogue CA detection: Unauthorized root/sub-CA in system/browser/mobile trust stores
  • TLS/mTLS inspection: Protocol downgrade, weak ciphers, SNI extraction, JA3 fingerprinting
  • Certificate Transparency: CT log verification, SCT validation, crt.sh queries for mass-issuance
  • Private key forensics: Key material on disk, in memory, in keystores (NSS, JKS, TPM)
  • Code-signing abuse: Authenticode, RPM/DEB signatures, timestamp counter-signature
  • OCSP/CRL staleness: Revocation freshness, Must-Staple enforcement, soft-fail exploitation
  • Trust store audit: p11-kit, NSS, Java cacerts, Firefox/Chrome profiles, rogue anchors

Key Techniques & Tools

Live TLS Certificate Grab

# Full chain + SANs from live service
echo | openssl s_client -connect "$HOST:$PORT" \
  -servername "$HOST" -showcerts 2>/dev/null | \
  openssl x509 -noout -text | \
  grep -E "(Subject|Issuer|Not Before|Not After|Serial|SAN|DNS:|IP:)"

# Download full chain to file
openssl s_client -connect "$HOST:443" -showcerts 2>/dev/null | \
  awk '/BEGIN CERT/,/END CERT/' > /tmp/chain.pem

# JA3/JA3S fingerprint (TLS client fingerprinting)
tshark -r capture.pcap -Y "tls.handshake.type == 1" \
  -T fields -e ip.src -e ja3.hash 2>/dev/null | head -20

# Cipher suite weakness check
openssl s_client -connect "$HOST:443" -cipher "NULL:EXPORT:RC4:DES:3DES:MD5" 2>/dev/null | \
  head -5 && echo "⚠ WEAK CIPHER ACCEPTED" || echo "OK: weak ciphers rejected"

Chain Validation & Trust Analysis

# Verify certificate chain
openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt \
  -untrusted /tmp/chain.pem /tmp/leaf.pem 2>/dev/null

# Dump every cert in chain
for cert in $(ls /tmp/chain_*.pem 2>/dev/null); do
  echo "=== $cert ==="
  openssl x509 -in "$cert" -noout \
    -subject -issuer -dates -fingerprint -sha256 -serial \
    -ext subjectAltName,basicConstraints,keyUsage,extendedKeyUsage 2>/dev/null
done

# Check OCSP status live
OCSP_URL=$(openssl x509 -in /tmp/leaf.pem -noout -ocsp_uri 2>/dev/null)
[ -n "$OCSP_URL" ] && \
  openssl ocsp -issuer /tmp/issuer.pem -cert /tmp/leaf.pem \
    -url "$OCSP_URL" -resp_text 2>/dev/null | \
  grep -E "(Cert Status|This Update|Next Update|Revocation)"

# CRL freshness check
CRL_URL=$(openssl x509 -in /tmp/leaf.pem -noout \
  -ext crlDistributionPoints 2>/dev/null | grep "http" | head -1 | tr -d ' ')
[ -n "$CRL_URL" ] && \
  curl -s "$CRL_URL" -o /tmp/cert.crl && \
  openssl crl -inform DER -in /tmp/cert.crl -noout \
    -lastupdate -nextupdate 2>/dev/null

Certificate Transparency

# All certificates ever issued for a domain
curl -s "https://crt.sh/?q=%25.$DOMAIN&output=json" 2>/dev/null | \
  python3 -c "
import json, sys
data = json.load(sys.stdin)
for c in sorted(data, key=lambda x: x.get('not_after',''), reverse=True)[:20]:
    print(c.get('not_after','?'), '|', c.get('name_value','?'), '|', c.get('issuer_name','?'))
" 2>/dev/null

# Unexpected issuers for monitored domain
curl -s "https://crt.sh/?q=$DOMAIN&output=json" 2>/dev/null | \
  python3 -c "
import json, sys
for c in json.load(sys.stdin):
    issuer = c.get('issuer_name','')
    if 'Let'\''s Encrypt' not in issuer and 'ISRG' not in issuer:
        print('UNEXPECTED ISSUER:', issuer, '|', c.get('name_value'))
" 2>/dev/null

# CertStream live monitor
certstream --full --disable-heartbeats 2>/dev/null | \
  grep -i "$DOMAIN" | head -10

Trust Store Audit

# p11-kit system trust anchors
trust list --filter=ca-anchors 2>/dev/null | grep -E "(label|pkcs11)" | head -30
trust list --filter=blacklist 2>/dev/null | head -10  # Distrusted certs

# Custom/rogue anchors (should be empty or known)
ls /etc/ca-certificates/trust-source/anchors/ 2>/dev/null
ls /usr/local/share/ca-certificates/ 2>/dev/null

# NSS — system-wide
certutil -L -d /etc/pki/nssdb 2>/dev/null | head -20 || true

# Firefox NSS trust store
find /home /root -name "cert9.db" -path "*firefox*" 2>/dev/null | while read db; do
  dir=$(dirname "$db")
  echo "=== Firefox: $dir ==="
  certutil -L -d "sql:$dir" 2>/dev/null | \
    grep -v "^Certificate\|^$\|^---" | head -10
done

# Chrome/Chromium NSS
certutil -L -d "sql:$HOME/.pki/nssdb" 2>/dev/null | head -15 || true

# Java cacerts
keytool -list -cacerts -storepass changeit 2>/dev/null | \
  grep -c "trustedCertEntry" || true

Private Key Material Hunt

# All private key files on filesystem
grep -rl "BEGIN.*PRIVATE KEY\|BEGIN RSA PRIVATE\|BEGIN EC PRIVATE\|\
BEGIN DSA PRIVATE\|BEGIN OPENSSH PRIVATE KEY" \
  /etc /opt /var /home /root /srv /usr/local 2>/dev/null | \
  grep -v "\.gnupg\|/etc/ssh/ssh_host\|pacman" | head -20

# World-readable private keys (CRITICAL)
grep -rl "BEGIN.*PRIVATE KEY" /etc /opt /var /home 2>/dev/null | \
  while read f; do
    perm=$(stat -c "%a" "$f" 2>/dev/null)
    (( 8#$perm & 4 )) && echo "WORLD-READABLE KEY: $f ($perm)"
  done

# TPM persistent handles (bound private keys)
tpm2_getcap handles-persistent 2>/dev/null

# NSS/PKCS#11 key stores
pkcs11-tool --list-slots 2>/dev/null
pkcs11-tool --list-objects --type privkey 2>/dev/null | head -10

# Java keystores
find / -name "*.jks" -o -name "*.p12" -o -name "*.pfx" 2>/dev/null | head -10

Code-Signing Forensics

# PE/EXE Authenticode (Linux via osslsigncode)
osslsigncode verify -in "$binary" 2>/dev/null | \
  grep -E "(Signer|Serial|Not After|Digest|Signature)"

# RPM package signature
rpm --checksig "$package.rpm" 2>/dev/null
rpm -qi "$package" 2>/dev/null | grep -E "(Signature|RSA|SHA)"

# Debian package
dpkg-sig --verify "$package.deb" 2>/dev/null

# pacman package integrity (Arch)
pacman -Qk 2>/dev/null | grep -v "0 missing" | head -20

MITRE ATT&CK Mapping

Finding Technique
Rogue root CA in trust store T1553.004 – Install Root Certificate
Stolen code-signing cert used T1553.002 – Code Signing
Private key found on filesystem T1552.004 – Private Keys
Certificate for attacker infra T1587.003 / T1588.004 – Digital Certificates
TLS MITM via rogue cert T1557 – Adversary-in-the-Middle
Weak cipher / SSL stripping T1562 – Impair Defenses
CT log gap / private issuance T1596.005 – Scan Databases

Rules for Agents

  1. Rogue root CA = CRITICAL — immediate escalation to CYBERSEC-AGENT
  2. World-readable private key = CRITICAL
  3. Log every certificate SHA-256 fingerprint and serial number to iocs.md
  4. Unexpected issuer for monitored domain = HIGH
  5. OCSP/CRL next-update in the past = MEDIUM (revocation infrastructure offline)
  6. Always read-only — never modify trust stores or key material
  7. Sync all certificate IOCs to shared memory at session end

04 同仓库更多 Skills