Current File : //usr/lib/python2.7/site-packages/passlib/handlers/mssql.pyo |
�
�
5Xc @ s( d Z d d l m Z m Z d d l m Z d d l Z d d l Z e j e � Z
d d l m Z d d l
m Z d d l m Z m Z m Z d d l j j Z d d g Z d
� Z d Z e d � Z d � Z d
� Z d e j e j e j f d � � YZ d e j e j e j f d � � YZ! d S( s� 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/
i����( t hexlifyt unhexlify( t sha1N( t warn( t consteq( t
bascii_to_strt unicodet ut mssql2000t mssql2005c C s t | j d � | � j � S( Ns utf-16-le( R t encodet digest( t secrett salt( ( s: /usr/lib/python2.7/site-packages/passlib/handlers/mssql.pyt
_raw_mssql9 s t 0x0100c C s� t | t � r7 t | � | k r� | j t � r� t SnL t | t � rn t | � | k r� | j t � r� t Sn t j j
| d � � t S( s# common identify for mssql 2000/2005t hash( t
isinstanceR t lent
startswitht UIDENTt Truet bytest BIDENTt uht exct ExpectedStringErrort False( R t csizet bsize( ( s: /usr/lib/python2.7/site-packages/passlib/handlers/mssql.pyt _ident_mssqlB s !!c C s� t | t � re t | � | k r� | j t � r� y t | d j d � � SWqb t k
r^ qb Xq� nq t | t � r� t | � | k r� | j t � r� y t | d � SWq� t k
r� q� Xq� n t
j j | d � � t
j j
| � � d S( sA common parser for mssql 2000/2005; returns 4 byte salt + checksumi s utf-8R N( R R R R R R R
t TypeErrorR R R R R t InvalidHashError( R R R t handler( ( s: /usr/lib/python2.7/site-packages/passlib/handlers/mssql.pyt _parse_mssqlP s !
!
c B si e Z d Z d Z d
Z d Z d Z Z e d � � Z e d � � Z
d � Z d � Z e d � � Z
RS( s* 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 R
i( i c C s t | d d � S( Ni^ i. ( R ( t clsR ( ( s: /usr/lib/python2.7/site-packages/passlib/handlers/mssql.pyt identify� s c C s0 t | d d | � } | d | d d | d � S( Ni^ i. R
i t checksum( R"