<!-- README.md -->

# Hermes and PyMapper detection package

This package accompanies Section 21 and Appendix C V01-V06. It contains experimental file, network and host rules with separately measured validation scopes. No specimen is executed by the validators. The public hierarchy begins at `detection/hermes-pymapper/`; `section-21/` is only the local upload batch.

## Files and evidence classes

| Material | Purpose |
| :--- | :--- |
| [YARA rules](rules/hermes_pymapper.yar) | Six rules for retained Python structures, LOLD/client raw PEs and module DLLs |
| [Specimen manifest](validation/yara_corpus.json) | 38 unique identities, six required rule classes, source/public paths |
| [YARA report](validation/yara_validation_v2.json) | 29 intended matches, nine uncovered forms, complete negative-corpus scan |
| [YARA validator](tools/validate_yara.py) | Hash enforcement, explicit class denominators and twelve altered-byte controls |
| [Goodware manifest](reference/goodware-manifest.json) | 16,084 pinned files with source archives and members |
| [Historical corpus builder](tools/build_goodware_corpus.py) | Original collection procedure; its live selection is not an exact restorer |
| [Network/host guide](network-host/README.md) | Suricata replay, Sigma adapters, source identities and inert controls |
| [Hunt queries](queries/sysmon_hunts.kql) and [schema contract](queries/HUNT-QUERIES.md) | Two unexecuted KQL deployment templates |
| [Erinyes checks](validation/erinyes_offline_checks.json) | Two offline checks against the previously published source archive |
| [Slice provenance](inputs/slice-provenance.json) | Parent identities and extraction offsets for two raw configuration negatives |

The six YARA classes contain eight obfuscated Python loaders, two embedded wrappers, one Stage 2 mapper, two LOLD PEs, one integrated Hermes client and fifteen module DLLs. Later module versions and historical/cache wrapper variants are included. The nine uncovered identities remain explicit: plaintext October 9 loader, gzip-wrapped SMAP, Stage 3 raw PE/image-layout buffer/overlay/container, two raw configuration fragments, and the reflective hidden-desktop helper. The rules do not unpack or decrypt these representations.

The observed zero YARA matches among 16,084 reference files applies to this corpus only. Its 1,084 PE and 15,000 Python files are concentrated in Python/PyPI and Microsoft runtime dependencies. No broad Windows fleet, installer/protector set, organizational traffic baseline or independent family holdout was evaluated. Twelve marker-removal controls are derived memory buffers, not twelve additional benign applications.

## Reproduce the YARA measurement

Create an isolated environment using Python 3.14.2 and yara-python/libyara 4.5.4, the measured versions:

```bash
uv venv /tmp/hermes-detection-env --python 3.14.2
uv pip install --python /tmp/hermes-detection-env/bin/python yara-python==4.5.4
```

Acquire the earlier sample artifacts listed by `public_path` and `prior_artifact_id` in the specimen manifest. Place them beneath a combined archive root, preserving those public paths. The Section 21 raw configuration slices are provided at [loldcfg_b7cb7663.bin](inputs/loldcfg_b7cb7663.bin) and [loldcfg_e44cec7d.bin](inputs/loldcfg_e44cec7d.bin). Their exact parent slices are described in the provenance record. Thirty-six whole-file specimen identities reuse earlier batches without another upload.

The reference corpus bytes are not included in this package. Its manifest lists each file's SHA-256, size, source URL/archive and member. To reproduce the recorded result, obtain those exact members and preserve their manifest-relative `pe/` and `py/` paths under a corpus root. The validator rejects a changed or unavailable file. The three locally sourced Microsoft runtime DLLs are already archived in `stage-chain/stage3-extraction/`; their manifest filenames include the original hashes.

The historical builder queries moving package metadata and a moving popularity list. Running it now creates a new selection and does not reproduce the recorded corpus merely because the command succeeds. Exact-file hashes, not the package names or today's latest release, determine whether a recreated corpus is the measured one. The large reference payload set remains retained locally; its complete manifest and collection procedure are published.

Run from this bundle directory, with actual assembled input roots:

