el-bakkali/azure-bruteforce-defense
GitHub: el-bakkali/azure-bruteforce-defense
基于Azure OpenAI的SSH暴力破解防护系统,用自然语言对话替代KQL实现威胁狩猎和日志分析。
Stars: 0 | Forks: 0
🛡️ Azure 暴力破解 SSH 防御
AI 驱动的威胁狩猎与日志分析 — 无需 KQL。
用通俗的语言与您的安全日志对话。Azure OpenAI 负责其余的工作。
快速部署 • 架构 • 功能 • 演示 • 结构 • 许可证
## 💡 这是什么? 这是一个**概念验证**项目,展示了 Azure AI 如何变革安全运营。您无需编写复杂的 KQL 查询在日志中搜寻威胁,只需与 AI 助手**聊天**,它即可: - 自动**查询您的 Azure Log Analytics** 工作区 - 使用 GPT-4o-mini **分析 SSH 暴力破解攻击** - 在 Syslog 和 auditd 数据中**搜寻 NullClaw**(一款基于 Zig 构建的攻击工具) - **提供可操作的建议** — 严重性评级、修复步骤、安全态势评估 ## 🏗 架构 ``` ┌─────────────────────────────────────────────────────────────────────┐ │ Azure Resource Group │ │ │ │ ┌──────────────┐ SSH Brute-Force ┌──────────────────────┐ │ │ │ Defender VM │◄──────────────────────│ Function App (B1) │ │ │ │ Ubuntu 22.04 │ SimulateAttack() │ │ │ │ │ ── Fail2ban │ │ ├─ SimulateAttack │ │ │ │ ── AMA │ │ ├─ AnalyzeLogs │ │ │ │ ── auditd │ │ └─ ChatProxy ──────►├──┤ │ └──────┬───────┘ └──────────┬───────────┘ │ │ │ Syslog │ │ │ ▼ │ │ │ ┌──────────────┐ KQL Queries ┌─────────┴────────┐ │ │ │ Log Analytics │◄──────────────────────│ Azure OpenAI │ │ │ │ Workspace │ │ GPT-4o-mini │ │ │ │ ── Sentinel │ │ (Managed ID) │ │ │ └──────────────┘ └──────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────┐ │ │ │ Frontend — Static Website (Azure Blob Storage) │ │ │ │ Chat UI → AnalyzeLogs → ChatProxy → GPT-4o-mini response │ │ │ └──────────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘ ``` | 组件 | 用途 | |---|---| | **Defender VM** | Ubuntu 22.04 B2s,配备 Fail2ban、Azure Monitor Agent、auditd | | **Function App** | 3 个函数 — 攻击模拟、日志分析、AI 聊天代理 | | **Log Analytics** | 集中式日志存储,通过 DCR 采集 Syslog | | **Microsoft Sentinel** | 用于安全分析和威胁狩猎的 SIEM 层 | | **Azure OpenAI** | 用于自然语言日志分析的 GPT-4o-mini | | **Static Website** | 用于对话式威胁狩猎的聊天型前端 | ## ✨ 功能 ### 🗣️ 对话式威胁狩猎 用通俗的语言提问 — AI 会查询您的日志并返回结构化的分析结果: ``` You: "Are there any brute-force attacks in the last hour?" AI: "I detected 47 failed SSH login attempts from 3 unique IPs. Top attacker: 185.220.101.x with 32 attempts targeting 'root'. Severity: MEDIUM. Fail2ban has banned 2 of 3 IPs..." ``` ### 🔍 NullClaw 威胁狩猎 自动检测 [NullClaw](https://github.com/nullclaw) — 一款 Zig 编译的攻击工具 — 覆盖 4 个向量: - **安装** — git clone / 下载尝试 - **编译** — Syslog 中的 Zig 构建命令 - **执行** — auditd 中 Zig 编译的二进制签名 - **行为** — 亚秒级 SSH 暴力破解爆发(Zig 速度指纹) ### 🤖 Azure OpenAI 集成 - 使用 **managed identity**(代码中无 API 密钥) - `DefaultAzureCredential` 实现零密钥认证 - ChatProxy 暴露兼容 OpenAI 的 `/v1/chat/completions` 端点 ### 🛡️ 自动化防御 - **Fail2ban** 在 3 次 SSH 登录失败后自动封禁 IP - **NSG rules** 用于网络层面的封锁 - **严重性评估** — NONE / LOW / MEDIUM / HIGH / CRITICAL - 每次分析生成**可操作的建议** ## 🚀 快速部署 ### 前置条件 - 具有 **Contributor** 权限的 Azure 订阅 - 已安装 Azure CLI(`az login`) - PowerShell 7+ - Python 3.11+ ### 选项 1:Bicep 模板(推荐) 使用一条命令部署整个基础设施: ``` # Clone the repo git clone https://github.com/el-bakkali/azure-bruteforce-defense.git cd azure-bruteforce-defense # Create resource group az group create --name rg-bruteforce-defense --location uksouth # Deploy infrastructure az deployment group create ` --resource-group rg-bruteforce-defense ` --template-file infra/main.bicep ` --parameters adminPassword='YourSecurePassword123!' # Deploy Function App code .\post-deploy-config.ps1 # Enable static website & deploy frontend $storageAccount = (az deployment group show -g rg-bruteforce-defense -n main --query properties.outputs.storageAccountName.value -o tsv) az storage blob service-properties update ` --account-name $storageAccount ` --static-website --index-document index.html --auth-mode login az storage blob upload ` --account-name $storageAccount ` --container-name '$web' ` --file frontend/index.html ` --name index.html ` --content-type "text/html" --auth-mode login --overwrite ``` ### 选项 2:PowerShell 脚本(分步执行) ``` # 1. Deploy infrastructure (VM, Function App, LAW, Sentinel, NSG, DCRs) .\deploy-infrastructure.ps1 # 2. Deploy Function App code .\post-deploy-config.ps1 # 3. (可选) 部署 Sentinel 分析规则 .\deploy-sentinel-rules.ps1 ``` ### 部署后:Azure OpenAI 设置(如果使用选项 2) 1. 在 Azure 门户中**创建 Azure OpenAI 资源** 2. **部署 gpt-4o-mini** 模型(GlobalStandard SKU) 3. 为 Function App managed identity **分配角色**: az role assignment create ` --assignee (az functionapp identity show -g rg-bruteforce-defense -n由 Mehdi El Bakkali 构建 — Azure Security & AI
标签:AI, AI合规, auditd, Azure, GPT-4o, Libemu, LLM, Log Analytics, NullClaw, PE 加载器, Python, Sentinel, SSH, SSH安全, Syslog, Unmanaged PE, 安全运营, 扫描框架, 无KQL查询, 无后门, 暴力破解防御, 自动化代码审查, 逆向工具