Hrichy-0/Credential-Stuffing-Simulator

GitHub: Hrichy-0/Credential-Stuffing-Simulator

该项目通过模拟银行 API 流量并利用 Isolation Forest 无监督学习,研究如何从正常用户行为中检测 credential stuffing 攻击。

Stars: 0 | Forks: 0

# Credential-Stuffing-Simulator: 无监督机器学习 ## 概述 本项目模拟了一个高度逼真的银行 API 环境,用于生成、分析和分类合成网络流量。通过构建自定义的多线程 orchestrator,我生成了一个包含合法人类用户和恶意行为者(Brute-Forcer 和 Password Sprayer)的平衡数据集。随后,我设计了行为特征,并部署了 Isolation Forest 机器学习模型来追踪异常。 ## 🏗️ 架构与方法论 1. **目标 (Flask):** 构建了一个本地银行 API,配置为记录传入的请求头、IP 地址和认证状态。 2. **网络靶场 (Python/Concurrent Futures):** 设计了一个多线程流量生成器,模拟三种不同的行为特征: * **正常人类:** 笨拙的输入(20% 的错误率),静态 IP,针对单一账户。 * **Brute-Force Bots:** 高频率,快速轮换 IP,针对大量唯一的用户名。 * **Password Sprayers:** “低速慢速”频率,在多个账户中尝试单一密码,以规避基本的速率限制。 3. **特征工程 (Pandas):** 提取原始 JSON 日志,并设计了高级行为特征,包括请求速率(请求之间的时间)、唯一账户针对性和失败率。 4. **威胁追踪 (Scikit-Learn):** 调整了无监督 Isolation Forest 算法,以成功将合法客户的噪音与针对性的网络攻击区分开来。 5. **探索性数据分析 (Seaborn/Plotly):** 使用 3D 散点图、相关性热力图和特征分布箱线图来描绘 AI 的决策边界。 ## 📊 关键发现与可视化 *(将你的截图上传到 `images` 文件夹并在此处链接它们)* * **基准错觉:** 发现并修复了一个逻辑缺陷,在该缺陷中,AI 最初由于严格的污染约束而将大量操作的正常人类用户标记为异常。 * **特征分离:** Seaborn Pairplots 证明,`unique_usernames` 结合 `failure_rate` 为识别 credential stuffing 创造了一个近乎完美的数学边界。 ## 🛠️ 技术栈 * **模拟:** Python, Flask, Concurrent Futures, Faker * **数据科学:** Pandas, Scikit-Learn (Isolation Forest) * **数据可视化:** Plotly (3D 交互式), Seaborn, Matplotlib ### 📊 关键发现与可视化 **3D 威胁全景** ![3D 威胁全景](https://raw.githubusercontent.com/Hrichy-0/Credential-Stuffing-Simulator/main/[images/threat_landscape.png](https://github.com/Hrichy-0/Credential-Stuffing-Simulator/tree/main/images#:~:text=3Dthreatanalysis.png)) **相关性热力图** ![相关性热力图](https://raw.githubusercontent.com/Hrichy-0/Credential-Stuffing-Simulator/main/[images/correlation_heatmap.png](https://github.com/Hrichy-0/Credential-Stuffing-Simulator/tree/main/images#:~:text=1%20minute%20ago-,featureboxplots.png,-Add%20files%20via)) **威胁数据 Pairplot** ![Pairplot 矩阵](https://raw.githubusercontent.com/Hrichy-0/Credential-Stuffing-Simulator/main/[images/pairplot_matrix.png](https://github.com/Hrichy-0/Credential-Stuffing-Simulator/tree/main/images#:~:text=threatbehaviourcorrelationmatrix.png))
标签:Apex, Flask, Python, Scikit-Learn, 代码示例, 异常检测, 数据分析, 无后门, 机器学习, 网络安全, 逆向工具, 隐私保护