def __init__(self, domain, username, password, **kwargs):
        """
        Initializes the PasswordAuthentication with the supplied domain, username and password.

        :param domain: The windows domain name
        :param user: The windows username
        :param password: The users password
        :param: kwargs: A optional dictionary which can be used to configure

                Compatibility Flags
                -------------------
                disable_mic       - Windows Vista and later support the inclusion of a MIC (Message Integrity Code)
                                    during authentication. MIC codes are optional during authentication, but offer
                                    obvious security benefits. Setting this flag to 'True' will disable then generation
                                    of MIC codes; emulating the behavior of Windows XP and earlier.
                                    Default and recommended value is 'False'
                disable_timestamp - When 'True' the timestamp in the MsvAvTimestamp pair (if present) is used the NTLMv2
                                    computation. Setting the flag to 'False' emulates Windows XP/2003 and earlier clients
                                    which ignore the MsvAvTimestamp. Default and recommended value is 'True'
                disable_only_128  - Windows NT4 SP4 and later support 128bit session keys. If session security is
                                    negotiated with anything less the protocol may have been compromised. Setting this
                                    flag to 'True' will enable support for 56bit and 40bit keys by disabling exceptions
                                    which are normally raised if 128bit encryption is not negotiated.
                                    The default and recommended value is 'False'

                Application Supplied Data
                -------------------------
                spn_target        - Service principal name (SPN) of the service to which the client wishes to
                                   authenticate. Default value is 'None'
                                   It is only necessary to include a Client Supplied TargetName when explicitly required
                                   by the server application. SPN Target Name is only supported on Windows Vista or
                                   later.
                channel_bindings - A byte string representing the 'gss_channel_bindings_struct' which will be hashed
                                   and sent during authentication. If the value is 'None' channel bindings will not be
                                   sent. Default value is 'None'
                                   It is only necessary to include Channel Bindings if the server application explicitly
                                   requires it. Channel Bindings are only supported on Windows Server 2008 R2 and later.
                compatibility    - Lan Manager Compatibility Level to use
                                    On Windows Clients the level is set by an 'Administrator' in
                                    HKLM\SYSTEM\CurrentControlSet\Control\Lsa\LmCompatibilityLevel
                                    0 : Use LM and NTLM authentication, but never use NTLMv2 session security.
                                    1 : Use LM and NTLM authentication, but use NTLMv2 session security if possible
                                    2 : Use only NTLM authentication, but use NTLMv2 session security if possible
                                    3 : Use only NTLMv2 authentication, but use NTLMv2 session security if possible
                                    4 : Use only NTLMv2 authentication, but use NTLMv2 session security if possible
                                    5 : Use only NTLMv2 authentication, but use NTLMv2 session security if possible
                                    Note: Levels 3 to 5 are identical in terms of client behaviour, they only differ
                                    with respect to Domain Controller behaviour which is not applicable here

        NTLMv1 and NTLM2 Signing and Sealing is only available in Windows NT 4.0 SP4 and later
        """
        self._domain = domain
        self._username = username
        self._password = password
        self._challenge = kwargs.get('challenge', None)
        self._lm_compatibility = kwargs.get('compatibility', 3)

        if (self._lm_compatibility < 0) or (self._lm_compatibility > 5):
            raise Exception('Unknown Lan Manager Compatibility Level')

        # Initialise a random default 8 byte NTLM client challenge
        self._client_challenge = os.urandom(8)

        # NTLM participants can include additional data in the TargetInfo (AV_PAIRS) to prevent MiTM and replay attacks
        self._av_timestamp = kwargs.get('timestamp', True)
        self._av_channel_bindings = kwargs.get('channel_bindings', None)
def __init__ ( self , domain , username , password , ** kwargs ) : self . _domain = domain self . _username = username self . _password = password self . _challenge = kwargs . get ( 'challenge' , None ) self . _lm_compatibility = kwargs . get ( 'compatibility' , 3 ) if ( self . _lm_compatibility < 0 ) or ( self . _lm_compatibility > 5 ) : raise Exception ( 'Unknown Lan Manager Compatibility Level' ) self . _client_challenge = os . urandom ( 8 ) self . _av_timestamp = kwargs . get ( 'timestamp' , True ) self . _av_channel_bindings = kwargs . get ( 'channel_bindings' , None )
Initializes the PasswordAuthentication with the supplied domain, username and password.

        :param domain: The windows domain name
        :param user: The windows username
        :param password: The users password
        :param: kwargs: A optional dictionary which can be used to configure

                Compatibility Flags
                -------------------
                disable_mic       - Windows Vista and later support the inclusion of a MIC (Message Integrity Code)
                                    during authentication. MIC codes are optional during authentication, but offer
                                    obvious security benefits. Setting this flag to 'True' will disable then generation
                                    of MIC codes; emulating the behavior of Windows XP and earlier.
                                    Default and recommended value is 'False'
                disable_timestamp - When 'True' the timestamp in the MsvAvTimestamp pair (if present) is used the NTLMv2
                                    computation. Setting the flag to 'False' emulates Windows XP/2003 and earlier clients
                                    which ignore the MsvAvTimestamp. Default and recommended value is 'True'
                disable_only_128  - Windows NT4 SP4 and later support 128bit session keys. If session security is
                                    negotiated with anything less the protocol may have been compromised. Setting this
                                    flag to 'True' will enable support for 56bit and 40bit keys by disabling exceptions
                                    which are normally raised if 128bit encryption is not negotiated.
                                    The default and recommended value is 'False'

                Application Supplied Data
                -------------------------
                spn_target        - Service principal name (SPN) of the service to which the client wishes to
                                   authenticate. Default value is 'None'
                                   It is only necessary to include a Client Supplied TargetName when explicitly required
                                   by the server application. SPN Target Name is only supported on Windows Vista or
                                   later.
                channel_bindings - A byte string representing the 'gss_channel_bindings_struct' which will be hashed
                                   and sent during authentication. If the value is 'None' channel bindings will not be
                                   sent. Default value is 'None'
                                   It is only necessary to include Channel Bindings if the server application explicitly
                                   requires it. Channel Bindings are only supported on Windows Server 2008 R2 and later.
                compatibility    - Lan Manager Compatibility Level to use
                                    On Windows Clients the level is set by an 'Administrator' in
                                    HKLM\SYSTEM\CurrentControlSet\Control\Lsa\LmCompatibilityLevel
                                    0 : Use LM and NTLM authentication, but never use NTLMv2 session security.
                                    1 : Use LM and NTLM authentication, but use NTLMv2 session security if possible
                                    2 : Use only NTLM authentication, but use NTLMv2 session security if possible
                                    3 : Use only NTLMv2 authentication, but use NTLMv2 session security if possible
                                    4 : Use only NTLMv2 authentication, but use NTLMv2 session security if possible
                                    5 : Use only NTLMv2 authentication, but use NTLMv2 session security if possible
                                    Note: Levels 3 to 5 are identical in terms of client behaviour, they only differ
                                    with respect to Domain Controller behaviour which is not applicable here

        NTLMv1 and NTLM2 Signing and Sealing is only available in Windows NT 4.0 SP4 and later