Jenkinxs/Sentinel
GitHub: Jenkinxs/Sentinel
利用生成器-审查者双 LLM 反馈循环,将自然语言威胁描述自动转化为经语法验证和语义审查的 YARA 规则,并支持目录扫描。
Stars: 0 | Forks: 0
# Sentinel
用通俗的语言描述威胁。Sentinel 会根据该描述生成一条 YARA 规则。它会检查语法,根据你的意图审查规则,并通过生成器-审查者的反馈循环不断对其进行优化。随后,你可以扫描指定目录以查找匹配项。
## 快速开始
```
git clone https://github.com/Jenkinxs/Sentinel.git
cd Sentinel
pip install -r requirements.txt
cp .env.example .env
# 编辑 .env —— 添加你的 OpenRouter API key
```
本项目没有系统依赖。YARA 编译使用的是 `yara_x`(纯 Python)。
## 用法
### CLI(交互式)
```
python backend/LanguageProcessor.py
```
### CLI(非交互式)
```
python backend/LanguageProcessor.py --cli \
-d "Detect Cobalt Strike beacon with named pipe and registry artifacts" \
--scan-dir /tmp/samples \
--no-deploy
```
### Web UI
```
python frontend/app.py --port 8081
```
打开 http://localhost:8081。描述该威胁。可选择性地添加上下文文件并设置扫描目录。点击 **RUN**。
## 工作原理
```
Describe threat -> Generator LLM writes YARA rule
-> yara_x verifies syntax (auto-fixes up to N retries)
-> Reviewer LLM checks semantic match against your intent
-> Generator + Reviewer converse (N feedback loops) to refine
-> Save to rules/ -> optionally scan directory
```
两个独立的 LLM(生成器和审查者)运行着一个反馈循环。生成器负责编写规则。审查者负责提出批评意见。该循环随着时间的推移会生成更精确的规则。
## 配置
| 方法 | 文件 | 优先级 |
|---|---|---|
| 环境变量 | `.env`(已 gitignore) | 最高 —— 覆盖一切 |
| 配置文件 | `config.ini`(已 gitignore) | 后备默认值 |
| 示例配置 | `config.ini.example` | 带注释的模板 |
`config.ini` / `.env` 中的关键设置:
| 设置 | 默认值 | 描述 |
|---|---|---|
| `SENTINEL_API_KEY` | -- | OpenRouter(或兼容 OpenAI 的)API 密钥 |
| `generator` | `openai/gpt-oss-120b:free` | 用于规则生成的模型 |
| `reviewer` | `openai/gpt-oss-120b:free` | 用于规则审查的模型 |
| `yarac_retries` | 10 | 语法错误时的最大 LLM 修复尝试次数 |
| `feedback_loops` | 3 | 生成器-审查者优化迭代次数 |
| `stream` | True | 逐个 token 地流式传输 LLM 输出 |
### 本地模型(Ollama)
用于本地推理的 Modelfile 位于 `modelfiles/` 中:
| 角色 | 模型 | 文件 |
|---|---|---|
| 生成器 | Qwen3:8b | `modelfiles/Modelfile.SentinelGen` |
| 审查者 | Gemma3:4b | `modelfiles/Modelfile.SentinelRvw` |
将配置中的 `url` 设置为你的 Ollama endpoint。将 `generator` 和 `reviewer` 指向你的本地模型名称。
## 项目布局
```
Sentinel/
backend/
LanguageProcessor.py Pipeline: generate -> verify -> review -> feedback -> deploy
Deployer.py File scanner using compiled YARA rules
Verifier.py YARA syntax validation via yara_x
frontend/
app.py NiceGUI web interface (dark theme, live logs)
modelfiles/ Ollama Modelfiles for local inference
rules/ Generated YARA rules
config.ini Runtime configuration (gitignored)
config.ini.example Annotated config template
.env Environment overrides (gitignored)
.env.example Env template
SentinelGen System prompt for the generator LLM
SentinelRvw System prompt for the reviewer LLM
```
标签:AI风险缓解, AMSI绕过, DLL 劫持, Petitpotam, Python, YARA, 云资产可视化, 大语言模型, 威胁检测, 无后门, 自动化规则生成, 逆向工具