rabindra789/defenx

GitHub: rabindra789/defenx

DefenX 是一个为中小企业提供实时服务器扫描、威胁检测、日志告警及钓鱼检测能力的网络安全监控后端服务。

Stars: 0 | Forks: 0

# DefenX 后端 [![License: MIT](https://raw.githubusercontent.com/rabindra789/defenx/main/LICENSE)](https://opensource.org/licenses/MIT) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/fb8517d991115252.svg)](https://github.com/rabindra789/defenx/actions/workflows/ci.yml) [![Python](https://img.shields.io/badge/Python-3.12+-3776AB?logo=python&logoColor=white)](https://www.python.org/) [![FastAPI](https://img.shields.io/badge/FastAPI-0.119-009688?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/) [![Docker](https://img.shields.io/badge/Docker-ready-2496ED?logo=docker&logoColor=white)](https://www.docker.com/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md) **DefenX** 是一款专为中小企业设计的网络安全监控后端。它提供**实时服务器扫描**、**威胁检测**、**日志**、**告警**、**仪表盘指标**以及**钓鱼检测 API**。该后端为前端仪表盘或客户端应用提供了简洁的 REST API。 ## 🚀 功能 - 实时**服务器端口扫描**与 HTTP 检查。 - 针对可疑活动的**安全事件与告警管理**。 - 支持搜索和查看最近日志的**集中式日志记录**。 - 用于获取指标和趋势的**仪表盘 endpoint**。 - 用于查看/更新扫描设置的**配置 endpoint**。 - 针对电子邮件或文本内容的**钓鱼扫描器**。 - 用于检查服务状态的**健康检查 endpoint**。 - 提供 **OpenAPI / Swagger 文档**。 ## 🏗 架构 ``` graph TD A[Client / Dashboard] -->|REST API| B[DefenX Backend] B --> C[Monitoring Module] B --> D[Phishing Scanner] B --> E[Incident & Alert Manager] B --> F[Logging System] B --> G[Dashboard Metrics] C --> H[Port Scanner] C --> I[HTTP Health Check] C --> J[Network Monitor] D --> K[Email/Text Analysis] E --> L[Alert Routing] F --> M[Search & Retrieval] G --> N[Trend & Overview Endpoints] H --> O[Target Servers] I --> O J --> O K --> P[External Threat Feeds] ``` ## 更多文档 | 文件 | 描述 | |------|-------------| | [`frontend-guide.md`](frontend-guide.md) | 前端集成指南 | | [`netmon-daemon.md`](netmon-daemon.md) | 网络监控 daemon 设置 | | [`defenx-service.md`](defenx-service.md) | 将 DefenX 作为系统服务运行 | | [`Dockerfile`](Dockerfile) | 容器构建配置 | | [`docker-compose.yml`](docker-compose.yml) | 多服务部署 | ## 📦 安装 ``` git clone https://github.com/rabindra789/defenx.git cd defenx python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` ## 🏃 运行后端 ``` uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload ``` * 服务器运行于:`http://localhost:8000` * 交互式 API 文档: * Swagger UI:`http://localhost:8000/docs` * Redoc:`http://localhost:8000/redoc` ## 📂 API 结构 所有 endpoint 均归类在 `/api` 下: | 模块 | 前缀 | 描述 | | ---------- | ---------------- | ------------------------------------ | | Monitoring | `/api/monitor` | 触发扫描,获取上次扫描结果 | | Incidents | `/api/incidents` | 列出和获取安全事件 | | Alerts | `/api/alerts` | 列出、确认告警 | | Logs | `/api/logs` | 获取最近日志,搜索日志 | | Dashboard | `/api/dashboard` | 概览与趋势指标 | | Config | `/api/config` | 查看或更新扫描设置 | | Health | `/api/health` | 后端与扫描器健康状态、指标 | | Phishing | `/api/phishing` | 扫描电子邮件/文本是否包含钓鱼内容 | ### Endpoint 示例 #### 触发扫描 ``` POST /api/monitor/scan Content-Type: application/json { "ports": [22, 80, 443] } ``` #### 获取上次扫描 ``` GET /api/monitor/last ``` #### 钓鱼扫描 ``` POST /api/phishing/scan Content-Type: application/json { "content": "Please click here to verify your account", "custom_keywords": ["verify"], "custom_domains": ["malicious.com"] } ``` #### 仪表盘概览 ``` GET /api/dashboard/overview ``` ## ⚙ 配置 可在 `app/core/config.py` 中进行配置: ``` scan_ports_default = [22, 80, 443, 3306, 8080] scan_timeout = 2 # seconds per port scan_concurrency = 100 # concurrent port checks scan_target = "127.0.0.1" # default target server scan_interval_seconds = 60 # automatic scan interval in seconds ``` 前端也可以使用 `/api/config` endpoint 在运行时读取/更新设置。 ## 📝 前端开发者注意事项 1. 所有路由均带有 `/api` 前缀。 2. 使用 `/docs` 下的 **Swagger 文档**进行交互式测试。 3. **扫描器会在后台自动运行**;`/api/monitor/last` 始终返回最新的扫描结果。 4. 告警和安全事件支持实时获取;请使用 `/api/alerts/latest` 和 `/api/incidents/all`。 5. 钓鱼 API 是独立的;您可以随时调用它来检查电子邮件/文本。 ## 🛠 技术栈 * Python 3.11+ * FastAPI * HTTPX(用于异步 HTTP 检查) * Asyncio(用于并发处理) * 内存存储(可扩展至数据库) * OpenAPI / Swagger UI(用于 API 文档) ## 📄 许可证 MIT License
标签:AMSI绕过, AV绕过, FastAPI, Python, REST API, 威胁检测, 插件系统, 数据统计, 无后门, 监控后端, 端口扫描, 网络安全, 请求拦截, 逆向工具, 钓鱼检测, 隐私保护