From 29bfc1cca6c17a715320185e2b7fe5f15d191b24 Mon Sep 17 00:00:00 2001 From: Zach Goldman Date: Tue, 30 Jul 2024 18:28:16 -0500 Subject: [PATCH 1/2] add necessary metadata for bruteforce --- lib/metasploit/framework/login_scanner/ldap.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/metasploit/framework/login_scanner/ldap.rb b/lib/metasploit/framework/login_scanner/ldap.rb index 2d63ddb94c12..802910404d22 100644 --- a/lib/metasploit/framework/login_scanner/ldap.rb +++ b/lib/metasploit/framework/login_scanner/ldap.rb @@ -11,11 +11,23 @@ class LDAP include Metasploit::Framework::LDAP::Client include Msf::Exploit::Remote::LDAP + # TODO: Verify if we need this additional metadata: https://github.com/rapid7/metasploit-framework/blob/master/lib/metasploit/framework/login_scanner/http.rb#L15-L23 + LIKELY_PORTS = [ 389, 636 ] + LIKELY_SERVICE_NAMES = [ 'ldap', 'ldaps', 'ldapssl' ] + attr_accessor :opts, :realm_key # @!attribute use_client_as_proof # @return [Boolean] If a login is successful and this attribute is true - an LDAP::Client instance is used as proof attr_accessor :use_client_as_proof + # This method sets the sane defaults for things + # like timeouts and TCP evasion options + def set_sane_defaults + self.opts ||= {} + self.connection_timeout = 30 if self.connection_timeout.nil? + nil + end + def attempt_login(credential) result_opts = { credential: credential, @@ -23,7 +35,8 @@ def attempt_login(credential) proof: nil, host: host, port: port, - protocol: 'ldap' + protocol: 'tcp', + service_name: 'ldap' } result_opts.merge!(do_login(credential)) @@ -34,7 +47,8 @@ def do_login(credential) opts = { username: credential.public, password: credential.private, - framework_module: framework_module + framework_module: framework_module, + ldap_auth: 'auto' }.merge(@opts) connect_opts = ldap_connect_opts(host, port, connection_timeout, ssl: opts[:ssl], opts: opts) From e377e746e91107be729cf33d6dd73493e39111a7 Mon Sep 17 00:00:00 2001 From: cgranleese-r7 <69522014+cgranleese-r7@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:10:09 +0100 Subject: [PATCH 2/2] Update lib/metasploit/framework/login_scanner/ldap.rb --- lib/metasploit/framework/login_scanner/ldap.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/metasploit/framework/login_scanner/ldap.rb b/lib/metasploit/framework/login_scanner/ldap.rb index 802910404d22..ef0ae8d63076 100644 --- a/lib/metasploit/framework/login_scanner/ldap.rb +++ b/lib/metasploit/framework/login_scanner/ldap.rb @@ -11,7 +11,6 @@ class LDAP include Metasploit::Framework::LDAP::Client include Msf::Exploit::Remote::LDAP - # TODO: Verify if we need this additional metadata: https://github.com/rapid7/metasploit-framework/blob/master/lib/metasploit/framework/login_scanner/http.rb#L15-L23 LIKELY_PORTS = [ 389, 636 ] LIKELY_SERVICE_NAMES = [ 'ldap', 'ldaps', 'ldapssl' ]