# Malware Config Extraction

> Use when you need the malware's embedded configuration, covering C2 addresses, encryption keys, campaign IDs, mutex names, and operational parameters, pulled from the binary without full reverse engineering. Covers locating config blobs via strings and entropy, decoding common schemes (XOR, RC4, AES), extracting configs from memory dumps, parsing structured configs (JSON, custom binary formats), and validating extracted C2 addresses safely. Use when triage shows encoded strings, when the C2 is dead and you need the next address, or when threat intel needs campaign tracking data.

- Skill: `mizazhaider-ceh/malware-config-extraction` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/malware-config-extraction`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/malware-config-extraction/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Marketing & Growth
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/malware-config-extraction

---


The config is the malware's orders: where to beacon, how often, which
campaign it belongs to, what key encrypts its traffic. Extracting it turns
one sample into network IOCs, campaign attribution, and sometimes the
decryption key for victim data. Configs are usually encoded (XOR, RC4) or
encrypted (AES) and stored as a blob in the binary or built at runtime in
memory. This skill covers finding the blob, identifying the scheme,
decoding it, and validating the result without ever talking to the attacker's
infrastructure. Scope: extract configs only from samples you are authorized
to handle, in an isolated lab, during authorized DFIR or threat intel work.
Never connect to an extracted C2 address; validation is offline only.

## Quick Workflow

1. Run FLOSS and look for encoded blobs: long base64-ish strings, high
   entropy regions, or structured-looking binary data.
2. Find the decoder: search for XOR loops, RC4 KSA constants, or AES
   S-boxes near the blob (capa often flags the crypto capability).
3. Identify the key: hardcoded key bytes, a key derived from a string, or
   a key built at runtime (then you need memory).
4. Reimplement the decode in Python and run it against the blob.
5. Parse the plaintext: look for URLs, IPs, ports, intervals, campaign
   IDs, mutex names.
6. Validate offline: does the plaintext have structure (delimiters,
   JSON, known field names)? Do the URLs resolve to plausible hosts?
7. Record the config with the sample hash, decoder script, and confidence
   per field.

## 1. Finding the config blob

```bash
# Long encoded strings are the classic sign
floss -n 20 sample.exe | awk 'length > 60' | head -20

# High-entropy contiguous regions in the binary
python3 - <<'EOF'
import math, collections
data = open('sample.exe','rb').read()
for off in range(0, len(data), 4096):
    chunk = data[off:off+4096]
    c = collections.Counter(chunk)
    e = -sum(v/len(chunk)*math.log2(v/len(chunk)) for v in c.values())
    if e > 7.5:
        print(f"offset {off:#x} entropy {e:.2f}")
EOF
```

Example output shape:

```text
offset 0x2a000 entropy 7.91
offset 0x2b000 entropy 7.88
```

A contiguous high-entropy region of a few KB inside an otherwise normal
binary is very often the encrypted config. Note its file offset and size;
you will feed exactly those bytes to the decoder.

## 2. Identifying the encoding scheme

Look at the code around the blob reference (cross-reference in a
disassembler, or capa's crypto hits):

- **Single-byte XOR**: a loop XORing each byte with one constant. Plaintext
  guessable by trying all 256 keys and scoring for printable text.
- **Multi-byte XOR**: key repeats every N bytes. Try key lengths 2 to 32.
- **RC4**: key scheduling loop with 256-byte state array and the
  characteristic swap pattern. Key often a short ASCII string nearby.
- **AES**: S-box constants (0x63, 0x7c, ...) or Windows CAPI / BCrypt
  imports. Key may be in the blob header or derived.

```python
# Single-byte XOR brute force with printable scoring
def xor_bruteforce(blob: bytes) -> tuple:
    best = (0, 0, b"")
    for key in range(256):
        pt = bytes(b ^ key for b in blob)
        score = sum(32 <= c < 127 or c in (10, 13) for c in pt)
        if score > best[0]:
            best = (score, key, pt)
    return best[1], best[2]

key, pt = xor_bruteforce(blob)
print(f"key={key:#x} preview={pt[:80]!r}")
```

Expected output shape when it works:

```text
key=0x4a preview=b'http://beacon.example-cdn[.]net/api/v2/beacon\x00\x00CAMP-2026-118\x00'
```

If the preview is still garbage, the scheme is not single-byte XOR: move
to multi-byte, then RC4.

## 3. RC4 configs: the workhorse case

```python
def rc4(key: bytes, data: bytes) -> bytes:
    s = list(range(256))
    j = 0
    for i in range(256):
        j = (j + s[i] + key[i % len(key)]) % 256
        s[i], s[j] = s[j], s[i]
    i = j = 0
    out = bytearray()
    for byte in data:
        i = (i + 1) % 256
        j = (j + s[i]) % 256
        s[i], s[j] = s[j], s[i]
        out.append(byte ^ s[(s[i] + s[j]) % 256])
    return bytes(out)

# Key is often an ASCII string near the blob or a fixed constant
for candidate in [b"NimbusKey2026", b"config_key", key_from_strings]:
    pt = rc4(candidate, blob)
    if b"http" in pt or b"." in pt[:16]:
        print(f"HIT with {candidate!r}: {pt[:100]!r}")
        break
