Yescrypt/DSIPS

GitHub: Yescrypt/DSIPS

轻量级Linux服务器入侵检测与防御系统,实现实时日志监控、多类攻击检测、自动IP封禁和Telegram即时告警的一站式安全防护。

Stars: 3 | Forks: 0

# 🛡️ DSIPS ### 检测与安全入侵防御系统 **实时攻击检测 · 自动 IP 封禁 · Telegram 告警** [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue?style=flat-square)](https://python.org) [![License: MIT](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE) [![Platform: Linux](https://img.shields.io/badge/platform-Linux-orange?style=flat-square)](#)
## 什么是 DSIPS? DSIPS 是一个轻量级、**生产就绪的 IDS/IPS**,专为 Linux 服务器设计。它实时监控您的服务器日志,在攻击发生时进行检测,通过防火墙自动封禁恶意 IP,并向您的 Telegram 发送即时告警。 **无重型守护进程。无复杂配置。一条命令即可安装。** ``` Your Linux Server Your Cloud API Your Telegram ┌────────────────┐ ┌──────────────┐ ┌─────────────────┐ │ DSIPS Agent │ │ dsips API │ │ 🔴 Alert! │ │ │ POST /alert │ │ Bot sends │ SQL Injection │ │ Watches logs │ ─────────────► │ Receives │ ───────────► │ IP: 1.2.3.4 │ │ Detects hits │ │ alert │ │ Server: web-01 │ │ Blocks IPs │◄───────────── │ Queues cmd │◄──────────── │ │ │ │ GET /commands │ │ Admin press │ [Block] [WHOIS]│ └────────────────┘ └──────────────┘ └─────────────────┘ │ │ iptables / ufw / ipset ▼ 🚫 Attacker blocked ``` ## ✨ 功能特性 | | | |---|---| | 🔍 **实时监控** | nginx, apache, auth.log, syslog | | 💉 **SQL Injection** | 完整的模式库,包括盲注 | | 💥 **RCE / Command Injection** | Shell 转义,代码执行尝试 | | 📂 **Directory Traversal / LFI** | 路径遍历,PHP filter chains | | 🔑 **Brute Force** | 基于单 IP 的认证失败追踪 | | 🌊 **DDoS Detection** | 基于单 IP 的请求速率阈值 | | 🔍 **Scanner Detection** | sqlmap, nikto, nmap, gobuster 等 | | 🔮 **XSS** | 反射型 XSS 模式检测 | | 🚫 **Auto Block** | iptables / ufw / ipset (自动检测) | | 📱 **Telegram Alerts** | 带有 封禁/解封 按钮的富文本消息 | | 📡 **Command Polling** | Agent 轮询 API 获取管理命令 | | 🔁 **Alert Queue** | API 不可达时的本地队列 | ## 🚀 安装说明 ``` git clone https://github.com/Yescrypt/dsips.git cd DSIPS sudo bash install.sh ``` 就是这样。安装程序会问你 **3 个问题**: ``` Detected OS: Ubuntu 22.04 Continue with this system? [Y/n] ? Server name [web-server-1]: ? Your Telegram User ID: (Get it: open @dsips_bot in Telegram, send /start) > 123456789 ``` 然后它会: - 安装系统依赖 - 创建 Python virtual environment - 写入 `/etc/dsips/config.json` - 安装并启动 `dsips` systemd 服务 ## 📱 Telegram 告警 当检测到攻击时,您会收到: ``` 🔴 DSIPS Security Alert ━━━━━━━━━━━━━━━━━━━━ 💉 Attack: SQL Injection 🌐 IP: 185.220.101.42 🖥️ Server: web-server-1 📍 Path: /login?id=1' UNION SELECT... ⏰ Time: 2025-01-15 14:32:01 UTC 🎯 Severity: CRITICAL ━━━━━━━━━━━━━━━━━━━━ [🔒 Block IP] [🔓 Unblock IP] [🔍 WHOIS] [🗺️ IP Info] ``` 按下 **[Block IP]** → API 将命令排队 → 您的 agent 进行轮询并在 10 秒内执行 `iptables` 封禁。 ## ⚙️ 配置说明 配置文件自动创建于 `/etc/dsips/config.json`: ``` { "server_name": "web-server-1", "telegram_user_id": "123456789", "firewall_backend": "auto", "ddos_threshold": 100, "ddos_window": 10, "block_critical": 86400, "block_high": 3600, "block_ddos": 600, "whitelisted_ips": ["127.0.0.1", "::1"], "dry_run": false } ``` | 字段 | 默认值 | 描述 | |-------|---------|-------------| | `server_name` | hostname | 显示在告警中 | | `telegram_user_id` | — | 您的 Telegram 数字 ID | | `firewall_backend` | `auto` | `auto` / `iptables` / `ufw` / `ipset` | | `ddos_threshold` | `100` | 触发 DDoS 封禁的窗口内请求数 | | `ddos_window` | `10` | 时间窗口(秒) | | `block_critical` | `86400` | 严重攻击的封禁时长 (24小时) | | `block_high` | `3600` | 高危攻击的封禁时长 (1小时) | | `block_ddos` | `600` | DDoS 的封禁时长 (10分钟) | | `whitelisted_ips` | `127.0.0.1` | 永不封禁的 IP | | `dry_run` | `false` | 仅检测不封禁 | ## 🔒 攻击类型与严重性 | 攻击 | 严重性 | 自动封禁 | 检测机制 | |--------|----------|-----------|-----------| | SQL Injection | 🔴 Critical | ✅ 24小时 | UNION, 盲注, 时间型 | | Remote Code Execution | 🔴 Critical | ✅ 24小时 | Shell 转义, eval | | Command Injection | 🔴 Critical | ✅ 24小时 | 管道, 反引号 | | Directory Traversal | 🟠 High | ✅ 1小时 | `../`, `/etc/passwd` | | Local File Inclusion | 🟠 High | ✅ 1小时 | PHP filters, wrappers | | Brute Force | 🟠 High | ✅ 1小时 | 10 次失败 / 60秒 | | DDoS | 🟠 High | ✅ 10分钟 | 100 次请求 / 10秒 | | XSS | 🟠 High | 仅告警 | Script 标签, 事件处理器 | | Scanner Tools | 🟡 Medium | ✅ 10分钟 | User-Agent 模式 | ## 🗂️ 项目结构 ``` dsips/ ├── agent/ │ ├── config/ │ │ └── settings.py # Loads /etc/dsips/config.json │ └── core/ │ ├── detector.py # Attack pattern engine │ ├── monitor.py # Async log tail │ ├── blocker.py # iptables / ufw / ipset │ ├── reporter.py # Sends alerts to Cloud API │ └── poller.py # Polls API for Telegram commands │ └── main.py # Entry point ├── install.sh # Interactive installer ├── uninstall.sh # Clean removal ├── requirements.txt # Python deps (aiohttp only) └── README.md ``` ## 🔧 管理维护 ``` # 服务控制 systemctl status dsips systemctl restart dsips journalctl -u dsips -f # 编辑 config nano /etc/dsips/config.json systemctl restart dsips # 卸载 sudo bash uninstall.sh ``` ## 🗺️ 路线图 - **v1.0** ✅ 实时 IDS · 自动封禁 · Telegram 告警 - **v1.1** GeoIP 封禁 · fail2ban 导入 · ipset 集成 - **v1.2** ML 异常检测 · 自定义规则引擎 - **v2.0** 集中式仪表板 · WAF 模式 · 多服务器视图 ## 🤝 贡献指南 欢迎 Pull requests。对于重大更改,请先开一个 issue 讨论。 ## 📄 许可证 [MIT](LICENSE)
标签:AppImage, CISA项目, DDoS防护, DOE合作, IPS, iptables, IP自动封禁, LangChain, Linux服务器安全, PB级数据处理, PE 加载器, Python, Sysadmin工具, Telegram告警, ufw, Web应用防火墙, 入侵检测系统, 入侵防御系统, 威胁情报, 威胁检测与响应, 威胁猎捕, 安全数据湖, 安全运维, 实时攻击检测, 开发者工具, 无后门, 服务器防护, 网络安全, 轻量级, 防火墙集成, 隐私保护