返回首页

ZAP/SQLMap免费替代方案:本地搭建Web渗透测试平台全指南

Burp Suite Professional 是Web渗透测试的行业标准,但 $449/年的许可证让很多独立安全研究员和小团队望而却步。OWASP (Zed Attack Proxy)+ + 的组合可以覆盖 Burp Pro 95% 的核心功能,而且完全免费开源。

定价对比

项目 Burp Suite Pro Burp Suite ZAP + SQLMap + Nuclei
年费 $449/用户 $6,995/年 免费
代理抓包 完整 完整 完整(ZAP)
主动扫描 支持 支持 支持(ZAP + Nuclei)
SQL注入检测 基础 基础 专业级(SQLMap)
插件生态 BApp Store 有限 丰富
测试 支持 支持 支持
集成 有限 完整 完整
脚本扩展 Montoya API 有限 /JS脚本

工具矩阵

OWASP ZAP:Web应用安全扫描器,Burp的直接替代品 SQLMap:自动化SQL注入检测和利用工具,比Burp的SQL检测强10倍 Nuclei:基于模板的快速漏洞扫描器,社区模板覆盖3000+漏洞 ffuf/gobuster:目录和参数爆破 httpx:HTTP探测工具

安装完整渗透测试工具链

系统准备

  && apt install -y \
  default-jre python3 python3-pip \
  curl wget git unzip

# 安装(Nuclei等工具需要)
wget https://go.dev/dl/go1.22.4.-amd64.tar.gz
tar -C /usr/local -xzf go1.22.4.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bashrc
source ~/.bashrc

安装 OWASP ZAP

# 方式一:Docker(推荐)
docker pull ghcr.io/zaproxy/zaproxy:stable

# 快速扫描
docker run -t ghcr.io/zaproxy/zaproxy zap-full-scan.py \
  -t https://target.example.com \
  -r report.

# 作为代理运行
docker run -u zap -p 8090:8090 -i ghcr.io/zaproxy/zaproxy \
  zap.sh -daemon -host 0.0.0.0 -port 8090 \
  -config api.disablekey=true

# 方式二:Linux安装包
wget https://github.com/zaproxy/zaproxy/releases/download/v2.15.0/ZAP_2_15_0_unix.sh
chmod +x ZAP_2_15_0_unix.sh
./ZAP_2_15_0_unix.sh

安装 SQLMap

git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git /opt/sqlmap
ln -s /opt/sqlmap/sqlmap.py /usr/local/bin/sqlmap

# 验证安装
sqlmap --version

安装 Nuclei

go install -v .com/projectdiscovery/nuclei/v3/cmd/nuclei@latest

# 下载社区模板
nuclei -update-templates

# 验证
nuclei -version

安装辅助工具

# ffuf - 目录/参数爆破
go install github.com/ffuf/ffuf/v2@latest

# httpx - HTTP探测
go install github.com/projectdiscovery/httpx/cmd/httpx@latest

# subfinder - 子域名枚举
go install github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest

# waybackurls - 历史URL提取
go install github.com/tomnomnom/waybackurls@latest

# Gxss - 反射检测
go install github.com/KathanP19/Gxss@latest

ZAP 详细配置

配置文件优化

# ~/.ZAP/config.xml 关键配置
# 调整线程数(根据目标承受能力调整)
cat > /tmp/zap-config.xml << 'EOF'
<config>
  <connection>
    <timeoutInSecs>60</timeoutInSecs>
    <threadPool>20</threadPool>
  </connection>
  <scanner>
    <maxScanDurationInMins>60</maxScanDurationInMins>
    <maxResultsToList>1000</maxResultsToList>
  </scanner>
</config>
EOF

ZAP API自动化扫描脚本

cat > /opt/zap-auto-scan.sh << 'SCRIPT'
#!/bin/bash
ZAP_URL="http://localhost:8090"
TARGET="$1"
REPORT_DIR="/tmp/zap-reports/$(date +%Y%m%d_%H%M%S)"
mkdir -p "$REPORT_DIR"

