RickDevopsSecure/-XIPE-AI-Security-Scanner

GitHub: RickDevopsSecure/-XIPE-AI-Security-Scanner

面向 LLM 应用和 AI 平台的自主渗透测试框架,完整覆盖 OWASP LLM Top 10 漏洞类别。

Stars: 0 | Forks: 0

# XIPE — AI 安全扫描器 ### *针对 LLM 应用和 AI 平台的自主 AI 渗透测试* ![Version](https://img.shields.io/badge/version-2.1.0-red) ![AWS](https://img.shields.io/badge/AWS-ECS%20Fargate-orange) ![AI](https://img.shields.io/badge/AI%20Brain-Groq%20%2F%20Llama3-blue) ![License](https://img.shields.io/badge/license-Proprietary-black) ![Status](https://img.shields.io/badge/status-Production%20Ready-brightgreen) ## ⚠️ 法律免责声明 本工具**仅供授权的安全测试**使用。所有扫描必须在获得目标系统所有者明确的书面授权后进行。Inbest Cybersecurity 对未经授权的使用不承担任何责任。未经授权的使用可能违反当地和国际网络安全法律。 ## 概述 XIPE 解决了企业安全中的一个关键缺口:无法系统性地评估 AI 平台是否存在 OWASP LLM Top 10 漏洞。传统扫描器对 AI 特有的风险视而不见。XIPE 的构建正是为了填补这一空白。 **XIPE 的功能:** - 发现并识别 AI 平台(LibreChat、Flowise、OpenAI 兼容 API、自定义 LLM 端点) - 检测 SPA/CloudFront 架构并自动消除误报 - 在启用开放注册时,注册测试账户以获取认证访问权限 - 使用 AI 大脑(通过 Groq 的 Llama 3.1)生成针对特定平台的攻击提示 - 测试所有 OWASP LLM Top 10 漏洞类别 - 生成包含执行摘要、技术发现和修复建议的 PDF 报告 - 通过 Microsoft Teams 通知安全团队 - 将所有结果归档到 S3 以供审计追踪 ## 架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ XIPE v2.1 │ │ │ │ Trigger Layer │ │ ├── AWS Lambda (xipe-trigger) │ │ ├── EventBridge Schedule (daily 08:00 UTC) │ │ └── CLI / Microsoft Teams / REST API │ │ │ │ Execution Layer │ │ └── AWS ECS Fargate (xipe-cluster) │ │ ├── Web Recon Module (SPA detection, endpoints) │ │ ├── Live AI Tester (LibreChat client + attacks) │ │ ├── API Security Tester (auth, IDOR, HTTP methods) │ │ ├── Prompt Injection Module (LLM01, LLM07) │ │ ├── RAG Security Tester (LLM02, LLM08) │ │ └── Agent Security Tester (LLM06) │ │ │ │ AI Brain Layer │ │ └── Groq API (Llama 3.1 8B Instant) │ │ ├── analyze_target() → custom attack strategy │ │ ├── generate_next_attack() → adaptive attack prompts │ │ ├── analyze_response() → vulnerability detection │ │ ├── write_finding() → professional findings │ │ └── generate_executive_summary() → C-level report │ │ │ │ Output Layer │ │ ├── PDF Report (WeasyPrint) │ │ ├── JSON Findings │ │ ├── S3 Archive │ │ ├── Microsoft Teams Notification │ │ └── Public Stats JSON (landing page) │ └─────────────────────────────────────────────────────────────────┘ ``` ## OWASP LLM Top 10 覆盖范围 | ID | 漏洞 | 模块 | 状态 | |----|--------------|--------|--------| | LLM01 | Prompt Injection | `prompt_injection.py`, `live_ai_tester.py` | ✅ 激活 | | LLM02 | 敏感信息泄露 | `rag_tester.py`, `live_ai_tester.py` | ✅ 激活 | | LLM03 | 供应链 | `web_recon.py` | 🔄 部分 | | LLM04 | 数据和模型投毒 | `live_ai_tester.py` | 🔄 部分 | | LLM05 | 输出处理不当 | `agent_tester.py` | ✅ 激活 | | LLM06 | 过度代理 | `agent_tester.py`, `live_ai_tester.py` | ✅ 激活 | | LLM07 | 系统提示泄露 | `live_ai_tester.py` | ✅ 激活 | | LLM08 | 向量和嵌入弱点 | `rag_tester.py` | ✅ 激活 | | LLM09 | 虚假信息 | `live_ai_tester.py` | 🔄 部分 | | LLM10 | 无界消费 | `api_tester.py` | ✅ 激活 | ## 前置条件 - Python 3.11+ - 启用 BuildKit 的 Docker - 配置了适当 IAM 权限的 AWS CLI v2 - Groq API 密钥(可在 console.groq.com 获取免费额度) - AWS 资源:ECS 集群、ECR 仓库、Lambda 函数、S3 存储桶、EventBridge 规则 ### 所需 AWS IAM 权限 ``` { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecs:RunTask", "ecs:DescribeTasks", "iam:PassRole", "s3:PutObject", "s3:GetObject", "s3:ListBucket", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "ssm:GetParameter" ], "Resource": "*" } ] } ``` ## 安装说明 ### 1. 克隆仓库 ``` git clone https://github.com/RickDevopsSecure/-XIPE-AI-Security-Scanner.git cd -XIPE-AI-Security-Scanner ``` ### 2. 安装依赖 ``` python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` ### 3. 配置环境 ``` cp config.yaml.example config.yaml ``` 编辑 `config.yaml`: ``` scope: base_urls: - "https://your-target.com" aws: enabled: true region: us-east-1 s3_bucket: your-xipe-results-bucket modules: web_recon: true live_ai_tester: true api_tester: true prompt_injection: true rag_tester: true agent_tester: true ``` ### 4. 设置 API 密钥 ``` export OPENAI_API_KEY="your-groq-api-key" # Groq key goes here ``` ### 5. 本地运行 ``` python main.py --config config.yaml ``` ## AWS 云部署 ### 1. 创建 ECR 仓库 ``` aws ecr create-repository --repository-name xipe-ai-scanner --region us-east-1 ``` ### 2. 构建并推送 Docker 镜像 ``` aws ecr get-login-password --region us-east-1 | \ docker login --username AWS --password-stdin \ .dkr.ecr.us-east-1.amazonaws.com docker buildx build --platform linux/amd64 \ -f deploy/Dockerfile \ -t .dkr.ecr.us-east-1.amazonaws.com/xipe-ai-scanner:latest \ --push . ``` ### 3. 创建 ECS 任务定义 ``` aws ecs register-task-definition \ --family xipe \ --region us-east-1 \ --network-mode awsvpc \ --requires-compatibilities FARGATE \ --cpu 1024 \ --memory 2048 \ --execution-role-arn arn:aws:iam:::role/ecsTaskExecutionRole \ --task-role-arn arn:aws:iam:::role/ecsTaskExecutionRole \ --runtime-platform '{"cpuArchitecture":"X86_64","operatingSystemFamily":"LINUX"}' \ --container-definitions '[{ "name": "xipe", "image": ".dkr.ecr.us-east-1.amazonaws.com/xipe-ai-scanner:latest", "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/xipe", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "xipe" } }, "environment": [ {"name": "OPENAI_API_KEY", "value": ""} ] }]' ``` ### 4. 部署 Lambda 触发器 ``` cd deploy/ terraform init terraform apply ``` 或通过 AWS 控制台手动操作 — 请参阅 `deploy/lambda_trigger.py` 获取 Lambda 函数代码。 ### 5. 配置 S3 存储桶权限 ``` aws iam put-role-policy \ --role-name ecsTaskExecutionRole \ --policy-name xipe-s3-access \ --policy-document '{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject", "s3:ListBucket"], "Resource": [ "arn:aws:s3:::your-xipe-results-bucket", "arn:aws:s3:::your-xipe-results-bucket/*" ] }] }' ``` ## 使用说明 ### CLI (本地) ``` python main.py --config config.yaml ``` ### AWS Lambda (远程) ``` # 创建 payload 文件 python3 -c " import json data = { 'target_url': 'https://target.com', 'client_name': 'Client Name', 'requester': 'Your Name' } open('/tmp/xipe_payload.json', 'w').write(json.dumps(data)) " # 调用 Lambda aws lambda invoke \ --function-name xipe-trigger \ --region us-east-1 \ --payload fileb:///tmp/xipe_payload.json \ output.json cat output.json ``` ### 快速启动脚本 ``` # 安装启动脚本 curl -o ~/xipe_launch.py https://raw.githubusercontent.com/RickDevopsSecure/-XIPE-AI-Security-Scanner/main/xipe_launch.py echo 'alias xipe="python3 ~/xipe_launch.py"' >> ~/.zshrc source ~/.zshrc # 运行扫描 — PDF 在 90 秒内自动下载 xipe https://target-ai-platform.com "Client Name" ``` ### 监控扫描进度 ``` # 实时日志 aws logs tail /ecs/xipe --follow --region us-east-1 # 检查 S3 已完成的报告 aws s3 ls s3://your-xipe-results-bucket/engagements/ --region us-east-1 ``` ## API 参考 ### Lambda 触发器 Payload ``` { "target_url": "https://target.com", "client_name": "Client Organization", "requester": "Analyst Name" } ``` ### Lambda 响应 ``` { "statusCode": 200, "body": { "message": "XIPE task launched", "task_arn": "arn:aws:ecs:us-east-1:...", "engagement_id": "ENG-AUTO-20260316-0157", "timestamp": "2026-03-16T01:57:30Z" } } ``` ### 任务 ID 格式 ``` ENG-AUTO-YYYYMMDD-HHMM ``` ### S3 报告结构 ``` s3://bucket/engagements/ └── ENG-AUTO-20260316-0157/ ├── reporte_XIPE_local.pdf ← Full PDF report └── findings.json ← Machine-readable findings ``` ### 公共统计端点 ``` https://bucket.s3.amazonaws.com/public/stats.json ``` ``` { "total_scans": 47, "total_findings": 1423, "critical": 89, "high": 312, "medium": 718, "low": 189, "targets_scanned": 47, "last_updated": "2026-03-16T02:38:00Z" } ``` ## AI 大脑 XIPE 使用 AI 大脑(当前为 Groq/Llama 3.1 8B Instant)进行智能、自适应的测试。 ### 第一阶段 — 当前:Groq/Llama 3.1 ``` from agent.ai_brain import XIAIBrain brain = XIAIBrain(logger=logger) # 分析目标并生成攻击策略 strategy = brain.analyze_target(target_url, recon_data) # 生成自适应攻击提示 prompt = brain.generate_next_attack(history, strategy, "system_prompt_leakage") # 分析 AI 响应以查找漏洞 analysis = brain.analyze_response(prompt, response, "injection", strategy) # 撰写专业发现 finding = brain.write_finding(analysis, strategy, evidence) # 生成执行摘要 summary = brain.generate_executive_summary(findings, url, strategy, duration) ``` ### 第二阶段 — 路线图:Inbest 定制模型 该架构与提供商无关。所有 AI 调用都通过 `XIAIBrain._call_claude()` 进行。要切换提供商,请更新 `agent/ai_brain.py` 中的端点和模型。 **微调路线图:** 1. 每次扫描都会将攻击提示 + AI 响应 + 漏洞标签存储在 S3 中 2. 在约 1,000 次任务后,在此数据集上微调 Mistral 7B 或 Llama 3 3. 在 ECS 上与 XIPE 一起部署微调后的模型 4. 零外部 API 依赖,零单次扫描成本 ## 报告结构 每次任务生成: | 部分 | 描述 | |---------|-------------| | 封面 | 客户名称、任务 ID、日期、授权参考 | | 执行摘要 | 总体风险评级、发现数量、关键建议 | | 发现详情 | ID、严重性、描述、证据、修复建议 | | 修复路线图 | 按严重性排序的优先修复列表 | | 技术附录 | 原始 HTTP 证据、扫描方法论 | **严重性分类:** | 级别 | CVSS 范围 | 业务影响 | |-------|-----------|----------------| | CRITICAL | 9.0–10.0 | 可能被立即利用 | | HIGH | 7.0–8.9 | 被利用的可能性很高 | | MEDIUM | 4.0–6.9 | 在特定条件下可被利用 | | LOW | 0.1–3.9 | 风险有限 | | INFO | 0.0 | 仅供参考 | ## 配置参考 ``` # config.yaml scope: base_urls: - "https://target.com" endpoints: {} # Auto-discovered during scan aws: enabled: true region: us-east-1 s3_bucket: xipe-results-bucket ecs_cluster: xipe-cluster task_definition: xipe modules: web_recon: true live_ai_tester: true api_tester: true prompt_injection: true rag_tester: true agent_tester: true engagement: client_name: "Client Organization" lead_tester: "Ricardo - Inbest Cybersecurity" authorized_by: "Client Security Team" auth_ref: "authorization_letter.pdf" notifications: teams_webhook: "" # Set via SSM or environment variable ``` ## 支持的目标类型 | 平台 | 检测 | 认证 | AI 攻击 | |----------|-----------|------|------------| | LibreChat | ✅ | ✅ 自动注册 | ✅ | | Flowise | ✅ | ✅ | ✅ | | OpenAI 兼容 API | ✅ | 🔄 基于令牌 | ✅ | | 自定义聊天机器人 | ✅ | 🔄 手动 | ✅ | | RAG 系统 | ✅ | 🔄 | ✅ | | 任意 Web 应用 | ✅ | ❌ | 🔄 | ## 安全运营集成 ### Microsoft Teams 通过 SSM Parameter Store 配置: ``` aws ssm put-parameter \ --name /xipe/teams_webhook_url \ --value "https://your-org.webhook.office.com/..." \ --type SecureString \ --region us-east-1 ``` ### EventBridge 定时扫描 ``` # 每日 08:00 UTC 扫描 aws events put-rule \ --name xipe-daily-scan \ --schedule-expression "cron(0 8 * * ? *)" \ --region us-east-1 ``` ### CI/CD 集成 ``` # GitHub Actions 示例 - name: XIPE Security Scan run: | python3 -c " import json open('/tmp/payload.json','w').write(json.dumps({ 'target_url': '${{ env.TARGET_URL }}', 'client_name': '${{ env.CLIENT_NAME }}', 'requester': 'CI/CD Pipeline' })) " aws lambda invoke \ --function-name xipe-trigger \ --region us-east-1 \ --payload fileb:///tmp/payload.json \ output.json ``` ## 项目结构 ``` -XIPE-AI-Security-Scanner/ ├── main.py # Entry point ├── config.yaml # Scan configuration ├── requirements.txt ├── xipe_launch.py # Quick launch script (local CLI) │ ├── agent/ │ ├── orchestrator.py # Module coordinator │ ├── finding.py # Finding data model │ └── ai_brain.py # AI Brain (Groq/Llama3) │ ├── modules/ │ ├── web_recon.py # Reconnaissance + SPA detection │ ├── live_ai_tester.py # Live AI interaction + attacks │ ├── librechat_client.py # LibreChat API client │ ├── api_tester.py # API security testing │ ├── prompt_injection.py # LLM01 / LLM07 │ ├── rag_tester.py # LLM02 / LLM08 │ └── agent_tester.py # LLM06 │ ├── reporting/ │ ├── pdf_report.py # PDF generation (WeasyPrint) │ ├── teams_notifier.py # Microsoft Teams integration │ ├── dashboard.py # HTML dashboard │ └── stats_aggregator.py # Cumulative stats → S3 │ ├── utils/ │ └── logger.py # Structured logging │ ├── deploy/ │ ├── Dockerfile # Container image │ ├── lambda_trigger.py # Lambda function │ └── main.tf # Terraform (optional) │ └── index.html # Landing page (GitHub Pages) ``` ## 路线图 **v2.2 — 下一版本** - [ ] 针对 LibreChat 实时攻击交付的 SSE 流修复 - [ ] 支持实时聊天界面的 WebSocket - [ ] GraphQL 端点检测和测试 - [ ] 西班牙语报告生成 **v3.0 — Inbest 模型** - [ ] 在 XIPE 扫描数据集上微调 Llama 3 - [ ] 本地部署选项(无外部 API) - [ ] 多目标并行扫描 - [ ] SIEM 集成 (Splunk, Sentinel) - [ ] 合规性映射 (ISO 27001, NIST AI RMF) ## 构建技术 | 组件 | 技术 | |-----------|-----------| | 运行时 | Python 3.11 | | 容器化 | Docker + AWS ECS Fargate | | AI 大脑 | Groq API — Llama 3.1 8B Instant | | PDF 生成 | WeasyPrint | | 云基础设施 | AWS Lambda, ECS, S3, EventBridge, SSM | | 通知 | Microsoft Teams Webhooks | | 调度 | AWS EventBridge | ## 关于 Inbest Cybersecurity **Inbest Cybersecurity** 是一家位于墨西哥瓜达拉哈拉的网络安全公司,专注于 AI 安全评估、取证调查以及为拉丁美洲的企业客户提供事件响应服务。 - 网站: [inbest.cloud](https://inbest.cloud) - 邮箱: security@inbest.cloud - GitHub: [@RickDevopsSecure](https://github.com/RickDevopsSecure) ## 许可证 专有 — © 2026 Inbest Cybersecurity。保留所有权利。 本软件是 Inbest Cybersecurity 的专有财产。严禁未经授权的复制、分发或使用。如需许可咨询,请联系 security@inbest.cloud。 *XIPE — 自主 AI 安全测试,由 Inbest Cybersecurity 提供支持*
标签:AI安全, AI治理, API安全测试, Chatbot安全, Chat Copilot, CISA项目, DNS枚举, Llama 3, LLM安全测试, OWASP Top 10, Prompt注入, RAG安全, Red Canary, SaaS安全, Sysdig, TGT, 域名收集, 大模型漏洞扫描, 密码管理, 攻防演练, 模型指纹识别, 渗透测试框架, 网络安全工具, 自动化红队, 请求拦截, 防御, 零日漏洞检测