qm-rajat/PentestSEO

GitHub: qm-rajat/PentestSEO

一个将安全渗透测试、SEO分析、网站QA和技术基础设施检查整合到统一CLI界面的Python模块化框架。

Stars: 0 | Forks: 0

``` ██████╗ ███████╗███╗ ██╗████████╗███████╗███████╗████████╗███████╗███████╗ ██████╗ ██╔══██╗██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██╔════╝██╔════╝██╔═══██╗ ██████╔╝█████╗ ██╔██╗ ██║ ██║ █████╗ ███████╗ ██║ ███████╗█████╗ ██║ ██║ ██╔═══╝ ██╔══╝ ██║╚██╗██║ ██║ ██╔══╝ ╚════██║ ██║ ╚════██║██╔══╝ ██║ ██║ ██║ ███████╗██║ ╚████║ ██║ ███████╗███████║ ██║ ███████║███████╗╚██████╔╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝╚══════╝ ╚═════╝ ``` **一体化安全 · SEO · QA · 技术分析框架** [![Python](https://img.shields.io/badge/Python-3.12+-00d4ff?style=for-the-badge&logo=python&logoColor=white)](https://python.org) [![Platform](https://img.shields.io/badge/Platform-Linux-ff6b35?style=for-the-badge&logo=linux&logoColor=white)](https://linux.org) [![License](https://img.shields.io/badge/License-MIT-26de81?style=for-the-badge)](LICENSE) [![Modules](https://img.shields.io/badge/Modules-38+-a855f7?style=for-the-badge)](modules/) [![Author](https://img.shields.io/badge/Author-Rajat_Kumar_Dash-ff6b6b?style=for-the-badge)](https://github.com/qm-rajat) [![Status](https://img.shields.io/badge/Status-Active-26de81?style=for-the-badge)]()
## 📌 目录 - [概述](#-overview) - [v1.1 版本更新](#-whats-new-in-v11) - [功能矩阵](#-feature-matrix) - [架构](#-architecture) - [文件夹结构](#-folder-structure) - [安装](#-installation) - [使用](#-usage) - [扫描配置](#-scan-profiles) - [所有模块](#-all-modules) - [REST API 模式](#-rest-api-mode) - [定时扫描](#-scheduled-scans) - [告警系统](#-alert-system) - [报告](#-reports) - [隐蔽模式](#-stealth-mode) - [外部工具](#-external-tools) - [法律免责声明](#-legal-disclaimer) - [作者](#-author) ## 🚀 概述 **PentestSEO** 是一个功能强大、模块化的 CLI 框架,基于 Python 3.12 构建,将**安全渗透测试**、**SEO 分析**、**网站 QA(质量保证)**和**技术基础设施检查**统一到一个工具中。 无论您是寻找漏洞的安全研究员、审计客户网站的 SEO 工程师、检查代码质量的开发人员,还是检查服务器配置的系统管理员 —— PentestSEO 都能为您在一个地方提供所需的一切。 ``` User Input │ ▼ ┌─────────────────────────┐ │ Interactive CLI Menu │ ← Rich terminal UI └───────────┬─────────────┘ │ ┌───────▼────────┐ │ Crawl Engine │ ← Up to 100+ pages, forms, links, params └───────┬────────┘ │ ┌──────────▼──────────────┐ │ 38+ Scan Modules │ ← Security · SEO · QA · Technical · Recon └──────────┬──────────────┘ │ ┌──────────▼──────────────┐ │ Result Aggregator │ ← Deduplication + Risk Scoring └──────────┬──────────────┘ │ ┌──────────▼──────────────┐ │ Multi-Format Reports │ ← Terminal · JSON · TXT · HTML └─────────────────────────┘ ``` ## ✨ v1.1 版本更新 | 功能 | 描述 | |---|---| | 🌐 **REST API 模式** | 将 PentestSEO 作为带有异步任务队列的 Flask API 服务器运行 | | 📅 **扫描调度器** | 内置 cron 风格调度器:每小时 / 每天 / 每周 / 每月 | | 🔔 **告警系统** | 关键发现通过电子邮件 (SMTP) + Slack webhook 通知 | | 📊 **HTML 报告** | 精美的暗色模式交互式 HTML 报告,带有风险评分环 | | 🎯 **风险评分** | 每次扫描的加权 0–100 风险评分及等级(Critical → Minimal) | | 🔄 **扫描对比** | 对比两次扫描:新发现 vs 已解决 vs 未变更 | | 📸 **截图** | Playwright/Selenium 页面捕获 + Core Web Vitals (LCP, CLS, TBT) | | ↪ **开放重定向** | 检测 20 多个参数名称的重定向参数滥用 | | 🎯 **SSRF 检测** | 测试 AWS/GCP 元数据端点、localhost、内部端口 | | 📁 **敏感文件** | 检查 60 多个路径:`.env`、`.git`、备份、密钥、SQL 转储 | | 🔑 **JWT 分析** | 算法滥用 (none)、弱密钥、缺少过期时间 | | 🌐 **CORS 检查** | 通配符 + 凭证、null 源、反射源攻击 | | ⏱ **速率限制** | 登录端点的暴力破解保护检测 | | 🛡 **WAF 检测** | 指纹识别 11 家 WAF 供应商,包括 Cloudflare、ModSecurity | | 📊 **Schema 验证** | JSON-LD 结构化数据 / Schema.org 验证 | | 🔗 **内部链接** | 孤立页面、链接深度分析、锚文本质量 | | 📄 **重复内容** | 精确 + 模糊内容、标题和元描述去重 | | 🔐 **GDPR 检查器** | Cookie 同意、隐私政策、跟踪器检测(13 种类型) | | 🌐 **HTTP/2 + HTTP/3** | 协议支持、IPv6、HSTS 预加载状态 | | 🔍 **WHOIS 查询** | 域名年龄、到期时间、注册商、隐私保护 | ## 🗂 功能矩阵 ### 🔒 安全测试 — 13 个模块 | 模块 | 描述 | 外部工具 | |---|---|---| | `xss` | XSS 检测,包含反射型 payload 探测 | XSStrike | | `sqli` | SQL 注入测试,基于错误的回退机制 | sqlmap | | `csrf` | CSRF token 检测 + SameSite cookie 分析 | — | | `dirbrute` | 目录与文件暴力破解 | dirsearch | | `subdomain` | 子域名枚举 + DNS 暴力破解 | subfinder | | `portscan` | 20 多个常见服务的端口扫描 | nmap | | `vulnscan` | CVE 级别的漏洞扫描 | nikto | | `open_redirect` | 通过 20 多个参数名称进行开放重定向检测 | — | | `ssrf` | 针对云元数据端点的 SSRF 测试 | — | | `sensitive_files` | 并行检查 60 多个敏感路径 | — | | `jwt` | JWT 算法滥用、弱密钥破解 | — | | `cors` | CORS 错误配置检测 | — | | `rate_limit` | 登录暴力破解保护检测 | — | ### 📈 SEO 分析 — 10 个模块 | 模块 | 描述 | |---|---| | `meta` | Title、description、OG 标签、canonical、noindex | | `headings` | H1–H6 层级结构分析 | | `keywords` | 关键词密度、堆砌检测、字数统计 | | `sitemap` | Sitemap.xml 检测与验证 | | `robots` | robots.txt 解析,SPF/DMARC 声明 | | `pagespeed` | 加载时间、压缩、渲染阻塞脚本 | | `mobile` | Viewport、响应式框架、固定宽度元素 | | `schema` | JSON-LD / Microdata / Open Graph 验证 | | `internal_links` | 孤立页面、链接深度、锚文本质量 | | `duplicate` | 精确 + 模糊重复内容、标题、元描述 | ### ✅ 网站 QA — 7 个模块 | 模块 | 描述 | |---|---| | `grammar` | 通过 LanguageTool 进行语法检查 | | `spelling` | 拼写检查,提供单词级建议 | | `brokenlinks` | 并行失效链接检测(100+ 链接) | | `alttags` | 图片 alt 属性验证 | | `htmlvalid` | W3C HTML 验证(在线 + 本地回退) | | `accessibility` | WCAG 2.1 基础:ARIA、标签、对比度提示 | | `gdpr` | Cookie 同意、隐私政策、13 种跟踪器类型 | ### ⚙️ 技术分析 — 9 个模块 | 模块 | 描述 | 外部工具 | |---|---|---| | `techstack` | 50+ 技术指纹(CMS、框架、CDN) | — | | `ssl` | 证书过期、弱加密套件、TLS 版本 | sslscan | | `dns` | A/MX/NS/TXT, SPF, DMARC, DKIM, DNSSEC | — | | `cdn` | 10+ CDN 供应商检测 | — | | `httpheaders` | 10 个安全头部评分,cookie 分析 | — | | `waf` | 11 家 WAF 供应商指纹识别 | — | | `screenshot` | 全页截图 + Core Web Vitals | Playwright / Selenium | | `http_version` | HTTP/2, HTTP/3, IPv6, HSTS 预加载 | curl | | `whois` | 域名年龄、到期时间、注册商、隐私保护 | — | ## 🏗 架构 ``` PentestSEO/ │ ├── pentestseo.py # Entry point (CLI + --api flag) ├── installer.sh # Auto-installer (apt / pacman / dnf / brew) ├── requirements.txt ├── README.md │ ├── core/ # Framework engine │ ├── menu.py # Rich interactive CLI menu │ ├── crawler.py # Web crawler (pages, forms, links, params) │ ├── stealth.py # Stealth mode: delays, UA rotation, shuffling │ ├── scanner_manager.py # Dynamic module loader & runner │ ├── progress.py # Rich progress display utilities │ ├── history.py # Scan history (JSON store) │ └── report.py # Multi-format report generator + risk scoring │ ├── modules/ │ ├── security/ # 13 security modules │ ├── seo/ # 10 SEO modules │ ├── qa/ # 7 QA modules │ ├── technical/ # 9 technical modules │ └── recon/ # Recon modules (WHOIS) │ ├── profiles/ # Scan profiles (module bundles) │ ├── quick_scan.py │ ├── security_scan.py │ ├── seo_scan.py │ ├── qa_scan.py │ ├── technical_scan.py │ └── full_audit.py │ ├── api/ │ └── server.py # Flask REST API server │ ├── scheduler/ │ └── scheduler.py # Built-in cron-style scan scheduler │ ├── alerts/ │ └── alerter.py # Email + Slack alert system │ ├── templates/ │ └── report.html # Dark-mode interactive HTML report template │ ├── config/ │ ├── schedules.json # Saved scheduled scans │ └── alerts.json # Alert configuration │ ├── scans/ # Saved scan reports │ └── domain_timestamp/ │ ├── report.txt │ ├── report.json │ ├── report.html │ └── screenshots/ │ └── wordlists/ └── directory.txt # Brute-force wordlist (100+ paths) ``` ## 📦 安装 ### 1. 克隆仓库 ``` git clone https://github.com/qm-rajat/PentestSEO.git cd PentestSEO ``` ### 2. 运行安装程序 ``` chmod +x installer.sh ./installer.sh ``` 安装程序会自动: - 检测您的操作系统 (Debian/Ubuntu · Arch · Fedora/RHEL · macOS) - 通过 `apt` / `pacman` / `dnf` / `brew` 安装系统工具 - 安装所有 Python 依赖 - 创建默认字典和目录结构 ### 3. 手动依赖安装(可选) ``` pip install -r requirements.txt ``` ### 4. 安装 Playwright(用于截图 + Core Web Vitals) ``` pip install playwright playwright install chromium ``` ## 🖥 使用 ### 交互式 CLI 模式 ``` python3 pentestseo.py ``` ``` ____ _ _ ____ _____ ___ | _ \ ___ _ __ | |_ ___ ___| |_/ ___|| ____/ _ \ | |_) / _ \ '_ \| __/ _ \/ __| __\___ \| _|| | | | | __/ __/ | | | || __/\__ \ |_ ___) | |__| |_| | |_| \___|_| |_|\__\___||___/\__|____/|_____\___/ Security • SEO • QA • Technical • v1.1 Use Responsibly — Authorized Testing Only ╭──────────────────────────────────────────────────╮ │ Main Menu │ │ │ │ 1 Single Website Scan │ │ 2 Multiple Website Scan │ │ 3 View Scan History │ │ 4 Compare Two Scans │ │ 5 Scheduled Scans │ │ 6 Alert Configuration │ │ 7 Exit │ ╰──────────────────────────────────────────────────╯ ``` ### REST API 模式 ``` python3 pentestseo.py --api python3 pentestseo.py --api --port 8080 --host 127.0.0.1 ``` ## 🎯 扫描配置 | 配置 | 包含模块 | 用例 | |---|---|---| | **Quick Scan** ⚡ | techstack, httpheaders, robots, sitemap, ssl, waf | 快速站点概览 | | **Security Scan** 🔒 | sensitive_files, cors, csrf, rate_limit, open_redirect, ssrf, jwt, portscan, xss, sqli, dirbrute, vulnscan | 全面安全审计 | | **SEO Audit** 📈 | meta, headings, keywords, sitemap, robots, mobile, pagespeed, schema, internal_links, duplicate | SEO 深度分析 | | **QA Audit** ✅ | grammar, spelling, brokenlinks, alttags, htmlvalid, accessibility, gdpr | 内容质量检查 | | **Technical** ⚙️ | whois, techstack, ssl, dns, cdn, httpheaders, waf, http_version, screenshot | 基础设施检查 | | **Full Audit** 🔍 | **所有 38+ 个模块** | 完整分析 | ### 运行扫描 ``` Enter target URL: https://example.com Select Scan Profile: 1 Quick Scan Tech, headers, robots, sitemap, SSL, WAF 2 Security Scan XSS, SQLi, CSRF, CORS, SSRF, ports, files, JWT 3 SEO Audit Meta, headings, keywords, schema, links, speed 4 QA Audit Grammar, spelling, links, alt, HTML, WCAG, GDPR 5 Technical SSL, DNS, CDN, headers, WAF, HTTP/2, screenshots 6 Full Audit All modules (~38 checks) Enable stealth mode? [y/n]: n Crawl limit (default 100): 50 ``` ## 🌐 REST API 模式 启动 API 服务器: ``` python3 pentestseo.py --api --port 5000 ``` ### 端点 | 方法 | 端点 | 描述 | |---|---|---| | `GET` | `/` | API 信息和可用端点 | | `GET` | `/health` | 健康检查 | | `POST` | `/scan/start` | 启动异步扫描任务 | | `GET` | `/scan/status/` | 轮询扫描状态 | | `GET` | `/scan/results/` | 获取完整 JSON 结果 | | `GET` | `/scan/report//` | 下载报告 | | `GET` | `/history` | 查看所有历史扫描 | | `POST` | `/compare` | 比较两份扫描报告 | ### 示例:启动扫描 ``` curl -X POST http://localhost:5000/scan/start \ -H "Content-Type: application/json" \ -d '{ "target": "https://example.com", "profile": "quick", "crawl_limit": 30, "stealth": false }' ``` ``` { "success": true, "data": { "job_id": "a1b2c3d4", "message": "Scan started.", "poll": "/scan/status/a1b2c3d4" } } ``` ### 示例:轮询状态 ``` curl http://localhost:5000/scan/status/a1b2c3d4 ``` ``` { "success": true, "data": { "id": "a1b2c3d4", "target": "https://example.com", "profile": "quick", "status": "done", "risk_score": 42, "started_at": "2024-01-15T10:30:00", "finished_at": "2024-01-15T10:32:45" } } ``` ### 示例:比较两次扫描 ``` curl -X POST http://localhost:5000/compare \ -H "Content-Type: application/json" \ -d '{ "scan_a": "/path/to/scans/example.com_20240101_120000", "scan_b": "/path/to/scans/example.com_20240115_120000" }' ``` ## 📅 定时扫描 PentestSEO 包含一个内置的 cron 风格调度器,可通过主菜单(**选项 5**)访问或以编程方式访问。 ### 支持的间隔 | 间隔 | 频率 | |---|---| | `hourly` | 每 60 分钟 | | `daily` | 每 24 小时 | | `weekly` | 每 7 天 | | `monthly` | 每 30 天 | ### 调度菜单 ``` [ SCHEDULER MENU ] 1 View scheduled scans 2 Add new scheduled scan 3 Remove scheduled scan 4 Toggle enable/disable 5 Back ``` ### 添加定时扫描 ``` Target URL: https://example.com Profile: security Interval: daily Stealth mode?: n Crawl limit: 50 Alert email (optional): admin@yoursite.com Slack webhook URL (optional): https://hooks.slack.com/... Schedule added: a1b2c3d4 ``` 计划任务保存在 `config/schedules.json` 中,并在后台自动运行。 ## 🔔 告警系统 通过主菜单(**选项 6**)配置告警,或直接编辑 `config/alerts.json`。 ### 支持的渠道 | 渠道 | 配置 | |---|---| | **Email** | SMTP (Gmail, Outlook, 自定义) | | **Slack** | Incoming webhook URL | ### 告警阈值 ``` Alert on Critical findings?: y Alert on High findings?: y Alert on Medium findings?: n Always alert (every scan)?: n ``` ### 邮件配置 ``` { "email": { "enabled": true, "smtp_host": "smtp.gmail.com", "smtp_port": 587, "username": "you@gmail.com", "password": "app-password", "from_addr": "you@gmail.com", "to_addrs": ["team@yourcompany.com"] } } ``` ### Slack 配置 ``` { "slack": { "enabled": true, "webhook_url": "https://hooks.slack.com/services/YOUR/WEBHOOK/URL" } } ``` ## 📊 报告 每次扫描生成三种报告格式,保存在 `scans/domain_timestamp/` 中: ``` scans/ └── example.com_20240115_103000/ ├── report.txt ← Plain text, terminal-friendly ├── report.json ← Machine-readable, API-ready ├── report.html ← Interactive dark-mode HTML └── screenshots/ ├── home.png └── about.png ``` ### 终端报告 扫描期间实时的 Rich 格式输出,包含按模块分组的严重性着色发现。 ### JSON 报告 ``` { "target": "https://example.com", "profile": "security", "timestamp": "2024-01-15T10:30:00", "risk_score": 65, "risk_grade": "High Risk", "stats": { "critical": 1, "high": 4, "medium": 8, "low": 12, "pass": 15 }, "modules": { ... } } ``` ### HTML 报告功能 - 🌙 暗色模式设计 - 📊 动画风险评分环 (0–100) - 🔢 严重性摘要标签 - 🔍 跨所有发现的实时搜索 - 🔽 按严重级别筛选 - 📂 可折叠模块部分(高/严重级别自动展开) - 📸 截图画廊 - 📱 移动端响应式 ### 风险评分 ``` 0–9 → Minimal Risk (Green) 10–24 → Low Risk (Blue) 25–49 → Medium Risk (Yellow) 50–74 → High Risk (Orange) 75–100 → Critical Risk (Red) ``` ### 对比扫描 ``` # 从主菜单 → 选项 4 # 或通过 API: POST /compare { "scan_a": "/path/scan1", "scan_b": "/path/scan2" } ``` 输出显示: - ✅ **已解决** 的发现自上次扫描以来已修复) - ⚠️ **新增** 的发现(自上次扫描以来出现) - 📊 **未变更** 的发现计数 ## 🥷 隐蔽模式 在扫描配置期间或通过 API 使用 `"stealth": true` 启用。 | 功能 | 描述 | |---|---| | **随机延迟** | 请求之间 1–4 秒的随机暂停 | | **轮换 User Agents** | 随机轮换 9 个浏览器 UA 字符串 | | **打乱模块顺序** | 安全模块以随机顺序运行 | | **速率限制** | 防止触发 IDS/WAF 阈值规则 | | **随机化 Header** | Accept-Language, Cache-Control 变化 | ## 🔧 外部工具 PentestSEO 集成了这些工具(由 `installer.sh` 自动安装): | 工具 | 用途 | 安装 | |---|---|---| | `nmap` | 端口扫描与服务检测 | `apt install nmap` | | `sqlmap` | SQL 注入测试 | `apt install sqlmap` | | `nikto` | Web 漏洞扫描 | `apt install nikto` | | `sslscan` | SSL/TLS 加密套件分析 | `apt install sslscan` | | `dirsearch` | 目录暴力破解 | `pip install dirsearch` | | `subfinder` | 子域名枚举 | `go install subfinder` | | `XSStrike` | XSS 检测 | `git clone /opt/XSStrike` | | `curl` | HTTP/2 检测 | 预装 | | `Playwright` | 截图 + CWV | `pip install playwright` | | `Selenium` | 截图回退方案 | `pip install selenium` | ## 📋 Python 依赖 ``` rich>=13.7.0 # Terminal UI requests>=2.31.0 # HTTP client beautifulsoup4>=4.12.0 # HTML parsing lxml>=5.0.0 # XML/HTML parser dnspython>=2.6.0 # DNS resolution tldextract>=5.1.0 # Domain parsing python-whois>=0.9.4 # WHOIS lookups pyOpenSSL>=24.0.0 # SSL analysis language-tool-python # Grammar + spelling flask>=3.0.0 # REST API server flask-cors>=4.0.0 # CORS for API playwright>=1.40.0 # Screenshots (optional) selenium>=4.16.0 # Screenshots fallback (optional) ``` ## ⚖️ 法律免责声明 ``` ╔══════════════════════════════════════════════════════════════════════════╗ ║ ⚠ LEGAL DISCLAIMER ⚠ ║ ╠══════════════════════════════════════════════════════════════════════════╣ ║ ║ ║ PentestSEO is designed for EDUCATIONAL PURPOSES and AUTHORIZED ║ ║ SECURITY TESTING ONLY. ║ ║ ║ ║ BY USING THIS TOOL, YOU AGREE THAT: ║ ║ ║ ║ 1. You will only scan systems you OWN or have WRITTEN PERMISSION to ║ ║ test. Verbal permission is not sufficient. ║ ║ ║ ║ 2. You will NOT use this tool to conduct unauthorized access, ║ ║ denial of service, data exfiltration, or any form of cyberattack. ║ ║ ║ ║ 3. You understand that UNAUTHORIZED SCANNING IS A CRIMINAL OFFENSE ║ ║ under laws including: ║ ║ • Computer Fraud and Abuse Act (CFAA) — United States ║ ║ • Computer Misuse Act 1990 — United Kingdom ║ ║ • IT Act 2000, Section 66 — India ║ ║ • Cybercrime laws in your jurisdiction ║ ║ ║ ║ 4. The author, Rajat Kumar Dash, bears NO responsibility for any ║ ║ misuse, damage, data loss, legal consequences, or criminal ║ ║ liability arising from use of this tool. ║ ║ ║ ║ ALWAYS get permission. ALWAYS act ethically. ║ ║ Hacking without consent is a CRIME. ║ ║ ║ ╚══════════════════════════════════════════════════════════════════════════╝ ``` ## 👤 作者
**Rajat Kumar Dash** [![GitHub](https://img.shields.io/badge/GitHub-qm--rajat-181717?style=for-the-badge&logo=github)](https://github.com/qm-rajat) [![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE) *为安全和开发者社区用 ❤️ 构建。* *负责任地使用。道德地黑客。保持合法。*
``` PentestSEO v1.1 · Python 3.12 · Linux · MIT License © 2024 Rajat Kumar Dash · For authorized use only ```
标签:Parrot OS, Python, SEO工具, 密码管理, 对称加密, 技术分析, 插件系统, 无后门, 模块化设计, 漏洞分析, 特征检测, 白盒测试, 网站分析, 网络安全, 自动化修复, 自动化审计, 质量保证, 路径探测, 逆向工具, 隐私保护