sqlmap安装
- sqlmap的github项目地址:
https://github.com/sqlmapproject/sqlmap/
- sqlmap需要python环境:
https://www.python.org/downloads/
- python安装和配置:
https://blog.csdn.net/zhongcui8067/article/details/80439934
- 如下图,我们已经可以使用sqlmap了
sqlmap使用
主要还是记录一些常用的命令
简单使用流程
我在本地搭建了一个sqlilabs的环境,访问如下图
使用sqlmap测试是否存在注入点,所用参数 -u–>代表url
1 | python sqlmap.py -u http://127.0.0.1/sql/sqli/Less-1/?id=1 |
sqlmap探测到布尔盲注,时间盲注和联合查询
获取MySQL中的数据库名称,使用命令 –dbs
1 | python sqlmap.py -u http://127.0.0.1/sql/sqli/Less-1/?id=1 --dbs |
通过 '-D'
指定数据库,--tables
查询数据表
通过 '-T'
指定数据表,--columns
查询字段名称
通过–dump获取数据
sqlmap的基础命令(常用)
- -u:指定被扫描的url
- -b:获取banner信息
- –is-dba:是否是管理员权限
- –current-db:当前数据库
- –current-user:当前用户
- –dbs:列举数据库
- –tables:列举数据库的表名
- –count:检索所有条目数
- –columns:获取表的列名
- –dump:获取表中的数据,包含列
- -v:显示详细信息
sqlmap进阶命令(常用)
--level
:测试等级(1-5),默认为1。大于2时,会检测cookie注入;大于3时,会检测头注入--risk
:执行测试的风险(0-3,默认为1)。risk越高,检测越慢越安全--technique
:指定注入类型。B->布尔注入;E->报错注入;U->联合查询;T->延时注入;S->堆叠查询--time-sec
:DBMS响应的延迟时间(默认为5秒)--proxy
:使用代理服务器连接到目标URL--cookie
:指定cookie--user-agent
:指定请求头。--random-agent
:从./txt/user-agents.txt中获取随机获取请求头--method
:强制使用给定的HTTP方法--safe-freq
:测试一个给定安全网址的两个访问请求--delay
:可以设定两个HTTP(S)请求间的延迟,设定为0.5的时候是半秒,默认是没有延迟的--timeout
:可以设定一个HTTP(S)请求超过多久判定为超时,10表示10秒,默认是30秒--dbms
:指定数据库。mysql、oracle、mssql等--os
:指定操作系统--os-shell
:获取一个shell,根据网站的语言
sqlmap所有命令
所有命令请参考:https://blog.csdn.net/ghosttzs/article/details/7362359
或者参考如下脑图
sqlmap中的tamper
挂在嘴边的一句话,sqlmap绕waf,所用到的模块就是tamper,所用命令 --tamper=xxxxx
先来看一下,sqlmap中的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头 |
关于各版本数据库的用法请参考:https://www.freebuf.com/sectool/179035.html
如何自己写poc或陪着tamper:https://poc.evalbug.com/