AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/acme/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/acme/__pycache__/crypto_util.cpython-310.pyc
o

[Pd�A�@s�dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
ddlmZdd	lmZdd
lmZddlZddlmZddlmZdd
lmZe�e�ZejZGdd�d�ZGdd�d�Zddeddfdedede de de dee!e fde
ee!dej"fdd�Z#			d>d ed!e
eee!ee!fd"e$d#e
eeej%ej&fdef
d$d%�Z'd&eej"ej(fdee!fd'd(�Z)d)eej"ej(fdee!fd*d+�Z*d)eej"ej(fdee!fd,d-�Z+d)eej"ej(fdee!fd.d/�Z,			1		d?d2ej-d!e
ee!d3e
e d4e d5e$d6e
eej.d7e
eeej%ej%fdej"fd8d9�Z/ej0fd:eej"d;e defd<d=�Z1dS)@zCrypto utilities.�N)�Any)�Callable)�List)�Mapping)�Optional)�Set)�Tuple)�Union)�crypto)�SSL)�errorsc@sReZdZdeeeejejfffdd�Z	de
jdeeejejffdd�Z
dS)	�_DefaultCertSelection�certscC�
||_dS�N)r)�selfr�r�2/usr/lib/python3/dist-packages/acme/crypto_util.py�__init__%�
z_DefaultCertSelection.__init__�
connection�returncCs|��}|j�|d�Sr)�get_servernamer�get)rr�server_namerrr�__call__(sz_DefaultCertSelection.__call__N)�__name__�
__module__�__qualname__r�bytesrr
�PKey�X509rr�
Connectionrrrrrrr
$s"(r
c@s�eZdZdZdeddfdejdeeee	e
je
jffde
deeejeegefdeeejge	e
je
jffddfd	d
�Zdedefdd
�Zdejddfdd�ZGdd�d�Zde	eeffdd�ZdS)�	SSLSocketa�SSL wrapper for sockets.

    :ivar socket sock: Original wrapped socket.
    :ivar dict certs: Mapping from domain names (`bytes`) to
        `OpenSSL.crypto.X509`.
    :ivar method: See `OpenSSL.SSL.Context` for allowed values.
    :ivar alpn_selection: Hook to select negotiated ALPN protocol for
        connection.
    :ivar cert_selection: Hook to select certificate for connection. If given,
        `certs` parameter would be ignored, and therefore must be empty.

    N�sockr�method�alpn_selection�cert_selectionrcCsX||_||_||_|s|std��|r|rtd��|}|dur't|r$|ni�}||_dS)Nz*Neither cert_selection or certs specified.z(Both cert_selection and certs specified.)r$r&r%�
ValueErrorr
r')rr$rr%r&r'�actual_cert_selectionrrrr:s�
zSSLSocket.__init__�namecC�t|j|�Sr)�getattrr$�rr*rrr�__getattr__P�zSSLSocket.__getattr__rcCs�|�|�}|durt�d|���dS|\}}t�|j�}|�tj�|�tj	�|�
|�|�|�|jdur>|�
|j�|�|�dS)a�SNI certificate callback.

        This method will set a new OpenSSL context object for this
        connection when an incoming connection provides an SNI name
        (in order to serve the appropriate certificate, if any).

        :param connection: The TLS connection object on which the SNI
            extension was received.
        :type connection: :class:`OpenSSL.Connection`

        Nz=Certificate selection for server name %s failed, dropping SSL)r'�logger�debugrr�Contextr%�set_options�OP_NO_SSLv2�OP_NO_SSLv3�use_privatekey�use_certificater&�set_alpn_select_callback�set_context)rr�pair�key�cert�new_contextrrr�_pick_certificate_cbSs
�


zSSLSocket._pick_certificate_cbc@sHeZdZdZdejddfdd�Zdedefdd	�Z	d
ede
fdd�ZdS)
zSSLSocket.FakeConnectionzFake OpenSSL.SSL.Connection.rrNcCrr)�_wrapped)rrrrrrsrz!SSLSocket.FakeConnection.__init__r*cCr+r)r,r?r-rrrr.vr/z$SSLSocket.FakeConnection.__getattr__�unused_argscGs
|j��Sr)r?�shutdown)rr@rrrrAys
z!SSLSocket.FakeConnection.shutdown)rrr�__doc__rr"r�strrr.�boolrArrrr�FakeConnectionns
rEc
Cs�|j��\}}t�|j�}|�tj�|�tj�|�|j	�|j
dur*|�|j
�|�t�
||��}|��t�d|�z	|��W||fStjyX}zt�|��d}~ww)NzPerforming handshake with %s)r$�acceptrr2r%r3r4r5�set_tlsext_servername_callbackr>r&r8rEr"�set_accept_stater0r1�do_handshake�Error�socket�error)rr$�addr�context�ssl_sockrLrrrrF}s"

