CasperSecurity

Current Path : /lib/python3/dist-packages/requests/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/requests/__pycache__/auth.cpython-310.pyc

o

Ba�_�'�@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZddlmZddlmZd	Zd
Zdd�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z]
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
�N)�	b64encode�)�urlparse�str�
basestring)�extract_cookies_to_jar)�to_native_string)�parse_dict_headerz!application/x-www-form-urlencodedzmultipart/form-datacCs�t|t�stjd�|�td�t|�}t|t�s(tjd�t|��td�t|�}t|t�r2|�d�}t|t�r<|�d�}dt	t
d�||f�����}|S)zReturns a Basic Auth string.z�Non-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in ({!r}) to a string or bytes object in the near future to avoid problems.)�categoryz�Non-string passwords will no longer be supported in Requests 3.0.0. Please convert the object you've passed in ({!r}) to a string or bytes object in the near future to avoid problems.�latin1zBasic �:)
�
isinstancer�warnings�warn�format�DeprecationWarningr�type�encoderr�join�strip)�username�password�authstr�r�//usr/lib/python3/dist-packages/requests/auth.py�_basic_auth_strs,

�

�



�rc@�eZdZdZdd�ZdS)�AuthBasez4Base class that all auth implementations derive fromcCstd��)NzAuth hooks must be callable.)�NotImplementedError��self�rrrr�__call__KszAuthBase.__call__N��__name__�
__module__�__qualname__�__doc__r"rrrrrH�rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
HTTPBasicAuthz?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS�N)rr�r rrrrr�__init__Rs
zHTTPBasicAuth.__init__cC�(t|jt|dd�k|jt|dd�kg�S�Nrr��allr�getattrr�r �otherrrr�__eq__V��zHTTPBasicAuth.__eq__cC�
||kSr*rr2rrr�__ne__\�
zHTTPBasicAuth.__ne__cC�t|j|j�|jd<|S)N�
Authorization�rrr�headersrrrrr"_�zHTTPBasicAuth.__call__N)r$r%r&r'r,r4r7r"rrrrr)Osr)c@r)�
HTTPProxyAuthz=Attaches HTTP Proxy Authentication to a given Request object.cCr9)NzProxy-Authorizationr;rrrrr"gr=zHTTPProxyAuth.__call__Nr#rrrrr>dr(r>c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�HTTPDigestAuthz@Attaches HTTP Digest Authentication to the given Request object.cCs||_||_t��|_dSr*)rr�	threading�local�
_thread_localr+rrrr,oszHTTPDigestAuth.__init__cCsDt|jd�s d|j_d|j_d|j_i|j_d|j_d|j_dSdS)N�initT�r)�hasattrrBrC�
last_nonce�nonce_count�chal�pos�
num_401_calls)r rrr�init_per_thread_stateus�z$HTTPDigestAuth.init_per_thread_statecs�|jjd}|jjd}|jj�d�}|jj�d�}|jj�d�}d�|dur*d}n|��}|dks6|dkr=d	d
�}	|	�n |dkrHdd
�}
|
�n|dkrSdd�}|�n
|dkr]dd�}|��fdd�}
�duridSd}t|�}|jpsd}|jr~|d|j7}d|j||jf}d||f}�|�}�|�}||jj	kr�|jj
d7_
nd|j_
d|jj
}t|jj
��d�}||�d�7}|t
���d�7}|t�d�7}t�|���dd�}|dkr�d|||f�}|s�|
|d||f�}n|dks�d|�d �v�r
d!|||d|f}|
||�}ndS||j_	d"|j||||f}|�r&|d#|7}|�r/|d$|7}|�r8|d%|7}|�rC|d&||f7}d'|S)(z
        :rtype: str
        �realm�nonce�qop�	algorithm�opaqueN�MD5zMD5-SESScS�"t|t�r
|�d�}t�|���S�N�utf-8)r
rr�hashlib�md5�	hexdigest��xrrr�md5_utf8��

z4HTTPDigestAuth.build_digest_header.<locals>.md5_utf8�SHAcSrRrS)r
rrrU�sha1rWrXrrr�sha_utf8�r[z4HTTPDigestAuth.build_digest_header.<locals>.sha_utf8zSHA-256cSrRrS)r
rrrU�sha256rWrXrrr�sha256_utf8�r[z7HTTPDigestAuth.build_digest_header.<locals>.sha256_utf8zSHA-512cSrRrS)r
rrrU�sha512rWrXrrr�sha512_utf8�r[z7HTTPDigestAuth.build_digest_header.<locals>.sha512_utf8cs�d||f�S)N�%s:%sr)�s�d��	hash_utf8rr�<lambda>�sz4HTTPDigestAuth.build_digest_header.<locals>.<lambda>�/�?z%s:%s:%srcrz%08xrT���auth�,z%s:%s:%s:%s:%sz>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"z
, opaque="%s"z, algorithm="%s"z
, digest="%s"z , qop="auth", nc=%s, cnonce="%s"z	Digest %s)rBrH�get�upperr�path�queryrrrFrGrr�time�ctime�os�urandomrUr]rW�split)r �method�urlrLrMrNrOrP�
_algorithmrZr^r`rb�KD�entdig�p_parsedrq�A1�A2�HA1�HA2�ncvaluerd�cnonce�respdig�noncebit�baserrfr�build_digest_headers�

��z"HTTPDigestAuth.build_digest_headercKs|jr	d|j_dSdS)z)Reset num_401_calls counter on redirects.rN)�is_redirectrBrJ)r r!�kwargsrrr�handle_redirect�s�zHTTPDigestAuth.handle_redirectcKs"d|jkrdksnd|j_|S|jjdur!|jj�|jj�|j�dd�}d|�	�vr�|jjdkr�|jjd7_t
jd	t
jd
�}t
|jd|dd��|j_|j|��|j��}t|j|j|j�|�|j�|�|j|j�|jd<|jj|fi|��}|j�|�||_|Sd|j_|S)
zo
        Takes the given response and tries digest-auth, if needed.

        :rtype: requests.Response
        i�i�rNzwww-authenticaterD�digest�zdigest )�flags)�countr:)�status_coderBrJrI�request�body�seekr<ro�lower�re�compile�
IGNORECASEr	�subrH�content�close�copyr�_cookies�raw�prepare_cookiesr�rxry�
connection�send�history�append)r r!r��s_auth�pat�prep�_rrrr�
handle_401�s0	

�zHTTPDigestAuth.handle_401cCs||��|jjr|�|j|j�|jd<z	|j��|j_	Wn
t
y)d|j_	Ynw|�d|j�|�d|j
�d|j_|S)Nr:�responser)rKrBrFr�rxryr<r��tellrI�AttributeError�
register_hookr�r�rJrrrrr"s�zHTTPDigestAuth.__call__cCr-r.r/r2rrrr4*r5zHTTPDigestAuth.__eq__cCr6r*rr2rrrr70r8zHTTPDigestAuth.__ne__N)r$r%r&r'r,rKr�r�r�r"r4r7rrrrr?ls
f,r?)r'rur�rsrUr@r�base64r�compatrrr�cookiesr�_internal_utilsr�utilsr	�CONTENT_TYPE_FORM_URLENCODED�CONTENT_TYPE_MULTI_PARTr�objectrr)r>r?rrrr�<module>s&,
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY