Add boofuzz with a reproducible localhost protocol check

Run the boofuzz check from the issue #6 conditional backlog: a made-up
TRC1 protocol is described with Size and Checksum blocks, the default
frame matches bytes built with struct and zlib, and a localhost server
receives all 575 payload mutations with a correct length and CRC-32.
The check also records the limits found: replies to fuzzed messages are
not read by default, String mutations are UTF-8 text, and a target that
stops listening ends the run early without a failed test case.
This commit is contained in:
Akshat
2026-10-21 16:08:03 +05:30
parent 22dda197fd
commit 1fef42aedf
7 changed files with 164 additions and 13 deletions
+1
View File
@@ -184,6 +184,7 @@ Run samples only in isolated, disposable environments, and follow your organizat
![A browser displaying a network packet trace](.github/section-art/web-protocols.png)
- [boofuzz](https://github.com/jtpereyda/boofuzz) - Python framework for describing a protocol's message fields and sending mutated messages to a target, useful for testing a reconstructed protocol against a live service; crash detection needs a process monitor or restart callback.
- [Burp Suite](https://portswigger.net/burp) - Intercepting proxy and toolkit for inspecting, replaying, and modifying HTTP and WebSocket traffic. **Commercial**, with a free Community Edition.
- [Chrome DevTools](https://developer.chrome.com/docs/devtools/) - Browser tools for stepping through JavaScript, inspecting network requests, and examining runtime state.
- [HTTP Toolkit](https://httptoolkit.com/) - Intercepts and inspects HTTP(S) traffic from browsers, desktop applications, Android devices, and containers with automated interception setup. **Commercial**, with a free open-source edition.
+32
View File
@@ -811,6 +811,38 @@
"source_browser_urls": [
"https://github.com/CERT-Polska/malduck/blob/0425e0209ec30b656e75ff94071e01c34c4cffa5/README.md"
]
},
{
"name": "boofuzz",
"url": "https://github.com/jtpereyda/boofuzz",
"section": "Web and protocols",
"description": "Python framework for describing a protocol's message fields and sending mutated messages to a target, useful for testing a reconstructed protocol against a live service; crash detection needs a process monitor or restart callback.",
"research_priority": "B",
"decision": "added",
"checked_at": "2026-10-21",
"next_review": "2026-11-21",
"evidence_type": "reproduced (CI)",
"task": "Protocol grammar/state experiments",
"constraints": "Replies to fuzzed messages are read only with receive_data_after_fuzz=True; String mutations are UTF-8 text and max_len counts characters; without a process monitor or restart callback a stopped target ends the run early with only an info message and no failed test case; default combinatorial depth grows quickly.",
"sources": [
"https://raw.githubusercontent.com/jtpereyda/boofuzz/41a808ef6bdb19ba64d811dc5d882b66a1033316/README.rst"
],
"source_commit": "41a808ef6bdb19ba64d811dc5d882b66a1033316",
"license_api": "GPL-2.0",
"license_api_is_complete_audit": false,
"canonical_repo": "jtpereyda/boofuzz",
"archived": false,
"default_branch_commit_at": "2026-09-21T14:51:39Z",
"github_release": {
"tag_name": "v0.4.2",
"published_at": "2023-10-06T23:34:19Z",
"html_url": "https://github.com/jtpereyda/boofuzz/releases/tag/v0.4.2"
},
"reproduction": "examples/resource-intake/README.md",
"reproduced_scope": "Localhost TRC1 protocol: default frame, 575 payload mutations with correct length/CRC, sent and replied frames match; replies unread by default, UTF-8 string mutations, and a stopped target ends the run without a failure",
"source_browser_urls": [
"https://github.com/jtpereyda/boofuzz/blob/41a808ef6bdb19ba64d811dc5d882b66a1033316/README.rst"
]
}
]
}
+2 -1
View File
@@ -67,9 +67,10 @@ For subsequent reviews, confirm the exact host, target, board/backend, distribut
## Additional conditional candidates (2026-10-19)
Checked on **2026-10-19 UTC**; recheck by **2026-11-19**. These address the Malduck extractor and newer Hermes-bytecode items in issue #6. Fixtures, commands and dated results are in [the examples](../examples/resource-intake/README.md); **reproduced (CI)** means the bounded checks run in the resource-example workflow.
Checked on **2026-10-19 UTC**; recheck by **2026-11-19**. These address the Malduck extractor, newer Hermes-bytecode, and boofuzz protocol-hypothesis items in issue #6. Fixtures, commands and dated results are in [the examples](../examples/resource-intake/README.md); **reproduced (CI)** means the bounded checks run 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. |
| hermes-dec: [README](https://raw.githubusercontent.com/P1sec/hermes-dec/2e796663e1fedb93dca51060797ebf3327b3fedb/README.md) | **Reproduced (CI), added to Language runtimes and packagers.** HBC 98 and 99 fixtures from pinned `hermes-compiler` builds parse, disassemble, and decompile with function names, strings, and branches intact, but with an unsupported-version warning. With `-g1` debug info, `hbc-file-parser` raises a `TypeError` after printing the header. The pseudo-code does not preserve JavaScript behavior: executing it prints `21` where the original prints `25`, because registers are shared across functions. Release 0.1.8 (2026-10-15) is newer than the 2026-10-13 research snapshot. AGPL-3.0-or-later. |
| boofuzz: [README](https://raw.githubusercontent.com/jtpereyda/boofuzz/41a808ef6bdb19ba64d811dc5d882b66a1033316/README.rst) | **Reproduced (CI), added to Web and protocols.** A made-up TRC1 protocol described with `Size` and `Checksum` blocks rendered the independently built default frame, and a localhost server received all 575 payload mutations with a correct length and CRC-32. Limits: replies to fuzzed messages are read only with `receive_data_after_fuzz=True`; `String` mutations are UTF-8 text and `max_len` counts characters; without a process monitor or restart callback, a target that stops listening ends the run early with only an info message and no failed test case. The entry is scoped to testing a reconstructed protocol, not general fuzzing. Latest release v0.4.2 (2023-10-06) is older than the default branch (2026-09-21). GPL-2.0. |
+9 -2
View File
@@ -1,6 +1,6 @@
# Five bounded resource examples
# Seven bounded resource examples
These self-authored fixtures demonstrate Construct, Scapy, YARA-X, Vineflower, Malduck, and hermes-dec. 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, Malduck, hermes-dec, and boofuzz. 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, Node.js, and an Internet connection for the pinned packages, JAR, and Hermes compilers. From the repository root:
@@ -34,6 +34,7 @@ $resourcePython = Join-Path $resourceExamplesDir "venv\Scripts\python.exe"
| 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 |
| hermes-dec 0.1.8 | [`hbc_fixture.js`](hbc_fixture.js) compiled by `hermes-compiler` 250829098.0.19 (HBC 98) and 260318099.0.4 (HBC 99) at `-g0` and `-g1`; header version, disassembly, and pseudo-code landmarks (function names, strings, `<Mod>`, constant `7`) | See the limits below |
| boofuzz 0.4.2 | A made-up TRC1 protocol (`TRC1`, kind, big-endian length, payload, big-endian CRC-32) described with `Size` and `Checksum` blocks; the default frame matches bytes built with `struct` and `zlib`, and a localhost server receives all 575 payload mutations with a correct length and CRC, replying to each | One-field-at-a-time fuzzing (`max_depth=1`) against a localhost server only; see the limits below |
The branch oracle for `Probe.java` is:
@@ -51,6 +52,12 @@ The hermes-dec check also records three limits:
- With `-g1` location info, `hbc-file-parser` prints the header and then raises a `TypeError` in `debug_info_parser.py`; `-g0` files parse cleanly. The disassembler and decompiler succeed at both levels.
- The original fixture prints `even:negative:25` under Node.js; executing the pseudo-code prints `even:negative:21`, because register variables are shared across functions instead of being local to each call.
The boofuzz check also records three limits:
- Replies to fuzzed messages are read only with `receive_data_after_fuzz=True`; by default `last_recv` stays empty.
- `String` mutations are text: byte patterns such as `\xde\xad\xbe\xef` are sent UTF-8 encoded, and `max_len` counts characters, so a 48-character limit produced a 96-byte payload.
- Without a process monitor or restart callback, a target that stops listening ends the run after 17 of 575 cases with only an info message ("Ending fuzzing"); no test case is marked failed and `fuzz()` returns normally.
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, Java 17, and Node.js 22; 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.
@@ -3,3 +3,4 @@ scapy==2.8.0
yara-x==1.21.0
hermes-dec==0.1.8
malduck==4.4.1
boofuzz==0.4.2
+19 -8
View File
@@ -1,10 +1,10 @@
{
"checked_at": "2026-10-20T14:20:47.418756+00:00",
"checked_at": "2026-10-21T10:37:03.178692+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",
"node": "v24.21.0"
"node": "v22.23.3"
},
"results": [
{
@@ -42,6 +42,12 @@
"version": "0.1.8",
"result": "passed",
"scope": "HBC 98/99 at -g0/-g1: header, disassembly and pseudo-code landmarks; -g1 debug-info parsing raises TypeError; executing the pseudo-code prints 21, not 25"
},
{
"name": "boofuzz",
"version": "0.4.2",
"result": "passed",
"scope": "Localhost TRC1 protocol: default frame, 575 payload mutations with correct length/CRC, sent and replied frames match; replies unread by default, UTF-8 string mutations, and a stopped target ends the run without a failure"
}
],
"inputs": [
@@ -67,11 +73,11 @@
},
{
"path": "verify.py",
"sha256": "1d06631607af8e9cfd8c0f85e55792dd1e672b2c00f75cbaaf772511e50d9b09"
"sha256": "aa313b02eaeff382612fcddc4cb125a4791b5fe6fd22e1da04c845b2177447d2"
},
{
"path": "requirements.txt",
"sha256": "e82f3a0ec8e0920c97b12fc63d92cfe34c898c2999ac70c6dba931ea21ac8d05"
"sha256": "b33267171f85855685fac22109ef800e065ffdbe5a43fe6e00b3ef64ae6dfca6"
}
],
"golden_hex": "534d4b310500017472616365",
@@ -113,14 +119,19 @@
"hbc_sha256": {
"98": {
"g0": "d1ceacc1f40097b798abf4eeaf8f2f0a663afa9ed8d8fdd5f2b2d99ee2e422a8",
"g1": "607bacb57bde59047aacfc9831c2d4a0d2a39812b77e4e99c7b1d2f296c423ad"
"g1": "d5f33936891fdc73684e9440c6898ba9a346813b4d95d3a89a484df3b1aae668"
},
"99": {
"g0": "f51e55203c85ab6fd016ab83862f81aa61cc2f441087c10ef712c2148bf7b57d",
"g1": "1435f40bec256fc1c62fd79135400157449ed18ef804cedd1f2437c04916174e"
"g1": "1aee0a677f150b400ad20900e3782a084c2e2177ef68a6bb8360e735d65629c3"
}
},
"original_output": "even:negative:25",
"pseudocode_output": "even:negative:21"
},
"boofuzz": {
"cases": 575,
"frames_before_target_stopped": 17,
"default_frame": "545243310100057472616365315bd5a1"
}
}
+100 -2
View File
@@ -1,18 +1,22 @@
"""Reproduce six narrow resource examples with independent expected outputs."""
"""Reproduce seven narrow resource examples with independent expected outputs."""
import argparse
from datetime import datetime, timezone
import hashlib
from importlib.metadata import PackageNotFoundError, version
import csv
import io
import json
from pathlib import Path
import platform
import re
import socket
import struct
import subprocess
import sys
import tarfile
import tempfile
import threading
import zlib
from urllib.request import urlopen
@@ -34,6 +38,7 @@ HBC_PSEUDOCODE_OUTPUT = "even:negative:21"
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}
TRC1_CASES = 575
def sha256(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
@@ -157,8 +162,98 @@ def verify_malduck(work):
assert results["wrong-key"] == (None, []) and results["no-marker"] == (None, [])
return sha256(work / "duckcfg-good.bin")
def trc1_frame(payload=b"trace"):
"""TRC1: magic, kind, big-endian payload length, payload, big-endian CRC-32 of the payload (built with struct and zlib)."""
return b"TRC1\x01" + struct.pack(">H", len(payload)) + payload + struct.pack(">I", zlib.crc32(payload))
def trc1_valid(frame):
length = struct.unpack(">H", frame[5:7])[0] if len(frame) >= 7 else -1
payload = frame[7:-4]
return frame[:5] == b"TRC1\x01" and len(payload) == length and frame[-4:] == struct.pack(">I", zlib.crc32(payload))
class Trc1Server(threading.Thread):
"""Localhost TRC1 server: replies OK plus the CRC to valid frames, or stops listening on a payload over crash_over bytes."""
def __init__(self, crash_over=None):
super().__init__(daemon=True)
self.crash_over, self.frames, self.replies, self.crashed = crash_over, [], [], False
self.sock = socket.create_server(("127.0.0.1", 0))
def run(self):
while not self.crashed:
try:
conn, _ = self.sock.accept()
except OSError:
return
with conn:
frame = conn.recv(7)
while 7 <= len(frame) < 7 + struct.unpack(">H", frame[5:7])[0] + 4:
chunk = conn.recv(65536)
if not chunk:
break
frame += chunk
self.frames.append(frame)
if self.crash_over is not None and len(frame) - 11 > self.crash_over:
self.crashed = True
self.sock.close()
return
reply = b"OK" + frame[-4:] if trc1_valid(frame) else b"BAD"
self.replies.append(reply)
conn.sendall(reply)
def fuzz_trc1(work, crash_over=None, **options):
from boofuzz import Block, Byte, Checksum, FuzzLoggerCsv, Request, Session, Size, Static, String, Target, TCPSocketConnection
request = Request("trc1", children=(
Static(name="magic", default_value=b"TRC1"),
Byte(name="kind", default_value=1, fuzzable=False),
Size(name="length", block_name="body", length=2, endian=">", fuzzable=False),
Block(name="body", children=(String(name="payload", default_value="trace", max_len=48),)),
Checksum(name="crc", block_name="body", algorithm="crc32", endian=">", fuzzable=False),
))
server = Trc1Server(crash_over)
server.start()
sent, received, log = [], [], io.StringIO()
def record(target, fuzz_data_logger, session, *args, **kwargs):
sent.append(session.last_send)
received.append(session.last_recv)
session = Session(
target=Target(connection=TCPSocketConnection("127.0.0.1", server.sock.getsockname()[1], recv_timeout=2)),
web_port=None, fuzz_loggers=[FuzzLoggerCsv(file_handle=log)], db_filename=str(work / f"boofuzz-{len(list(work.glob('boofuzz-*')))}.db"),
sleep_time=0, restart_sleep_time=0, post_test_case_callbacks=[record], **options,
)
session.connect(request)
session.fuzz(max_depth=1)
rows = list(csv.reader(io.StringIO(log.getvalue())))
return request.render(), server, sent, received, rows
def verify_boofuzz(work):
rendered, server, sent, received, _ = fuzz_trc1(work, receive_data_after_fuzz=True)
assert rendered == trc1_frame(), rendered.hex()
assert len(server.frames) == TRC1_CASES and sent == server.frames and received == server.replies
assert all(trc1_valid(frame) for frame in server.frames), "a fuzzed frame has a wrong length or CRC"
# String mutations are text: b"\xde\xad\xbe\xef" patterns are sent UTF-8 encoded, and max_len counts characters.
longest = max(server.frames, key=len)
assert len(longest) - 11 == 96 and longest[7:15] == "\xde\xad\xbe\xef".encode()
# By default, replies to fuzzed messages are not read.
_, _, _, default_received, _ = fuzz_trc1(work, index_end=5)
assert default_received == [b""] * 5, default_received
# Without a restart method or monitor, a target that stops listening ends the run early with only an info message.
_, crashed, _, _, rows = fuzz_trc1(work, crash_over=40, restart_threshold=1)
kinds = [row[1] for row in rows]
assert crashed.crashed and len(crashed.frames) < TRC1_CASES and "fail" not in kinds and "error" not in kinds
assert any("Ending fuzzing" in row[-1] for row in rows)
return {"cases": TRC1_CASES, "frames_before_target_stopped": len(crashed.frames), "default_frame": rendered.hex()}
def verify(work, jar):
for package, expected in {"construct": "2.10.70", "scapy": "2.8.0", "yara-x": "1.21.0", "hermes-dec": "0.1.8", "malduck": "4.4.1"}.items():
for package, expected in {"construct": "2.10.70", "scapy": "2.8.0", "yara-x": "1.21.0", "hermes-dec": "0.1.8", "malduck": "4.4.1", "boofuzz": "0.4.2"}.items():
try:
installed = version(package)
except PackageNotFoundError as exc:
@@ -240,6 +335,7 @@ def verify(work, jar):
duck_digest = verify_malduck(work)
hbc_digests = verify_hermes_dec(work)
boofuzz_summary = verify_boofuzz(work)
return {
"checked_at": datetime.now(timezone.utc).isoformat(),
@@ -251,6 +347,7 @@ def verify(work, jar):
{"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"},
{"name": "hermes-dec", "version": "0.1.8", "result": "passed", "scope": "HBC 98/99 at -g0/-g1: header, disassembly and pseudo-code landmarks; -g1 debug-info parsing raises TypeError; executing the pseudo-code prints 21, not 25"},
{"name": "boofuzz", "version": "0.4.2", "result": "passed", "scope": "Localhost TRC1 protocol: default frame, 575 payload mutations with correct length/CRC, sent and replied frames match; replies unread by default, UTF-8 string mutations, and a stopped target ends the run without a failure"},
],
"inputs": [{"path": name, "sha256": sha256(SOURCE / name)} for name in ("BranchDemo.java", "Probe.java", "hbc_fixture.js", "malduck_modules/duckcfg/__init__.py", "malduck_modules/duckcfg/duckcfg.yar", "verify.py", "requirements.txt")],
"golden_hex": GOLDEN.hex(),
@@ -260,6 +357,7 @@ def verify(work, jar):
"hermes_dec": {"compilers": {str(v): {"url": u, "sha256": d} for v, (u, d) in HERMESC.items()},
"hbc_sha256": {str(v): d for v, d in hbc_digests.items()},
"original_output": HBC_ORIGINAL_OUTPUT, "pseudocode_output": HBC_PSEUDOCODE_OUTPUT},
"boofuzz": boofuzz_summary,
}