$npx -y skills add meltedinhex/analyst-ai-pack --skill diffing-malware-samples-to-find-changesCompares two related malware samples to surface what changed between variants using
| 1 | # Diffing Malware Samples to Find Changes |
| 2 | |
| 3 | ## When to Use |
| 4 | |
| 5 | - You have two related samples (suspected variants of one family) and want a fast, structural diff |
| 6 | before a full BinDiff. |
| 7 | - You need to quantify similarity and pinpoint changed sections/imports for variant tracking. |
| 8 | |
| 9 | **Do not use** this as authoritative function-level diffing — that requires BinDiff/Diaphora on |
| 10 | disassembly. This skill does structural/statistical diffing and executes nothing. |
| 11 | |
| 12 | ## Prerequisites |
| 13 | |
| 14 | - Two sample files (read inertly). Optional: `ssdeep`/`tlsh` for fuzzy scores (degrade gracefully). |
| 15 | |
| 16 | ## Workflow |
| 17 | |
| 18 | ### Step 1: Structural diff |
| 19 | |
| 20 | ```bash |
| 21 | python scripts/analyst.py diff a.bin b.bin |
| 22 | ``` |
| 23 | |
| 24 | Compares file size, per-section SHA-256 and entropy, and the import name sets, reporting added/ |
| 25 | removed/changed sections and imports. |
| 26 | |
| 27 | ### Step 2: Similarity score |
| 28 | |
| 29 | Reports a byte-level similarity ratio and, if available, ssdeep/tlsh fuzzy-hash comparison scores. |
| 30 | |
| 31 | ### Step 3: Prioritize changed regions |
| 32 | |
| 33 | Changed sections (same name, different hash) and new imports are the high-value targets for deeper |
| 34 | disassembly diffing. |
| 35 | |
| 36 | ### Step 4: Document |
| 37 | |
| 38 | Record what changed and the similarity score to support variant/lineage tracking. |
| 39 | |
| 40 | ## Validation |
| 41 | |
| 42 | - Section comparison keys on section name; identical sections report equal hashes. |
| 43 | - Import diff lists are accurate (added vs removed vs common). |
| 44 | - Fuzzy-hash scores are reported only when the library is available, else clearly omitted. |
| 45 | |
| 46 | ## Pitfalls |
| 47 | |
| 48 | - Recompilation shifting addresses makes raw byte diff noisy — rely on section/import structure. |
| 49 | - Packers making both samples look similar (packed) while the payloads differ — unpack first. |
| 50 | - Treating a high byte-similarity as proof of same author without corroboration. |
| 51 | |
| 52 | ## References |
| 53 | |
| 54 | - See [`references/api-reference.md`](references/api-reference.md) for the differ. |
| 55 | - PE format and ssdeep references (linked in frontmatter). |