Module: Metasploit::Framework::LDAP::Client

Included in:
Metasploit::Framework::LoginScanner::LDAP, Msf::Exploit::Remote::LDAP
Defined in:
lib/metasploit/framework/ldap/client.rb

Instance Method Summary collapse

Instance Method Details

#ldap_connect_opts(rhost, rport, connect_timeout, ssl: true, opts: {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/metasploit/framework/ldap/client.rb', line 8

def ldap_connect_opts(rhost, rport, connect_timeout, ssl: true, opts: {})
  connect_opts = {
    host: rhost,
    port: rport,
    connect_timeout: connect_timeout,
    proxies: opts[:proxies]
  }

  if ssl
    connect_opts[:encryption] = {
      method: :simple_tls,
      tls_options: {
        verify_mode: OpenSSL::SSL::VERIFY_NONE
      }
    }
  end

  case opts[:ldap_auth]
  when Msf::Exploit::Remote::AuthOption::SCHANNEL
    raise Msf::ValidationError, 'The SSL option must be enabled when using SCHANNEL authentication.' unless ssl

    connect_opts.merge!(ldap_auth_opts_scahnnel(opts))
  when Msf::Exploit::Remote::AuthOption::KERBEROS
    connect_opts.merge!(ldap_auth_opts_kerberos(opts))
  when Msf::Exploit::Remote::AuthOption::NTLM
    connect_opts.merge!(ldap_auth_opts_ntlm(opts))
  when Msf::Exploit::Remote::AuthOption::PLAINTEXT
    connect_opts.merge!(ldap_auth_opts_plaintext(opts))
  when Msf::Exploit::Remote::AuthOption::AUTO
    if opts[:username].present? && opts[:domain].present?
      connect_opts.merge!(ldap_auth_opts_ntlm(opts))
    elsif opts[:username].present?
      connect_opts.merge!(ldap_auth_opts_plaintext(opts))
    end
  end

  connect_opts
end