abhiiibabariya-dev/ioc-scanner
GitHub: abhiiibabariya-dev/ioc-scanner
这是一个基于 Python 标准库的无依赖工具,用于从文本中提取并扫描威胁指标(IOC),支持对接 VirusTotal 等多源情报平台进行自动化研判。
Stars: 0 | Forks: 0
IOC Scanner
提取 IOC 并针对 VirusTotal、AbuseIPDB 和 OTX AlienVault 进行扫描
## 功能 **IOC Scanner** 是一款面向 SOC 分析师的 Python CLI 工具,具有以下功能: 1. **提取**:从任何文本(报告、日志、电子邮件、威胁情报)中提取 IOC 2. **分类**:对其进行分类(IPv4、域名、URL、MD5、SHA1、SHA256、电子邮件、CVE) 3. **扫描**:针对多个威胁情报源进行扫描 4. **生成**:生成包含威胁级别的可执行报告 自动处理已还原的 IOC(`hxxps://`、`[.]`)。零外部依赖——仅使用 Python 标准库。 ## 支持的 IOC 类型 | 类型 | 示例 | 自动检测 | |------|---------|:---:| | IPv4 | `8.8.8.8`, `185.220.101[.]34` | 是 | | Domain | `evil.com`, `c2[.]malware[.]net` | 是 | | URL | `https://evil.com/payload`, `hxxps://...` | 是 | | MD5 | `d41d8cd98f00b204e9800998ecf8427e` | 是 | | SHA1 | `da39a3ee5e6b4b0d3255bfef95601890afd80709` | 是 | | SHA256 | `a7ffc6f8bf1ed76651c14756a061d662...` | 是 | | Email | `attacker@phishing.com` | 是 | | CVE | `CVE-2024-21762` | 是 | ## 威胁情报源 | 源 | IP | 域名 | 哈希 | API 密钥 | |------|:--:|:------:|:----:|---------| | VirusTotal | 是 | 是 | 是 | `VIRUSTOTAL_API_KEY` | | AbuseIPDB | 是 | -- | -- | `ABUSEIPDB_API_KEY` | | OTX AlienVault | 是 | 是 | 是 | `OTX_API_KEY` | ## 快速开始 ``` # 安装 git clone https://github.com/abhiiibabariya-dev/ioc-scanner.git cd ioc-scanner # 设置 API keys(可选 -- 无需此设置即可进行提取) export VIRUSTOTAL_API_KEY="your-key" export ABUSEIPDB_API_KEY="your-key" export OTX_API_KEY="your-key" # 从文本中提取 IOCs python -m ioc_scanner.cli extract "Found C2 at 185.220.101.34 with hash d41d8cd98f00b204e9800998ecf8427e" # 从文件中提取 python -m ioc_scanner.cli extract sample_iocs/threat_report.txt --file # 针对 threat feeds 扫描 IOCs python -m ioc_scanner.cli scan "185.220.101.34" -t ipv4 # 扫描 threat report 中的所有 IOCs python -m ioc_scanner.cli scan sample_iocs/threat_report.txt --file # JSON 输出 python -m ioc_scanner.cli scan sample_iocs/threat_report.txt --file -f json # 保存 report python -m ioc_scanner.cli scan sample_iocs/threat_report.txt --file -o report.txt ``` ## 示例输出 ``` ====================================================================== IOC SCANNER - THREAT INTELLIGENCE REPORT Scan Time: 2026-04-08 12:00:00 UTC Total IOCs: 6 Malicious: 3 | Clean: 3 ====================================================================== [!] 185.220.101.34 Type: ipv4 | Threat Level: CRITICAL | Status: MALICIOUS [VirusTotal] MALICIOUS (score: 78.0%) - malicious_engines: 14 - total_engines: 90 [AbuseIPDB] MALICIOUS (score: 95.0%) - abuse_score: 95 - country: DE - total_reports: 1247 [+] 8.8.8.8 Type: ipv4 | Threat Level: LOW | Status: CLEAN [VirusTotal] CLEAN (score: 0.0%) [AbuseIPDB] CLEAN (score: 0.0%) ``` ## 作为库使用 ``` from ioc_scanner.extractor import extract_iocs from ioc_scanner.scanner import IOCScanner from ioc_scanner.feeds import get_feed # 提取 IOCs iocs = extract_iocs("Check IP 185.220.101.34 and hash d41d8cd98f00b204e9800998ecf8427e") for ioc in iocs: print(f"{ioc.ioc_type.value}: {ioc.value}") # 针对 feeds 扫描 scanner = IOCScanner() scanner.add_feed(get_feed("virustotal", "YOUR_API_KEY")) results = scanner.scan_text("Suspicious IP: 185.220.101.34") for r in results: print(f"{r.ioc.value}: {r.threat_level}") ``` ## 项目结构 ``` ioc-scanner/ ├── ioc_scanner/ │ ├── __init__.py │ ├── extractor.py # IOC extraction & classification │ ├── feeds.py # Threat intelligence feed integrations │ ├── scanner.py # Core scanning engine & report generator │ └── cli.py # Command-line interface ├── sample_iocs/ │ └── threat_report.txt # Sample threat report for testing ├── tests/ │ └── test_extractor.py # Unit tests ├── setup.py └── README.md ``` ## 运行测试 ``` pip install pytest pytest tests/ -v ``` ## 许可证 MIT License - 详见 [LICENSE](LICENSE)。标签:AbuseIPDB, Ask搜索, Defanged IOC, IOC扫描, IOC提取, IP信誉, Python, VirusTotal, 去混淆, 哈希检测, 域名检测, 威胁情报, 安全运营, 开发者工具, 开源安全工具, 扫描框架, 无后门, 网络安全, 网络调试, 自动化, 逆向工程平台, 隐私保护