chrispsk/python-web-vulnerability-scanner

GitHub: chrispsk/python-web-vulnerability-scanner

一款教育用途的 Python Web 漏洞扫描器,通过爬取目标站点并注入测试 payload 来检测基本的反射型 XSS 和 SQL 注入漏洞指示。

Stars: 0 | Forks: 0

# Python Web 漏洞扫描器 用于检测 Web 应用程序中基本**反射型 XSS**和 **SQL 注入指示**的教育性 Python Web 漏洞扫描器。 该扫描器会爬取目标网站,查找链接和 HTML 表单,发送测试 payload,并分析 HTTP 响应以寻找潜在的漏洞。 ## 功能 * 爬取内部链接并构建简单的站点地图 * 检测 URL 参数中的反射型 XSS * 检测 HTML 表单中的反射型 XSS * 检测 URL 参数中的 SQL 注入指示 * 检测 HTML 表单中的 SQL 注入指示 * 支持基于错误的 SQL 注入检查 * 支持基于布尔的 SQL 注入检查 * 可选的 HTTP 标头 SQL 注入检查 * 可选的隐藏表单字段测试 * 打印包含易受攻击 URL 和 payload 的最终摘要 ## 技术栈 * Python * requests * BeautifulSoup4 ## 安装说明 安装所需的 Python 包: ``` pip install requests beautifulsoup4 ``` ## 用法 python main.py --url http://testasp.vulnweb.com/ python main.py --url http://testasp.vulnweb.com/ --max-pages 2 python main.py --url http://testasp.vulnweb.com/ --test-headers python main.py --url http://testasp.vulnweb.com/ --test-hidden python main.py --url http://testasp.vulnweb.com/ --test-headers --test-hidden python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-headers python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-hidden python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-headers --test-hidden python main.py --url http://testasp.vulnweb.com/ --ignore http://testasp.vulnweb.com/logout python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --ignore http://testasp.vulnweb.com/logout python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-headers --ignore http://testasp.vulnweb.com/logout python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-hidden --ignore http://testasp.vulnweb.com/logout python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-headers --test-hidden --ignore http://testasp.vulnweb.com/logout python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --ignore http://testasp.vulnweb.com/logout --ignore http://testasp.vulnweb.com/register 基本扫描: ``` python main.py --url http://testasp.vulnweb.com/ --max-pages 2 ``` 结合 HTTP 标头 SQL 注入测试的扫描: ``` python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-headers ``` 扫描隐藏表单字段: ``` python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-hidden ``` 启用两项可选检查的扫描: ``` python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --test-headers --test-hidden ``` 爬取时忽略特定 URL: ``` python main.py --url http://testasp.vulnweb.com/ --max-pages 2 --ignore http://testasp.vulnweb.com/logout ``` ## 检测示例 ### URL 参数中的 XSS 目标 URL 示例: ``` http://example.com/search.asp?q=test ``` 扫描器将 XSS payload 注入到参数值中: ``` http://example.com/search.asp?q= ``` 如果 payload 反射在 HTTP 响应中,扫描器会报告潜在的反射型 XSS 漏洞。 ### 表单中的 XSS 表单示例: ```
``` 扫描器将 XSS payload 提交到表单字段中,例如: ``` ``` 如果 payload 出现在响应中,扫描器会报告潜在的反射型 XSS 漏洞。 ### URL 参数中的 SQL 注入 目标 URL 示例: ``` http://example.com/showforum.asp?id=0 ``` 扫描器测试的 SQL 注入 payload 如下: ``` 3 OR 1=1 -- 3 AND 1=2 -- ``` 如果 true 和 false payload 产生了显著差异的响应,扫描器会报告潜在的基于布尔的 SQL 注入漏洞。 ### 表单中的 SQL 注入 登录表单示例: ```
``` 扫描器将 SQL 注入测试 payload 提交到表单字段中,例如: ``` ' OR '1'='1' -- ' AND '1'='2' -- ``` 如果响应差异显著或包含 SQL 错误信息,扫描器会报告潜在的 SQL 注入漏洞。 ## 示例输出 ``` [+] Starting vulnerability scan... [+] Scanning: http://testasp.vulnweb.com/showforum.asp?id=0 [+] Testing URL parameters in: http://testasp.vulnweb.com/showforum.asp?id=0 [!] Possible SQL injection discovered in link: http://testasp.vulnweb.com/showforum.asp?id=0 ================================================================================ [+] Vulnerability Scan Summary ================================================================================ [!] Total possible findings: 1 [1] SQL Injection Location type : URL parameter URL : http://testasp.vulnweb.com/showforum.asp?id=0 Parameter : id Details : Boolean-based SQL injection indicator Payload : TRUE: 3 OR 1=1 -- | FALSE: 3 AND 1=2 -- -------------------------------------------------------------------------------- [+] Scan completed. ``` ## 限制说明 这是一个教育性项目,不能替代专业的安全测试工具。 当前限制: * 不执行 JavaScript * 可能无法完全爬取单页应用 (SPA) * 默认不支持经过身份验证的扫描 * 不测试 JSON 或 XML API * 可能产生误报或漏报 * 不利用漏洞或提取数据 ## 法律免责声明 请仅在您拥有或获得明确测试许可的应用程序上使用此工具。 未经授权扫描网站或系统可能是违法行为。本项目专为教育目的、受控实验室测试以及基础 Web 安全学习而创建。
标签:CISA项目, DOE合作, Python, SQL注入检测, Web安全, XSS检测, 加密, 无后门, 漏洞扫描器, 蓝队分析, 逆向工具