Add Malduck with a reproducible config-extraction check

Run the Malduck check from the issue #6 conditional backlog: a
self-authored YARA-triggered extractor recovers an RC4-encrypted config
from a self-built sample, and wrong-key and no-marker samples yield no
config. The check runs in the resource-example workflow beside the four
existing examples.
This commit is contained in:
Akshat
2026-10-20 03:22:49 +05:30
parent 29449628ed
commit 7d33416434
10 changed files with 161 additions and 12 deletions
+1
View File
@@ -1,3 +1,4 @@
.DS_Store
.lycheecache
lychee/
__pycache__/
+1
View File
@@ -128,6 +128,7 @@ Run samples only in isolated, disposable environments, and follow your organizat
- [CAPE Sandbox](https://github.com/kevoreilly/CAPEv2) - Automated sandbox derived from Cuckoo that runs samples in virtual machines and records behavior, unpacked payloads, and malware configurations.
- [FLARE-VM](https://github.com/mandiant/flare-vm) - Installation scripts that turn a Windows virtual machine into a malware-analysis and reverse-engineering workstation.
- [Malduck](https://github.com/CERT-Polska/malduck) - Python library of cryptography, compression, and memory-model helpers with a YARA-driven framework for writing your own malware configuration extractors; it does not ship family extractors.
- [oletools](https://github.com/decalage2/oletools) - Python tools for inspecting Office, OLE, and RTF files and extracting macros, embedded objects, and other document artifacts.
- [PE-sieve](https://github.com/hasherezade/pe-sieve) - Scans a running process for injected or modified code, such as hollowed modules, hooks, and shellcode, and dumps what it finds.
- [REMnux](https://remnux.org/) - Linux toolkit for analyzing malicious executables, documents, scripts, and network traffic, available as a virtual machine, container, or installer.
+34
View File
@@ -746,5 +746,39 @@
"automated_result": "HTTP 403",
"evidence": "Official page content retrieved during review; exact URL excluded from lychee, not the whole domain."
}
],
"conditional_checks": [
{
"name": "Malduck",
"url": "https://github.com/CERT-Polska/malduck",
"section": "Malware analysis",
"description": "Python library of cryptography, compression, and memory-model helpers with a YARA-driven framework for writing your own malware configuration extractors; it does not ship family extractors.",
"research_priority": "B",
"decision": "added",
"checked_at": "2026-10-19",
"next_review": "2026-11-19",
"evidence_type": "reproduced (CI)",
"task": "Configuration extraction primitives",
"constraints": "Extractors and YARA rules are user-supplied; useful beside FLOSS/capa, not universal family recovery.",
"sources": [
"https://raw.githubusercontent.com/CERT-Polska/malduck/0425e0209ec30b656e75ff94071e01c34c4cffa5/README.md"
],
"source_commit": "0425e0209ec30b656e75ff94071e01c34c4cffa5",
"license_api": "GPL-3.0",
"license_api_is_complete_audit": false,
"canonical_repo": "CERT-Polska/malduck",
"archived": false,
"default_branch_commit_at": "2025-06-22T15:04:14Z",
"github_release": {
"tag_name": "v4.4.1",
"published_at": "2024-05-10T13:20:36Z",
"html_url": "https://github.com/CERT-Polska/malduck/releases/tag/v4.4.1"
},
"reproduction": "examples/resource-intake/README.md",
"reproduced_scope": "Self-authored YARA-triggered extractor and RC4 config; wrong-key and no-marker samples yield no config",
"source_browser_urls": [
"https://github.com/CERT-Polska/malduck/blob/0425e0209ec30b656e75ff94071e01c34c4cffa5/README.md"
]
}
]
}
+10
View File
@@ -64,3 +64,13 @@ Reviewed on **2026-10-13 UTC**; recheck by **2026-11-13**, or earlier if an upst
| WinDbg MCP: [setup](https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/set-up-windbg-mcp) · [overview](https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/windbg-mcp-overview) | Built into WinDbg 1.2610.1001.0+. Official clients are VS Code with GitHub Copilot and GitHub Copilot CLI; other clients use best-effort custom configuration. Only one active MCP client can connect to each WinDbg session. Protected operations require permitted MCP sampling for cross-prompt injection checks. No Windows target or client was tested here. |
For subsequent reviews, confirm the exact host, target, board/backend, distribution channel, and license/edition before widening claims. An archived repository or old reference can remain useful; deprecation and unsupported installation routes require a human decision rather than automatic deletion.
## Conditional-candidate checks
Checked on **2026-10-19 UTC**; recheck by **2026-11-19**. Issue #6 lists Malduck among the conditional candidates that need a self-authored extractor and a known encrypted configuration. The fixture, commands, and dated report are in [the examples](../examples/resource-intake/README.md); **reproduced (CI)** means the check runs in the resource-example workflow.
| Candidate / primary evidence | Result and decision |
| --- | --- |
| Malduck: [README](https://raw.githubusercontent.com/CERT-Polska/malduck/0425e0209ec30b656e75ff94071e01c34c4cffa5/README.md) | **Reproduced (CI), added to Malware analysis.** A self-authored YARA-triggered extractor recovered an RC4-encrypted config built by an independent RC4 implementation; wrong-key and no-marker samples yielded nothing. Malduck supplies primitives and the extraction framework, not family extractors. Latest release v4.4.1 (2024-05-10); default branch last changed 2025-06-22. GPL-3.0. |
The machine-readable record is under `conditional_checks` in [the JSON snapshot](priority-candidates.json). The other conditional candidates remain in issue #6.
+4 -3
View File
@@ -1,6 +1,6 @@
# Four bounded resource examples
# Five bounded resource examples
These self-authored fixtures demonstrate Construct, Scapy, YARA-X, and Vineflower. They are small selection examples, not upstream test suites or evidence of full platform/version support.
These self-authored fixtures demonstrate Construct, Scapy, YARA-X, Vineflower, and Malduck. They are small selection examples, not upstream test suites or evidence of full platform/version support.
Use Python 3.11 with `venv`/`pip` support, JDK 17, and an Internet connection for the pinned packages and JAR. From the repository root:
@@ -19,6 +19,7 @@ The runner downloads [Vineflower 1.12.0](https://github.com/Vineflower/vineflowe
| Scapy 2.8.0 | Known Ethernet/IP/UDP fields and `trace` payload; independent IP/UDP checksum checks; PCAP write/read | Offline packets only, no transmission or live capture |
| YARA-X 1.21.0 | Self-authored rule matches the golden bytes and not `negative sample`; unescaped `{` in a regex produces `CompileError` | Python API and this documented regex difference, not all YARA rules/modules |
| Vineflower 1.12.0 | Java 17 record and switch expression; compile → decompile → rebuild; main prints `25`, five branch vectors match explicit expected values | This fixture only, no obfuscation or other Java target versions |
| Malduck 4.4.1 | A [self-authored extractor](malduck_modules/duckcfg/__init__.py) and [YARA rule](malduck_modules/duckcfg/duckcfg.yar); a sample with marker `DKCFG1`, an 8-byte key, and a config encrypted by an independent RC4 implementation yields two C2 URLs, campaign `trace-7`, and sleep `300`; wrong-key and no-marker samples yield no config | Extractor framework, procmem reads, and RC4 only; no real malware family |
The branch oracle for `Probe.java` is:
@@ -30,6 +31,6 @@ The branch oracle for `Probe.java` is:
9:-1
```
The [dated local result](verified.json) records host/tool versions, input hashes, artifact digest, and the tested scope. CI repeats the examples and uploads current results through the [resource-example workflow](../../.github/workflows/resource-examples.yml). The current job uses Linux, Python 3.11, and Java 17; it makes no Windows, macOS, hardware, or other-version claim.
The [dated local result](verified.json) records host/tool versions, input hashes, artifact digests, and the tested scope; it was produced in a Linux x86_64 container. CI repeats the examples and uploads current results through the [resource-example workflow](../../.github/workflows/resource-examples.yml). The current job uses Linux, Python 3.11, and Java 17; it makes no Windows, macOS, hardware, or other-version claim.
See the [candidate review](../../docs/priority-candidates.md) for primary sources, documented requirements, and the nineteen entries without execution verification.
@@ -0,0 +1,25 @@
"""Self-authored Malduck extractor for the DKCFG1 fixture: marker, 8-byte RC4 key, uint16 length, ciphertext."""
from malduck import Extractor, rc4
class DuckCfg(Extractor):
family = "duckcfg"
yara_rules = ("duckcfg",)
@Extractor.string("cfg")
def config_block(self, p, addr, match):
key = p.readv(addr + 6, 8)
size = p.uint16v(addr + 14)
plain = rc4(key, p.readv(addr + 16, size))
if not plain.startswith(b"c2="):
return None
config = {"family": self.family, "urls": []}
for field in plain.decode("ascii").split(";"):
name, value = field.split("=", 1)
if name == "c2":
config["urls"].append(value)
elif name == "campaign":
config["campaign"] = value
elif name == "sleep":
config["sleep"] = int(value)
return config
@@ -0,0 +1,7 @@
rule duckcfg
{
strings:
$cfg = "DKCFG1"
condition:
$cfg
}
@@ -1,3 +1,4 @@
construct==2.10.70
scapy==2.8.0
yara-x==1.21.0
malduck==4.4.1
+32 -6
View File
@@ -1,8 +1,8 @@
{
"checked_at": "2026-10-13T02:59:07.191970+00:00",
"checked_at": "2026-10-19T21:51:28.521712+00:00",
"host": {
"platform": "Linux-6.1.0-53-cloud-amd64-x86_64-with-glibc2.36",
"python": "3.11.2",
"platform": "Linux-6.8.0-117-generic-x86_64-with-glibc2.36",
"python": "3.11.17",
"javac": "javac 17.0.20.1"
},
"results": [
@@ -29,6 +29,12 @@
"version": "1.12.0",
"result": "passed",
"scope": "Java 17 record/switch expression, rebuild, main output and five branch vectors"
},
{
"name": "Malduck",
"version": "4.4.1",
"result": "passed",
"scope": "Self-authored YARA-triggered extractor and RC4 config; wrong-key and no-marker samples yield no config"
}
],
"inputs": [
@@ -40,13 +46,21 @@
"path": "Probe.java",
"sha256": "efecf11dc98b876125987476835805989b2fa2f6b52b722b695d7711169fe67a"
},
{
"path": "malduck_modules/duckcfg/__init__.py",
"sha256": "21ec275a54f2a24121648e37f6a75c69d528a3498c34179e0ef2f6634b50fb8a"
},
{
"path": "malduck_modules/duckcfg/duckcfg.yar",
"sha256": "7b36aaf95fad7f8544eb87962b61277d383ce616d43fd880c3ee4f74a9001581"
},
{
"path": "verify.py",
"sha256": "a25cf9c230b8e0d2016d225ff2b8abbf461883f1102df3b9ab5cdcd4e9f3f93e"
"sha256": "fcd9e83f2d18fc595296f193acd3fcdd23b104727361411d16a63c0ffdad6990"
},
{
"path": "requirements.txt",
"sha256": "db6df24e77cc6098c67850a1589720247932a58694261684b9351d0a6bc8ede3"
"sha256": "59e3114feda99afa36dfc0ca42d9f31660e5ddb6b6bddb2c1fb8ed0c821d85b0"
}
],
"golden_hex": "534d4b310500017472616365",
@@ -61,5 +75,17 @@
"1:22",
"2:22",
"9:-1"
]
],
"malduck": {
"sample_sha256": "23366aee6b6831f13d37926ab773ef0319f6fb36be3295ca778d5858da3af2e3",
"expected_config": {
"family": "duckcfg",
"urls": [
"http://192.0.2.10/gate",
"http://198.51.100.7/gate"
],
"campaign": "trace-7",
"sleep": 300
}
}
}
+46 -3
View File
@@ -1,4 +1,4 @@
"""Reproduce four narrow resource examples with independent expected outputs."""
"""Reproduce five narrow resource examples with independent expected outputs."""
import argparse
from datetime import datetime, timezone
import hashlib
@@ -14,12 +14,16 @@ from urllib.request import urlopen
from construct import Byte, Bytes, Const, ConstructError, Int16ul, Struct, Terminated
from scapy.all import Ether, IP, Raw, UDP, rdpcap, wrpcap
import yara_x
from malduck.extractor import ExtractManager, ExtractorModules
SOURCE = Path(__file__).resolve().parent
JAR_URL = "https://github.com/Vineflower/vineflower/releases/download/1.12.0/vineflower-1.12.0.jar"
JAR_SHA256 = "1dfcfe974395734fa467ce620661c7623d05ba83670de0529b1fbd63ff548b9d"
GOLDEN = bytes.fromhex("534d4b310500017472616365")
EXPECTED_BRANCHES = "-1:-1\n0:11\n1:22\n2:22\n9:-1"
DUCK_KEY = b"duck-key"
DUCK_PLAIN = b"c2=http://192.0.2.10/gate;c2=http://198.51.100.7/gate;campaign=trace-7;sleep=300"
DUCK_CONFIG = {"family": "duckcfg", "urls": ["http://192.0.2.10/gate", "http://198.51.100.7/gate"], "campaign": "trace-7", "sleep": 300}
def sha256(path):
@@ -41,8 +45,41 @@ def run(*args):
return completed.stdout.strip()
def rc4(key, data):
"""Independent RC4 used only to build the Malduck fixture."""
state, j = list(range(256)), 0
for i in range(256):
j = (j + state[i] + key[i % len(key)]) & 0xFF
state[i], state[j] = state[j], state[i]
i = j = 0
out = bytearray()
for byte in data:
i = (i + 1) & 0xFF
j = (j + state[i]) & 0xFF
state[i], state[j] = state[j], state[i]
out.append(byte ^ state[(state[i] + state[j]) & 0xFF])
return bytes(out)
def duck_sample(key=DUCK_KEY, marker=b"DKCFG1"):
return b"\x00" * 64 + marker + DUCK_KEY + struct.pack("<H", len(DUCK_PLAIN)) + rc4(key, DUCK_PLAIN) + b"\x00" * 32
def verify_malduck(work):
modules = ExtractorModules(str(SOURCE / "malduck_modules"))
results = {}
for name, data in {"good": duck_sample(), "wrong-key": duck_sample(key=b"bad-key!"), "no-marker": duck_sample(marker=b"XXXXXX")}.items():
path = work / f"duckcfg-{name}.bin"
path.write_bytes(data)
manager = ExtractManager(modules)
results[name] = (manager.push_file(str(path)), manager.config)
assert results["good"] == ("duckcfg", [DUCK_CONFIG]), results["good"]
assert results["wrong-key"] == (None, []) and results["no-marker"] == (None, [])
return sha256(work / "duckcfg-good.bin")
def verify(work, jar):
for package, expected in {"construct": "2.10.70", "scapy": "2.8.0", "yara-x": "1.21.0"}.items():
for package, expected in {"construct": "2.10.70", "scapy": "2.8.0", "yara-x": "1.21.0", "malduck": "4.4.1"}.items():
assert version(package) == expected, f"Unexpected {package} version"
schema = Struct(
@@ -104,6 +141,8 @@ def verify(work, jar):
assert run("java", "-cp", str(classes), "BranchDemo") == "25"
assert run("java", "-cp", str(classes), "Probe") == EXPECTED_BRANCHES
duck_digest = verify_malduck(work)
return {
"checked_at": datetime.now(timezone.utc).isoformat(),
"host": {"platform": platform.platform(), "python": platform.python_version(), "javac": run("javac", "-version")},
@@ -112,11 +151,15 @@ def verify(work, jar):
{"name": "Scapy", "version": "2.8.0", "result": "passed", "scope": "Offline packet/PCAP round trip and independent IP/UDP checksums; no traffic sent"},
{"name": "YARA-X", "version": "1.21.0", "result": "passed", "scope": "Python API positive/negative matching and strict-regex CompileError"},
{"name": "Vineflower", "version": "1.12.0", "result": "passed", "scope": "Java 17 record/switch expression, rebuild, main output and five branch vectors"},
{"name": "Malduck", "version": "4.4.1", "result": "passed", "scope": "Self-authored YARA-triggered extractor and RC4 config; wrong-key and no-marker samples yield no config"},
],
"inputs": [{"path": name, "sha256": sha256(SOURCE / name)} for name in ("BranchDemo.java", "Probe.java", "verify.py", "requirements.txt")],
"inputs": [{"path": name, "sha256": sha256(SOURCE / name)} for name in (
"BranchDemo.java", "Probe.java", "malduck_modules/duckcfg/__init__.py",
"malduck_modules/duckcfg/duckcfg.yar", "verify.py", "requirements.txt")],
"golden_hex": GOLDEN.hex(),
"vineflower_artifact": {"url": JAR_URL, "sha256": JAR_SHA256},
"expected_main": "25", "expected_branches": EXPECTED_BRANCHES.splitlines(),
"malduck": {"sample_sha256": duck_digest, "expected_config": DUCK_CONFIG},
}