albertotijunelis/hashguard
GitHub: albertotijunelis/hashguard
文件验证与威胁情报平台,集成本地静态分析与多源威胁情报查询,提供一键式恶意文件检测和风险评分能力。
Stars: 0 | Forks: 0
文件验证与威胁情报平台
HashGuard 是一个专业级文件分析平台,集成了加密哈希、恶意软件签名匹配、PE 可执行文件检查、YARA 规则扫描、多源威胁情报、自动化风险评分以及 IOC 提取功能 —— 全部通过现代化的 GUI、CLI 或 Python API 实现。 ## 功能特性 | 类别 | 功能 | 详情 | |----------|---------|---------| | **哈希** | 流式哈希 | 单次遍历计算 SHA-256, SHA-1, MD5 | | **签名** | 签名匹配 | 通过 `signatures.json` 标记已知的恶意文件 | | **风险评分** | 综合评分 | 0-100 风险评分,包含安全 / 可疑 / 恶意判定 | | **PE 分析** | 可执行文件检查 | 通过 `pefile` 进行节区、导入表、熵值、加壳检测 | | **YARA** | 基于规则的扫描 | `yara_rules/` 中包含 5 个类别共 28+ 条规则 | | **IOC 提取** | 字符串分析 | URLs, IPs, 域名, PowerShell, 加密货币钱包, 注册表键 | | **威胁情报** | MalwareBazaar | 免费哈希声誉查询 —— 自动运行 | | **威胁情报** | URLhaus | 免费有效载荷数据库查询 —— 自动运行 | | **威胁情报** | AlienVault OTX | 免费哈希声誉 (OTX v2) —— 自动运行 | | **威胁情报** | AbuseIPDB | IP 声誉 (免费层级, 需要 `ABUSEIPDB_API_KEY`) | | **威胁情报** | VirusTotal | 使用 `--vt` 标志 + API 密钥进行文件哈希 + URL 扫描 | | **URL 分析** | 下载并扫描 | 从 URL 获取文件,计算哈希,并检查所有来源 | | **GUI** | 拖放操作 | 将文件拖放到具有风险可视化的暗色主题界面中 | | **CLI** | 批量模式 | 扫描目录,导出 JSON / CSV / HTML 报告 | | **分发** | 安装程序 + 便携版 | NSIS 安装程序, 便携版 ZIP, 独立 `.exe` | ## 架构 ``` ┌──────────────────────────────────────────────────┐ │ HashGuard │ ├──────────┬──────────┬────────────────────────────┤ │ CLI │ GUI │ Python API │ │ cli.py │ gui.py │ from hashguard import │ ├──────────┴──────────┴────────────────────────────┤ │ scanner.py │ │ compute_hashes() → analyze() → analyze_url() │ ├──────────┬──────────┬──────────┬─────────────────┤ │ PE │ YARA │ Threat │ Risk Scorer │ │ Analyzer │ Scanner │ Intel │ + IOC Extractor │ │ pefile │ yara‑py │ VT / MB │ risk_scorer.py │ │ │ 28+rules │ URLhaus │ string_extractor│ │ │ │ OTX │ .py │ ├──────────┴──────────┴──────────┴─────────────────┤ │ reports.py │ │ JSON / CSV / HTML batch reports │ └──────────────────────────────────────────────────┘ ``` ## 快速开始 ### 从 PyPI 安装 ``` pip install hashguard ``` ### 从源码安装 ``` git clone https://github.com/albertotijunelis/hashguard.git cd hashguard pip install -e . ``` ### CLI ``` hashguard file.exe # hashes + signatures + PE + YARA + threat intel + risk score hashguard file.exe --vt --json # also query VirusTotal (requires VT_API_KEY) hashguard --url https://example.com/file.exe # download & analyze file from URL hashguard --batch ./samples -o report.html # batch scan to HTML hashguard --gui # launch GUI ``` ### GUI ``` hashguard-gui ``` GUI 采用暗色界面,支持拖放操作、URL 分析、实时进度显示、可视化风险评分条、颜色编码的威胁指示器、IOC 提取展示、PE 节区详情、YARA 匹配显示以及多源威胁情报。 ### Python API ``` from hashguard import analyze, analyze_pe, yara_scan, compute_risk, extract_strings # 完整分析 (hashes + signatures + PE + YARA + threat intel + risk score + IOCs) result = analyze("file.exe") print(result.hashes["sha256"]) print(result.malicious) print(result.risk_score) # {"score": 72, "verdict": "malicious", "factors": [...]} print(result.strings_info) # extracted URLs, IPs, domains, PowerShell, crypto wallets print(result.pe_info) # PE sections, imports, entropy print(result.yara_matches) # YARA rule matches print(result.threat_intel) # MalwareBazaar + URLhaus + AlienVault OTX results print(result.to_json()) # 同时查询 VirusTotal (需要 VT_API_KEY 环境变量) result = analyze("file.exe", vt=True) # 独立 PE 分析 pe = analyze_pe("file.exe") print(pe.packed, pe.packer_hint, pe.suspicious_imports) ``` ## YARA 规则 将 `.yar` / `.yara` 文件放置在 `yara_rules/` 目录中。HashGuard 自带 **28+ 条规则**,涵盖 5 个类别: | 文件 | 规则数 | 检测内容 | |------|-------|---------| | `default.yar` | 11 | PowerShell, 注入, 反调试, 勒索软件, 键盘记录器, Mimikatz, shellcode, 下载器, 混淆, 网络, 持久化 | | `ransomware.yar` | 3 | 勒索信, 文件扩展名更改, 卷影副本删除 | | `trojans.yar` | 4 | 反向 Shell, 剪贴板劫持, 屏幕捕获, 数据窃取 | | `packers.yar` | 6 | UPX, MPRESS, ASPack, Themida/VMProtect, Enigma, PECompact | | `scripts.yar` | 4 | VBA 宏下载器, 批处理载荷, JS 下载器, HTA 载荷 | 每次扫描时会自动加载自定义规则。 ## 配置 | 变量 | 描述 | |---|---| | `VT_API_KEY` | VirusTotal API 密钥 (添加 VT 查询; 其他来源无需此密钥即可运行) | | `ABUSEIPDB_API_KEY` | AbuseIPDB API 密钥 (添加 IP 声誉查询; 可在 abuseipdb.com 免费获取) | | `HASHGUARD_SIGNATURES` | 自定义签名数据库的路径 | 设置也可以通过 **GUI 设置标签页** 进行配置,该设置会持久化保存到 `%APPDATA%/HashGuard/config.json`。 ## 对比 | 功能 | HashGuard | VirusTotal (web) | ClamAV | |---------|:----------:|:----------------:|:------:| | 离线哈希 | **是** | 否 | 是 | | 风险评分 | **是** | 部分 | 否 | | IOC 提取 | **是** | 否 | 否 | | PE 分析 | **是** | 部分 | 否 | | YARA 规则 | **是** | 否 | 是 | | MalwareBazaar | **是** | 否 | 否 | | URLhaus | **是** | 否 | 否 | | AlienVault OTX | **是** | 否 | 否 | | VirusTotal | **是** | **是** | 否 | | GUI + CLI | **是** | 仅网页 | 仅 CLI | | Windows 安装程序 | **是** | 不适用 | 是 | | 开源 | **MIT** | 否 | **GPL** | ## 构建 ``` cd scripts py -3.12 -m PyInstaller hashguard-cli.spec # CLI executable py -3.12 -m PyInstaller hashguard-gui.spec # GUI executable ``` 版本发布通过 GitHub Actions 自动化 —— 推送一个 `v*` 标签,工作流将发布可执行文件、便携版 ZIP 和 Windows 安装程序。 ## 项目结构 ``` src/hashguard/ scanner.py core analysis engine risk_scorer.py composite 0-100 risk scoring string_extractor.py automated IOC/string extraction pe_analyzer.py PE executable inspection yara_scanner.py YARA rules scanning threat_intel.py MalwareBazaar + URLhaus + AlienVault OTX + AbuseIPDB cli.py command-line interface gui.py Tkinter dark-themed GUI with risk visualization config.py configuration management reports.py JSON / CSV / HTML reports logger.py logging utilities yara_rules/ YARA rule files (.yar) — 5 category files, 28+ rules signatures.json malware hash signatures tests/ 101 pytest tests assets/branding/ logo and icon files scripts/ PyInstaller specs and build tooling ``` ## 许可证 [MIT](LICENSE)标签:CVE, DNS 反向解析, IOC提取, IP 地址批量处理, PE文件分析, Python, TLP, YARA, 云安全监控, 云资产可视化, 哈希校验, 域名收集, 威胁情报, 开发者工具, 恶意代码分析, 搜索语句(dork), 数字签名, 文件分析, 无后门, 无服务器架构, 沙箱, 漏洞挖掘, 网络信息收集, 网络安全, 逆向工具, 配置文件, 防病毒, 隐私保护, 静态分析