Class: Metasploit::Framework::LoginScanner::FTP

Inherits:
Object
  • Object
show all
Includes:
Ftp::Client, Base, RexSocket
Defined in:
lib/metasploit/framework/login_scanner/ftp.rb

Overview

This is the LoginScanner class for dealing with FTP. It is responsible for taking a single target, and a list of credentials and attempting them. It then saves the results.

Constant Summary collapse

DEFAULT_PORT =
21
LIKELY_PORTS =
[ DEFAULT_PORT, 2121 ]
LIKELY_SERVICE_NAMES =
[ 'ftp' ]
PRIVATE_TYPES =
[ :password ]
REALM_KEY =
nil

Instance Attribute Summary collapse

Attributes included from Ftp::Client

#banner, #datasocket

Attributes included from Tcp::Client

#max_send_size, #send_delay, #sock

Instance Method Summary collapse

Methods included from Ftp::Client

#connect, #connect_login, #data_connect, #data_disconnect, #raw_send, #raw_send_recv, #recv_ftp_resp, #send_cmd, #send_cmd_data, #send_pass, #send_quit, #send_user

Methods included from Tcp::Client

#chost, #connect, #cport, #disconnect, #proxies, #rhost, #rport, #set_tcp_evasions, #ssl, #ssl_version

Instance Attribute Details

#ftp_timeout ⇒ Integer

Returns The timeout in seconds to wait for a response to an FTP command.

Returns:

  • (Integer) —

    The timeout in seconds to wait for a response to an FTP command



27
28
29
# File 'lib/metasploit/framework/login_scanner/ftp.rb', line 27

def ftp_timeout
  @ftp_timeout
end

Instance Method Details

#attempt_login(credential) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/metasploit/framework/login_scanner/ftp.rb', line 39

def (credential)
  result_options = {
      credential: credential
  }

  begin
    ftpsock = connect(true)
    res = send_user(credential.public, ftpsock)
    res = send_pass(credential.private, ftpsock) if res =~ /^(331|2)/
    if res.nil?
      result_options[:proof] = 'No response to login command'
      result_options[:status] = Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
    elsif res.start_with?('2')
      result_options[:proof] = res.strip
      result_options[:status] = Metasploit::Model::Login::Status::SUCCESSFUL
    else
      result_options[:proof] = res.strip
      result_options[:status] = Metasploit::Model::Login::Status::INCORRECT
    end
  rescue ::EOFError, Errno::ECONNRESET, Rex::ConnectionError, Rex::ConnectionTimeout, ::Timeout::Error => e
    result_options[:status] = Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
    result_options[:proof] = e.message
  ensure
    disconnect
  end

  result = ::Metasploit::Framework::LoginScanner::Result.new(result_options)
  result.host         = host
  result.port         = port
  result.protocol     = 'tcp'
  result.service_name = 'ftp'
  result
end