@@ -26,11 +26,13 @@ def initialize(info = {})
26
26
] , Msf ::Exploit ::Remote ::FtpServer )
27
27
end
28
28
29
+ # (see Msf::Exploit#setup)
29
30
def setup
30
31
super
31
32
@state = { }
32
33
end
33
34
35
+ # (see TcpServer#on_client_connect)
34
36
def on_client_connect ( c )
35
37
@state [ c ] = {
36
38
:name => "#{ c . peerhost } :#{ c . peerport } " ,
@@ -46,6 +48,25 @@ def on_client_connect(c)
46
48
c . put "220 FTP Server Ready\r \n "
47
49
end
48
50
51
+ # Dispatches client requests to command handlers.
52
+ #
53
+ # Handlers should be named +on_client_command_*+, ending with a
54
+ # downcased FTP verb, e.g. +on_client_command_user+. If no handler
55
+ # exists for the given command, returns a generic default response.
56
+ #
57
+ # @example Handle SYST requests
58
+ # class Metasploit4 < Msf::Exploit
59
+ # include Msf::Exploit::Remote::FtpServer
60
+ # ...
61
+ # def on_client_command_syst(cmd_conn, arg)
62
+ # print_status("Responding to SYST request")
63
+ # buf = build_exploit_buffer(cmd_conn)
64
+ # cmd_conn.put("215 Unix Type: #{buf}\r\n")
65
+ # end
66
+ # end
67
+ #
68
+ # @param (see TcpServer#on_client_data)
69
+ # @return (see TcpServer#on_client_data)
49
70
def on_client_data ( c )
50
71
data = c . get_once
51
72
return if not data
@@ -184,6 +205,15 @@ def active_data_port_for_client(c,port)
184
205
end
185
206
186
207
208
+ # Create a socket for the protocol data, either PASV or PORT,
209
+ # depending on the client.
210
+ #
211
+ # @see http://tools.ietf.org/html/rfc3659 RFC 3659
212
+ # @see http://tools.ietf.org/html/rfc959 RFC 959
213
+ # @param c [Socket] Control connection socket
214
+ #
215
+ # @return [Socket] A connected socket for the data connection
216
+ # @return [nil] on failure
187
217
def establish_data_connection ( c )
188
218
begin
189
219
Timeout . timeout ( 20 ) do
0 commit comments