
Motor de procedencia y reducción de falsos positivos para Windows PE sin dependencias (Authenticode integrado + catálogos de seguridad del SO, verificación ROL32 de Rich Header, detección de compilaciones reproducibles y entropía diferencial de secciones).
Motor determinista de procedencia de PE y reducción de falsos positivos para DFIR en Windows
Los escáneres de malware estáticos ingenuos, las heurísticas de YARA y los scripts de entropía sufren tasas de falsos positivos extremas (a menudo del 40% al 60% en endpoints limpios). Clasifican erróneamente de forma rutinaria utilidades legítimas del sistema Windows, ensamblados .NET, aplicaciones Electron, paquetes de PyInstaller y compilaciones C/C++ de desarrolladores sin firmar como malware.
TrueVerdict es un motor de triaje de ejecutables portables (PE32 / ) sin dependencias, construido estrictamente sobre la biblioteca estándar de Python (, , , ) y las API criptográficas nativas de Win32 (, ). Reduce los falsos positivos a al reemplazar las heurísticas de un solo indicador con una .
PE32+ctypesstructmathhashlibwintrust.dllcrypt32.dll0.00% en corpus estándar de SO/desarrollador)| Trampa del escáner ingenuo | Por qué los binarios limpios la activan | Cómo TrueVerdict elimina el falso positivo |
|---|---|---|
| 1. Firmas digitales "faltantes" en archivos del sistema Windows | Más del 50% de los binarios de C:\Windows\System32 (cmd.exe, notepad.exe, powershell.exe, regedit.exe) no contienen una tabla de certificados Authenticode incrustada (IMAGE_DIRECTORY_ENTRY_SECURITY == 0). | Consulta tanto las firmas PKCS#7 incrustadas (WinVerifyTrust) como la base de datos del Catálogo de seguridad del SO Windows (CatRoot .cat) mediante CryptCATAdminCalcHashFromFileHandle + CryptCATAdminEnumCatalogFromHash. |
| 2. Marcas de tiempo de compilación "futuras / falsificadas" (p. ej., año 2034 o 2089) | A partir de Windows 10 1607+, Microsoft cambió a Compilaciones Reproducibles (Brepro), reemplazando el TimeDateStamp de COFF con un hash de compilación determinista. | Analiza IMAGE_DIRECTORY_ENTRY_DEBUG en busca de IMAGE_DEBUG_TYPE_REPRO (Type 16). Reconoce hashes de compilación deterministas y suprime las alertas de marcas de tiempo falsas. |
3. Alta entropía del archivo (H > 7.2 bits/byte) | Los iconos/PNG comprimidos en .rsrc, los metadatos de .NET o las superposiciones de instaladores (PyInstaller, InnoSetup, NSIS, Electron) se acercan naturalmente a 7.5 - 7.99 bits/byte. | Calcula la Entropía Diferencial de Secciones, aislando el código ejecutable (.text) de los recursos no ejecutables (.rsrc) y tomando la huella de contenedores de aplicaciones conocidos. |
4. Importaciones de API Win32 de doble uso (VirtualAllocEx, ResumeThread) |
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)"]Ejecutar python trueverdict.py --benchmark evalúa 32 binarios reales del sistema y de desarrollador de Windows 11 (incluidas utilidades firmadas por catálogo, binarios con marca de tiempo futura Brepro y una compilación C/C++ limpia sin firmar) junto con 5 especímenes PE64 adversarios sintéticos:
======================================================================================
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)Observe cómo C:\Windows\System32\cmd.exe en Windows 11 no lleva ninguna firma Authenticode incrustada, tiene una marca de tiempo de compilación del año 2034 (0x789F4656) e importa ResumeThread. Un escáner heurístico ingenuo lo puntúa con 80/100 (Malicioso/Sospechoso). TrueVerdict resuelve su firma del Catálogo del SO, valida su entrada IMAGE_DEBUG_TYPE_REPRO, verifica su suma de comprobación del Rich Header DanS y reduce su puntuación de riesgo 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 requiere cero paquetes externos de PyPI y funciona directamente en cualquier instalación estándar de Python 3.10+ en 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
Publicado bajo la Licencia MIT.
Los compiladores, navegadores, depuradores y entornos de ejecución de lenguajes (python.exe, cmd.exe, kernel32.dll) importan legítimamente API de manipulación de memoria e hilos. |
Evalúa la Densidad de la Tabla de Importaciones y los Clústeres Combinatorios, suprimiendo las API de doble uso cuando están incrustadas dentro de tablas de importación CRT/SO de alta densidad (55+ importaciones) o firmas verificadas. |
| 5. Compilaciones de desarrollador locales sin firmar | Los binarios C/C++, Rust o Go compilados localmente carecen de certificados Authenticode y son marcados por reglas de "Sin firmar = Sospechoso". | Aplica Sin firmar != Malicioso (penalización base de 0) y valida la procedencia del compilador descifrando el Rich Header de MSVC (DanS) y verificando su suma de comprobación ROL32. |