%PDF- %PDF-
| Direktori : /lib/python3.9/site-packages/passlib/handlers/__pycache__/ |
| Current File : //lib/python3.9/site-packages/passlib/handlers/__pycache__/mssql.cpython-39.opt-1.pyc |
a
f�Wc"! � @ s� d Z ddlmZmZ ddlmZ ddlZddlZe�e �Z
ddlmZ ddl
mZ ddlmZmZmZ ddlm mZ dd gZd
d� ZdZed
�Zdd� Zdd� ZG dd� dejejej�Z G dd � d ejejej�Z!dS )a� passlib.handlers.mssql - MS-SQL Password Hash
Notes
=====
MS-SQL has used a number of hash algs over the years,
most of which were exposed through the undocumented
'pwdencrypt' and 'pwdcompare' sql functions.
Known formats
-------------
6.5
snefru hash, ascii encoded password
no examples found
7.0
snefru hash, unicode (what encoding?)
saw ref that these blobs were 16 bytes in size
no examples found
2000
byte string using displayed as 0x hex, using 0x0100 prefix.
contains hashes of password and upper-case password.
2007
same as 2000, but without the upper-case hash.
refs
----------
https://blogs.msdn.com/b/lcris/archive/2007/04/30/sql-server-2005-about-login-password-hashes.aspx?Redirected=true
http://us.generation-nt.com/securing-passwords-hash-help-35429432.html
http://forum.md5decrypter.co.uk/topic230-mysql-and-mssql-get-password-hashes.aspx
http://www.theregister.co.uk/2002/07/08/cracking_ms_sql_server_passwords/
� )�hexlify� unhexlify)�sha1N)�warn)�consteq)�
bascii_to_str�unicode�u� mssql2000� mssql2005c C s t | �d�| ��� S )Nz utf-16-le)r �encode�digest)�secret�salt� r �:/usr/lib/python3.9/site-packages/passlib/handlers/mssql.py�
_raw_mssql9 s r s 0x0100�0x0100c C s^ t | t�r&t| �|krZ| �t�rZdS n4t | t�rLt| �|krZ| �t�rZdS ntj� | d��dS )z#common identify for mssql 2000/2005T�hashF)
�
isinstancer �len�
startswith�UIDENT�bytes�BIDENT�uh�exc�ExpectedStringError)r �csize�bsizer r r �_ident_mssqlB s
r c C s� t | t�rNt| �|kr�| �t�r�zt| dd� �d��W S tyJ Y q�0 nVt | t�r�t| �|kr�| �t �r�zt| dd� �W S ty� Y q�0 nt
j�| d��t
j�
|��dS )zAcommon parser for mssql 2000/2005; returns 4 byte salt + checksum� N�utf-8r )r r r r r r r � TypeErrorr r r r r ZInvalidHashError)r r r Zhandlerr r r �_parse_mssqlP s
r$ c @ sX e Zd ZdZd ZdZdZd ZZe dd� �Z
e dd� �Zd d
� Zdd� Z
e d
d� �ZdS )r
a* This class implements the password hash used by MS-SQL 2000, and follows the :ref:`password-hash-api`.
It supports a fixed-length salt.
The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:
:type salt: bytes
:param salt:
Optional salt string.
If not specified, one will be autogenerated (this is recommended).
If specified, it must be 4 bytes in length.
:type relaxed: bool
:param relaxed:
By default, providing an invalid value for one of the other
keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
will be issued instead. Correctable errors include
``salt`` strings that are too long.
�r �( � c C s t |dd�S )N�^ �. �r ��clsr r r r �identify� s zmssql2000.identifyc C s* t |dd| �}| |d d� |dd � d�S )Nr( r) r'