geevarghesekthomas84-sys/spaf

GitHub: geevarghesekthomas84-sys/spaf

一个融合多源 AI 的异步攻击性安全框架,实现从侦察到漏洞利用再到修复建议的渗透测试全流程自动化。

Stars: 2 | Forks: 0


███████╗██████╗  █████╗ ███████╗

██╔════╝██╔══██╗██╔══██╗██╔════╝

███████╗██████╔╝███████║█████╗  

╚════██║██╔═══╝ ██╔══██║██╔══╝  

███████║██║     ██║  ██║██║     

╚══════╝╚═╝     ╚═╝  ╚═╝╚═╝     

**智能渗透测试自动化框架**

*扫描。分析。利用。修复 — 全自动。*


[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE) [![Python](https://img.shields.io/badge/Python-3.9%2B-3776AB?style=flat-square&logo=python&logoColor=white)](https://python.org) [![Async](https://img.shields.io/badge/Engine-Asyncio-00C7B7?style=flat-square&logo=python&logoColor=white)](https://docs.python.org/3/library/asyncio.html) [![MongoDB](https://img.shields.io/badge/Database-MongoDB-47A248?style=flat-square&logo=mongodb&logoColor=white)](https://mongodb.com) [![Docker](https://img.shields.io/badge/Docker-Ready-2496ED?style=flat-square&logo=docker&logoColor=white)](Dockerfile) [![Stars](https://img.shields.io/github/stars/geevarghesekthomas84-sys/spaf?style=flat-square&logo=github&color=gold)](https://github.com/geevarghesekthomas84-sys/spaf/stargazers)
**— AI 提供商 —** [![Gemini](https://img.shields.io/badge/Google%20Gemini-2.0%20Flash-8E75B2?style=flat-square&logo=googlegemini&logoColor=white)](https://ai.google.dev) [![Claude](https://img.shields.io/badge/Anthropic%20Claude-3.5%20Sonnet-D97757?style=flat-square&logo=anthropic&logoColor=white)](https://anthropic.com) [![Ollama](https://img.shields.io/badge/Ollama-Local%20%7C%20Streaming-black?style=flat-square&logo=ollama&logoColor=white)](https://ollama.ai) [![LM Studio](https://img.shields.io/badge/LM%20Studio-Local%20%7C%20Streaming-FFD21E?style=flat-square&logo=huggingface&logoColor=black)](https://lmstudio.ai) [![Shodan](https://img.shields.io/badge/Shodan-Passive%20Intel-FF0000?style=flat-square&logo=shodan&logoColor=white)](https://shodan.io)
## 📌 什么是 SPAF? **SPAF** 是一个专业的异步攻击性安全框架,充当**AI 驱动的红队大脑**。它超越了传统的扫描器,能够自动将漏洞数据转化为武器化的攻击情报。 - 🎯 对任何目标运行**多向量扫描** - 🧠 每次扫描后自动运行 **AI 威胁分析**(Google、Claude、Ollama、LM Studio) - 🚀 **自动生成 Python 概念验证漏洞利用脚本** - 🛠️ 接收**生产可用的修复代码**(Ansible、Terraform 或 Bash) - 🕵️ 通过 TOR、代理轮换和指纹随机化实现**完全匿名**操作 - ⏱️ 具备智能警报功能的 **24/7 影子监控** - 📡 **被动 Shodan 情报** — 无需触碰目标即可获取开放端口和组织信息 - 📊 **导出发现结果**为 CSV/JSON 格式,便于向客户交付 - 🔍 **对比两次扫描** — 即时查看变更(新增/已修复/未更改) - 🐳 **Docker 开箱即用** — 一条命令即可启动完整技术栈 ## ✨ 核心功能集
### 🧠 AI 智能套件 连接任何主流 AI 模型进行红队级别的分析。在**每次扫描**之后,SPAF 会自动将发现结果发送到您配置的 AI,并生成针对特定模块的情报报告,涵盖攻击路径、漏洞利用技术、CVE 关联和可行的修复建议——直接在终端中打印。 **支持的提供商(适用于所有命令):** | 提供商 | 类型 | 快捷方式 | |---|---|---| | Google Gemini 2.0 Flash | ☁️ 远程 | `spaf gemini` | | Anthropic Claude 3.5 | ☁️ 远程 | `spaf claude` | | Ollama (本地) | 💻 流式传输 | `spaf ollama` | | LM Studio (本地) | 💻 流式传输 | `spaf lmstudio` | ### 🕵️ 隐蔽与行动安全引擎 每一个请求都封装在可配置的行动安全层中。 - 原生 **TOR** 集成 (`socks5://`) - 轮换的 **SOCKS5/HTTP 代理**链 - 动态 **User-Agent** 指纹轮换 - 每个模块的**并发**与请求延迟控制 ### 📡 被动 Shodan 情报 在 `.env` 中设置 `SHODAN_API_KEY`,用被动的 Shodan 数据丰富每次侦察扫描——开放端口、组织、ISP 和国家——**无需向目标发送任何数据包**。
### 🔍 侦察模块 在发动任何攻击载荷之前,构建完整的攻击面地图。 - 通过 `crt.sh` 进行被动子域枚举 - 主动 DNS 暴力破解(12 个以上常见前缀) - DNS 记录审计:SPF、DMARC、AXFR 区域传送 - WHOIS 注册人电子邮件暴露分析 - **Shodan 被动 IP 情报**(可选) ### 🌐 Web 安全审计 对 Web 应用安全态势进行深度评估。 - 安全头:CSP、HSTS、XFO、X-Content-Type - Cookie 标志:`Secure`、`HttpOnly`、`SameSite` - 敏感路径探测:`.env`、`.git`、管理门户 - TLS/SSL:协议版本、证书到期
### 🔌 网络情报 高速、可配置的端口扫描,结合自动威胁关联。 - 集成 **Nmap**,支持 `light`、`normal`、`aggressive` 配置文件 - **RustScan** 涡轮发现(异步 TCP) → 移交给 Nmap 进行深度分析 - 服务版本检测与操作系统指纹识别 - 通过 **NIST NVD API** 自动映射 CVE(有速率限制,支持 API 密钥) ### 📊 报告与导出 生成高管级别的交付物。 - 🌑 **深色模式 HTML 仪表板**,按严重程度排序的发现结果 - 📄 **结构化 JSON** 输出,适用于流水线 - 📋 **CSV 导出** (`spaf export`),生成面向客户的电子表格 - 🔍 **扫描对比** (`spaf diff`) — 直观比较任意两次扫描
## 🚀 安装 ``` # 克隆仓库 git clone https://github.com/geevarghesekthomas84-sys/spaf.git cd spaf # 创建并激活虚拟环境 python -m venv venv source venv/bin/activate # Linux / macOS venv\Scripts\activate # Windows # 安装依赖 pip install -r requirements.txt pip install -e . # 安装 Shell tab-completion(可选但推荐) spaf --install-completion # 运行交互式设置向导 spaf setup ``` ## 🐳 Docker 部署 最快的启动方式——无需手动设置 MongoDB 或 Python 环境。 ``` # 1. 一条命令启动 MongoDB + SPAF docker-compose up -d # 2. 运行任意扫描 docker-compose run spaf recon target.com docker-compose run spaf scan target.com --scanner rustscan --ports 1-65535 # 3. 进入交互式 AI Shell docker-compose run spaf shell # 覆盖整个命令 docker-compose run spaf export target.com --format csv ``` ## ⚙️ 配置 将 `.env.example` 复制到 `.env` 并配置您的提供商: ``` # ─── AI Provider(选择一个)──────────────────────────────────── AI_PROVIDER=google # google | claude | ollama | lmstudio # Remote providers GOOGLE_API_KEY=your_key ANTHROPIC_API_KEY=your_key # Model overrides(可选 — 显示默认值) GOOGLE_MODEL=gemini-2.0-flash ANTHROPIC_MODEL=claude-3-5-sonnet-20241022 # Local providers OLLAMA_URL=http://localhost:11434/v1 OLLAMA_MODEL=llama3.2 # optional, auto-detected LM_STUDIO_URL=http://localhost:1234/v1 LM_STUDIO_MODEL=your-model # optional, auto-detected from loaded model # ─── APIs ──────────────────────────────────────────────────────── NIST_API_KEY=your_key # free: https://nvd.nist.gov/developers/request-an-api-key SHODAN_API_KEY=your_key # free: https://account.shodan.io/register # ─── Stealth / OpsSec ──────────────────────────────────────────── USE_TOR=false PROXY_FILE=./proxies.txt RANDOM_USER_AGENT=true # ─── Database ──────────────────────────────────────────────────── SPAF_MONGO_URI=mongodb://localhost:27017 ``` ## 💻 用法 ``` # ─── Reconnaissance ────────────────────────────────────────────── spaf recon target.com # Recon + AI + Shodan (if key set) spaf recon target.com --passive --no-ai # Passive OSINT only # ─── Network Scanning ──────────────────────────────────────────── spaf scan target.com # Nmap + AI analysis spaf scan target.com --scanner rustscan --ports 1-65535 # RustScan → Nmap spaf scan target.com --intensity aggressive # Deep scan (-sV -sC -O -A) # ─── Web Security ──────────────────────────────────────────────── spaf webscan https://target.com # Full web audit + AI spaf crawl https://target.com --depth 3 # Spider + AI # ─── AI Provider 快捷方式(均上下文安全)──────────────────────── spaf test-ai # Health check + status table spaf chat "How do I bypass a WAF?" # Configured provider spaf gemini "Explain CVE-2024-1234" # Google Gemini spaf claude "Write an Ansible remediation task" # Anthropic Claude spaf ollama "List SMB exploitation paths" # Ollama — live streaming spaf lmstudio "Analyze these HTTP headers" # LM Studio — live streaming # ─── 对过去扫描的 AI 分析 ──────────────────────────────────────── spaf ai # Re-analyze (no re-scan) spaf ai --provider ollama # Use Ollama for this run # ─── Exploit 与 Remediation ────────────────────────────────────── spaf poc # Generate Python exploit script spaf poc --output exploit.py spaf remediate --format ansible # Fix code (ansible/terraform/bash) # ─── Operations ────────────────────────────────────────────────── spaf export target.com --format csv # Export findings to CSV spaf export target.com --format json # Export findings to JSON spaf diff # Compare two scans spaf scope show # View engagement scope spaf scope add target.com # Add to scope spaf scope remove target.com # Remove from scope spaf watch target.com --interval 3600 --module webscan # 24/7 monitoring spaf report target.com --format html # Premium HTML report spaf history # Past scan records spaf shell # Interactive AI shell spaf update # Update SPAF to latest ``` ## 🤖 AI 提供商设置 ### 快速对比 | 提供商 | 类型 | 模型 | 隐私性 | 流式传输 | 最适用场景 | | :--- | :---: | :--- | :---: | :---: | :--- | | **Google Gemini** | ☁️ 远程 | `gemini-2.0-flash` | 低 | ❌ | 最快,上下文最大 | | **Anthropic Claude** | ☁️ 远程 | `claude-3-5-sonnet-20241022` | 低 | ❌ | 报告编写,修复建议 | | **Ollama** | 💻 本地 | 自动检测 | ✅ 高 | ✅ 实时 | 离线环境,无限使用 | | **LM Studio** | 💻 本地 | 自动检测 | ✅ 高 | ✅ 实时 | 私有化,数据不离开主机 | ### Ollama 设置 ``` # 1. 安装 Ollama → https://ollama.com # 2. 拉取模型 ollama pull llama3.2 ollama pull qwen2.5-coder # great for exploit/remediation code # 3. 在 .env 中设置 AI_PROVIDER=ollama OLLAMA_URL=http://localhost:11434/v1 # default, change if remote OLLAMA_MODEL=llama3.2 # optional — auto-detected if not set # 4. 测试连接 spaf test-ai # 5. 使用快捷方式(tokens 实时流式传输) spaf ollama "List exploitation paths for open SMB ports" ``` ### LM Studio 设置 ``` # 1. 下载 LM Studio → https://lmstudio.ai # 2. 在应用中加载任意 GGUF 模型 # 3. 前往:Local Server 选项卡 → Start Server # 4. 在 .env 中设置 AI_PROVIDER=lmstudio LM_STUDIO_URL=http://localhost:1234/v1 # default LM_STUDIO_MODEL=your-model-name # optional — auto-detected from loaded model # 5. 测试连接 spaf test-ai # 6. 使用快捷方式(tokens 实时流式传输) spaf lmstudio "Analyze these HTTP headers for security risks" ``` ## 📡 Shodan 集成 利用**被动 Shodan 情报**丰富每一次 `spaf recon` 扫描——获取开放端口、组织、ISP 和国家信息——而无需向目标发送任何数据包。 ``` # 1. 获取免费的 API key → https://account.shodan.io/register # 2. 添加至 .env SHODAN_API_KEY=your_api_key # 3. 安装 Shodan 库 pip install shodan # 4. 运行 recon — Shodan 数据将被自动获取 spaf recon target.com ``` ## 🔍 扫描对比与导出 ``` # 查看扫描历史以获取 ID spaf history # 比较两次扫描 — 查看新增、已修复或未更改的内容 spaf diff # 将目标的所有 findings 导出到 CSV(供客户使用) spaf export target.com --format csv spaf export target.com --format json --output /tmp/findings.json ``` ## 🗂️ 接合范围 ``` # 初始化 scope(在当前目录创建 scope.json) spaf scope add target.com spaf scope add 10.0.0.0/24 # 查看当前 scope spaf scope show # 移除目标 spaf scope remove 10.0.0.0/24 # 使用自定义 scope 文件 spaf scope show --file engagement_scope.json ``` ## 📁 项目结构 ``` spaf/ ├── spaf/ │ ├── cli/ # Typer CLI — all commands │ ├── core/ # Async engine & BaseModule │ ├── modules/ # recon, network, webscan, crawler │ ├── utils/ # AI orchestrator, proxy, risk, validator, logger │ ├── database/ # MongoDB async driver (Motor) with full indexes │ └── reports/ # HTML & JSON report generator ├── tests/ # Pytest test suite ├── plugins/ # Drop-in custom scan modules ├── Dockerfile # Python 3.12-slim + nmap ├── docker-compose.yml # MongoDB 7 + SPAF with healthcheck ├── scope.json # Engagement scope (auto-created) ├── COMMANDS.md # Full command reference └── .env.example # Configuration template ``` ## 🔒 隐蔽与行动安全 | 变量 | 描述 | |---|---| | `USE_TOR=true` | 通过 TOR 路由所有请求 (`socks5://127.0.0.1:9050`) | | `PROXY_FILE=./proxies.txt` | 轮换的 SOCKS5/HTTP 代理链文件 | | `RANDOM_USER_AGENT=true` | 为每个请求随机化浏览器 User-Agent | | `NIST_API_KEY=` | NIST NVD API 密钥(CVE 查找速率提高 10 倍——免费注册) | | `SHODAN_API_KEY=` | 侦察中的被动 Shodan 情报(提供免费套餐) | ## ⚠️ 法律免责声明
由 **[geevarghesekthomas84-sys](https://github.com/geevarghesekthomas84-sys)** 用 🔥 打造 ⭐ 如果您觉得 SPAF 有用,请考虑给仓库点个 Star——这对我们帮助很大!
标签:AI安全, Asyncio, Chat Copilot, CISA项目, Claude, CTI, CVE映射, CVE检测, DLL 劫持, Docker, Gemini, LLM评估, LM Studio, MongoDB, Ollama, POC生成, Python, 修复建议, 大语言模型, 安全防御评估, 密码管理, 异步编程, 无后门, 无线安全, 智能攻防框架, 智能漏洞分析, 网络安全, 网络安全审计, 自动化侦察, 自动化安全评估, 自动化渗透测试, 计算机取证, 请求拦截, 逆向工具, 隐私保护