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 |
references/config-c2-extraction.md
View on GitHub# Config & C2 Extraction
Goal: pull the actionable configuration out of a sample/implant — C2 hosts, ports, sleep/jitter,
keys, mutexes, campaign IDs — to generate IOCs, attribute campaigns, and seed network detection.
Config extraction is the highest-value RE output for threat intel.
## Theory / mechanism
Most commodity families embed an encrypted **configuration blob** that the implant decodes at
runtime. Extraction strategies, cheapest first:
1. **Static decode of a known format.** Family extractors know the offset/key/structure (Cobalt
Strike TLV table XOR'd with a single byte; AsyncRAT/Quasar .NET config fields; RedLine settings).
2. **Runtime/heap recovery.** When the static blob is too mutated, dump the **decoded** config from
process memory after the implant parses it (Cobalt Strike's "runtime configuration" C-array on the
heap; .NET config objects after the static constructor runs).
3. **Generic protocol RE.** For unknown C2: capture N check-ins, separate fixed vs variable fields,
identify the crypto, recover the key (hardcoded / derived / exchanged), build a decoder.
A **config-extractor framework** standardizes this at scale. **MACO** (Malware Analysis Configuration
Objects, by the Canadian Centre for Cyber Security) defines a common output model so extractors from
different frameworks (MACO, MWCP, CAPE, MalDuck, RATDecoders) emit harmonized JSON. **CAPEv2** runs
extractors during sandboxing and supports MACO/MWCP/MalDuck/RATDecoders parsers; CAPE's own framework
is just a pure-Python `def extract_config(data)`. CCCS's **configextractor-py** wraps all of these and
powers Assemblyline's ConfigExtractor service — feed extracted C2/keys straight into a TI database.
## Modern 2024-2026 tooling (verified)
- **1768.py** (Didier Stevens, v0.0.23 / Mar 2025) — decrypts Cobalt Strike Windows beacon configs
from PE, shellcode, and **memory dumps**; v0.0.20+ added **runtime configuration** recovery (the
C/C++ config array on the heap), `-S/--sanitycheck` (validates config values 1 and 7), and
CSV/JSON output.
- **CobaltStrikeParser** (Sentinel-One) — parses beacon config from PE / memory dump / URL by
matching the encoded-table byte patterns; knows the **v3 XOR key 0x69** and **v4 XOR key 0x2e**.
- **cobaltstrike-config-extractor / libcsce** (Stroz Friedberg) — `csce` emits all known settings as
JSON shaped like the Malleable C2 profile.
- **AdaptixC2 config extractor** (Unit 42, 2025) — AdaptixC2 (functionally like CS/Sliver/Havoc/
Mythic) first appeared on MalwareBazaar **May 2025** and in DFIR Report intrusions **July 2025**;
Unit 42 published a config extractor for the current version.
- **MACO + configextractor-py + CAPEv2** — the pipeline glue for scaling extraction across families.
> Sliver/Havoc lack mature public *config* extractors; pivot on them via **network fingerprints**
> (JA4X — see `references/network-c2-detection.md`) and mTLS/protocol artifacts instead.
## Complete working extraction
### A. Cobalt Strike
```bash
# self-contained extractor (this skill): handles XOR key 0x69/0x2e + brute-force, TLV parse
python3 scripts/cs_config_extract.py beacon.bin --json
# full coverage incl. runtime/heap configs from a memory dump
python3 1768.py -S beacon.bin # sanity-checked
python3 1768.py -S process_memory.dmp # v0.0.20+ heap runtime config
python3 parse_beacon_config.py beacon.bin # CobaltStrikeParser
csce beacon.bin # libcsce -> Malleable-profile JSON
```
`scripts/cs_config_extract.py` is dependency-free: it tries XOR keys `0x2e`/`0x69` then brute-forces,
locates the TLV table by its `00 01 00 01 00 02` (BeaconType) marker, and parses
C2Server/Port/SleepTime/Jitter/UserAgent/HttpGet|PostUri/SpawnTo/PipeName/Watermark/KillDate/
ProcInject settings.
### B. AdaptixC2 / framework families
```bash
# AdaptixC2 (Unit 42, 2025) - run the published extractor on the implant blob
python3 adaptixc2_extractor.py implant.bin
# scale across families via MACO / configextractor-py (Assemblyline-style)
pip install maco # full framework
pip install maco-model # model only, for interop
configextractor sample.bin # runs all available MACO/MWCP/CAPE extractors
# in CAPE: extractors auto-run; results exported in MACO model -> TI DB
```
### C. Generic / unknown C2 protocol RE
```python
import struct
# 1. capture >= 10 check-ins; align them, mark fixed vs variable byte ranges.
# 2. identify crypto: uniform high entropy -> stream/AES; short repeating xor -> single/short key;
# block-aligned length -> AES/DES/ChaCha.
# 3. recover key: search .rdata/.data for the const; or trace derive-from-beacon-ID; or capture
# the handshake that exchanges it.
def decode_c2(frame: bytes, key: bytes):
magic = frame[:4] # constant per family
command = frame[4] # 0x01 checkin / 0x02 task-response ...
length = struct.unpack('>H', frame[5:7])[0]
body = bytes(b ^ key[i % len(key)] for i, b in enumerate(frame[7:7+length]))
return {'magic': magic.hex(), 'command': command, 'body': body}
# 4. validate: decoded body should contain plausible JSON / hostnames / known opcodes.
```
## Detection
- **Network IOCs from configs** feed Suricata/Sigma directly: C2 host:port, URIs (e.g. CS
`HttpGet/PostUri`), `UserAgent`, `HostHeader`, `PipeName`, `Watermark` (CS license/team-server
fingerprint — pivots to actor infrastructure).
- **YARA-X** for the encoded config table itself (works on disk + memory):
```yara
rule CobaltStrike_Encoded_Config {
meta: description = "Cobalt Strike beacon encoded config table (XOR 0x2e/0x69)"
strings:
$v4 = { 2e 2f 2e 2f 2e 2c } // BeaconType TLV XOR 0x2e
$v3 = { 69 68 69 68 69 6b } // BeaconType TLV XOR 0x69
condition: any of them
}
```
- **Host IOCs:** mutex / named-pipe from config (`\\.\pipe\MSSE-####-server` style for CS),
spawn-to process, kill-date.
- Push extracted config IOCs into a tracking DB (Assemblyline/MISP) so the same C2 is flagged on
next sight — the DFIR Report has shown CS infra being blocked 76 days before public naming via this.
## OPSEC
- Static config extraction is offline and safe (no detonation). Runtime/heap recovery needs a memory
dump from a (controlled) detonation — see fileless/memory cluster OPSEC.
- Beacon watermark/license attribution: handle per ROE; do not publish team-server PII without
authorization. Treat recovered keys/configs as sensitive intel.
- When validating a recovered decoder against live infra, **do not actually beacon to the real C2**
from attributable infrastructure — replay against a local stand-in or analyze passively.
## References
- Didier Stevens — 1768.py (CS config, v0.0.23, runtime config): https://github.com/DidierStevens/DidierStevensSuite/blob/master/1768.py
- SANS ISC — *Cobalt Strike's "Runtime Configuration"* (heap config recovery): https://isc.sans.edu/diary/30426
- Sentinel-One — CobaltStrikeParser (XOR 0x69/0x2e patterns): https://github.com/Sentinel-One/CobaltStrikeParser
- Securityinbits — *AdaptixC2 Defender Guide* (May/Jul 2025 ITW, Unit 42 extractor): https://www.securityinbits.com/threat-intelligence/adaptixc2-defender-guide/
- CCCS — MACO config extractor framework: https://github.com/CybercentreCanada/Maco
- CCCS — configextractor-py (MACO/MWCP/CAPE wrapper): https://github.com/CybercentreCanada/configextractor-py
- Sekoia — *Advent of Configuration Extraction: Pipeline Overview* (MACO/Assemblyline pipeline, 2025): https://blog.sekoia.io/advent-of-configuration-extraction-part-1-pipeline-overview-first-steps-with-kaiji-configuration-unboxing/
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 |