echo "[*] Starting spider: $TARGET"
# 被动爬虫
curl -s "$ZAP_URL/JSON/spider/action/scan/?url=$TARGET&maxChildren=100&recurse=true"
sleep 5

# 监控爬虫进度
while true; do
  PROGRESS=$(curl -s "$ZAP_URL/JSON/spider/view/status/" | python3 -c "import sys,json;print(json.load(sys.stdin)['status'])")
  echo "Spider progress: $PROGRESS%"
  [[ "$PROGRESS" == "100" ]] && break
  sleep 10
done

echo "[*] Starting active scan"
# 主动扫描
curl -s "$ZAP_URL/JSON/ascan/action/scan/?url=$TARGET&recurse=true&inScopeOnly=true"
sleep 5

while true; do
  PROGRESS=$(curl -s "$ZAP_URL/JSON/ascan/view/status/" | python3 -c "import sys,json;print(json.load(sys.stdin)['status'])")
  echo "Active scan progress: $PROGRESS%"
  [[ "$PROGRESS" == "100" ]] && break
  sleep 30
done

echo "[*] Generating reports"
# HTML报告
curl -s "$ZAP_URL/OTHER/core/other/htmlreport/" > "$REPORT_DIR/report.html"
# JSON报告
curl -s "$ZAP_URL/JSON/core/view/alerts/?baseurl=$TARGET&start=0&count=500" > "$REPORT_DIR/alerts.json"

# 统计结果
TOTAL=$(python3 -c "import json;f=open('$REPORT_DIR/alerts.json');d=json.load(f);print(len(d.get('alerts',[])))")
echo "[+] Scan complete. Found $TOTAL alerts. Reports saved to $REPORT_DIR"
SCRIPT

chmod +x /opt/zap-auto-scan.sh

SQLMap 高级用法

基础扫描

# 扫描GET参数
sqlmap -u "https://target.com/page?id=1" --batch --level=3 --risk=2

# 扫描POST请求(从Burp/ZAP复制请求)
sqlmap -r request.txt --batch --level=3 --risk=2

# 指定数据库类型加速
sqlmap -u "https://target.com/api?user=test" --dbms=mysql --batch

高级实战

# 1. 自动化WAF绕过
sqlmap -u "https://target.com/id=1" \
  --tamper=space2comment,between,randomcase \
  --random- \
  --delay=0.5 \
  --batch

# 2. 数据库枚举
sqlmap -u "https://target.com/id=1" \
  --dbs --batch

# 3. 指定表提取数据
sqlmap -u "https://target.com/id=1" \
  -D database_name -T users --dump \
  --batch

# 4. OS Shell(需要高权限)
sqlmap -u "https://target.com/id=1" \
  --os-shell --batch

# 5. 批量扫描多个URL
sqlmap -m urls.txt --batch --output-dir=/tmp/sqlmap-results

# 6. 配合Cookie认证扫描
sqlmap -u "https://target.com/api/data?id=1" \
  --cookie="session=abc123;token=xyz" \
  --batch --level=4

# 7. JSON格式POST
sqlmap -u "https://target.com/api/login" \
  --='{"username":"test","password":"test"}' \
  --headers="Content-Type: application/json" \
  --batch

SQLMap Tamper脚本选择

# MySQL绕过WAF
sqlmap --tamper=space2comment,between,randomcase,charencode

# MSSQL绕过
sqlmap --tamper=space2comment,between,charunicodeencode

# 通用绕过组合
sqlmap --tamper=apostrophemask,apostrophencode,base64encode,between,\
charencode,equaltolike,greatest,halfversionedmorekeywords,\
modsecurityversioned,space2comment,space2plus,space2randomblank,\
unionalltounion,unmagicquotes,versionedmorekeywords

Nuclei 实战

