403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/share/crypto-policies/python/cryptopolicies/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/share/crypto-policies/python/cryptopolicies/__pycache__/cryptopolicies.cpython-39.opt-1.pyc
a

�
�goG�@s.ddlZddlZddlZddlZddlZddlZddlmZmZe	�
dd�ddiBZddd	�Zd
Z
dZdd
hhd�hd�ddhhd�hd�hd�hd�hd�hd�d�
ZGdd�d�ZGdd�dej�Zdd�Ze�dd �Zd!d"�Zd0d$d%�ZGd&d'�d'e�Zd(d)�ZGd*d+�d+�Zd,d-�ZGd.d/�d/�ZdS)1�N�)�	alg_lists�
validation)Zarbitrary_dh_groupsZmin_dh_sizeZmin_dsa_sizeZmin_rsa_sizeZ
sha1_in_certsZ	ssh_certsZmin_ec_size�)�ANYZDISABLE_ETMZDISABLE_NON_ETM)ZDEFAULTZENFORCEZRELAX)ZetmZ__ems�*)�tls�ssl�openssl�nss�gnutls�java-tls�ssh�openssh�openssh-server�openssh-client�libssh�ipsec�ike�	libreswan�kerberos�krb5�dnssec�bindrr>r	rr>r	rr
rr>rrr>rrr>rr	r>rrr>rrr>r
r	r)
rrr
rrrrrrr
c@s(eZdZefdd�Zdd�Zdd�ZdS)�
ScopeSelectorcCs�|��|_}|�d�|_|jr&|n
|dd�}tjj||jd�tjj||jd�|�d�rr|dd��d�n|g|_	tjj
|j	t|jd�dS)a=
        Initialize a scope selector.
        An example would be `ssh` in `ciphers@ssh = -NULL`.
        When openssh backend will request the configuration,
        it'll offer (`{'ssh', 'openssh'}`) as scopes
        and the rule above will be taken into account.
        Both patterns and scopes are cast to lowercase.
        For more examples, refer to tests/unit/parsing/test_scope_selector.py
        >>> ss = ScopeSelector('!{SSH,IPsec}')
        >>> ss.matches({'ipsec', 'libreswan'})
        False
        >>> ss.matches({'tls', 'openssl'})
        True
        �!rN)Zoriginal_pattern�{����,)�lower�pattern�
startswith�	_positiver�scopeZillegal_charactersZcurly_brackets�split�_globsZresulting_globs�
ALL_SCOPES)�selfr �p�r)�B/usr/share/crypto-policies/python/cryptopolicies/cryptopolicies.py�__init__>s$�zScopeSelector.__init__cCsd|j�d�S)Nz<ScopeSelector pattern=�>)r �r'r)r)r*�__str__YszScopeSelector.__str__csR|jtkrdSdd��D��|jr:t�fdd�|jD��St�fdd�|jD��S)aE
        Checks whether ScopeSelector matches one of the scopes.
        For more examples, refer to tests/unit/parsing/test_scope_selector.py
        >>> ScopeSelector('{SSH,IPsec}').matches({'ipsec', 'libreswan'})
        True
        >>> ScopeSelector('!{SSH,IPsec}').matches({'ipsec', 'libreswan'})
        False
        TcSsg|]}|���qSr))r)�.0�sr)r)r*�
<listcomp>g�z)ScopeSelector.matches.<locals>.<listcomp>c3s|]}t��|�VqdS�N��fnmatch�filter�r/�g��scopesr)r*�	<genexpr>jr2z(ScopeSelector.matches.<locals>.<genexpr>c3s|]}t��|�VqdSr3r4r7r9r)r*r;kr2)r �	SCOPE_ANYr"�anyr%�all�r'r:r)r9r*�matches\s	
zScopeSelector.matchesN)�__name__�
__module__�__qualname__r<r+r.r@r)r)r)r*r=src@s0eZdZdZdZdZdZdZdZdZ	dd	�Z
d
S)�	OperationzCAn operation that comes with the right-hand value of the directive.r�����cCsd|j��S)Nz
Operation.)�namer-r)r)r*�__repr__zszOperation.__repr__N)rArBrC�__doc__�RESET�PREPEND�APPEND�OMIT�SET_INT�SET_ENUMrKr)r)r)r*rDpsrDcs�dd��|��rR�tjvr2�tvr2tjt|�fgS�tjvsD�tvr�tj	�
���nH�tvrftj	�����tvr�|t�vr�tj	��|t���tj
|fgS|��}t�fdd�|D��s�fdd�|D�}tjdfgdd�|D�St�fd	d�|D���r�g}|D]�}|�d
��r:tj�t�|dd���ddd�}nL|�d
��rltj�t�|dd���ddd�}ntj�t�|dd���}|��fd
d�|D���q|Stj	�|��dS)ae
    Parses right-hand parts of the directives
    into lists of operation/value pairs.
    For more examples, refer to tests/unit/test_parsing.py
    >>> parse_rhs('', 'cipher')
    [(Operation.RESET, None)]
    >>> parse_rhs('IDEA-CBC SEED-CBC', 'cipher')
    [(Operation.RESET, None),
     (Operation.APPEND, 'IDEA-CBC'),
     (Operation.APPEND, 'SEED-CBC')]
    >>> # 3DES-CBC gets prepended last for higher prio
    >>> parse_rhs('+*DES-CBC', 'cipher')
    [(Operation.PREPEND, 'DES-CBC'),
     (Operation.PREPEND, '3DES-CBC')]
    >>> parse_rhs('ENFORCE', '__ems')
    [(Operation.SET_ENUM, 'ENFORCE')]
    cSs|�d�p|�d�S)N)�+�-rS)r!�endswith)�vr)r)r*�differential�szparse_rhs.<locals>.differentialc3s|]}�|�VqdSr3r)�r/rV�rWr)r*r;�r2zparse_rhs.<locals>.<genexpr>cs"g|]}t�|��D]}|�qqSr))r�glob)r/rV�x��	prop_namer)r*r1�r2zparse_rhs.<locals>.<listcomp>NcSsg|]}tj|f�qSr))rDrOrXr)r)r*r1�r2c3s|]}�|�VqdSr3r)rXrYr)r*r;�r2rSrrcsg|]}�|f�qSr)r)rX)�opr)r*r1�r2)�isdigitr�ALL�INT_DEFAULTSrDrQ�int�ENUMSr�rulesZNonIntPropertyIntValueErrorZIntPropertyNonIntValueErrorZBadEnumValueErrorrRr$r=rMr>r!rNrZrUrOrP�extendZ%MixedDifferentialNonDifferentialError)�rhsr]�valuesZ
operations�valueZunglobr))rWr^r]r*�	parse_rhs~sF
�
�  ri�	Directive�r]r#�	operationrhcs�|��sgStj�|�|�d�\}}|��|��}}tj�||�d|vrZ|�dd�n|tf\����fdd�t|��D�S)aQ
    Parses configuration lines into tuples of directives.
    For more examples, refer to tests/unit/test_parsing.py
    >>> parse_line('cipher@TLS = RC4* NULL')
    [Directive(prop_name='cipher', scope='tls',
               operation=Operation.RESET, value=None),
     Directive(prop_name='cipher', scope='tls',
               operation=Operation.APPEND, value='RC4-40'),
     Directive(prop_name='cipher', scope='tls',
               operation=Operation.APPEND, value='RC4-128'),
     Directive(prop_name='cipher', scope='tls',
               operation=Operation.APPEND, value='NULL')]
    �=�@rcs$g|]\}}t����||d��qS)rk)rjr)r/rlrh�r]r#r)r*r1�s�
�zparse_line.<locals>.<listcomp>)�striprrdZcount_equals_signsr$Z	empty_lhsr<ri)�lineZlhsrfr)ror*�
parse_line�s �rrFc
Cs\z t|�}|D]}t|j�qWn6tjyV}z|s8�t�|�WYd}~n
d}~00dSr3)rrrr#rZPolicySyntaxError�warnings�warn)rqrt�l�d�exr)r)r*�syntax_check_line�srxcseZdZ�fdd�Z�ZS)�PolicySyntaxDeprecationWarningcs@|�dd�}d|�d�}|d|�d�7}|d7}t��|�dS)N�
z and zoption z is deprecatedz", please rewrite your rules using z; z2be advised that it is not always a 1-1 replacement)�replace�superr+)r'Z
deprecatedZreplacement�msg��	__class__r)r*r+�s
z'PolicySyntaxDeprecationWarning.__init__)rArBrCr+�
__classcell__r)r)r~r*ry�srycCs�t�dd|�}|�dd�}d�dd�|�d�D��}|�dd�}d�d	d�|�d�D��}d�d
d�|�d�D��}t�dd|���}t�d|�r�t�t	d
d��ddddd�}|�
�D]`\}}d|d}t�||�}|r�t�t	||��t�|d|�}|D]}|d|�d|��7}q�q�t�dd|���}ddddddd�}|�
�D]x\}}d|d}i}t�||�D]}	t�|||�||	�d�<�qj|�
�D]\}
}t�t	|
|���q�t�|||�}�qFt
tjd d d!��}|�r,d"�d#d�|d d!�D��}
t�d$|d!d|
�rd%|
��nd|�}|���q�t�d&d|�}t
tjd d d!��}|�r�d"�d'd�|d d!�D��}
t�d(|d!d|
�r�d%|
��nd|�}|���qNt�d)d|�S)*a
    Preprocesses text before parsing.
    Fixes line breaks, handles backwards compatibility.
    >>> preprocess_text('cipher = c1 \\ \nc2#x')
    'cipher = c1 c2'
    >>> with warnings.catch_warnings():
    ...     warnings.simplefilter("ignore")
    ...     preprocess_text('ike_protocol = IKEv2')
    'protocol@IKE = IKEv2'
    >>> with warnings.catch_warnings():
    ...     warnings.simplefilter("ignore")
    ...     preprocess_text('min_tls_version=TLS1.3')
    'protocol@TLS = -SSL2.0 -SSL3.0 -TLS1.0 -TLS1.1 -TLS1.2'
    z#.*�rm� = rzcss|]}|��VqdSr3�rp�r/rur)r)r*r;r2z"preprocess_text.<locals>.<genexpr>z\
css|]}|��VqdSr3r�r�r)r)r*r;	r2css|]}t�dd|�VqdS)z\s+� N)�re�subr�r)r)r*r;
r2z
+z\bprotocol\s*=�protocolzprotocol@TLSz
cipher@TLSz
cipher@SSHz	group@SSHzprotocol@IKE)Z
tls_cipherZ
ssh_cipherZ	ssh_groupZike_protocolz\bz\s*=(.*)z

z =z7hash@DNSSec = -SHA1
sign@DNSSec = -RSA-SHA1 -ECDSA-SHA1z7hash@DNSSec = SHA1+
sign@DNSSec = RSA-SHA1+ ECDSA-SHA1+zetm@SSH = DISABLE_ETMz
etm@SSH = ANYzetm@\1 = DISABLE_ETMzetm@\1 = ANY)zsha1_in_dnssec = 0zsha1_in_dnssec = 1zssh_etm = 0zssh_etm = 1zssh_etm@([^= ]+) = 0zssh_etm@([^= ]+) = 1rNrr�css|]}d|VqdS�rTNr)rXr)r)r*r;8r2z\bmin_dtls_version = zprotocol@TLS = z\bmin_dtls_version = 0\bcss|]}d|VqdSr�r)rXr)r)r*r;@r2z\bmin_tls_version = z\bmin_tls_version = 0\b)r�r�r{�joinr$rp�findallrsrtry�items�finditer�group�listrZDTLS_PROTOCOLS�popZ
TLS_PROTOCOLS)�textZPOSTFIX_REPLACEMENTS�fr�toZregex�ms�mZPLAIN_REPLACEMENTSr@�matchZmatch_frZmatch_toZ
dtls_versions�negZtls_versionsr)r)r*�preprocess_text�sp�����r�c@sJeZdZdZd
dd�Zedd��Zedd��Zed	d
��Zedd��Z	dS)�ScopedPolicya�
    An entity constructing lists of what's `.enabled` and what's `.disabled`
    when the given scopes are active.
    >>> sp = ScopedPolicy(parse_line('cipher@TLS = RC4* NULL'), {'tls'})
    >>> 'AES-192-GCM' in sp.disabled['cipher']
    True
    >>> sp.enabled['cipher']
    ['RC4-40', 'RC4-128', 'NULL']
    >>> ScopedPolicy(parse_line('min_dh_size=2048')).integers['min_dh_size']
    2048
    Ncs^|pt�}t���_dd�t��D��_dd�tjD��_	|D�]��t
�j�}|�|�r>�j
tjkrrg�j	�j<q>�j
tjkr��j	�j}�j|vr�|��j�q>�j
tjkr�j	�j}�j|vr�|��j�|�d�j�q>�j
tjk�r�fdd��j	�jD��j	�j<q>�j
tjk�r0�j�j�j<q>�j�j�j<q>�fdd�tj��D��_dS)NcSsi|]\}}||d�qS)rr))r/�krVr)r)r*�
<dictcomp>Yr2z)ScopedPolicy.__init__.<locals>.<dictcomp>cSsi|]
}|g�qSr)r))r/r]r)r)r*r�Zr2rcsg|]}|�jkr|�qSr))rh�r/�e)�	directiver)r*r1ms
�z)ScopedPolicy.__init__.<locals>.<listcomp>cs&i|]\�}���fdd�|D��qS)csg|]}|�j�vr|�qSr))�enabledr�)r]r'r)r*r1xs�z4ScopedPolicy.__init__.<locals>.<dictcomp>.<listcomp>r))r/Zalg_listr-r\r*r�xs�)�setra�copy�integersrcr��enumsrr`r�rr#r@rlrDrMr]rOrh�appendrN�remove�insertrPrQZdisabled)r'�
directivesZrelevant_scopes�ssr�r))r�r'r*r+Vs8