```

RC4 configs commonly decode to a delimited structure: C2 URL, port,
beacon interval, campaign ID, mutex, sometimes a second-stage URL. Parse
generously: split on null bytes and common delimiters, then classify each
field by shape (URL regex, IPv4 regex, integer range for intervals).

## 4. Configs built at runtime: go to memory

When the key is derived at runtime (from system info, a decrypted string,
or a previous C2 response), static decoding fails. Instead, let the sample
decode it and read memory:

1. Run the sample in the debugger or sandbox until after the decode call
   (break on the decode function or on the first network connect).
2. Dump the process memory region holding the plaintext config.
3. Search the dump for URL patterns.

```bash
# From a memory dump or a live debugger memory map
strings -n 6 memdump.bin | grep -iE "https?://|[0-9]{1,3}\.[0-9]{1,3}" | sort -u
```

Example output shape:

```text
http://beacon.example-cdn[.]net/api/v2/beacon
http://backup.example-cdn[.]net/api/v2/beacon
CAMP-2026-118
```

Runtime extraction also catches configs fetched from the C2 (second-stage
config): capture the network traffic in the sandbox and decode the
response with the session key from memory.

## 5. Parsing structured configs

Decoded output is rarely clean. Common layouts:

```text
# Null-delimited fields
b'http://c2.example[.]net\x00\x0050\x00CAMP-118\x00Global\\Mtx_7f3a\x00'
  -> fields: c2_url, (pad), beacon_interval=50, campaign, mutex

# Length-prefixed TLV
# first 4 bytes LE = length, then that many bytes, repeat

# JSON (modern implants)
{"c2":["https://a.example[.]net","https://b.example[.]net"],
 "interval":60,"jitter":15,"campaign":"CAMP-2026-118"}
```

Write a small parser per family and keep it with the decoder script; the
next sample of the same family will use the same layout with different
values. When fields are ambiguous, label confidence: a URL-shaped field
is high confidence C2, a 4-digit number could be a port or an interval
(medium confidence until the sandbox confirms beacon timing).

## 6. Safe validation

Validate without contacting the attacker:

- Syntax: URLs parse, IPs are valid, ports in range.
- Corroboration: does the sandbox report show connection attempts to the
  extracted address? Does the beacon interval match observed timing?
- Plausibility: campaign IDs matching the family's known format,
  mutex names matching the strings in the binary.
- Never: no DNS lookups of the C2 domain from non-lab networks, no HTTP
  requests, no "testing" the address. Treat extracted infrastructure as
  hostile and handle it as IOC data only.

## Edge cases

- Config split across multiple blobs: some families store the C2 in one
  blob and the key material in another. Decode all high-entropy regions,
  not just the first.
- Rolling XOR keys derived from the PE timestamp or volume serial: the
  static blob decodes differently per victim. Document the derivation;
  the IOC is the algorithm plus the observed instance.
- Configs updated by the C2 at runtime: the embedded config is only the
  bootstrap. Note which fields are bootstrap vs updatable.
- Fake configs: some samples carry decoy plaintext that looks like a
  config but is never used. Confirm usage via the network trace before
  publishing IOCs.
- AES with key in a separate section: the S-box tells you AES, but the
  key schedule in memory tells you the key. Extract from a memory dump
  at the right moment.
- .NET configs: often stored as encrypted resources or settings. Decrypt
  with the assembly's own method by invoking it in a controlled harness
  rather than reimplementing crypto.
- Empty decode results: the blob may be compressed after encryption.
  Try zlib/deflate decompression on the decoded bytes before concluding
  failure.

## Escalation

- If the crypto is custom or unrecognized after serious effort, escalate
  to a reverse engineer: reimplementing unknown ciphers from assembly is
  specialist work, and mistakes produce false IOCs.
- If the config contains victim-specific data (hostnames, usernames from
  a targeted intrusion), escalate handling: that data may be sensitive
  and subject to incident-specific handling rules.
- If extraction reveals active C2 infrastructure, hand the IOCs to threat
  intel and the SOC immediately; do not wait for the full report.
- If the same config (campaign ID, key) appears across supposedly
  unrelated families, escalate as a possible shared-builder or
  affiliate-program finding; that is attribution-relevant.

## Detection and defender view

Extracted configs are among the highest-value IOCs because they are
operational: C2 domains go to the proxy blocklist and DNS monitoring,
campaign IDs go to threat intel for clustering, beacon intervals become
network detection thresholds. Write the extraction as a repeatable
script, not a one-off: the next 50 samples of this family get processed
in seconds, and the SOC gets fresh IOCs the same day. Share the decoder
(without the sample) with trusted intel partners when appropriate; a
shared decoder multiplies everyone's coverage. Track config reuse across
campaigns: when a new sample carries an old campaign ID, that is a
clustering signal worth more than any single IOC.

## Key references

- MITRE ATT&CK: T1071 (Application Layer Protocol), T1573 (Encrypted
  Channel), T1327 (Obtain Capabilities, for config-driven tooling)
- Mandiant FLARE FLOSS:
  https://github.com/mandiant/flare-floss
- CyberChef (interactive decode prototyping):
  https://gchq.github.io/CyberChef/
- Practical Malware Analysis (Sikorski and Honig), Chapter 13
  (data encoding)
- Malpedia (family configs and decoders reference):
  https://malpedia.caad.fkie.fraunhofer.de/
- CAPE Sandbox config extraction modules:
  https://capev2.readthedocs.io/

