Less 28
基于错误_GET_过滤UNION/SELECT_单引号_小括号_字符型_盲注*

五颜六色的真好看。
0x01. 判断注入类型
1
和1"
正常回显,1'
报错,单引号字符型。
2'%26%26'1'='1
回显为id=1
,有小括号。


0x02. 判断过滤与绕过
看着还行:
$id = blacklist($id);
$hint = $id;
function blacklist($id)
{
$id= preg_replace('/[\/\*]/',"",$id); //strip out /*
$id= preg_replace('/[--]/',"",$id); //Strip out --.
$id= preg_replace('/[#]/',"",$id); //Strip out #.
$id= preg_replace('/[ +]/',"",$id); //Strip out spaces.
$id= preg_replace('/[ +]/',"",$id); //Strip out spaces.
$id= preg_replace('/union\s+select/i',"",$id); //Strip out UNION & SELECT.
return $id;
}
没有过滤or
与and
。
过滤了相连的union
和select
,/i
同时匹配大小写,\s
匹配任意空白字符如制表符、换行符、空格等,使用%a0
可以绕过。
过滤了--
、#
以及/**/
。
过滤了两次空格
。
过滤了/
但没过滤\
。
0x03. 注入过程
这关没有报错回显,可以明注、盲注。
0x03-01. 基于正确注入
同 Less 26,使用%a0
代替空格,union%a0select
即可绕过过滤。
0x03-02. 基于Bool盲注
同 Less 26,将双写的or
去掉即可。
Less 28a
基于错误_GET_过滤所有_单引号_字符型_盲注*
题目给的太简单了,在 Less 28 的基础上还注释掉了很多过滤,这里给了一个比较强的过滤条件:
$id = blacklist($id);
$hint = $id;
function blacklist($id)
{
$id = preg_replace('/or/i',"",$id);
$id = preg_replace('/and/i',"",$id);
$id = preg_replace('/[\/\*]/',"",$id);
$id = preg_replace('/[--]/',"",$id);
$id = preg_replace('/[#]/',"",$id);
$id = preg_replace('/[\/\\\\]/',"",$id);
$id = preg_replace('/[ +]/',"",$id);
$id = preg_replace('/[\s]/',"",$id);
$id = preg_replace('/select/i',"",$id);
$id = preg_replace('/union/i',"",$id);
$id = preg_replace('/union\s+select/i',"",$id);
return $id;
}
- 过滤
or
、and
- 过滤
--
、#
、/**/
- 过滤
/
、\
- 过滤
空格
两次 - 过滤
union
、select
同时匹配大小写 - 过滤
union
且空白字符
连接select
同时匹配大小写
基本上过滤了所有字符,但是,所有的一次性过滤都能用双写绕过!除非循环过滤。
这里直接脚本盲注,实际情况大部分是没有回显的。
脚本使用 Less 26 中,稍加修改即可:
-
or
=||
、and
=&&
=%26%26
-
注释
=||'1'='1'
-
空格
=()
-
union select
=ununionion%a0selselectect
深入理解SQL注入绕过WAF和过滤机制
SQL注入绕过union+select过滤
过滤到此告一段落,大部分的过滤情况已足够,还有很多高阶技巧有待学习。
网友评论