```bash
/tmp/hermes-detection-env/bin/python tools/validate_yara.py \
  --rules rules/hermes_pymapper.yar \
  --corpus validation/yara_corpus.json \
  --archive-root /path/to/combined-archive \
  --goodware-manifest reference/goodware-manifest.json \
  --goodware-root /path/to/goodware-corpus \
  --output /tmp/hermes-yara-reproduction/yara_validation_v2.json
```

For the research tree, substitute `--repo-root /path/to/goop`. Choose a new output filename: the validator refuses to overwrite a report. Every selected byte stream is read as data. YARA compilation warnings, missing files, identity mismatches and scan timeouts fail the run. A ruleset-name/class contract prevents an empty or incomplete ruleset from silently shrinking the denominator. The report separates intended matches, cross-class matches, uncovered inputs and reference-file matches.

The recorded run has 38 unique specimen identities, 29 intended inputs, six successful rules, zero cross-class matches, zero reference-file matches and twelve successful controls. Seven separate failure checks covered an empty ruleset, a missing rule, empty reference entries, wrong size, wrong hash, a duplicate identity and an existing output destination. Independent reproduction matched the published report bytes under the same Python and YARA versions.

## Network and host reproduction

Follow the [network/host guide](network-host/README.md). It pins the Suricata image digest and Python parser dependencies, explains offline `--network none` execution, and separates three sources of results: original PCAP replay, original Windows Security/Procmon field checks, and constructed fixtures. Its synthetic packets contain inert bodies and replacement identifiers. They are never presented as packets captured from the specimen.

The original whole PCAPs remain local, identified by hash in the network input manifest. They contain full laboratory traffic, payload transfers and authentication fields. This release does not republish those whole captures. Their replay measurements require the retained originals; the public synthetic replay is independently reproducible and has a narrower evidentiary role. Original Security XML and selected Procmon events are reused from Section 9 at the public paths listed in the network guide.

No original Sysmon recording, deployed SIEM backend result, or production benign-traffic measurement is supplied. Sigma parsing and predicate evaluation establish the stated field tests. Convert and validate the rules against the actual collector and backend before deployment. KQL templates require the documented normalized schema and were not engine-tested. In particular, a Security PID must not be substituted for a Sysmon process GUID.

## Erinyes offline checks

Reuse `tooling/erinyes-carrier-study/erinyes-d07c8b88.tar.gz`, original artifact ID `c06-erinyes`, already staged with Section 5. The full source revision is `d07c8b88a1f39576197cbd79eb868a2ddaa91c1b`. The check record pins the archive hash, Go version, two input identities, scores, indicator weights and result summaries. Extract the archive into a separate directory and build its own source and catalog:

```bash
GOFLAGS=-buildvcs=false GOCACHE=/tmp/hermes-erinyes-cache just build
./erinyes --signatures ./signatures --format json --verbose \
  --output /tmp/erinyes-candidate.json scan /path/to/candidate.py
```

`-buildvcs=false` avoids trying to infer VCS state from an extracted archive. The built version string is `dev`; the independent archive identity supplies the source pin. The two recorded inputs returned exit status 1 because they were flagged, with scores 140 and 155 against threshold 60. Both also have known-hash entries, so these are two smoke checks, not a measurement of generalization to unknown variants. Reproductions should compare input hashes, signature names, hit weights, verdicts and summary counts; timestamps and durations vary.

The supplied command is offline. The tool's separate hunt/sweep commands access GitHub and are not run by these checks. Preserve skipped-file/error counts and scan settings when interpreting a repository result. A score is the sum of indicator weights, not a percentage. Historical descriptive labels in the archived catalog do not establish the attribution claims evaluated separately in Sections 13 and 17.

## Deployment and maintenance

The public rules begin in experimental status. Select relevant inputs, confirm sensor/parser coverage, run local benign controls and review alert context before enforcement. Keep acquisition date, component role and exact identity attached to IOC records. Revalidate changed wrappers, native section/ABI layouts and protocol revisions. A structural match does not identify a human operator; an old hosting association does not establish current control of an address or account.

The manuscript's response guidance follows the acquired capabilities and laboratory observations. Preserve execution, persistence and collection evidence; isolate an executing infection through the incident process; scope affected credentials and application sessions; establish a trusted host state. The malware's remover return values are not verified eradication receipts.