phathela/ims-hub
GitHub: phathela/ims-hub
一个多源情报关联平台,支持 SOCMINT、IMINT、HUMINT、SIGINT、网络威胁和地理空间数据的统一摄取、实体解析、威胁评分与报告生成。
Stars: 0 | Forks: 0
# IMS Hub — 情报管理系统
一个基于 FastAPI、SQLAlchemy 和 NetworkX 构建的生产级、多源情报关联平台。
## 架构
```
Sources → Ingestion → Normalisation → Enrichment → Storage → Reports
(adapters) (entity (SQLite/ (daily threat,
(SOCMINT, resolution, PGSQL, geo pattern,
IMINT, geo/temporal NetworkX) entity profile)
HUMINT, correlation,
SIGINT, threat scoring)
Cyber,
Geospatial)
```
## 快速开始 (SQLite — 无额外依赖)
```
# 安装 Python deps
pip install -r requirements.txt
# 运行服务器
uvicorn app.main:app --reload --port 8000
# 在另一个终端中,运行 demo
python demo.py
```
API 文档可在 **http://localhost:8000/docs** (Swagger UI) 访问。
## Docker / PostgreSQL
```
docker compose up --build
```
启动内容如下:
- **IMS Hub** 运行在 8000 端口
- **PostgreSQL + PostGIS** 运行在 5432 端口
- **pgAdmin** 运行在 5050 端口 (登录凭证: `admin@ims.local` / `admin`)
## API 文档
所有端点都需要 `X-API-Key` 请求头。提供两种密钥级别:
| 密钥 | Header 值 |
|-----|-------------|
| Admin | `ims-admin-key-change-me` |
| Analyst | `ims-analyst-key-change-me` |
(可通过 `ADMIN_API_KEY` / `ANALYST_API_KEY` 环境变量修改这些密钥。)
### 摄取端点
#### 摄取 HUMINT 报告
```
curl -X POST http://localhost:8000/ingest/humint \
-H "Content-Type: application/json" \
-H "X-API-Key: ims-admin-key-change-me" \
-d '{
"source_type": "humint",
"payload": {
"pseudonym": "ECHO-7",
"report_text": "Observed suspicious vehicle activity at logistics hub.",
"timestamp": "2026-05-10T23:30:00Z",
"location": {"lat": -25.987, "lon": 28.112},
"confidence": 0.85
}
}'
```
#### 摄取 SOCMINT 帖子
```
curl -X POST http://localhost:8000/ingest/socmint \
-H "Content-Type: application/json" \
-H "X-API-Key: ims-admin-key-change-me" \
-d '{
"source_type": "socmint",
"payload": {
"platform": "twitter",
"author": "threat_actor_77",
"content": "Target reconnaissance complete.",
"timestamp": "2026-05-10T14:30:00Z"
}
}'
```
#### 摄取 SIGINT
```
curl -X POST http://localhost:8000/ingest/sigint \
-H "Content-Type: application/json" \
-H "X-API-Key: ims-admin-key-change-me" \
-d '{
"source_type": "sigint",
"payload": {
"src_ip": "192.168.1.5",
"dst_ip": "10.0.0.23",
"src_port": 44322,
"dst_port": 3389,
"protocol": "TCP",
"timestamp": "2026-05-10T14:35:00Z"
}
}'
```
### 报告生成
#### 每日威胁简报
```
curl -X POST "http://localhost:8000/reports/daily-threat?report_date=2026-05-10" \
-H "X-API-Key: ims-admin-key-change-me"
```
#### 实体档案
```
curl -X POST "http://localhost:8000/reports/entity-profile?entity_name=10.45.0.23" \
-H "X-API-Key: ims-admin-key-change-me"
```
返回所有相关事实的时间线,以及可通过以下地址访问的 NetworkX 图谱图像:
```
http://localhost:8000/output/entity_graph_.png
```
#### 地理空间模式
```
curl -X POST "http://localhost:8000/reports/geo-pattern?lat_min=-26.0&lat_max=-25.5&lon_min=28.0&lon_max=28.5&time_start=2026-05-01T00:00:00Z&time_end=2026-05-11T00:00:00Z" \
-H "X-API-Key: ims-admin-key-change-me"
```
### 查询端点
```
# 列出 raw records
curl "http://localhost:8000/query/raw?limit=10" -H "X-API-Key: ims-admin-key-change-me"
# 查询 normalised facts
curl "http://localhost:8000/query/facts?min_threat=0.3" -H "X-API-Key: ims-admin-key-change-me"
# 查看 audit log
curl "http://localhost:8000/query/audit" -H "X-API-Key: ims-admin-key-change-me"
```
## 来源类型与适配器
| 来源 | 适配器 | Payload 校验 |
|--------|---------|-------------------|
| **SOCMINT** | `adapters/socmint.py` | platform, author, content, timestamp |
| **IMINT** | `adapters/imint.py` | image_id, capture_time, sensor_type, coordinates |
| **HUMINT** | `adapters/humint.py` | pseudonym, report_text, timestamp; 对静态文本进行加密 |
| **SIGINT** | `adapters/sigint.py` | src_ip, dst_ip, src_port, dst_port, protocol, timestamp |
| **Cyber Threat** | `adapters/cyber_threat.py` | stix_bundle (STIX 2.1) |
| **Geospatial** | `adapters/geospatial.py` | geojson (Feature/FeatureCollection/Point/Polygon) |
## 威胁评分
- **基线评分**:按实体类型分配(IP 地址和 STIX 恶意软件 → 0.6,人员 → 0.4,位置 → 0.2)
- **丰富评分**:当事实通过实体名称、地理邻近性或时间邻近性关联时,其威胁评分将被平均化
- 这会产生传播效应:与高威胁事实关联的低威胁事实会继承更高的分数
## 可扩展性接口
- **Celery**:用于高容量情报流的异步富化处理,将内联的 `enrich_new_fact()` 调用替换为 Celery 任务
- **PostgreSQL + PostGIS**:用于生产环境,将 `DATABASE_URL` 切换到 PostgreSQL;PostGIS 增加了空间索引,可实现亚秒级的地理空间查询
- **Kafka / RabbitMQ**:在摄取和规范化之间插入消息队列,以解耦生产者和消费者
- **Graph DB (Neo4j)**:针对关系密集型工作负载,使用专用的图数据库替换 `relationship` SQL 表
- **ML 评分**:`threat_scoring.py` 模块是故意设计得非常简单的——您可以将其替换为训练好的分类器
## 项目结构
```
ims-hub/
├── app/
│ ├── main.py # FastAPI app entry point
│ ├── config.py # Environment-based configuration
│ ├── database.py # SQLAlchemy engine + session
│ ├── models.py # ORM models
│ ├── schemas.py # Pydantic request/response schemas
│ ├── auth.py # API key authentication
│ ├── logging_middleware.py
│ ├── adapters/ # Source-type ingestion adapters
│ │ ├── socmint.py
│ │ ├── imint.py
│ │ ├── humint.py
│ │ ├── sigint.py
│ │ ├── cyber_threat.py
│ │ └── geospatial.py
│ ├── engine/ # Normalisation + enrichment
│ │ ├── normalisation.py
│ │ └── enrichment.py
│ ├── routers/ # FastAPI route handlers
│ │ ├── ingestion.py
│ │ ├── reports.py
│ │ └── query.py
│ └── services/ # Business logic
│ ├── report_generator.py
│ ├── threat_scoring.py
│ └── graph_analysis.py
├── test_data/ # Example payloads for each source type
├── output/ # Generated graph images
├── demo.py # Demonstration script
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── README.md
```
## 安全
- **API 密钥认证** — 每个端点都需要有效的 `X-API-Key` 请求头
- **HUMINT 加密** — 报告文本通过 Fernet (AES-256) 进行静态加密
- **审计日志** — 每次摄取和报告生成都会记录用户、操作和参数
- **数据最小化** — 查询端点仅公开规范化后的事实;原始 payload 包含完整的原始数据
标签:AV绕过, Docker, Docker Compose, ESC4, FastAPI, GitHub, HTTP/HTTPS抓包, IMSHub, masscan, NetworkX, OSINT, pgAdmin, PostGIS, PostgreSQL, RESTful API, SQLAlchemy, SQLite, Swagger UI, 人工情报, 信号情报, 图像情报, 地理空间分析, 地理空间情报, 多源情报管理系统, 威胁情报平台, 威胁评分, 安全防御评估, 实体解析, 实时处理, 密码管理, 态势感知, 情报关联分析, 情报分析, 情报处理流水线, 情报富化, 情报收集, 情报管理, 情报规范化, 提示词优化, 数据摄取, 时空关联分析, 每日威胁报告, 测试用例, 漏洞研究, 特权检测, 社交媒体情报, 突变策略, 网络威胁情报, 网络安全, 网络诊断, 请求拦截, 逆向工具, 隐私保护