SeanCrimi-007/jarvis-siem
GitHub: SeanCrimi-007/jarvis-siem
一个自托管、基于 Sigma 规则的轻量级 SIEM 系统,用 Sysmon 监控 Windows 端端并实时检测威胁,专为蓝队学习与安全作品集而构建。
Stars: 0 | Forks: 0
# Jarvis SIEM
一个自托管的、基于 Sigma 的安全信息与事件管理系统,专为蓝队学习和网络安全作品集而构建。它通过 Sysmon 监控 Windows 终端节点,实时根据自定义的 Sigma 检测规则评估事件,在 Next.js 仪表盘中展示告警,并将关键检测推送到 React Native 移动应用。
它是 **Jarvis** 家族的一部分,与 [`jarvis-dashboard`](../jarvis-dashboard) 和 [`JarvisApp`](../JarvisApp) 并列。
## 架构
```
flowchart LR
subgraph Endpoint["Windows Endpoint"]
SM["Sysmon 15.x\n(kernel driver)"]
AG["Go Agent\nEvtSubscribe"]
SM -->|event log| AG
end
subgraph Homelab["Homelab — Ubuntu 24.04"]
CD["Caddy\nTailscale TLS"]
SV["Go Server :8080"]
SE["Sigma Engine\n12 rules"]
PG[("TimescaleDB\nPostgreSQL 17")]
CD -->|reverse proxy| SV
SV --> SE
SV <-->|pgx CopyFrom| PG
end
subgraph Clients["Clients"]
NX["Next.js 16\nDashboard :3000"]
JA["JarvisApp\nExpo / React Native"]
end
EX["Expo Push API\nexp.host"]
AG -->|HTTPS POST /api/v1/events| CD
NX -->|GET /api/v1/events\nGET /api/v1/alerts| CD
SE -->|high / critical match| EX
EX -->|APNs / FCM| JA
```
## 技术栈
| 层级 | 技术 |
|---|---|
| 终端节点监控 | Sysmon 15.x · [sysmon-modular](https://github.com/olafhartong/sysmon-modular) config |
| Agent | Go · [google/winops/winlog](https://github.com/google/winops/tree/master/winlog) (`EvtSubscribe` + bookmark) |
| 检测引擎 | [bradleyjkemp/sigma-go](https://github.com/bradleyjkemp/sigma-go) v0.6.6 · 12 Sigma 规则 |
| 服务端 | Go · [go-chi/chi](https://github.com/go-chi/chi) · [jackc/pgx](https://github.com/jackc/pgx) |
| 数据库 | 基于 PostgreSQL 17 的 [TimescaleDB](https://www.timescale.com/) 2.x · 7天压缩 · 30天保留 |
| 仪表盘 | Next.js 16 (App Router · Server Components · 时间范围选择器) |
| 网络 | [Tailscale](https://tailscale.com/) mesh VPN · `tailscale cert` (Let's Encrypt) |
| 反向代理 | [Caddy](https://caddyserver.com/) |
| 移动端推送 | [Expo Push API](https://docs.expo.dev/push-notifications/sending-notifications/) → JarvisApp (Expo SDK 54) |
## 检测到的威胁场景
涵盖 5 种 MITRE ATT&CK 战术的 12 条 Sigma 规则。代表性示例:
| 场景 | 技术 | 规则 | 级别 |
|---|---|---|---|
| PowerShell EncodedCommand 滥用 | [T1059.001](https://attack.mitre.org/techniques/T1059/001/) | `powershell_encoded_cmd.yml` | 高危 |
| 通过 comsvcs.dll 进行 LSASS 内存转储 | [T1003.001](https://attack.mitre.org/techniques/T1003/001/) | `comsvcs_memory_dump.yml` | 严重 |
| 删除卷影副本 (勒索软件) | [T1490](https://attack.mitre.org/techniques/T1490/) | `shadow_copy_deletion.yml` | 严重 |
| CertUtil 下载 cradle (LOLBIN) | [T1105](https://attack.mitre.org/techniques/T1105/) | `certutil_download.yml` | 高危 |
| 用于持久化的计划任务 | [T1053.005](https://attack.mitre.org/techniques/T1053/005/) | `schtasks_creation.yml` | 中危 |
| SAM hive 导出 (离线破解) | [T1003.002](https://attack.mitre.org/techniques/T1003/002/) | `reg_export_hklm.yml` | 严重 |
有关包含检测逻辑和攻击者上下文的详细演练,请参见 [`docs/case-studies/`](./docs/case-studies/)。
## 仓库结构
```
jarvis-siem/
├── agent/ Go agent — Sysmon EvtSubscribe → HTTPS shipper (Phase 1)
├── server/ Go server — ingest, Sigma eval, push, query API (Phase 1–5)
│ ├── migrations/ SQL migrations (001–004, idempotent)
│ ├── push/ Expo push sender — batched, receipt-polling
│ └── sigma/ Rule loader + evaluator wrapper
├── dashboard/ Next.js 16 — events table, alerts table, time-range pick (Phase 1–3)
├── rules/ Sigma .yml detection rules (process_creation) (Phase 2)
├── deploy/ Homelab setup — systemd units, Caddyfile, setup.sh (Phase 4)
├── docs/ Architecture write-up, case studies (Phase 6)
└── scripts/ dev-up.sh, dev-down.sh, build-linux.sh, push.sh
```
## 快速开始 (本地开发)
**前置条件:** Go 1.23+、Docker、Node 18+
```
git clone https://github.com/SeanCrimi-007/jarvis-siem
cd jarvis-siem
# 启动 TimescaleDB,应用 migrations,运行 Go server + Next.js dashboard
./scripts/dev-up.sh
# 打开 dashboard
open http://localhost:3000 # Events view
open http://localhost:3000/alerts # Sigma alerts
# 触发一个测试检测(PowerShell encoded command → 触发 High alert)
curl -X POST http://localhost:8080/api/v1/events \
-H "Content-Type: application/json" \
-d '[{
"ts": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'",
"hostname": "test-box",
"channel": "Microsoft-Windows-Sysmon/Operational",
"event_id": 1,
"raw_xml": "",
"data": {
"Image": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"CommandLine": "powershell.exe -enc SQBFAFgA",
"ParentImage": "C:\\Windows\\explorer.exe"
}
}]'
# 停止所有进程
./scripts/dev-down.sh
```
## 家庭实验室部署 (阶段 4)
服务器、数据库和仪表盘运行在一台改装过的 Ubuntu 24.04 笔记本电脑上。一个 Windows 终端节点运行 Sysmon agent,并通过 Tailscale HTTPS 传输事件。
```
# 在 homelab 机器上(以 root 身份运行)
sudo bash deploy/setup.sh --tailnet-host jarvis-siem..ts.net
# 在 'tailscale up' 认证之后:
sudo bash /opt/jarvis-siem/renew-cert.sh # issue first TLS cert
# 从 dev 机器上 — cross-compile + push binary + restart service
./scripts/push.sh jarvis-siem..ts.net
```
完整的 systemd unit、Caddyfile 模板和证书续期计时器请参见 [`deploy/`](./deploy/)。
## 配置
| 变量 | 位置 | 用途 |
|---|---|---|
| `SIEM_AGENT_TOKEN` | 服务端 + agent + 仪表盘 | 共享的 bearer token — 在各处保持一致设置 |
| `DATABASE_URL` | 服务端 | PostgreSQL 连接字符串 |
| `SIEM_RULES_DIR` | 服务端 | Sigma `.yml` 规则目录的路径 (默认:`../rules`) |
| `SIEM_SERVER_URL` | 仪表盘 `.env.local` | Go 服务器的 URL |
在家庭实验室中,密钥存放在 `/etc/jarvis-siem.env` 中(权限为 `0600`,由 root 拥有)。systemd unit 通过 `EnvironmentFile=` 加载它们 — 凭据绝不会出现在 unit 文件中。
## 阶段状态
| 阶段 | 描述 | 状态 |
|---|---|---|
| 1 | MVP 数据流 — Sysmon → agent → 服务端 → Postgres → 仪表盘 | ✅ 完成 |
| 2 | Sigma 检测引擎 — 12 条规则、告警表、/alerts 页面 | ✅ 完成 |
| 3 | TimescaleDB — hypertable、压缩、保留、时间范围过滤器 | ✅ 完成 |
| 4 | 家庭实验室部署 — Tailscale、Caddy TLS、systemd、推送脚本 | ✅ 完成 |
| 5 | 推送通知 — Expo push token、高危/严重 → JarvisApp | ✅ 完成 |
| 6 | 简历润色 — README、架构文档、案例研究 | ✅ 完成 |
## 反模式 (来自 PLAN.md §阶段 0)
在此代码库中明确避免了这些内容。请勿引入它们:
- ❌ `SwiftOnSecurity/sysmon-config` — 自 2021 年起已停止维护;请使用 `sysmon-modular`
- ❌ `markuskont/go-sigma-rule-engine` (原版) — 已停滞不前;请使用 `bradleyjkemp/sigma-go`
- ❌ `0xrawsec/golang-evtx` 用于实时事件订阅 — 它读取的是 `.evtx` 文件,而不是实时通道
- ❌ 在仪表盘中使用 `getServerSideProps` / `pages/` 路由 — 仅限 App Router
- ❌ TimescaleDB 中的 `add_drop_chunks_policy` — 已更名为 `add_retention_policy`
- ❌ 使用 Expo Go 进行推送通知测试 — 必须是开发版或生产版的 EAS build
- ❌ 在 systemd unit 文件中存储密钥 — 请使用带有 `0600` 权限文件的 `EnvironmentFile=`
标签:EVTX分析, Go, React, Ruby工具, Syscalls, Sysmon, TimescaleDB, 安全运营, 扫描框架, 日志审计, 测试用例, 自托管