Mohitexe09/Incident-Response-Tools-and-Platforms

GitHub: Mohitexe09/Incident-Response-Tools-and-Platforms

一个由 C++/Go/Python 三层服务协同的迷你 SIEM 与 Incident Response 原型平台,实现从端点日志采集、摄取标准化到规则检测与案件管理的完整链路。

Stars: 0 | Forks: 0

# Mini SIEM 与 Incident Response 平台 一个安全信息与事件管理 (SIEM) + Incident Response 平台的极简、可运行原型,由三个协同服务组成: ``` ┌───────────────────────┐ TCP / newline-JSON ┌──────────────────────┐ │ C++ Host Monitor │ ────────────────────────────▶ │ Go Ingestion │ │ (agent) │ raw log events │ Pipeline │ │ tails auth.log / │ │ parse → normalize │ │ syslog │ │ → enrich → forward │ └───────────────────────┘ └──────────┬───────────┘ │ HTTP POST (JSON) │ ▼ ┌──────────────────────┐ │ Python Detection & │ │ Case Mgmt Engine │ │ rules → incidents → │ │ SQLite + JSON cases │ └──────────────────────┘ ``` ## 1. 架构设计 | 跳数 | 协议 | 原因 | |-----|----------|-----| | C++ → Go | **TCP socket,换行符分隔的 JSON (NDJSON)** | C++ 保持轻量(无需 gRPC/protobuf 工具链);Go 低成本读取流;以后可以轻松替换为 TLS、Kafka 或 gRPC。 | | Go → Python | **HTTP POST `/ingest` (JSON)** | Python Web 框架可以将其简化为一行代码实现;使检测引擎能够独立扩展,并可被 Elastic / OpenSearch / Wazuh manager 替换。 | | Python → 存储 | **SQLite + JSON case 文件** | 零安装持久化;磁盘上的 case 文件反映了真实的 IR 平台(TheHive、Shuffle)如何交接 artifacts。 | 设计选择: - **C++** 负责端点上的*热路径*:极低的 CPU/RAM 占用,作为 daemon 运行在靠近 kernel/日志源的位置。 - **Go** 负责*吞吐量*:每个连接使用 goroutines,利用 channels 进行 backpressure,进行 JSON 标准化和丰富化处理(hostname、geo、asset tags)。 - **Python** 负责*表达能力*:规则、关联、case 管理以及集成(email、Slack、MISP、TheHive)——在这些领域,迭代速度比原始性能更重要。 运行顺序:**Python → Go → C++**(下游优先,以确保不会丢弃任何事件)。 ## 2. 构建与运行 ``` # Terminal 1 — 检测引擎 cd python-engine && python3 -m venv .venv && source .venv/bin/activate pip install flask python detection_engine.py # listens on :8080 # Terminal 2 — 摄取管道 cd go-ingestor go run ingestor.go # TCP :9000 → forwards to http://localhost:8080/ingest # Terminal 3 — 主机监控 (Linux/macOS) cd cpp-agent g++ -std=c++17 -O2 host_monitor.cpp -o host_monitor sudo ./host_monitor /var/log/auth.log 127.0.0.1 9000 # (在 macOS 上尝试 /var/log/system.log;或者传入任何你可以 tail 的文件) ``` 通过模拟登录失败来触发检测: ``` for i in 1 2 3 4; do logger "sshd[1234]: Failed password for invalid user alice from 10.0.0.7 port 22 ssh2" done ``` 几秒钟内,一个 case 文件会出现在 `python-engine/cases/INC-*.json` 中,并且 `python-engine/siem.db` 中也会新增一行记录(`sqlite3 siem.db 'select * from incidents;'`)。 ## 3. 仓库结构 ``` mini-siem/ ├── README.md ├── cpp-agent/ │ └── host_monitor.cpp # tails a log file, ships NDJSON over TCP ├── go-ingestor/ │ ├── go.mod │ └── ingestor.go # TCP server → parse/normalize → HTTP forward └── python-engine/ ├── detection_engine.py # Flask + rule engine + case manager └── rules.yaml # declarative detection rules ``` 请查看每个源文件中的内联注释以了解其设计说明。
标签:C++, Golang, PB级数据处理, Python, SIEM系统, 安全事件响应, 安全编程, 安全运维, 数据擦除, 无后门, 日志审计, 逆向工具