Merge pull request #495 from @qtc-de

Add ldap-signing module
main
mpgn 2021-11-24 20:35:36 +01:00 committed by GitHub
commit f2ce260666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
from impacket.ldap import ldap
class CMEModule:
'''
Checks whether LDAP signing is required.
Module by Tobias Neitzel (@qtc_de)
'''
name = 'ldap-signing'
description = 'Check whether LDAP signing is required'
supported_protocols = ['ldap']
opsec_safe= True
multiple_hosts = True
def options(self, context, module_options):
'''
No options available.
'''
pass
def on_login(self, context, connection):
'''
Perform a second logon attempt without LDAP signing.
'''
domain = connection.domain
username = connection.username
password = connection.password
ldap_host = connection.conn.getRemoteHost()
try:
connection = ldap.LDAPConnection('ldap://{}'.format(ldap_host))
connection.login(username, password, domain, '', '')
context.log.highlight('LDAP signing is NOT enforced on {}'.format(ldap_host))
except ldap.LDAPSessionError as e:
error_msg = str(e)
if 'strongerAuthRequired' in error_msg:
context.log.info('LDAP signing is enforced on {}'.format(ldap_host))
else:
context.log.error("Unexpected LDAP error: '{}'".format(error_msg))
except Exception as e:
context.log.error("Unexpected LDAP error: '{}'".format(str(e)))