�
��zSSLSocket.accept)rrrrB�_DEFAULT_SSL_METHODrKrrrrr
r r!�intrrr"rrrCrr.r>rErFrrrrr#-s.

����
��
�r#i�i,)�rr*�host�port�timeoutr%�source_address�alpn_protocolsrcCs.t�|�}|�|�d|i}z%t�d||t|�r"d�|d|d�nd�||f}	tj|	fi|��}
Wntj	yE}zt
�|��d}~wwt�
|
��@}t�||�}
|
��|
�|�|durd|
�|�z
|
��|
��Wntjy�}zt
�|��d}~wwWd�|
��S1s�wY|
��S)aProbe SNI server for SSL certificate.

    :param bytes name: Byte string to send as the server name in the
        client hello message.
    :param bytes host: Host to connect to.
    :param int port: Port to connect to.
    :param int timeout: Timeout in seconds.
    :param method: See `OpenSSL.SSL.Context` for allowed values.
    :param tuple source_address: Enables multi-path probing (selection
        of source interface). See `socket.creation_connection` for more
        info. Available only in Python 2.7+.
    :param alpn_protocols: Protocols to request using ALPN.
    :type alpn_protocols: `list` of `str`

    :raises acme.errors.Error: In case of any problems.

    :returns: SSL certificate presented by the server.
    :rtype: OpenSSL.crypto.X509

    rVz!Attempting to connect to %s:%d%s.z
 from {0}:{1}r�rRN)rr2�set_timeoutr0r1�any�formatrK�create_connectionrLrrJ�
contextlib�closingr"�set_connect_state�set_tlsext_host_name�set_alpn_protosrIrA�get_peer_certificate)r*rSrTrUr%rVrWrN�
socket_kwargs�socket_tupler$rL�client�
client_sslrrr�	probe_sni�sJ

���
��


���
��rgF�private_key_pem�domains�must_staple�ipaddrscCs�t�tj|�}t��}g}|durg}|durg}t|�t|�dkr'td��|D]	}|�d|�q)|D]
}|�d|j�q5d�|��	d�}	tj
dd	|	d
�g}
|r^|
�tj
dd	dd
��|�|
�|�|�|�
d�|�|d
�t�tj|�S)a�Generate a CSR containing domains or IPs as subjectAltNames.

    :param buffer private_key_pem: Private key, in PEM PKCS#8 format.
    :param list domains: List of DNS names to include in subjectAltNames of CSR.
    :param bool must_staple: Whether to include the TLS Feature extension (aka
        OCSP Must Staple: https://tools.ietf.org/html/rfc7633).
    :param list ipaddrs: List of IPaddress(type ipaddress.IPv4Address or ipaddress.IPv6Address)
    names to include in subbjectAltNames of CSR.
    params ordered this way for backward competablity when called by positional argument.
    :returns: buffer PEM-encoded Certificate Signing Request.
    NrzAAt least one of domains or ipaddrs parameter need to be not empty�DNS:�IP:�, �ascii�subjectAltNameF��critical�values1.3.6.1.5.5.7.1.24sDER:30:03:02:01:05�sha256)r
�load_privatekey�FILETYPE_PEM�X509Req�lenr(�append�exploded�join�encode�
X509Extension�add_extensions�
set_pubkey�set_version�sign�dump_certificate_request)rhrirjrk�private_key�csr�sanlist�address�ips�
san_string�
extensionsrrr�make_csr�sF����


�r��loaded_cert_or_reqcs6|��j�t|�}�dur|S�g�fdd�|D�S)Ncsg|]}|�kr|�qSrr)�.0�d��common_namerr�
<listcomp>sz4_pyopenssl_cert_or_req_all_names.<locals>.<listcomp>)�get_subject�CN�_pyopenssl_cert_or_req_san)r��sansrr�r� _pyopenssl_cert_or_req_all_namess

r��cert_or_reqcs(d�d��t|�}��fdd�|D�S)a�Get Subject Alternative Names from certificate or CSR using pyOpenSSL.

    .. todo:: Implement directly in PyOpenSSL!

    .. note:: Although this is `acme` internal API, it is used by
        `letsencrypt`.

    :param cert_or_req: Certificate or CSR.
    :type cert_or_req: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.

    :returns: A list of Subject Alternative Names that is DNS.
    :rtype: `list` of `unicode`

    �:�DNScs$g|]}|���r|���d�qS)rX)�
