Sanil-Samir-Mhatre/ImpreX-Sentinel-Explainable-Multi-Channel-Communication-Threat-Intelligence-Engine

GitHub: Sanil-Samir-Mhatre/ImpreX-Sentinel-Explainable-Multi-Channel-Communication-Threat-Intelligence-Engine

基于 NLP 和可解释 AI 的多通道通信威胁分类引擎,能够将短信和邮件自动识别为合法、可疑或钓鱼威胁,并提供 token 级别的决策归因解释。

Stars: 0 | Forks: 0

# 🛡️ ImpreX Sentinel:可解释的多通道通信威胁情报引擎 [![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://streamlit.io/) [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/) [![PyTorch](https://img.shields.io/badge/PyTorch-2.0%2B-red.svg)](https://pytorch.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) **ImpreX Sentinel** 是一个先进的、基于 NLP 的威胁分类引擎,旨在检测和分析跨 **SMS、WhatsApp 和 Email** 通道的数字通信威胁。作为 ImpreX 生态系统中的核心安全模块,该引擎会对传入的消息进行评估,并将其分类为三个不同的风险级别:**合法**、**可疑**和**严重威胁(钓鱼/短信钓鱼)**。 为了克服深度神经网络的“黑盒”限制,ImpreX Sentinel 集成了由 **LIME (Local Interpretable Model-agnostic Explanations)** 驱动的**可解释 AI (XAI)**。这为安全分析师和最终用户提供了实时的、 token 级别的归因分析,展示了推动每个威胁决策的确切语言线索和关键词。 ## 🌟 核心功能 - **三级风险分类体系**:将通信分类为 `0: Ham (合法)`、`1: Spam (推广)` 和 `2: Phishing/Smishing (严重威胁)`。 - **URL 隔离策略**:自动将超链接替换为通用的 `urltoken` 占位符,迫使神经网络分析链接位置周围的语言和上下文模式,而不是仅仅依赖外部域名黑名单。 - **深度学习 GRU 引擎**:由门控循环单元 (GRU) 神经网络驱动,采用后端填充序列 (`maxlen=150`) 和加权 Cross-Entropy Loss,以处理 SMS 和 Email 长度上的类别不平衡问题。 - **基线 Naive Bayes 分类器**:基于 TF-IDF 特征训练的高速后备模型(准确率为 92.98%)。 - **可解释 AI(LIME 集成)**:生成特征贡献图和内联 token 高亮(标记如 *urgent*、*verify*、*account*、*suspended*、*credentials* 等关键词)。 - **Streamlit 开箱即用**:内置采用 60-30-10 调色板的 UI/UX 仪表盘,支持实时单条消息扫描和批量 CSV 处理。 ## 📊 基准评估指标(共摄取 571,780 条统一消息) | 模型架构 | 训练样本数 | 总体准确率 | 钓鱼精确率 | 关键性能亮点 | | :--- | :--- | :--- | :--- | :--- | | **Baseline Naive Bayes (TF-IDF)** | 457,424 | **92.98%** | **0.77** | 对 Spam (0.99) 和 Ham (0.96) 的精确率高 | | **Lightweight GRU Network (DL)** | 50,000 | **94.33%** | **0.80** | 配合 Early Stopping 达到 **94.75%** 的峰值验证准确率 | ### 数据集类别分布 - **Ham (类别 0)**:212,605 个样本(类别权重:`0.896`) - **Spam (类别 1)**:254,191 个样本(类别权重:`0.750`) - **Phishing (类别 2)**:104,984 个样本(类别权重:`1.815`) ## 🏗️ 仓库与目录结构 ``` ├── .streamlit/ │ └── config.toml # Streamlit 60-30-10 color theme (60% White, 30% Crimson, 10% Green) ├── app_mark3.py # Primary Streamlit Dashboard Application ├── app.py # Streamlit entrypoint wrapper ├── preprocessing.py # Regex URL masking ('urltoken'), normalization, & label mapping ├── models.py # GRU PyTorch Neural Network & Naive Bayes Baseline models ├── explainability.py # LIME Explainable AI pipeline wrapper ├── train_mark3.py # Dataset ingestion & model training script ├── spam_detection_mark3.ipynb # Interactive demonstration & evaluation notebook ├── mark3_gru_model.pth # Pre-trained GRU weights ├── tokenizer.pickle # Tokenizer vocabulary dictionary (maxlen=150) ├── tfidf_vectorizer.pickle # TF-IDF matrix vectorizer ├── naive_bayes_model.pkl # Baseline Naive Bayes model ├── requirements.txt # Python dependencies for Streamlit Cloud deployment └── README.md # Module documentation ``` ## ⚙️ 快速入门与本地安装 ### 1. 克隆仓库 ``` git clone https://github.com/Sanil-Samir-Mhatre/ImpreX-Sentinel-Explainable-Multi-Channel-Communication-Threat-Intelligence-Engine.git cd ImpreX-Sentinel-Explainable-Multi-Channel-Communication-Threat-Intelligence-Engine ``` ### 2. 安装依赖项 ``` pip install -r requirements.txt ``` ### 3. 启动 Streamlit 仪表盘 ``` python -m streamlit run app_mark3.py ``` ## 🚀 部署至 Streamlit Community Cloud 1. Fork 或将此仓库推送到 GitHub。 2. 登录 [Streamlit Community Cloud](https://streamlit.io/cloud)。 3. 点击 **New app**,选择您的仓库:`Sanil-Samir-Mhatre/ImpreX-Sentinel-Explainable-Multi-Channel-Communication-Threat-Intelligence-Engine`。 4. 将 **Main file path** 设置为 `app_mark3.py`(或 `app.py`)。 5. 点击 **Deploy!** ## 🎨 UI/UX 设计系统(60-30-10 调色板) - **60% 基础背景**:纯白 (`#FFFFFF`) 和灰白 (`#F8F9FA`),用于整洁的指标卡片。 - **30% 主要交互元素**:绯红色 (`#D9381E`),用于按钮、活动选项卡和 `.badge-critical` 威胁警报。 - **10% 指示强调色**:翠绿色 (`#10B981`),用于 `.badge-safe` 合法通信徽章。 ## 📜 许可证 本项目基于 [MIT 许可证](LICENSE) 开源。
标签:Kubernetes, NLP, 凭据扫描, 反钓鱼, 可解释AI, 垃圾邮件检测, 威胁情报, 开发者工具, 深度学习, 逆向工具