SecurityRonin/exec-pe-forensic

GitHub: SecurityRonin/exec-pe-forensic

Rust 编写的 Windows PE 二进制文件静态取证分析工具,解析 PE 结构并按 MITRE ATT&CK 标签输出异常检测结果。

Stars: 0 | Forks: 0

[![Crates.io](https://img.shields.io/crates/v/pe-core.svg)](https://crates.io/crates/pe-core) [![Docs.rs](https://img.shields.io/docsrs/pe-core)](https://docs.rs/pe-core) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![CI](https://github.com/SecurityRonin/exec-pe-forensic/actions/workflows/ci.yml/badge.svg)](https://github.com/SecurityRonin/exec-pe-forensic/actions) [![Sponsor](https://img.shields.io/badge/sponsor-h4x0r-pink)](https://github.com/sponsors/h4x0r) **解析 Windows PE 二进制文件,仅需三行 Rust 代码即可获得带有 MITRE 标签的取证检测结果。** ``` use pe_core::parser::parse_pe_path; use pe_analysis::detect_all; let pe = parse_pe_path("suspicious.exe")?; for hit in detect_all(&pe) { println!("[{}] {} — {}", hit.mitre_technique_id, hit.tactic, hit.description); } ``` ``` [T1027.002] defense-evasion — Packed/protected section 'UPX0' (entropy 7.82, known packer name) [T1055] defense-evasion — Suspicious API import: 'VirtualAllocEx' [T1055] defense-evasion — Suspicious API import: 'WriteProcessMemory' [T1055] defense-evasion — Suspicious API import: 'CreateRemoteThread' [T1486] impact — QWCrypt/RedCurl IOC '.qwCrypt' found in PE string table [T1562.001] defense-evasion — AV exclusion fragment 'Windows Defender\Exclusions' found in PE string table ``` ## 检测内容 | 检测项 | MITRE ID | 置信度 | 信号特征 | |-----------|----------|------------|--------| | 可疑 API 导入 | T1055 / T1134 | 高 | `VirtualAllocEx`, `WriteProcessMemory`, `CreateRemoteThread`, `BCryptEncrypt`, `ShellExecuteW`, 原始 Winsock, 以及 55+ 个其他特征 | | 加壳 / 受保护二进制文件 | T1027.002 | 高 | UPX, MPRESS, Themida, VMProtect, Enigma 节区名称 **或** Shannon 熵 ≥ 6.8 | | PE 结构异常 | T1027 | 中–高 | W+X 节区, EP 位于节区外, 仅虚拟节区, 虚拟/原始比例过大, 缺失 Rich header | | Overlay 数据 | T1027.009 | 高 | 附加在最后一个节区之后的字节 — dropper/second-stage 通道 | | TLS 回调 | T1055.005 | 高 | 在 PE entry point 之前执行的回调 — 反调试暂存区 | | 反调试 API 导入 | T1622 | 中 | `IsDebuggerPresent`, `NtQueryInformationProcess`, `QueryPerformanceCounter`, `FindWindowA`, 时间检查, 以及 25+ 个其他特征 | | Process hollowing 集群 | T1055.012 | 高 | 以下特征中出现 ≥ 3 项: `NtUnmapViewOfSection`, `WriteProcessMemory`, `SetThreadContext`, `VirtualAllocEx`, `ResumeThread`, 以及 8 个其他特征 | | 网络 / C2 字符串 | T1071.001 | 中 | `http://`, `https://`, `.onion`, `User-Agent:`, `/beacon`, `/implant`, `meterpreter`, `reverse_tcp`, 以及 15+ 个其他特征 | | 持久化字符串 | T1547.001 | 高 | `CurrentVersion\Run`, `Winlogon\Userinit`, `schtasks /create`, WMI event filters, `AppInit_DLLs`, COM `InprocServer32` | | 勒索软件字符串 | T1486 | 高 | `.wncry`, `.locked`, `HOW_TO_DECRYPT`, `bitcoin`, `monero`, `.onion`, `YOUR_FILES_ARE_ENCRYPTED`, 以及 20+ 个其他特征 | | 凭据 / 密钥字符串 | T1552.001 | 高 | `password=`, `api_key=`, `AKIA` (AWS key prefix), `-----BEGIN`, `Authorization: Bearer`, JWT prefix, DB connection strings | | .NET 异常 | T1027 | 中 | 带有原生 TLS 回调或 overlay 的托管二进制文件 — mixed-mode loader / dropper 模式 | | AV 排除字符串 | T1562.001 | 中 | Defender, Kaspersky, McAfee, Sophos, ESET, Bitdefender 注册表路径片段 | | QWCrypt / RedCurl IOCs | T1486 | 高 | `.qwCrypt`, `rbcw`, `excludeVM`, `ZAM64`, `zamguard`, `workers.dev` | 检测结果按 MITRE 技术 ID 排序 — 输出是确定性的,并且在多次运行中非常易于进行 diff 对比。 ## 安装 ``` [dependencies] pe-core = "0.1" pe-analysis = "0.1" ``` 这两个 crate 是刻意分开的。`pe-core` 是一个无 I/O、与介质无关的解析器:它接受 `&[u8]` 或文件路径,并返回一个 `PeFile` 结构体。`pe-analysis` 包含检测器;它们是针对 `&PeFile` 的纯函数,自身不进行任何 I/O 操作。如果你只需要结构化的 PE 元数据,可以单独使用 `pe-core`。 ## 从 `PeFile` 获取的内容 ``` pub struct PeFile { pub machine: u16, // 0x8664 AMD64 | 0x014C x86 | 0xAA64 ARM64 pub compile_timestamp: u32, // COFF timestamp — frequently zeroed or faked pub is_dll: bool, pub is_exe: bool, pub imports: Vec, // all imported symbol names pub exports: Vec, // exported symbol names (DLLs) pub sections: Vec, pub ascii_strings: Vec, // printable ASCII runs ≥ 6 chars pub utf16_strings: Vec, // UTF-16LE runs ≥ 6 chars pub sha256: String, // hex-encoded SHA-256 of the full binary pub size: usize, } pub struct PeSection { pub name: String, pub virtual_size: u32, pub raw_size: u32, pub virtual_address: u32, pub entropy: f32, // Shannon entropy 0.0 – 8.0 pub is_executable: bool, pub is_writable: bool, pub is_readable: bool, } ``` ## 架构 ``` exec-pe-forensic ├── pe-core PARSER layer — accepts &[u8] or Path, no CONTAINER/FS dependencies │ ├── parser goblin::pe::PE → PeFile struct (imports, sections, strings, SHA-256) │ └── strings extract_ascii / extract_utf16le / compute_entropy └── pe-analysis detectors — pure fn(&PeFile) -> Vec ├── suspicious_imports SUSPICIOUS_IMPORT_NAMES from forensicnomicon ├── packed PACKED_SECTION_NAMES + entropy threshold ├── av_exclusion AV_EXCLUSION_PATH_FRAGMENTS from forensicnomicon └── ioc QWCRYPT_PE_STRING_IOCS from forensicnomicon ``` 格式常量和 IOC 列表位于 [`forensicnomicon`](https://github.com/SecurityRonin/forensicnomicon) — 一个零依赖、编译期的知识库 crate。更新 IOC 列表意味着提升 `forensicnomicon` 的版本,而无需改动任何解析逻辑。 ## 66 项测试,严格遵守 TDD 每个检测器都是采用测试优先(先提交红灯 red commit,再提交绿灯 green)的方式编写的。真实样本库的验证是对单元测试套件的补充。 ``` cargo test ``` [隐私政策](https://securityronin.github.io/exec-pe-forensic/privacy/) · [服务条款](https://securityronin.github.io/exec-pe-forensic/terms/) · © 2026 Security Ronin Ltd
标签:DAST, DNS 反向解析, PE文件分析, Rust, 可视化界面, 恶意软件分析, 数字取证, 网络流量审计, 自动化脚本, 逆向分析, 通知系统