$npx -y skills add meltedinhex/analyst-ai-pack --skill extracting-encryption-keys-from-binariesLocates candidate encryption keys in a binary by finding high-entropy fixed-size
| 1 | # Extracting Encryption Keys From Binaries |
| 2 | |
| 3 | ## When to Use |
| 4 | |
| 5 | - You have a sample with hardcoded crypto and want to surface candidate keys/IVs (16/24/32-byte |
| 6 | high-entropy blocks) and passphrase strings. |
| 7 | - You are recovering material to decrypt config, C2 traffic, or ransomware test vectors. |
| 8 | |
| 9 | **Do not use** entropy alone as proof a region is a key — corroborate with proximity to crypto |
| 10 | constants/APIs and by attempting decryption. This skill reads the binary statically and executes |
| 11 | nothing. |
| 12 | |
| 13 | ## Prerequisites |
| 14 | |
| 15 | - The binary (read inertly). Pairs well with the crypto-constant scanner. |
| 16 | |
| 17 | ## Safety & Handling |
| 18 | |
| 19 | - Read bytes statically; handle recovered keys as sensitive and store securely. |
| 20 | |
| 21 | ## Workflow |
| 22 | |
| 23 | ### Step 1: Find high-entropy key-sized regions |
| 24 | |
| 25 | ```bash |
| 26 | python scripts/analyst.py keys sample.bin |
| 27 | ``` |
| 28 | |
| 29 | Slides a window of 16/24/32 bytes and reports regions whose entropy exceeds a threshold (likely |
| 30 | random key material), with offsets. |
| 31 | |
| 32 | ### Step 2: Surface printable secrets |
| 33 | |
| 34 | Extract printable strings that look like passphrases/hex keys (e.g., 32/64-hex, base64 of 16/32 |
| 35 | bytes). |
| 36 | |
| 37 | ### Step 3: Corroborate |
| 38 | |
| 39 | Rank candidates by proximity to crypto constants/API references and confirm by decrypting a known |
| 40 | ciphertext. |
| 41 | |
| 42 | ### Step 4: Document |
| 43 | |
| 44 | Record candidate keys, sizes, offsets, and the corroborating evidence. |
| 45 | |
| 46 | ## Validation |
| 47 | |
| 48 | - Candidate regions are exactly key-sized (16/24/32 bytes) and high-entropy. |
| 49 | - Hex/base64 key strings are length-consistent with a real key size. |
| 50 | - A candidate is confirmed only by successful decryption, not entropy alone. |
| 51 | |
| 52 | ## Pitfalls |
| 53 | |
| 54 | - Compressed/packed data producing many false high-entropy regions — unpack first. |
| 55 | - Keys derived at runtime (KDF) not present statically. |
| 56 | - Endianness/encoding of the key (raw vs hex vs base64) before use. |
| 57 | |
| 58 | ## References |
| 59 | |
| 60 | - See [`references/api-reference.md`](references/api-reference.md) for the extractor. |
| 61 | - FIPS 197 and ATT&CK T1573 (linked in frontmatter). |