nimatarhani/Threat-Intelligence-Log-Analyzer
GitHub: nimatarhani/Threat-Intelligence-Log-Analyzer
一个基于 Python 的安全自动化工具,通过解析 Apache 日志并调用 VirusTotal API 对 IP 进行威胁情报富化,自动生成结构化报告。
Stars: 1 | Forks: 0
# SOAR-Lite 威胁情报富化
## 概述
本项目是一个基于 Python 的安全自动化工具,用于解析 Apache 日志文件,提取唯一的 IP 地址,通过 VirusTotal API 进行检查,并生成用于威胁分析的结构化 JSON 报告。
## 问题
手动检查安全日志中的可疑 IP 地址既耗时又重复。该工具通过使用威胁情报对日志数据进行富化,自动化了调查的第一个阶段。
## 功能
- 解析 Apache 日志文件
- 使用正则表达式提取唯一的 IP 地址
- 集成 VirusTotal REST API
- 处理 API 错误和网络问题
- 在终端打印结果
- 将最终输出保存为 JSON 报告
- 使用 `.env` 进行安全的 API 密钥管理
## 技术栈
- Python 3
- requests
- python-dotenv
- VirusTotal API
- JSON
- 正则表达式
## 项目结构
```
main.py Main execution file
parser.py Extracts IP addresses from logs
connectors.py Handles VirusTotal API requests
config.py Loads configuration and API key
logs.log Input Apache log file
threat_report.json Output report
requirements.txt Python dependencies
.env API key storage
## 输入格式
The program reads a file named `logs.log` containing Apache access log lines.
Example:
text
5.10.20.30 - - [30/Jun/2026:10:40:00 +0330] "OPTIONS / HTTP/1.1" 200 0 "-" "Nikto/2.1.6"
127.0.0.1 - - [30/Jun/2026:10:45:10 +0330] "GET /dashboard HTTP/1.1" 200 1560 "-" "Mozilla/5.0"
## 工作原理
1. Reads the `logs.log` file
2. Extracts IP addresses from each line
3. Removes duplicate IPs
4. Sends each IP to VirusTotal API
5. Parses threat intelligence data
6. Prints results
7. Saves results into a JSON file
## 设置
1. Create a virtual environment
2. Install dependencies:
bash
pip install -r requirements.txt
3. Create a `.env` file and add your VirusTotal API key:
env
VIRUSTOTAL_API_KEY=your_api_key_here
## 运行
bash
python main.py
## 输出
The final analysis is saved in:
text
threat_report.json
## 备注
- This project is designed as a small SOAR-style enrichment workflow.
- It can be extended later with CSV output, IP reputation scoring, or support for more threat intelligence sources.
```
标签:Homebrew安装, 逆向工具