Skip to content

Commit

Permalink
PEP8 pedantry
Browse files Browse the repository at this point in the history
  • Loading branch information
the-useless-one committed Jun 12, 2023
1 parent 732bf7c commit 0ec06c3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pywerview/requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ def __init__(self, domain_controller, domain=str(), user=str(), password=str(),
self._tls_channel_binding_supported = False
self._logger.debug('TLS channel binding is not supported')

def _do_ntlm_auth(self, ldap_scheme, formatter, seal_and_sign = False, tls_channel_binding = False):
def _do_ntlm_auth(self, ldap_scheme, formatter, seal_and_sign=False, tls_channel_binding=False):
self._logger.debug('LDAP authentication with NTLM: ldap_scheme = {0} / seal_and_sign = {1} / tls_channel_binding = {2}'.format(
ldap_scheme, seal_and_sign, tls_channel_binding))
ldap_server = ldap3.Server('{}://{}'.format(ldap_scheme, self._domain_controller), formatter=formatter)
user = '{}\\{}'.format(self._domain, self._user)
ldap_connection_kwargs = {'user': user, 'raise_exceptions': True, 'authentication' : ldap3.NTLM}
ldap_connection_kwargs = {'user': user, 'raise_exceptions': True, 'authentication': ldap3.NTLM}

if self._lmhash and self._nthash:
ldap_connection_kwargs['password'] = '{}:{}'.format(self._lmhash, self._nthash)
Expand Down Expand Up @@ -123,7 +123,7 @@ def _do_ntlm_auth(self, ldap_scheme, formatter, seal_and_sign = False, tls_chann
sys.exit(-1)
elif self._tls_channel_binding_supported == True:
self._logger.warning('Falling back to TLS with channel binding')
self._do_ntlm_auth(ldap_scheme, formatter, tls_channel_binding = True)
self._do_ntlm_auth(ldap_scheme, formatter, tls_channel_binding=True)
return
else:
self._logger.critical('Invalid Credentials')
Expand All @@ -137,21 +137,21 @@ def _do_ntlm_auth(self, ldap_scheme, formatter, seal_and_sign = False, tls_chann
return
else:
self._logger.warning('Falling back to NTLM sealing')
self._do_ntlm_auth(ldap_scheme, formatter, seal_and_sign = True)
self._do_ntlm_auth(ldap_scheme, formatter, seal_and_sign=True)
return

who_am_i = ldap_connection.extend.standard.who_am_i()
self._logger.debug('Successfully connected to the LDAP as {}'.format(who_am_i))
self._ldap_connection = ldap_connection

def _do_kerberos_auth(self, ldap_scheme, formatter, seal_and_sign = False):
def _do_kerberos_auth(self, ldap_scheme, formatter, seal_and_sign=False):
self._logger.debug('LDAP authentication with Kerberos: ldap_scheme = {0} / seal_and_sign = {1}'.format(
ldap_scheme, seal_and_sign))
ldap_server = ldap3.Server('{}://{}'.format(ldap_scheme, self._domain_controller), formatter=formatter)
user = '{}@{}'.format(self._user, self._domain.upper())
ldap_connection_kwargs = {'user': user, 'raise_exceptions': True,
'authentication' : ldap3.SASL,
'sasl_mechanism' : ldap3.KERBEROS}
'authentication': ldap3.SASL,
'sasl_mechanism': ldap3.KERBEROS}

if seal_and_sign:
ldap_connection_kwargs['session_security'] = ldap3.ENCRYPT
Expand Down Expand Up @@ -215,7 +215,7 @@ def _do_kerberos_auth(self, ldap_scheme, formatter, seal_and_sign = False):
return
else:
self._logger.warning('Falling back to Kerberos sealing')
self._do_kerberos_auth(ldap_scheme, formatter, seal_and_sign = True)
self._do_kerberos_auth(ldap_scheme, formatter, seal_and_sign=True)
return

who_am_i = ldap_connection.extend.standard.who_am_i()
Expand Down Expand Up @@ -257,7 +257,7 @@ def _do_schannel_auth(self, ldap_scheme, formatter):
except Exception as e:
# I don't really understand exception when using SChannel authentication, but if you see this message
# your cert and key are probably not valid
self._logger.critical('Exception during SChannel authentication : {}'.format(e))
self._logger.critical('Exception during SChannel authentication: {}'.format(e))
sys.exit(-1)

who_am_i = ldap_connection.extend.standard.who_am_i()
Expand All @@ -276,7 +276,7 @@ def _get_netfqdn(self):
self._logger.warning('Socket error when opening the SMB connection')
return str()

self._logger.debug('SMB loging parameters : user = {0} / password = {1} / domain = {2} '
self._logger.debug('SMB loging parameters: user = {0} / password = {1} / domain = {2} '
'/ LM hash = {3} / NT hash = {4}'.format(self._user, self._password,
self._domain, self._lmhash,
self._nthash))
Expand Down

0 comments on commit 0ec06c3

Please sign in to comment.