Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit f2ce260

Browse files
author
mpgn
authored
Merge pull request #495 from @qtc-de
Add ldap-signing module
2 parents 79bcdfe + 577372e commit f2ce260

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

cme/modules/ldap-signing.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from impacket.ldap import ldap
2+
3+
class CMEModule:
4+
'''
5+
Checks whether LDAP signing is required.
6+
7+
Module by Tobias Neitzel (@qtc_de)
8+
'''
9+
name = 'ldap-signing'
10+
description = 'Check whether LDAP signing is required'
11+
supported_protocols = ['ldap']
12+
opsec_safe= True
13+
multiple_hosts = True
14+
15+
def options(self, context, module_options):
16+
'''
17+
No options available.
18+
'''
19+
pass
20+
21+
def on_login(self, context, connection):
22+
'''
23+
Perform a second logon attempt without LDAP signing.
24+
'''
25+
domain = connection.domain
26+
username = connection.username
27+
password = connection.password
28+
ldap_host = connection.conn.getRemoteHost()
29+
30+
try:
31+
connection = ldap.LDAPConnection('ldap://{}'.format(ldap_host))
32+
connection.login(username, password, domain, '', '')
33+
context.log.highlight('LDAP signing is NOT enforced on {}'.format(ldap_host))
34+
35+
except ldap.LDAPSessionError as e:
36+
37+
error_msg = str(e)
38+
39+
if 'strongerAuthRequired' in error_msg:
40+
context.log.info('LDAP signing is enforced on {}'.format(ldap_host))
41+
42+
else:
43+
context.log.error("Unexpected LDAP error: '{}'".format(error_msg))
44+
45+
except Exception as e:
46+
context.log.error("Unexpected LDAP error: '{}'".format(str(e)))

0 commit comments

Comments
 (0)