You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,7 +6,7 @@ This YARA rule generator creates YARA rules for the vulnerable / malicious drive
6
6
7
7
The generator processes the input samples and extract specific 'VersionInfo' values from the driver's PE headers. This includes e.g., the company name, file version, product version, description and other values. It then creates YARA rules that look for these specific values and uses a condition that's very permissive (`all of them`). This allows us to detect the drivers even if they are embedded in another file or loaded into memory.
8
8
9
-
The rule generator in version 0.4 generates five output files:
9
+
The rule generator in version 0.5 generates five output files:
10
10
11
11
| File Name | Description | Score |
12
12
| --- | --- | --- |
@@ -20,27 +20,53 @@ The rule generator in version 0.4 generates five output files:
Path to driver directories (can be used multiple times)
51
77
-y [yaml-files ...] Path to YAML files with information on the drivers (can be used multiple times)
78
+
-f log-file Write a log file
52
79
-o output-folder Output folder for rules
53
80
--debug Debug output
54
81
```
55
82
83
+
### Default paths
84
+
85
+
If no `-d`, `-y`, or `-o` values are given, defaults are resolved relative to the script location (`bin/yara-generator/`):
86
+
87
+
* Drivers: `../../drivers/`
88
+
* YAML metadata: `../../yaml/`
89
+
* Output: `../../detections/yara/`
90
+
91
+
This means running from the repository root or from the script directory works consistently.
92
+
93
+
### YAML validation
94
+
95
+
The generator skips YAML files that are invalid, do not parse to a top-level mapping, or do not contain a `KnownVulnerableSamples` list. Skipped files are reported in the log output.
96
+
97
+
### Existing rule files
98
+
99
+
The generator now merges newly generated rules with the existing output files instead of blindly overwriting them.
100
+
101
+
Rule update behavior:
102
+
103
+
* If an existing rule has identical detection logic (`strings` and `condition`), the existing rule is kept unchanged. Its original `date` is preserved and no `modified` field is added or updated.
104
+
* If an existing rule changes, the original `date` is preserved and a `modified` field is added or updated with the current date.
105
+
* If a rule is new, it is added with `date`set to the current date.
106
+
* If an older rule exists in the output file but no replacement rule is generated in the current run, the older rule is preserved as-is.
107
+
108
+
The merge logic also avoids churn from regenerated rules that are semantically identical but would otherwise only differ by the freshly generated `date` value.
The script writes hit files and a JSON summary (default: `/tmp/yara-malicious-validation/summary.json`).
207
+
It reports `intentionally skipped samples` separately (from `SKIP_DRIVERS`) and excludes them from `missing expected matches`.
208
+
It also reports root-cause breakdown for missing matches (`no PE FileInfo`, `insufficient VersionInfo strings`, `no YAML for grouped representative`, `grouped into vulnerable rule`).
209
+
When `--skip-generate` is used and no generator log exists yet, the script creates a temporary generator log under the output directory so missing matches can still be classified without rewriting the checked-in rule files.
210
+
The script exits with status `2`if`missing_reason_counts.unknown` is greater than `0`, which makes it suitable for CI.
211
+
212
+
Manual validation commands (equivalent workflow):
213
+
214
+
Run these commands from the repository root to confirm malicious-driver rules match malicious samples tracked in`yaml/`.
0 commit comments