基于 C++17 和 Qt 6 构建的 Web 漏洞扫描器,具备 GUI、CLI、可配置爬取和 JSON 报告功能。为教育目的而重构。
一个使用 C++17 和 Qt 6 构建的 Web 漏洞扫描器,具有图形界面和命令行界面。
本仓库包含 SmartScanner 3.0.0 的重建版本,仅供教育目的使用。它结合了 Web 爬取引擎、漏洞检测模块和 JSON 报告功能。
robots.txt 和站点地图处理、可配置的爬取深度和范围。执行的模块取决于配置和扫描过程中发现的资源。
| 组件 | 版本 / 详情 |
|---|---|
| CMake | 3.21 或更高版本 |
| 编译器 | 兼容 C++17 |
| Qt | 6.2 或更高版本 |
| Qt 模块 | Core、Gui、Widgets、Network、WebChannel、WebEngineWidgets、Xml |
| Ninja | 随附的 Windows 构建脚本所需 |
以下说明针对 Windows,使用 Visual Studio C++ 构建工具和兼容的 Qt MSVC 套件。GUI 入口点直接使用 Windows API(windows.h),因此在 Linux 或 macOS 上构建完整项目需要修改。
在为 CLI 配置项目时也需要 Qt GUI 依赖项,因为两个可执行文件共享同一个库。
打开一个已配置 Visual Studio 构建环境的 PowerShell 终端,然后导航到仓库根目录。根据你的安装情况调整 Qt 路径。
.\build.ps1 -QtPath "C:\Qt\6.8.3\msvc2022_64" -BuildType Release
.\deploy.ps1 -QtPath "C:\Qt\6.8.3\msvc2022_64"
第一个脚本使用 Ninja 构建项目。第二个脚本将可用的 Qt 库、插件和 WebEngine 资源复制到 build 目录中。
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="C:\Qt\6.8.3\msvc2022_64"
cmake --build build --parallel
.\deploy.ps1 -QtPath "C:\Qt\6.8.3\msvc2022_64"
构建会生成两个可执行文件:
build/sms.exe:命令行界面。build/gui.exe:图形界面。assets 目录会在构建期间自动复制到可执行文件旁边。请将其与可执行文件放在一起,因为加载默认配置需要它。
.\build\gui.exe
以下示例使用位于 http://localhost:8080 的本地测试应用程序。
# Display help and version information
.\build\sms.exe --help
.\build\sms.exe --version
# Scan a target and save a JSON report
.\build\sms.exe -u http://localhost:8080 -o report.json
# Scan multiple targets
.\build\sms.exe -u http://localhost:8080 -u http://localhost:8081
# Load a file containing one URL per line
.\build\sms.exe -f targets.txt -o report.json
# Limit crawl depth
.\build\sms.exe -u http://localhost:8080 --crawl-depth 2
# Use HTTP Basic authentication
.\build\sms.exe -u http://localhost:8080 --auth-basic "username:password"
# Use an HTTP proxy
.\build\sms.exe -u http://localhost:8080 --proxy http://localhost:8082
# Select a test module
.\build\sms.exe -u http://localhost:8080 -t httpheaders@o=owasp,others
CLI 接受使用 http:// 和 socks:// 方案的代理。其当前帮助文本中提到的 socks5:// 方案会被解析器拒绝。
使用 --exit-on 时,当某个问题达到或超过请求的严重性时,扫描会停止。然而,当前实现仅在发现的问题与请求的严重性完全匹配时才返回退出代码 1。
assets/default-scan-config.json 文件提供了默认配置:启用的模块、HTTP 超时、并行请求、爬取、排除项、认证和表单参数。
要创建你自己的配置:
Copy-Item assets/default-scan-config.json scan-config.json
# Edit scan-config.json, then start the scan
.\build\sms.exe -c scan-config.json -u http://localhost:8080 -o report.json
--test 接受的模块标识符列在该文件的 tests.scripts 下。--test 选项会替换配置中的模块选择。
随着扫描的进行,发现的问题会显示在控制台中。--output 选项会在扫描结束时写入 JSON 报告,包含:
目标目录必须已存在。现有的报告文件会被覆盖。
冒烟测试(*_smoke.cpp)可以通过 BUILD_TESTS 启用:
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="C:\Qt\6.8.3\msvc2022_64" -DBUILD_TESTS=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure
当前的 CTest 配置在运行所有测试时不带参数。某些测试,包括 sms_cli_smoke、issuedb_smoke 和 httpheader_smoke,需要参数,必须使用适当的路径单独运行。因此,运行完整的 CTest 套件可能会报告由此配置导致的失败。
例如,使用以下命令运行 CLI 测试:
.\build\sms_cli_smoke.exe .\build\sms.exe
GUI 测试需要能够初始化 Qt 和 WebEngine 的环境。
SmartScanner-Source/
├── CMakeLists.txt # Shared library, executables, and tests
├── src/ # Engine, crawler, detectors, CLI, and GUI
├── tests/ # Smoke tests
├── assets/ # Configuration, definitions, and scan resources
├── gui_assets/ # Embedded web interface: HTML, CSS, and JavaScript
├── sms_resources.qrc # CLI Qt resources
├── gui_resources.qrc # GUI Qt resources
├── build.bat # Windows build script
├── build.ps1 # PowerShell build script
└── deploy.ps1 # Copies Qt dependencies for Windows
原始文档将此项目描述为 专有,仅供教育目的重建(“Proprietary — Reconstructed for educational purposes”)。本仓库中未包含单独的 LICENSE 文件。
| 选项 | 描述 |
|---|
-u, --url <URL> | 添加一个目标;可重复使用 |
-f, --file <FILE> | 从文件读取目标 |
-c, --config <FILE> | 加载 JSON 配置 |
-o, --output <FILE> | 保存 JSON 报告 |
-d, --crawl-depth <DEPTH> | 设置爬取深度:0 禁用爬取,1 仅获取输入的 URL,2 或更高则跟随链接 |
--no-discovery | 等同于 --crawl-depth 0 |
--no-follow | 等同于 --crawl-depth 1 |
-s, --scope <REGEX> | 使用正则表达式定义范围 |
-t, --test <TESTS> | 选择模块;可重复使用 |
--auth-basic <user:pass> | 设置 HTTP Basic 凭据 |
--proxy <URL> | 配置带有明确端口的代理 |
--proxy-auth <user:pass> | 设置代理凭据 |
--user-agent <STRING> | 设置自定义 User-Agent |
--exit-on <LEVEL> | 在达到 informational、low、medium 或 high 严重性阈值时停止扫描 |