startswith�split�r��part��part_separator�prefixrrr�%s
�z._pyopenssl_cert_or_req_san.<locals>.<listcomp>��_pyopenssl_extract_san_list_raw)r��
sans_partsrr�rr�s�r�cs&d}d|�t|�}�fdd�|D�S)aiGet Subject Alternative Names IPs from certificate or CSR using pyOpenSSL.

    :param cert_or_req: Certificate or CSR.
    :type cert_or_req: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.

    :returns: A list of Subject Alternative Names that are IP Addresses.
    :rtype: `list` of `unicode`. note that this returns as string, not IPaddress object

    r�z
IP Addresscs&g|]}|���r|t��d��qSr)r�rxr��r�rrr�:s&z1_pyopenssl_cert_or_req_san_ip.<locals>.<listcomp>r�)r�r�r�rr�r�_pyopenssl_cert_or_req_san_ip)sr�cCsjt|tj�rt�tj|��d�}n
t�tj|��d�}t�d|�}d}|dur+g}|S|�	d��
|�}|S)aGet raw SAN string from cert or csr, parse it as UTF-8 and return.

    :param cert_or_req: Certificate or CSR.
    :type cert_or_req: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.

    :returns: raw san strings, parsed byte as utf-8
    :rtype: `list` of `unicode`

    zutf-8z5X509v3 Subject Alternative Name:(?: critical)?\s*(.*)rnNrX)�
isinstancer
r!�dump_certificate�
FILETYPE_TEXT�decoder��re�search�groupr�)r��text�raw_san�parts_separatorr�rrrr�=s�r��:	Tr;�
not_before�validity�	force_sanr�r�cCsZ|s|sJd��t��}|�tt�t�d��d��|�d�|dur%g}|dur+g}|dur1g}|�	t�
ddd��t|�dkrH|d|��_
|�|���g}|D]	}	|�	d	|	�qS|D]
}
|�	d
|
j�q_d�|��d�}|s�t|�d
ks�t|�dkr�|�	tj
dd|d��|�|�|�|dur�dn|�|�|�|�|�|�|d�|S)axGenerate new self-signed certificate.

    :type domains: `list` of `unicode`
    :param OpenSSL.crypto.PKey key:
    :param bool force_san:
    :param extensions: List of additional extensions to include in the cert.
    :type extensions: `list` of `OpenSSL.crypto.X509Extension`
    :type ips: `list` of (`ipaddress.IPv4Address` or `ipaddress.IPv6Address`)

    If more than one domain is provided, all of the domains are put into
    ``subjectAltName`` X.509 extension and first domain is set as the
    subject CN. If only one domain is provided no ``subjectAltName``
    extension is used, unless `force_san` is ``True``.

    z7Must provide one or more hostnames or IPs for the cert.��NsbasicConstraintsTsCA:TRUE, pathlen:0rrlrmrnrorXrpFrqrt)r
r!�set_serial_numberrQ�binascii�hexlify�os�urandomr�ryr}rxr�r��
set_issuerrzr{r|r~�gmtime_adj_notBefore�gmtime_adj_notAfterrr�)r;rir�r�r�r�r�r<r�r��ipr�rrr�gen_ss_cert\sH
���


r��chain�filetypecs:dttjtjfdtf�fdd��d��fdd�|D��S)z�Dump certificate chain into a bundle.

    :param list chain: List of `OpenSSL.crypto.X509` (or wrapped in
        :class:`josepy.util.ComparableX509`).

    :returns: certificate chain bundle
    :rtype: bytes

    r<rcst|tj�r	|j}t��|�Sr)r��jose�ComparableX509�wrappedr
r�)r<)r�rr�
_dump_cert�sz(dump_pyopenssl_chain.<locals>._dump_cert�c3s�|]}�|�VqdSrr)r�r<)r�rr�	<genexpr>�s�z'dump_pyopenssl_chain.<locals>.<genexpr>)r	r�r�r
r!rr{)r�r�r)r�r�r�dump_pyopenssl_chain�s"
r�)NFN)NNr�TNN)2rBr�r]�	ipaddress�loggingr�r�rK�typingrrrrrrrr	�josepyr��OpenSSLr
r�acmer�	getLoggerrr0�
SSLv23_METHODrPr
r#rrQrCr!rgrD�IPv4Address�IPv6Addressr�rwr�r�r�r�r r}r�rvr�rrrr�<module>s�
		h��
�
�
�7 ���
�7
�"""������
�&B

Anon7 - 2022
AnonSec Team