MouleshGopal/Wazuh-Active-Response-for-Windows-Brute-Force

GitHub: MouleshGopal/Wazuh-Active-Response-for-Windows-Brute-Force

该项目为 Wazuh 补充 Windows 暴力破解自动响应能力,解决 IP 解析与阻断的跨平台兼容问题。

Stars: 0 | Forks: 0

## Wazuh Active Response for Windows Brute Force ## 📌 Overview 这个项目扩展了 **Wazuh Active Response**,以处理 **Windows 服务器** 上的暴力登录尝试。 默认情况下,Wazuh 期望源 IP 地址报告在 `data.srcip` 字段中。虽然这对 Linux 日志有效,但 Windows 事件日志将 IP 地址报告在不同的字段:`data.win.eventdata.ipAddress`。 ## 🎯 Why This Process Is Needed - **Linux logs** → Report source IP in `data.srcip`。 - **Windows logs** → Report source IP in `data.win.eventdata.ipAddress`。 - 没有自定义解码器和规则,Wazuh 无法正确识别 Windows 日志中的源 IP。 - 此解决方案确保 Wazuh 能够解析 Windows 事件日志并自动阻止暴力攻击的源 IP。 此仓库提供必要的 **自定义规则、解码器以及可执行的活动响应脚本** 来填补这一空白。通过此设置, Wazuh 可以自动检测失败的登录尝试(事件 ID 4625)并阻止违规的 IP 地址。 ## 📂 Repository Contents - **Custom Decoder.txt** → 定义 Wazuh 如何解析 Windows 事件日志以提取 IP 地址字段。 - **Custom Rules.txt** → 包含失败登录尝试的检测规则(事件 ID 4625)。 - **Windows-ip-block.py** → 使用 Windows 防火墙阻止源 IP 的 Python 脚本。 - **Whitelist.json** → 文件允许你添加内部和 ISP IP 地址。 - **Already_blocked_logged.json** → 文件记录所有重复的 IP 地址。 ## ⚙️ Prerequisites - Wazuh Manager(Linux/Ubuntu)。 - 已安装 Wazuh Agent 的 Windows。 - 已安装 Python 3.x 的 Windows。 - **PyInstaller**(用于将 Python 脚本转换为可执行文件)。 - Windows 上的 **管理员权限**(修改防火墙所需)。 ## 🚀 Setup Instructions ### 1. Convert Python Script to Executable 打开 **Windows PowerShell** 并运行: ``` pip install pyinstaller pyinstaller --onefile Windows-ip-block.py ``` 可执行文件将在 `dist` 文件夹中创建。 ### 2. Deploy Rules and Decoders (Wazuh Manager) 将提供的文件复制到 Wazuh Manager 配置中: ``` # Rules sudo nano /var/ossec/etc/rules/local_rules.xml # Decoders sudo nano /var/ossec/etc/decoders/local_decoder.xml ``` 重启 Wazuh Manager: ``` sudo systemctl restart wazuh-manager ``` ### 3. Place Executable in Agent Directory (Windows) 将生成的 `.exe` 文件复制到: ``` C:\Program Files (x86)\ossec-agent\active-response\bin\ ``` 授予可执行文件 **完全控制权限**: - 右键 → 属性 → 安全 → 编辑 → 允许完全控制。 - 确保 **Local System 账户** 具有完全控制权限,因为 Wazuh 以 Local System 运行。 ### 4. Configure Active Response (Wazuh Manager) 编辑 `ossec.conf`: ``` windows_ip_block windows_ip_block.exe command,srcip yes no windows_ip_block local 60122 600 ``` 重启代理服务: ``` net stop wazuh-agent net start wazuh-agent ``` ## ✅ Verification 1. 在 Windows 服务器上触发失败登录尝试(事件 ID **4625**)。 2. 确认日志在 **Wazuh Dashboard GUI** 中可见。 3. 检查 **active response logs** 以验证 `.exe` 文件的执行。 4. 确保攻击者的 IP 在 Windows 防火墙中被阻止: ``` netsh advfirewall firewall show rule name=all ```
标签:Active Response, Event ID 4625, IP 封锁, PyInstaller, Python 脚本, RFI远程文件包含, Wazuh, Windows 安全, Windows 防火墙, 事件日志解析, 免杀技术, 可执行文件, 失败登录, 威胁阻断, 实时响应, 暴力破解检测, 漏洞挖掘, 端点检测, 红队行动, 自定义解码器, 规则配置, 逆向工具