gutddts/IOC-Hunter

GitHub: gutddts/IOC-Hunter

一款从文本和日志中提取九类入侵指标并与日志进行批量匹配的威胁情报分析系统,支持 STIX 导入和可视化报告生成。

Stars: 1 | Forks: 0

# IOC Hunter 威胁情报入侵指标 提取与匹配系统。 IOC Hunter 从文本/日志中提取入侵指标,对它们进行验证,将其与日志文件进行匹配,并生成综合报告。 ## 功能 - **提取**:提取包括 IPv4、域名、URL、MD5/SHA1/SHA256 哈希、电子邮件地址、注册表项和文件路径在内的 IOC - **验证**:验证 IOC 格式,检测误报,可选地检查网络可达性 - **匹配**:通过精确或模糊匹配,将提取的 IOC 与日志文件进行匹配 - **威胁情报源**:管理 IOC 集合,支持导入/导出 (CSV, JSON, STIX) - **报告**:生成 JSON 报告或带有图表和颜色编码 IOC 类型的精美 HTML 报告 ## 安装 ``` # 安装依赖 pip install -r requirements.txt # 或者安装为 package pip install -e . ``` ## 快速开始 ``` # 从文本文件提取 IOC python main.py extract -i samples/sample_logs.txt # 提取 IOC 并生成 HTML 报告 python main.py extract -i samples/sample_logs.txt --html report.html # 提取并与日志进行匹配 python main.py match -i samples/sample_logs.txt -l samples/sample_logs.txt # 导入 threat feed python main.py feed import -f samples/sample_ioc_report.json # 列出 feed 中的所有 IOC python main.py feed list # 验证 IOC python main.py validate -i samples/sample_logs.txt # 根据匹配结果生成 HTML 报告 python main.py match -i samples/sample_logs.txt -l samples/sample_logs.txt --html match_report.html ``` ## 使用方法 ### 提取 IOC ``` # 从文件 python main.py extract -i input.txt # 从 stdin cat input.txt | python main.py extract # 带有输出报告 python main.py extract -i input.txt -o results.json --html report.html ``` 支持的 IOC 类型: - **IPv4**:完整的 IP 地址(排除私有/保留范围) - **Domain**:域名(排除常见安全域名) - **URL**:包含协议和路径的完整 URL - **MD5**:32 字符的十六进制哈希值 - **SHA1**:40 字符的十六进制哈希值 - **SHA256**:64 字符的十六进制哈希值 - **Email**:电子邮件地址 - **Registry**:Windows 注册表项 (HKEY_*) - **File Path**:Windows (C:\...) 和 Linux (/...) 路径 ### 将 IOC 与日志进行匹配 ``` # 与单个日志文件匹配 python main.py match -i iocs.txt -l server.log # 与目录中的所有日志匹配 python main.py match -i iocs.txt -l /var/logs/ # 模糊匹配(部分匹配) python main.py match -i iocs.txt -l logs/ -m fuzzy # 生成 HTML 报告 python main.py match -i iocs.txt -l logs/ --html report.html ``` ### 管理威胁情报源 ``` # 从 CSV/JSON/STIX 导入 python main.py feed import -f feed.csv python main.py feed import -f feed.json # 列出 IOC(可选按类型过滤) python main.py feed list python main.py feed list -t ipv4 # 手动添加 IOC python main.py feed add --value 203.0.113.5 --type ipv4 --source "CSIRT" --confidence high # 移除 IOC python main.py feed remove --value 203.0.113.5 # 搜索 IOC python main.py feed search --query "evil" # 显示统计信息 python main.py feed stats # 导出 IOC python main.py feed export -o exported_iocs.json # 清除所有 IOC python main.py feed clear ``` ### 生成报告 ``` # JSON 报告 python main.py report -f json -o report.json --file input.txt # HTML 报告 python main.py report -f html -o report.html --file match_results.json ``` ### 验证 IOC ``` # 基本验证 python main.py validate -i input.txt # 带有网络检查(ping/DNS) python main.py validate -i input.txt --network # 保存验证报告 python main.py validate -i input.txt -o validation.json ``` ## 输出格式 ### JSON 报告 结构化的 JSON,包含提取/匹配统计信息、IOC 详细信息和元数据。 ### HTML 报告 精美的 HTML,包含: - 颜色编码的 IOC 类型标签 - 显示 IOC 分布的 CSS 饼图 - 用于类型比较的水平条形图 - 适用于桌面和移动端的响应式设计 - 带有上下文的详细匹配表 ## 项目结构 ``` IOC-Hunter/ ├── main.py # CLI entry point ├── requirements.txt # Dependencies ├── setup.py # Package configuration ├── README.md # This file ├── ioc_parser/ │ ├── extractor.py # IOC extraction (regex-based) │ └── validator.py # IOC validation ├── matcher/ │ ├── log_matcher.py # Log matching engine │ └── report_generator.py # Text/CSV report generator ├── feeds/ │ └── threat_feed.py # Threat feed management ├── output/ │ ├── json_output.py # JSON report formatter │ └── html_output.py # HTML report formatter ├── rules/ │ └── ioc_patterns.yaml # IOC regex patterns (YAML) ├── utils/ │ └── common.py # Shared utilities └── samples/ ├── sample_logs.txt # Example log data └── sample_ioc_report.json # Example output ``` ## 依赖项 - Python 3.8+ - PyYAML(可选,用于加载 YAML 模式) ## 许可证 MIT License
标签:IOC提取, IP 地址批量处理, Python, STIX, 威胁情报, 开发者工具, 恶意代码分类, 数据泄露, 文档结构分析, 无后门, 网络信息收集, 逆向工具