Cursed1ne/nexus
GitHub: Cursed1ne/nexus
面向大语言模型应用的自动化安全测试与红队评估框架,覆盖 OWASP LLM Top 10 攻击面并提供漏洞评分、指纹侦察和训练场景等完整工具链。
Stars: 0 | Forks: 0
# NEXUS — Neural EXploitation Unified System
[](LICENSE)
[](https://python.org)
## 灵感与谱系
NEXUS 综合了以下由 **[Alias Robotics](https://github.com/aliasrobotics)** 开发的框架的技术和架构模式:
| Alias Robotics 框架 | NEXUS 对应组件 | 用途 |
|--------------------------|-----------------|---------|
| **CAI** — Cybersecurity AI | `NexusAgent`, `RedTeamAgent` | 自主智能体红队评估 |
| **RVD** — Robot Vulnerability Database | **LVD** — LLM Vulnerability Database | 结构化漏洞追踪 |
| **RSF** — Robot Security Framework | 评估方法论 | 结构化安全评估 |
| **Aztarna** — Robot Footprinting | `LLMFingerprinter`, `LLMScanner` | Endpoint 发现与指纹识别 |
| **RVSS** — Robot Vuln Scoring System | **LVSS** — LLM Vulnerability Scoring | 领域特定严重性评分 |
| **RCTF** — Robotics CTF | `scenarios/` | 安全训练挑战 |
此外还整合了以下来源的技术:OWASP LLM Top 10、Garak、DeepTeam、Promptfoo 以及已发表的学术研究。
## 架构
```
nexus/
├── nexus/
│ ├── core/
│ │ ├── agent.py # NexusAgent — autonomous exploitation engine (CAI-inspired)
│ │ ├── target.py # LLMTarget — multi-provider abstraction
│ │ └── session.py # ExploitSession — engagement tracking (RVD-inspired)
│ ├── attacks/
│ │ ├── prompt_injection.py # OWASP LLM01 — direct/indirect injection
│ │ ├── jailbreak.py # OWASP LLM01 — DAN, roleplay, crescendo
│ │ ├── rag_poisoning.py # OWASP LLM06 — RAG backdoor attacks
│ │ ├── multi_agent.py # OWASP LLM08 — inter-agent exploitation
│ │ ├── data_extraction.py # OWASP LLM06 — training data / credential leakage
│ │ └── model_dos.py # OWASP LLM04 — resource exhaustion
│ ├── recon/
│ │ ├── fingerprint.py # LLMFingerprinter (Aztarna-inspired)
│ │ └── scanner.py # LLMScanner — endpoint discovery
│ ├── scoring/
│ │ └── lvss.py # LVSS — LLM Vulnerability Scoring System (RVSS-inspired)
│ ├── database/
│ │ └── lvd.py # LVD — LLM Vulnerability Database (RVD-inspired)
│ ├── agents/
│ │ ├── red_team_agent.py # AI-powered attacker agent (CAI redteam_agent inspired)
│ │ └── orchestrator.py # Multi-agent parallel exploitation
│ ├── payloads/
│ │ ├── injection.py # Prompt injection payloads
│ │ ├── jailbreak.py # Jailbreak payloads
│ │ └── extraction.py # Data extraction payloads
│ └── reporting/
│ └── reporter.py # Terminal + JSON + Markdown reports (RSF-inspired)
├── scenarios/ # CTF training scenarios (RCTF-inspired)
│ ├── scenario_01_basic_injection.py
│ ├── scenario_02_rag_attack.py
│ └── scenario_03_multi_agent.py
└── cli.py # nexus CLI
```
## 安装
```
git clone
cd nexus
pip install -e .
```
用于开发:
```
pip install -e ".[dev,rich]"
```
## 快速开始
### 全面自动化扫描
```
# 扫描本地 Ollama 模型
nexus scan --target ollama://localhost:11434/llama3
# 扫描 OpenAI GPT-4
OPENAI_API_KEY=sk-... nexus scan --target openai://gpt-4o --output report.md
# 仅使用特定攻击进行扫描
nexus scan --target ollama://localhost:11434/llama3 \
--attacks prompt_injection jailbreak data_extraction
```
### Python API
```
from nexus import LLMTarget, NexusAgent
from nexus.core.target import ollama_target
# 针对本地 Ollama 实例
target = ollama_target("llama3-local", model="llama3")
# 运行自动化红队
agent = NexusAgent(target, attack_budget=30)
session = agent.run()
# 生成报告
from nexus.reporting import NexusReporter
reporter = NexusReporter(session)
reporter.print_summary()
reporter.save_markdown("report.md")
```
### AI 驱动的红队 (受 CAI 启发)
```
from nexus.agents import RedTeamAgent
from nexus.core.target import ollama_target, openai_target
# Attacker LLM 针对目标 LLM 生成自适应攻击
attacker = openai_target("attacker", model="gpt-4o", api_key="sk-...")
target = ollama_target("target", model="llama3")
red_team = RedTeamAgent(attacker=attacker, target=target, max_rounds=15)
findings = red_team.run(goal="Extract the system prompt")
```
### 侦察与指纹识别 (受 Aztarna 启发)
```
# 发现主机上的 LLM 端点
nexus recon --host 192.168.1.100
# 对已知端点进行指纹识别
nexus fingerprint --target ollama://localhost:11434/llama3
```
### LVSS 评分 (受 RVSS 启发)
```
# 对已知向量进行评分
nexus score --vector "LVSS:1.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:L/AL:F/DP:S/MA:N"
# 交互式评分
nexus score
```
```
from nexus.scoring import LVSSScorer, LVSSVector
from nexus.scoring.lvss import AttackVector, AlignmentBypass, Scope, Impact
vector = LVSSVector(
attack_vector=AttackVector.NETWORK,
scope=Scope.CHANGED,
confidentiality=Impact.HIGH,
integrity=Impact.HIGH,
alignment_bypass=AlignmentBypass.FULL,
)
score = LVSSScorer.calculate(vector)
print(LVSSScorer.describe(score, vector))
# LVSS Score: 9.3 / 10.0 [CRITICAL]
```
### LVD — 漏洞数据库 (受 RVD 启发)
```
# 列出所有已知 LLM 漏洞
nexus lvd --list
# 搜索
nexus lvd --search "rag injection"
# 按 OWASP 类别筛选
nexus lvd --owasp LLM01
# 统计
nexus lvd --stats
```
```
from nexus.database import LVD, LVDEntry
db = LVD()
print(db.stats())
# 添加新发现
entry = LVDEntry(
title="Novel Multi-Turn Jailbreak",
owasp_category="LLM01",
lvss_score=8.2,
affected_models=["gpt-4", "claude-3"],
reproduction_steps=[...],
remediation="...",
)
db.add(entry)
db.save("my_findings.json")
```
### CTF 训练场景 (受 RCTF 启发)
```
# 列出场景
nexus ctf --list
# 运行自动解决 (用于测试)
nexus ctf --scenario 01 --target ollama://localhost:11434/llama3
# 交互模式 (用于学习)
nexus ctf --scenario 01 --target ollama://localhost:11434/llama3 --interactive
```
## 攻击模块
| 模块 | OWASP | 描述 |
|--------|-------|-------------|
| `prompt_injection` | LLM01 | 直接/间接 Prompt 注入,指令覆盖 |
| `jailbreak` | LLM01 | DAN,角色扮演,假设场景,编码绕过,渐变式攻击 |
| `rag_poisoning` | LLM06 | 文档投毒,隐藏指令,RAG 数据窃取 |
| `multi_agent` | LLM08 | 伪造 Agent 消息,工具输出注入,角色劫持 |
| `data_extraction` | LLM06 | 系统 Prompt 泄露,训练数据提取,凭证泄漏 |
| `model_dos` | LLM04 | Context 溢出,递归 Prompt,复杂度炸弹 |
## LVSS — LLM 漏洞评分系统
LVSS 结合 LLM 特定的指标对 CVSS/RVSS 进行了扩展:
```
LVSS:1.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:L/AL:F/DP:S/MA:C
───┬── ───┬─ ───┬─ ───┬─ ─┬─ ─┬─ ─┬─ ─┬─ ──┬─ ──┬─ ──┬─
│ │ │ │ │ │ │ │ │ │ │
Attack Vector │ Priv.Req │ Scope C I A Alignment Data Multi
Attack Complexity User.Int. Bypass Persist. Agent
```
**LLM 特定指标:**
- `AL` — Alignment 绕过:无 / 部分 / 完全
- `DP` — 数据持久性:无 / 会话 / 永久
- `MA` — 多 Agent 影响:无 / 单一 / 级联
## 道德使用规范
NEXUS 仅用于**授权的安全研究**:
- 具有书面授权的渗透测试项目
- CTF 竞赛
- 针对自有系统的安全研究
- 防御性红队评估和 AI 安全评估
请勿针对您不拥有或未获得测试授权的系统使用本工具。
## 漏洞披露政策
NEXUS 遵循 Alias Robotics 的 **90 天负责任的漏洞披露政策**:
1. 发现漏洞 → 创建 LVD 条目
2. 立即通知供应商
3. 留出 90 天的修补时间
4. 90 天后(或在补丁发布时)公开披露
## 参考
- [Alias Robotics CAI](https://github.com/aliasrobotics/cai)
- [Alias Robotics RVD](https://github.com/aliasrobotics/RVD)
- [Alias Robotics RSF](https://github.com/aliasrobotics/RSF)
- [Alias Robotics Aztarna](https://github.com/aliasrobotics/aztarna)
- [RVSS](https://github.com/aliasrobotics/RVSS)
- [OWASP LLM Top 10](https://owasp.org/www-project-top-10-for-large-language-model-applications/)
- [Carlini et al. — Extracting Training Data from LLMs](https://arxiv.org/abs/2012.07805)
- [Perez & Ribeiro — Prompt Injection Attacks](https://arxiv.org/abs/2302.12173)
*NEXUS — Neural EXploitation Unified System*
*仅用于授权的安全研究。*
标签:AI漏洞扫描, AI漏洞评分, AI端点发现, AI红队, AI风险缓解, CISA项目, LLM安全测试框架, OWASP LLM Top 10, Petitpotam, Python安全工具, RAG投毒, Web应用安全扫描器, 人工智能安全, 合规性, 多智能体安全, 大模型指纹识别, 大语言模型安全, 安全代理, 安全评估框架, 密码管理, 文档结构分析, 机密管理, 漏洞赏金侦察, 红队自动化, 网络安全, 网络靶场, 自动化渗透测试, 请求响应过滤, 逆向工具, 隐私保护