hypnguyen1209/offensive-claude / skills/malware-analysis
malware-analysis
UnverifiedUse when reverse-engineering or detecting malware — static triage + capa/YARA-X, emulation/DBI/.NET unpacking, dynamic/fileless/Volatility 3 memory analysis, C2 config extraction (Cobalt Strike/CAPE), C2 traffic detection (JA4+, beaconing)
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.0 KB |
| references/config-c2-extraction.md | markdown | 7.6 KB |
| references/dynamic-fileless-memory.md | markdown | 7.9 KB |
| references/network-c2-detection.md | markdown | 6.8 KB |
| references/static-triage-capa.md | markdown | 7.2 KB |
| references/unpacking-deobfuscation.md | markdown | 7.8 KB |
| references/yara-detection-engineering.md | markdown | 6.5 KB |
| scripts/auto_unpack.py | script | 6.8 KB |
| scripts/beacon_profiler.py | script | 4.6 KB |
| scripts/cs_config_extract.py | script | 5.0 KB |
| scripts/frida_unpack.js | script | 4.5 KB |
| scripts/mem_triage.py | script | 6.0 KB |
| scripts/triage.py | script | 9.0 KB |
| scripts/yara_gen.py | script | 5.9 KB |
scripts/frida_unpack.js
View on GitHub/*
* frida_unpack.js - Dynamic unpacking via API hooks (DBI approach).
*
* Hooks the memory-write + execute-transition APIs every runtime packer must use,
* and dumps each RWX/executable region the moment it is filled. Complements the
* static emulator (auto_unpack.py): use this when emulation fails (VM-protected,
* API-heavy, or .NET loaders) but you can detonate in an isolated VM.
*
* USAGE (isolated, snapshotted analysis VM, no real network):
* frida -f C:\sample.exe -l frida_unpack.js --no-pause
* # dumps land in the sample's working dir as dump_<addr>_<size>.bin
*
* Captures:
* - VirtualAlloc / VirtualAllocEx returns (tracks RWX allocations)
* - VirtualProtect transitions to PAGE_EXECUTE_* (unpack stub flips perms)
* - WriteProcessMemory (self/remote injection target)
* - LdrLoadDll (manual-mapped / reflective DLL loads)
* - .NET: System.Reflection.Assembly.Load(byte[]) via CLR (if managed)
*
* DEPENDENCIES: frida-tools (pip install frida-tools). Tested on Frida 16/17.
* OPSEC: this DETONATES the sample. Use a throwaway VM + INetSim/FakeNet, snapshot
* first, no internet routing.
*/
'use strict';
const PAGE_EXEC = 0x10 | 0x20 | 0x40 | 0x80; // EXECUTE | EXECUTE_READ | EXECUTE_READWRITE | EXECUTE_WRITECOPY
const tracked = {}; // base -> size
const dumped = new Set();
function isPE(ptr) {
try {
if (ptr.readU16() !== 0x5A4D) return false; // 'MZ'
const lfanew = ptr.add(0x3C).readU32();
if (lfanew <= 0 || lfanew > 0x1000) return false;
return ptr.add(lfanew).readU32() === 0x00004550; // 'PE\0\0'
} catch (e) { return false; }
}
function dumpRegion(base, size, tag) {
const key = base.toString();
if (dumped.has(key)) return;
try {
const rng = Process.findRangeByAddress(base);
const len = size && size > 0 ? size : (rng ? rng.size : 0x10000);
const fname = 'dump_' + tag + '_' + base + '_' + len + '.bin';
const f = new File(fname, 'wb');
f.write(base.readByteArray(len));
f.close();
dumped.add(key);
console.log('[+] dumped ' + tag + ' region ' + base + ' (' + len + ' bytes) -> ' + fname);
} catch (e) {
console.log('[-] dump failed @ ' + base + ': ' + e);
}
}
function hook(modExport, name, onLeave) {
const addr = Module.findExportByName(null, name);
if (!addr) { return; }
Interceptor.attach(addr, onLeave);
console.log('[*] hooked ' + name);
}
// VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect)
hook(null, 'VirtualAlloc', {
onEnter(args) { this.size = args[1].toInt32(); this.prot = args[3].toInt32(); },
onLeave(ret) {
if (!ret.isNull() && (this.prot & PAGE_EXEC)) {
tracked[ret.toString()] = this.size;
console.log('[*] VirtualAlloc RWX ' + ret + ' size=' + this.size);
}
}
});
// VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect)
hook(null, 'VirtualProtect', {
onEnter(args) { this.addr = args[0]; this.size = args[1].toInt32(); this.prot = args[2].toInt32(); },
onLeave(ret) {
if (this.prot & PAGE_EXEC) {
// perms flipped to executable -> unpack stub just finished writing code
const tag = isPE(this.addr) ? 'pe' : 'code';
dumpRegion(this.addr, this.size, tag);
}
}
});
// WriteProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, *written)
hook(null, 'WriteProcessMemory', {
onEnter(args) {
this.dst = args[1]; this.src = args[2]; this.n = args[3].toInt32();
if (this.n > 256) {
const tag = isPE(this.src) ? 'wpm_pe' : 'wpm';
dumpRegion(this.src, this.n, tag); // dump the buffer we were about to inject
}
}
});
// LdrLoadDll - catches reflective / manual map fallbacks routed through loader
hook(null, 'LdrLoadDll', {
onLeave() { /* presence logging only; range enumerated on demand below */ }
});
// On each new executable module load, check for in-memory-only PEs
const intervalId = setInterval(function () {
for (const base in tracked) {
const p = ptr(base);
if (isPE(p)) dumpRegion(p, tracked[base], 'rwx_pe');
}
}, 2000);
// .NET Assembly.Load(byte[]) hook (only if CLR loaded). Lazy attach.
setTimeout(function () {
const clr = Process.findModuleByName('clr.dll') || Process.findModuleByName('coreclr.dll');
if (clr) {
console.log('[*] managed process detected (' + clr.name + ') - attach dnSpyEx / ExtremeDumper for the Assembly.Load buffer');
}
}, 1500);
console.log('[*] frida_unpack armed - waiting for unpack/inject transitions');
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |