
Motore di provenienza e riduzione dei falsi positivi per Windows PE senza dipendenze (Authenticode incorporato + cataloghi di sicurezza del sistema operativo, verifica ROL32 dell'header Rich, rilevamento di build riproducibili ed entropia differenziale delle sezioni).
Motore deterministico di provenienza PE e riduzione dei falsi positivi per il DFIR su Windows
I scanner statici di malware naïf, le euristiche YARA e gli script basati sull'entropia soffrono di tassi di falsi positivi estremamente elevati (spesso dal 40% al 60% su endpoint puliti). Classificano regolarmente come malware utilità di sistema Windows legittime, assembly .NET, app Electron, bundle PyInstaller e build C/C++ non firmate di sviluppatori.
TrueVerdict è un motore di triage per Portable Executable (PE32 / ) a dipendenze zero, costruito esclusivamente sulla Python Standard Library (, , , ) e sulle API crittografiche native Win32 (, ). Riduce i falsi positivi a sostituendo le euristiche a singolo indicatore con una .
PE32+ctypesstructmathhashlibwintrust.dllcrypt32.dll0.00% su corpora standard di OS/sviluppatori)| Trappola del scanner naïf | Perché i binari puliti la attivano | Come TrueVerdict elimina il falso positivo |
|---|---|---|
| 1. Firme digitali "mancanti" sui file di sistema Windows | Oltre il 50% dei binari in C:\Windows\System32 (cmd.exe, notepad.exe, powershell.exe, regedit.exe) non contiene una tabella di certificati Authenticode incorporata (IMAGE_DIRECTORY_ENTRY_SECURITY == 0). | Interroga sia le firme PKCS#7 incorporate (WinVerifyTrust) sia il database del Catalogo di Sicurezza del Sistema Operativo Windows (CatRoot .cat) tramite CryptCATAdminCalcHashFromFileHandle + CryptCATAdminEnumCatalogFromHash. |
| 2. Timestamp di compilazione "futuri / falsificati" (es. anno 2034 o 2089) | A partire da Windows 10 1607+, Microsoft è passata alle Build Riproducibili (Brepro), sostituendo il TimeDateStamp COFF con un hash di build deterministico. | Analizza IMAGE_DIRECTORY_ENTRY_DEBUG alla ricerca di IMAGE_DEBUG_TYPE_REPRO (Type 16). Riconosce gli hash di build deterministici e sopprime i falsi allarmi sui timestamp. |
3. Entropia del file elevata (H > 7.2 bit/byte) | Icone/PNG compressi in .rsrc, metadati .NET o overlay di installer (PyInstaller, InnoSetup, NSIS, Electron) si avvicinano naturalmente a 7.5 - 7.99 bit/byte. | Calcola l'Entropia Differenziale delle Sezioni, isolando il codice eseguibile (.text) dalle risorse non eseguibili (.rsrc) e identificando le impronte dei container applicativi noti. |
4. Import di API Win32 a doppio uso (VirtualAllocEx, ResumeThread) | Compilatori, browser, debugger e runtime di linguaggi (, , ) importano legittimamente API di manipolazione della memoria e dei thread. |
flowchart TD
A["Target PE32 / PE32+ Binary"] --> L1["Layer 1: Dual-Path Cryptographic Verification\n(wintrust.dll Embedded PKCS#7 + CatRoot .cat Lookup)"]
L1 --> L2["Layer 2: Compiler Provenance\n(Rich Header 'DanS' XOR Decryption & ROL32 Checksum)"]
L2 --> L3["Layer 3: Debug & Timestamp Validation\n(IMAGE_DEBUG_TYPE_REPRO Deterministic Build Detection)"]
L3 --> L4["Layer 4: Differential Entropy & Section Permissions\n(.text vs .rsrc Segmentation + RWX Memory Detection)"]
L4 --> L5["Layer 5: Combinatorial IAT Profiling\n(MD5 Imphash + Offensive Cluster vs. Benign CRT Density)"]
L5 --> L6["Layer 6: Canonical Path & Identity Verification\n(System32 Path Validation + Levenshtein Typosquatting + VS_VERSIONINFO)"]
L6 --> L7["Layer 7: Multi-Vector Corroboration Gate\n(Blocks Single-Indicator Alerts; Requires >= 2 Independent Layers)"]
L7 --> V["Deterministic Triage Verdict\n(BENIGN / LOW_RISK_ANOMALY / SUSPICIOUS / MALICIOUS)"]L'esecuzione di python trueverdict.py --benchmark valuta 32 binari reali di sistema e di sviluppo di Windows 11 (incluse utilità firmate tramite catalogo, binari con timestamp futuro Brepro e una build C/C++ pulita non firmata) insieme a 5 campioni PE64 avversariali sintetici:
======================================================================================
TRUEVERDICT - LIVE FALSE-POSITIVE STRESS BENCHMARK & ADVERSARIAL VALIDATION
======================================================================================
[PHASE 1] Scanning 32 Legitimate OS & Developer Binaries...
--------------------------------------------------------------------------------------
BINARY NAME | SIGNING MODE | NAIVE | FINAL | VERDICT
--------------------------------------------------------------------------------------
notepad.exe | OS_CATALOG | 45 | 0 | BENIGN (99.9%)
cmd.exe | OS_CATALOG | 80 | 0 | BENIGN (99.9%)
svchost.exe | EMBEDDED_AUTHENTICODE | 60 | 0 | BENIGN (99.9%)
calc.exe | OS_CATALOG | 45 | 0 | BENIGN (99.9%)
explorer.exe | EMBEDDED_AUTHENTICODE | 60 | 0 | BENIGN (99.9%)
regedit.exe | OS_CATALOG | 45 | 0 | BENIGN (99.9%)
certutil.exe | OS_CATALOG | 45 | 0 | BENIGN (99.9%)
spoolsv.exe | OS_CATALOG | 80 | 0 | BENIGN (99.9%)
powershell.exe | OS_CATALOG | 45 | 0 | BENIGN (99.9%)
python.exe | EMBEDDED_AUTHENTICODE | 0 | 0 | BENIGN (99.9%)
clean_unsigned_dev_tool.exe | UNSIGNED | 20 | 0 | BENIGN (98.5%)
... (all 32 legitimate binaries score 0/100)
[PHASE 2] Scanning 5 Synthetic Adversarial Threat Specimens...
--------------------------------------------------------------------------------------
THREAT SPECIMEN | PRIMARY DETECTION VECTORS | SCORE | VERDICT
--------------------------------------------------------------------------------------
svchost.exe | L2_RICH_F,L6_MASQUE | 100 | MALICIOUS (99.4%)
scvhost.exe | L2_RICH_F,L6_MASQUE | 100 | MALICIOUS (99.4%)
reflective_rwx_stub.exe | L4_RWX_ME,L4_PACKED | 100 | MALICIOUS (99.4%)
hollow_injector.exe | L2_RICH_F,L3_TIMEST | 90 | MALICIOUS (94.6%)
tampered_cert_implant.exe | L1_CRYPTO,L2_RICH_F | 100 | MALICIOUS (99.4%)
======================================================================================
BENCHMARK SUMMARY: NAIVE HEURISTICS vs. TRUEVERDICT CORROBORATION ENGINE
======================================================================================
Total Binaries Evaluated : 37 (2.70s)
Naive Heuristic False Positives : 18/32 (56.25% FPR)
TrueVerdict False Positives : 0/32 (0.00% FPR)
Total False-Positive Risk Suppressed: -1175 heuristic noise points
Adversarial Threat Detection Rate : 5/5 (100.00% TPR)
======================================================================================
cmd.exe)Si noti come C:\Windows\System32\cmd.exe su Windows 11 non contenga alcuna firma Authenticode incorporata, abbia un timestamp di compilazione dell'anno 2034 (0x789F4656) e importi ResumeThread. Un scanner euristico naïf lo valuta 80/100 (Malevolo/Sospetto). TrueVerdict risolve la sua firma tramite Catalogo OS, convalida la sua voce IMAGE_DEBUG_TYPE_REPRO, verifica il checksum del suo Header Rich DanS e riduce il suo punteggio di rischio a 0/100 (BENIGN):
====================================================================================
TRUEVERDICT FORENSIC TRIAGE REPORT : cmd.exe
====================================================================================
File Path : C:\Windows\System32\cmd.exe
File Size : 344,064 bytes
SHA-256 : 97ac98b1a92c286054cce55239cfccdfc23a5517bd07fe693072c9ca96c7dabb
Imphash (MD5) : 010b165e4c37f484601d3dbd700c9423
Architecture : x64 (64-bit) | Linker: 14.38 | Container: NATIVE_UNPACKED
Compile Timestamp : 2034-02-16 12:02:30 UTC [REPRODUCIBLE_BUILD_HASH]
[1] CRYPTOGRAPHIC PROVENANCE (AUTHENTICODE + OS CATALOG)
------------------------------------------------------------------------------
Verification Mode : OS_CATALOG
Status : Valid Windows Security Catalog Signature
Verified Signer : Microsoft Windows Production PCA 2011
Certificate Issuer: Microsoft Root Certificate Authority 2010
OS Security Cat : C:\WINDOWS\system32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\Microsoft-Windows-Client-Desktop-Required-Package0512~31bf3856ad364e35~amd64~~10.0.26100.9444.cat
[2] COMPILER PROVENANCE (RICH HEADER & DEBUG METADATA)
------------------------------------------------------------------------------
Rich Header (DanS): Present | XOR Key: 0xD7965A3A | ROL32 Checksum: VALID (Authentic MSVC Build)
Toolchain Objects : 11 @comp.id records
CodeView PDB Path : cmd.pdb
[5] FALSE-POSITIVE SUPPRESSION & CORROBORATION MATRIX
------------------------------------------------------------------------------
[+] TRUST ANCHOR [L1_CRYPTO_TRUST ] (-75) Valid Windows Security Catalog Signature (Microsoft Windows Production PCA 2011)
[+] TRUST ANCHOR [L2_RICH_PROVENANCE ] (-15) Authentic MSVC Rich Header ('DanS') verified via ROL32 checksum (0xD7965A3A, 11 toolchain build objects)
[~] FP SUPPRESSED [L1_CATALOG_RECOVERY ] (-20) Binary has no embedded Authenticode table, but matched verified OS Catalog
[~] FP SUPPRESSED [L3_BREPRO_TIMESTAMP ] (-25) Non-chronological PE TimeDateStamp (0x789F4656) verified as deterministic Reproducible Build (IMAGE_DEBUG_TYPE_REPRO) hash
[~] FP SUPPRESSED [L5_DUAL_USE_API_SUPPRESSION] (-35) Dual-use Win32 APIs (ResumeThread) suppressed within high-density/trusted IAT (287 total imports)
[*] Active Risk Vectors: 0 (Zero corroborated threat indicators)
====================================================================================
NAIVE HEURISTIC SCORE : 80/100 --> TRUEVERDICT FINAL SCORE : 0/100 (-80 FP noise suppressed)
FINAL VERDICT : BENIGN (Confidence: 99.9% | Corroborated Layers: 0)
====================================================================================
TrueVerdict richiede zero pacchetti PyPI esterni e funziona immediatamente su qualsiasi installazione standard di Python 3.10+ su Windows.
git clone https://github.com/prox0959/TrueVerdict.git
cd TrueVerdict
# 1. Run the live False-Positive Stress Benchmark (32 OS/Dev binaries + 5 synthetic threats)
python trueverdict.py --benchmark
# 2. Triage a single binary (.exe, .dll, .sys)
python trueverdict.py C:\Windows\System32\cmd.exe
# 3. Triage an entire directory and export structured JSON
python trueverdict.py --dir C:\Windows\System32 --limit 50 --json system32_triage.json
# 4. Run unit & integration test suite
python -m unittest discover -s tests -v
Rilasciato sotto MIT License.
python.execmd.exekernel32.dllValuta la Densità della Tabella di Import e i Cluster Combinatori, sopprimendo le API a doppio uso quando sono incorporate in tabelle di import CRT/OS ad alta densità (55+ import) o con firme verificate. |
| 5. Build locali non firmate di sviluppatori | I binari C/C++, Rust o Go compilati localmente mancano di certificati Authenticode e vengono segnalati dalle regole "Non firmato = Sospetto". | Applica il principio Non firmato != Malevolo (penalità di base 0) e convalida la provenienza del compilatore decifrando l'Header Rich MSVC (DanS) e verificando il suo checksum ROL32. |