offensive-techniques/crypto-technique/SKILL.md
Auth/lab: cryptanalysis methodology; RSA/ECC, PRNG, padding/oracle, symmetric issues, key/ciphertext/signature triage, proof workflow.
npx skillsauth add aeondave/malskill crypto-techniqueInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Goal: help the agent diagnose cryptographic weaknesses, select the right attack, and execute exploitation to recover secrets—keys, plaintexts, random state, or authentication bypasses.
Before attempting attacks, reduce the problem to a concrete primitive and rank the most plausible weaknesses.
cyberchef for fast transform sanity checks, rsactftool for common weak-RSA triage, sagemath for algebraic or lattice work, and Python/pwntools only after the attack shape is clear.Cryptanalysis is a structured diagnosis → decision → execution loop:
Loop:
1. Parse the problem: read source code, dump key/ciphertext, connect to oracle.
2. Extract parameters: key size, exponents, curve equation, moduli, nonce/IV properties.
3. Diagnose weakness category: check parameter tables, structural anomalies, oracle behavior.
4. Select primary attack: consult decision trees in technique references.
5. Prepare exploit: build oracle harness, write solver script, or invoke tool.
6. Execute: measure timing/errors, recover secret, validate correctness.
7. Pivot: escalate to next stage (decrypt file, forge signature, assume compromised identity).
Exit when: plaintext recovered, key material compromised, or service bypassed.
Do not attempt multiple attacks in parallel without first ranking them by signal strength and likelihood.
Parse and extract cryptographic artifacts. Understand the attack surface before selecting tools.
If source is available (Python, OpenSSL, Go), look for:
e in RSA? Weak d values? Nonce reuse in DSA/ECDSA?random.randint() instead of secrets.randbelow()? Biased LFSR?Typical red flags:
random.seed() with predictable value (timestamp, PID).random.randint() for cryptographic operations.Dump and inspect all available cryptographic parameters.
RSA:
e, modulus n, ciphertext c.p, q, d, dp, dq, qinv.n factorable? Is e small? Is d abnormally small?ECC:
p, a, b, base point G, order n.p±1 factor smoothly? Is the curve singular or anomalous?DSA/ECDSA:
(r, s), nonce k, message hash.k? Is k drawn from a small space?Symmetric:
PRNG:
If attacking an oracle service (padding oracle, timing leak, signature verification error):
Load references/oracle-detection-checklist.md before building an oracle exploit; it separates real cryptographic signal from parser, cache, WAF, auth, and network-noise artifacts.
Use offensive-tools/network/* to interact with services; use python-patterns or pwntools for harness scripting.
Classify the problem and match it to a primary attack. Most crypto breaks reduce to:
n or solving DLP → choose based on key structure.If the primitive and anomaly are known but the attack construction is still missing after local tests, load knowledge/known-problem-hint-research.
Use it to find one decisive external hint — a paper, implementation note, technical article, public writeup, or discussion that matches the current fingerprint. Do not use it for broad crypto learning or before problem diagnosis; return with a local test and validation condition.
See references/rsa-technique.md.
Quick triage:
e (3 or 5)? → Try cube/fifth root first.e close to φ(n)? → Wiener's attack likely.n? → Common modulus attack.e? → Hastad broadcast.p-1 or q-1 factor smoothly? → Pollard p-1 or ECM.Tool families:
offensive-tools/cryptography/rsactftool/ — automated attack selection and execution.offensive-tools/cryptography/sagemath/ — lattice-based attacks (Wiener, Boneh-Durfee), custom factorization.offensive-tools/cryptography/sagemath/ — elliptic curve factorization (ECM), finite-field arithmetic, custom number-theory scripts.See references/ecc-technique.md.
Quick triage:
n is smooth? → Pohlig-Hellman reduction.k? → Recover private key directly.k drawn from small space? → Brute force or meet-in-the-middle.Tool families:
offensive-tools/cryptography/sagemath/ — ECDLP solving, singular curve reduction.offensive-tools/cracking/hashcat/ — brute-force nonce spaces if small enough.See references/lattice-lwe-technique.md.
Use lattice techniques when:
d in RSA).Tool families:
offensive-tools/cryptography/sagemath/ — LLL lattice reduction, Coppersmith's method.offensive-tools/cryptography/sagemath/ combined with python-patterns for custom constraint modeling.See references/prng-oracle-technique.md.
Tool families:
offensive-tools/cryptography/sagemath/ — lattice recovery for LCG/LFSR state.offensive-tools/network/* — oracle interaction harness (pwntools, boofuzz).python-patterns for oracle methodology.See references/symmetric-cipher-technique.md.
Tool families:
offensive-tools/cryptography/cyberchef/ — mode-specific decryption workflows, plaintext recovery.See references/dh-technique.md.
Quick triage:
p (< 1024 bits)? → Discrete log via Pohlig-Hellman or index calculus is feasible.p-1 factors smoothly? → Pohlig-Hellman reduction; complexity collapses with small factors.g^a mod p reused across sessions with same p? → Logjam / pre-computation attack.q is small (e.g., p = 2q+1 not satisfied, small subgroup)? → Small subgroup confinement attack.g is not a generator of the full group? → Attacker can confine secrets to a small subgroup.a is recovered.Tool families:
offensive-tools/cryptography/sagemath/ — discrete log solving, Pohlig-Hellman, index calculus for small primes.Use constraint solvers when the problem reduces to a set of equations or logical conditions over unknown variables:
solve_mod() or Gröbner basis.from z3 import *
# Example: recover seed from LCG outputs
seed = BitVec('seed', 32)
s = Solver()
# LCG: state = (a * seed + c) % m
a, c, m = 1664525, 1013904223, 2**32
out1, out2 = 0x12345678, 0x9abcdef0 # known outputs
s.add((a * seed + c) % m == out1)
if s.check() == sat:
print(s.model()[seed])
Tool families:
offensive-tools/cryptography/sagemath/ — algebraic solving, Gröbner basis, polynomial systems.z3 — SMT constraint solving; pip install z3-solver.See references/finite-field-technique.md.
(x_i, y_i) tuples with a stated prime? → Shamir secret sharing → Lagrange interpolation over GF(p) or GF(p^k).degree+1 shares; recover with Sage's lagrange_polynomial().GF(p^k) field; constant term of recovered polynomial is the secret.Tool families:
offensive-tools/cryptography/sagemath/ — Lagrange interpolation, GF(p), GF(p^k) field arithmetic.See references/ransomware-encryption-analysis.md.
Once the attack is selected:
offensive-tools/cryptography/rsactftool/ for automated factorization and decryption.offensive-tools/cryptography/sagemath/ with custom scripts for Coppersmith, LLL, or ECDLP.z3 SMT solver (pip install z3-solver) for bit-vector and integer constraint solving; fall back to SageMath for polynomial systems.offensive-tools/cryptography/sagemath/ or custom brute-force.offensive-tools/cryptography/cyberchef/ for offline workflows; load offensive-tools/cryptography/cyberchef/ Node API for programmatic chaining.| Problem shape | First tool skill | Why |
|---|---|---|
| RSA public key/ciphertext bundle | offensive-tools/cryptography/rsactftool/ | Automates common weak-RSA attacks and factorization checks |
| Lattice, finite field, ECC, DH, custom math | offensive-tools/cryptography/sagemath/ | Algebraic modeling and exact arithmetic |
| Encoding, mode experimentation, byte-level transforms | offensive-tools/cryptography/cyberchef/ | Fast reversible transform chains and visual sanity checks |
| Hash/password recovery | cracking-technique + offensive-tools/cracking/hashcat/ or john/ | Candidate generation and offline cracking strategy |
| Oracle interaction | coding/python-patterns/ + pwntools/socket harness | Repeatable measurements and controls |
references/problem-diagnosis.md — detailed problem reading checklist and parameter extraction.references/rsa-technique.md — RSA weakness diagnosis, attack selection matrix, quick-reference attack conditions.references/ecc-technique.md — ECC and DSA weakness diagnosis, nonce reuse patterns, curve singularity checks.references/lattice-lwe-technique.md — LLL lattice reduction, Coppersmith's method, LWE embedding, constraint modeling.references/prng-oracle-technique.md — PRNG state recovery, oracle timing/error-based methodology, Bleichenbacher/Manger padding oracles.references/oracle-detection-checklist.md — Oracle confirmation workflow: observable channels, timing gates, controls, and exploit-readiness criteria.references/symmetric-cipher-technique.md — ECB, CBC, CTR, and GCM mode weaknesses; plaintext recovery techniques.references/finite-field-technique.md — Shamir secret sharing recovery, Lagrange interpolation over GF(p) and GF(p^k), field extension arithmetic.references/dh-technique.md — Diffie-Hellman weak parameter attacks: small prime, Pohlig-Hellman, small subgroup confinement, logjam, static DH session recovery.references/ransomware-encryption-analysis.md — Malware/ransomware encryption triage: API identification, key hierarchy, file format analysis, memory extraction, and recovery-feasibility assessment.references/problem-diagnosis.md.offensive-tools/cryptography/ to execute.development
Auth/lab ref: Unicorn Engine CPU-only emulation for shellcode, decryptors, custom VM handlers, instruction tracing, memory hooks, and register-level experiments.
development
Auth/lab ref: Renode board and SoC simulation for MCU/RTOS firmware, UART/GPIO/peripheral modeling, GDB remote debugging, REPL platforms, and RESC scripts.
development
Auth/lab ref: Qiling OS-layer binary emulation for PE/ELF/Mach-O/UEFI/shellcode with rootfs, syscall/API hooks, filesystem mapping, and runtime patching.
databases
Auth/lab ref: QEMU user-mode and full-system emulation for cross-arch binaries, firmware, kernels, disks, serial consoles, networking, and GDB stubs.