天天看點

Sqli-labs less 2

Less-2

将'(單引号)添加到數字中。

Sqli-labs less 2

我們又得到了一個Mysql傳回的錯誤,提示我們文法錯誤。

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' LIMIT 0,1′ at line 1      

現在執行的查詢語句如下:

Select * from TABLE where id = 1' ;      

是以這裡的奇數個單引号破壞了查詢,導緻抛出錯誤。

是以我們得出的結果是,查詢代碼使用了整數。

Select * from TABLE where id = (some integer value);      

現在,從開發者的視角來看,為了對這樣的錯誤采取保護措施,我們可以注釋掉剩餘的查詢:

http://localhost/sqli-labs/Less-2/?id=1–-+      
Sqli-labs less 2

源代碼中可以分析到SQL語句為下:

$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";      
對id沒有經過處理      

可以成功注入的有:

or 1=1      
or 1=1 --+