1---2name: crypto-analysis3description: Use when assessing cryptography — TLS/PKI auditing, RSA/ECC key attacks, ECDSA nonce lattice recovery, symmetric/AEAD misuse, JWT/JOSE forgery, hash cracking, post-quantum migration review4metadata:5 source: https://skillmd.com/skills/hypnguyen1209/crypto-analysis6 type: offensive7 phase: analysis8 tools: testssl.sh, openssl, hashcat, john, RsaCtfTool, sagemath, jwt_tool, ecdsa-lattice9 mitre: [T1600, T1600.001, T1557, T1110.002, T1552.004, T1606.001, T1040]10kill_chain:11 phase: [recon, exploit]12 step: [1, 4]13 attck_tactics: [TA0043, TA0006, TA0009]14 attck_techniques: [T1600, T1600.001, T1557, T1557.001, T1110.002, T1552.004, T1606.001, T1040]15depends_on: [recon-osint]16feeds_into: [exploit-development, web-pentest, network-attack]17inputs: [tls_config, crypto_implementation, hash_samples, public_keys, jwt_tokens, signature_corpus]18outputs: [crypto_weakness_report, finding_record, recovered_keys, cracked_credentials]19references:20 - references/tls-pki-audit.md21 - references/rsa-attacks.md22 - references/ecc-nonce-attacks.md23 - references/symmetric-aead.md24 - references/jwt-jose.md25 - references/hash-pq.md26scripts:27 - scripts/tls_audit.py28 - scripts/rsa_attack.py29 - scripts/ecdsa_lattice.py30 - scripts/padding_oracle.py31 - scripts/gcm_nonce_reuse.py32 - scripts/jwt_forge.py33 - scripts/hash_triage.py34---3536# Cryptographic Analysis3738## When to Activate3940- Auditing TLS/SSL/SSH configurations and X.509 PKI (cipher suites, downgrade, protocol flaws)41- Reviewing crypto implementations in source code or captured traffic42- Attacking weak RSA/ECC keys (CTF and real-world weak-key hygiene)43- Recovering ECDSA/DSA private keys from reused or biased nonces (lattice/HNP)44- Exploiting symmetric/AEAD misuse: padding oracles, GCM nonce reuse, key-commitment45- Forging JWT/JOSE tokens (algorithm confusion, none, jwk/jku/kid injection)46- Cracking password hashes and grading KDF strength47- Assessing post-quantum readiness ("harvest now, decrypt later" exposure)4849## Technique Map5051| Technique | ATT&CK | CWE | Reference | Script |52|-----------|--------|-----|-----------|--------|53| TLS cipher/protocol downgrade audit | T1600.001 | CWE-326 | references/tls-pki-audit.md | scripts/tls_audit.py |54| Terrapin SSH prefix truncation (CVE-2023-48795) | T1557 | CWE-222 | references/tls-pki-audit.md | scripts/tls_audit.py |55| Marvin/Bleichenbacher RSA timing oracle | T1600 | CWE-208 | references/tls-pki-audit.md | scripts/tls_audit.py |56| X.509 / CT-log shadow-asset discovery | T1589 | CWE-295 | references/tls-pki-audit.md | scripts/tls_audit.py |57| RSA weak-key factoring (Fermat/Wiener/common-modulus) | T1600 | CWE-326 | references/rsa-attacks.md | scripts/rsa_attack.py |58| Coppersmith partial-key & ROCA (CVE-2017-15361) | T1600 | CWE-310 | references/rsa-attacks.md | scripts/rsa_attack.py |59| Hastad broadcast / batch-GCD | T1600 | CWE-326 | references/rsa-attacks.md | scripts/rsa_attack.py |60| ECDSA nonce reuse key recovery | T1552.004 | CWE-323 | references/ecc-nonce-attacks.md | scripts/ecdsa_lattice.py |61| Biased-nonce lattice/HNP (Minerva, PuTTY CVE-2024-31497) | T1552.004 | CWE-1241 | references/ecc-nonce-attacks.md | scripts/ecdsa_lattice.py |62| Psychic signature (0,0) (CVE-2022-21449) | T1606.001 | CWE-347 | references/ecc-nonce-attacks.md | scripts/ecdsa_lattice.py |63| CBC padding oracle (byte-by-byte decrypt) | T1040 | CWE-209 | references/symmetric-aead.md | scripts/padding_oracle.py |64| AES-GCM nonce reuse "forbidden attack" | T1040 | CWE-323 | references/symmetric-aead.md | scripts/gcm_nonce_reuse.py |65| AEAD key-commitment / invisible salamanders / partitioning oracle | T1606 | CWE-347 | references/symmetric-aead.md | scripts/gcm_nonce_reuse.py |66| JWT algorithm confusion RS256→HS256 (CVE-2024-54150) | T1606.001 | CWE-347 | references/jwt-jose.md | scripts/jwt_forge.py |67| JWT alg=none / jwk / jku / kid injection | T1606.001 | CWE-347 | references/jwt-jose.md | scripts/jwt_forge.py |68| Hash identification & GPU cracking | T1110.002 | CWE-916 | references/hash-pq.md | scripts/hash_triage.py |69| Weak KDF / fast-hash password storage | T1110.002 | CWE-916 | references/hash-pq.md | scripts/hash_triage.py |70| Post-quantum / HNDL exposure review | T1600 | CWE-327 | references/hash-pq.md | scripts/tls_audit.py |7172## Quick Start7374```bash75# 0. TLS/PKI posture in one shot (downgrade, ROBOT, SWEET32, Terrapin, cert/CT)76python3 scripts/tls_audit.py target.com:443 --ssh target.com:22 --ct --json out.json77testssl.sh --full --robot --sweet32 https://target.com # cross-check with the canonical tool7879# 1. RSA weak-key triage on a captured public key80python3 scripts/rsa_attack.py --pubkey server.pem --ct ciphertext.b64 --auto81# tries Fermat (p~=q), Wiener (small d), batch-GCD/common-modulus, ROCA fingerprint8283# 2. ECDSA key recovery from a signature corpus (reuse or bias)84python3 scripts/ecdsa_lattice.py recover sigs.json --curve secp256r1 --known-msb 485# reuse: needs 2 sigs w/ same r; bias: ~256-1200 sigs depending on leak8687# 3. Symmetric/AEAD misuse88python3 scripts/padding_oracle.py --url https://t/dec --ct $CT --block 16 # CBC oracle89python3 scripts/gcm_nonce_reuse.py forbidden ct1.bin ct2.bin --nonce $N # recover H + forge9091# 4. JWT forgery chain92python3 scripts/jwt_forge.py confusion --pubkey jwt_pub.pem --claims '{"role":"admin"}'93python3 scripts/jwt_forge.py none --claims '{"sub":"admin"}'9495# 5. Hash triage + crack plan96python3 scripts/hash_triage.py hashes.txt # identify + emit hashcat -m / john format97hashcat -m 22000 capture.hc22000 wl.txt -r rules/best64.rule98```99100## OPSEC & Detection (summary)101102| Technique | Telemetry / IOC | Detection (Sigma/EDR) | OPSEC note |103|-----------|-----------------|-----------------------|------------|104| TLS scanning / testssl | Burst of handshakes, many cipher renegotiations, malformed ClientHellos | NIDS: high TLS alert rate from one src; Zeek `ssl.log` anomalous cipher offers | Rate-limit, spread across source IPs; passive cert/CT recon leaves no target-side trace |105| Marvin/ROBOT oracle probing | ~10^4–10^6 RSA decrypts, repeated malformed pre-master/CMS | WAF/IDS: spike of TLS decrypt errors, identical-size payloads | Extremely loud; only against authorized hosts; use minimal query budgets |106| Terrapin MitM | Injected SSH_MSG_IGNORE, sequence-number gap at NEWKEYS | SSH server logs `kex` mismatch; netflow showing on-path device | Requires active MitM; detectable by strict-kex peers; abort if `kex-strict` present |107| ECDSA nonce harvesting | Bulk signature collection (Git, TLS, SSH, blockchain) | Mostly offline — no target telemetry once sigs captured | Collection is passive; recovery is offline; rotate-key advice in report |108| CBC padding oracle | Thousands of decrypt requests, alternating valid/invalid padding | Web logs: ~256×blocks requests to one endpoint; Sigma on 4xx burst | Very noisy (256×blocks×msgs); throttle, randomize timing |109| GCM nonce reuse / partitioning | Repeated (nonce,key) pairs; multi-key ciphertext blobs | App crypto audit; flag reused IVs in logs | Forbidden-attack math is offline once two ciphertexts captured |110| JWT forgery | Anomalous `alg`, external `jku`/`x5u` fetch, all-zero ES signature | Sigma: JWT with `alg:none`/HS after RS expected; egress to attacker JWKS URL | Each forged token is a single request; minimal noise |111| Hash cracking | None on target (offline) | N/A unless online spray (then T1110) | Offline; protect loot at rest; never spray live without scope |112113## Deep Dives114115- **references/tls-pki-audit.md** — TLS/SSL/SSH posture: cipher/protocol downgrade, Terrapin (CVE-2023-48795), Marvin/Bleichenbacher (CVE-2022-4304, CVE-2024-2236), SWEET32/DROWN/Logjam/POODLE, X.509 and Certificate-Transparency analysis.116- **references/rsa-attacks.md** — Weak-key factoring: Fermat, Wiener, common modulus, Hastad broadcast, Coppersmith partial-key, batch-GCD, ROCA (CVE-2017-15361); RsaCtfTool / cado-nfs / SageMath workflow.117- **references/ecc-nonce-attacks.md** — ECDSA/DSA nonce reuse, biased-nonce lattice/HNP recovery (Minerva, PuTTY CVE-2024-31497), invalid-curve attacks, psychic signatures (CVE-2022-21449).118- **references/symmetric-aead.md** — Block-cipher mode misuse: ECB detection, CBC padding oracle, CTR/GCM nonce reuse (forbidden attack), AEAD key-commitment / invisible salamanders / partitioning oracles.119- **references/jwt-jose.md** — JWT/JOSE token forgery: algorithm confusion (CVE-2024-54150), alg=none, jwk/jku/x5u/kid injection, weak-secret cracking, library-level CVE landscape.120- **references/hash-pq.md** — Hash identification, modern GPU cracking economics (RTX 40/50-series), KDF strength grading, and post-quantum migration / "harvest now, decrypt later" assessment (ML-KEM/ML-DSA, hybrid TLS, crypto-agility).