�
�zScopedPolicy.__init__cCst�|jd�S�Nr�)r�min_tls_versionr�r-r)r)r*r�|szScopedPolicy.min_tls_versioncCst�|jd�Sr�)r�max_tls_versionr�r-r)r)r*r��szScopedPolicy.max_tls_versioncCst�|jd�Sr�)r�min_dtls_versionr�r-r)r)r*r��szScopedPolicy.min_dtls_versioncCst�|jd�Sr�)r�max_dtls_versionr�r-r)r)r*r��szScopedPolicy.max_dtls_version)N)
rArBrCrLr+�propertyr�r�r�r�r)r)r)r*r�Is
&


r�cCs@|D](}tj�||�}t�|tj�r|Sqt�|||��dSr3)�os�pathr��access�R_OKrZPolicyFileNotFoundError)�
policyname�fname�pathsrvr(r)r)r*�lookup_file�s

r�c@sFeZdZdZdZdd�dd�Zdd�Zdd	d
�Zddd
�Zdd�Z	dS)�UnscopedCryptoPolicyz/etc/crypto-policiesz/usr/share/crypto-policiesN)�	policydircGsP||_d�|g|�R�|_g|_|�|�}|D]}||j|dd�7}q.||_dS)N�:T)�	subpolicy)r�r�r��lines�read_policy_file�_directives)r'Zpolicy_namer�Zsubpolicy_namesr�Zsubpolicy_namer)r)r*r+�s
zUnscopedCryptoPolicy.__init__cCs|jSr3)r�r-r)r)r*�is_empty�szUnscopedCryptoPolicy.is_emptycCst|j|pi�Sr3)r�r�r?r)r)r*�scoped�szUnscopedCryptoPolicy.scopedFc	
Cs�|jpd}|rtj�|d�}t|||s*dndtjj|tj�|j|�tj�|j|�f�}t|dd��}|�	�}Wd�n1s�0Yt
|�}|�d�}|D]}t|dd	�q�|D]}t|�q�d
d�|D�S)NZpolicies�modulesz.polz.pmodzutf-8)�encodingrzT)rtcSsg|]}t|�D]}|�qqSr))rr)r/rur[r)r)r*r1�r2z9UnscopedCryptoPolicy.read_policy_file.<locals>.<listcomp>)
r�r�r�r�r��curdir�
CONFIG_DIR�	SHARE_DIR�open�readr�r$rx)	r'rJr�Zpdirr(�fr�r�rur)r)r*r��s(
��&

z%UnscopedCryptoPolicy.read_policy_filecCsdd�}|��}d|j�d�}|d7}|d7}|d7}|d7}|d7}i|j�|j�|j�}|��D]\}}||||�7}qdd	}t��D]p\}}	|j|	d
�}
i|
j�|
j�|
j�}|��D]<\}}|||kr�|s�|d7}d}|||�d
|��|�7}q�q�|�s|d7}|S)NcSs2t|t�rd�|�nt|�}|�d|����dS)Nr�r�rz)�
isinstancer�r��str�rstrip)�keyrhr0r)r)r*�fmt�sz)UnscopedCryptoPolicy.__str__.<locals>.fmtz	# Policy z dump
z#
z?# Do not parse the contents of this file with automated tools,
z.# it is provided for review convenience only.
z"# Baseline values for all scopes:
Fr9z9# Scope-specific properties derived for select backends:
Trnz&# No scope-specific properties found.
)r�r�r�r�r�r��DUMPABLE_SCOPES)r'r�Zgeneric_scopedr0Zgeneric_allr]rhZanything_scope_specificZ
scope_nameZ	scope_setZspecific_scopedZspecific_allr)r)r*r.�s@����zUnscopedCryptoPolicy.__str__)N)F)
rArBrCr�r�r+r�r�r�r.r)r)r)r*r��s

r�)F)�collections�enumr5r�r�rsr�rr�dict�fromkeysrarcr<r&r�r�EnumrDri�
namedtuplerjrrrx�
FutureWarningryr�r�r�r�r)r)r)r*�<module>sL����3B
	SF

Youez - 2016 - github.com/yon3zu
LinuXploit