Satishherakal/Network-Traffic-Analyzer-Anomaly-Detector
GitHub: Satishherakal/Network-Traffic-Analyzer-Anomaly-Detector
基于 Isolation Forest 无监督学习算法的网络流量分析工具,用于检测端口扫描、DDoS 等异常行为。
Stars: 1 | Forks: 0
# 网络流量分析与异常检测器
一个基于机器学习的网络监控系统,利用 Isolation Forest 无监督学习算法捕获、分析并检测网络流量中的异常模式。
## 概述
本项目实现了一个用于自动化网络异常检测的 4 模块 Pipeline:
1. **数据包捕获** - 使用 Scapy 进行实时网络嗅探(或生成合成流量)
2. **特征工程** - 从原始数据包元数据中提取 9 个数值特征
3. **异常检测** - Isolation Forest 算法对正常与异常流量进行分类
4. **可视化** - Matplotlib 仪表板和交互式 Streamlit Web 界面
## 结果
| 指标 | 值 |
|--------|-------|
| Accuracy | 96.8% |
| Precision | 84.0% |
| Recall | 84.0% |
| F1 Score | 84.0% |
在 500 个合成数据包上进行了测试,注入了 4 种异常类型:端口扫描、DDoS 突发、数据渗透和 ICMP 洪泛。
## 技术栈
- Python、Scikit-learn、Pandas、NumPy
- Scapy(数据包捕获)
- Matplotlib、Seaborn(静态可视化)
- Streamlit、Plotly(交互式 Web 仪表板)
## 项目结构
```
main.py - Entry point (CLI orchestrator)
config.py - Centralized configuration
packet_capture.py - Module 1: Live packet capture (Scapy)
synthetic_traffic.py - Synthetic traffic generator (fallback)
feature_engineering.py - Module 2: Feature extraction and scaling
anomaly_detector.py - Module 3: Isolation Forest ML engine
visualizer.py - Module 4: Matplotlib dashboard
app.py - Streamlit web dashboard
```
## 设置
```
pip install -r requirements.txt
```
## 使用方法
```
# 使用合成流量运行(无需管理员权限)
python main.py --synthetic -c 500
# 使用实时捕获运行(Windows 需要管理员权限 + Npcap)
python main.py --live -c 200
# 启动 web dashboard
python -m streamlit run app.py
```
## 输出
- `output/traffic_data.csv` - 所有捕获的数据包数据
- `output/detected_anomalies.csv` - 检测到的异常及其分数
- `output/analysis_dashboard.png` - 6 面板可视化
- `output/report.txt` - 统计摘要
## 作者
Satish Herakal
标签:Apex, DDoS检测, DNS枚举, ICMP洪水检测, Kubernetes, Matplotlib, NumPy, Plotly, Python, Scapy, Scikit-learn, Streamlit, 入侵检测系统, 孤立森林, 安全数据湖, 异常检测, 插件系统, 数据窃取检测, 无后门, 无监督学习, 机器学习, 流量分类, 特征工程, 端口扫描检测, 网络安全, 网络安全工具, 网络流量分析, 访问控制, 逆向工具, 隐私保护