常用扫描命令

# 扫描单个目标
nuclei -u https://target.com -t cves/ -t vulnerabilities/

# 扫描URL列表
nuclei -l urls.txt -t cves/ -severity ,high

# 只运行特定类型模板
nuclei -u https://target.com -t technologies/ -t misconfigurations/

# 自定义并发和速率
nuclei -u https://target.com -c 50 -rl 100 -t cves/

# 输出JSON格式
nuclei -u https://target.com -json -o results.json

完整渗透测试流水线

cat > /opt/full--pipeline.sh << 'SCRIPT'
#!/bin/bash
DOMAIN="$1"
WORK_DIR="/tmp/pentest-$(date +%Y%m%d)"
mkdir -p "$WORK_DIR"

echo "[1/5] 子域名枚举"
subfinder -d "$DOMAIN" -silent > "$WORK_DIR/subdomains.txt"
echo "Found $(wc -l < "$WORK_DIR/subdomains.txt") subdomains"

echo "[2/5] HTTP存活探测"
cat "$WORK_DIR/subdomains.txt" | httpx -silent > "$WORK_DIR/alive.txt"
echo "Alive: $(wc -l < "$WORK_DIR/alive.txt")"

echo "[3/5] 提取历史URL"
cat "$WORK_DIR/subdomains.txt" | waybackurls > "$WORK_DIR/wayback.txt"
cat "$WORK_DIR/wayback.txt" | grep -iE '\.(php|asp|jsp|cgi)' | sort -u > "$WORK_DIR/dynamic_urls.txt"

echo "[4/5] Nuclei漏洞扫描"
nuclei -l "$WORK_DIR/alive.txt" -t cves/ -t vulnerabilities/ \
  -severity critical,high,medium \
  -json -o "$WORK_DIR/nuclei-results.json" \
  -c 25 -rl 50

echo "[5/5] SQLMap扫描动态URL"
head -100 "$WORK_DIR/dynamic_urls.txt" | while read url; do
  sqlmap -u "$url" --batch --level=2 --risk=1 \
    --output-dir="$WORK_DIR/sqlmap" 2>/dev/null
done

echo "[*] 完成!结果保存在 $WORK_DIR"
echo "  - 子域名: $WORK_DIR/subdomains.txt"
echo "  - 存活目标: $WORK_DIR/alive.txt"
echo "  - Nuclei结果: $WORK_DIR/nuclei-results.json"
SCRIPT

chmod +x /opt/full-pentest-pipeline.sh

ZAP vs Burp Suite 功能对比

功能 Burp Suite Pro OWASP ZAP
代理拦截 优秀 优秀
被动扫描 优秀 优秀
主动扫描 优秀 良好
Intruder 专业 Fuzzer替代
Repeater 优秀 手动请求器
SQL注入 基础 SQLMap远超
XSS检测 良好 良好
API扫描 支持 OpenAPI支持
插件生态 丰富 丰富
脚本能力 Java Python/JS/Java
认证支持 全面 全面
CI/CD 需企业版 原生支持
价格 $449/年 免费

常见问题

Q: ZAP的扫描能力真的比得上Burp吗? A: ZAP的主动扫描能力与Burp在同一水平线。Burp的优势在于Intruder的灵活性和某些高级插件。但配合SQLMap和Nuclei,整体能力超过Burp Pro单打独斗。

Q: 如何用ZAP扫描需要登录的页面? A: ZAP支持Session管理,在中配置认证方式(表单/Cookie/Token),ZAP会自动维护会话。

Q: SQLMap会不会破坏数据库? A: 默认情况下SQLMap使用安全的检测技术。加上--batch会自动选择安全选项。生产环境扫描建议使用--level=1 --risk=1

这套工具链是全球渗透测试社区的标配组合。工具免费,技术才是核心竞争力。与其花钱买Burp Pro的许可证,不如花时间精通这些开源工具的高级用法。

评论