Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/http/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/http/__pycache__/server.cpython-37.opt-2.pyc

B

YI~d��@s�dZdddddgZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZdd	lmZd
ZdZGdd�dej�ZGd
d�deje�ZGdd�dej�Z Gdd�de �Z!dd�Z"da#dd�Z$dd�Z%Gdd�de!�Z&e edddfdd�Z'e(dk�r�ddl)Z)e)�*�Z+e+j,dddd �e+j,d!d"dd#d$d%�e+j,d&d'e�-�d(d)�e+j,d*d+de.d,d-d.�e+�/�Z0e0j1�r�e&Z2nee!e0j3d/�Z2e'e2e0j4e0j5d0�dS)1z0.6�
HTTPServer�ThreadingHTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�partial)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c@seZdZdZdd�ZdS)r�cCs4tj�|�|jdd�\}}t�|�|_||_dS)N�)�socketserver�	TCPServer�server_bind�server_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�0/opt/alt/python37/lib64/python3.7/http/server.pyr
�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressr
rrrrr�sc@seZdZdZdS)rTN)rrrZdaemon_threadsrrrrr�sc
@sFeZdZdej��dZdeZe	Z
eZdZ
dd�Zdd�Zd	d
�Zdd�ZdEdd�ZdFdd�ZdGdd�Zdd�Zdd�Zdd�ZdHdd�Zdd�Ze�dd �e�ed!�ed"d#��D��Zd$ee d%�<d&d'�Z!d(d)�Z"dId*d+�Z#d,d-�Z$d.d/d0d1d2d3d4gZ%d
d5d6d7d8d9d:d;d<d=d>d?d@g
Z&dAdB�Z'dCZ(e)j*j+Z,dDd �e-j.�/�D�Z0d
S)JrzPython/rz	BaseHTTP/zHTTP/0.9c
Cs�d|_|j|_}d|_t|jd�}|�d�}||_|��}t	|�dkrLdSt	|�dk�r |d}yT|�
d�srt�|�d	d
�d
}|�d�}t	|�dkr�t�t|d�t|d
�f}Wn*tt
fk
r�|�tjd
|�dSX|dkr�|jdkr�d|_|dk�r|�tjd|�dS||_dt	|�k�r<dk�sTn|�tjd|�dS|dd�\}}t	|�dk�r�d|_|dk�r�|�tjd|�dS|||_|_|j�
d��r�d	|j�d	�|_ytjj|j|jd�|_Wnvtjjk
�r}z|�tjdt|��dSd}~XYn<tjjk
�rV}z|�tjdt|��dSd}~XYnX|j�dd�}	|	��dk�r|d|_n |	��dk�r�|jdk�r�d|_|j�dd�}
|
��dk�r�|jdk�r�|jdk�r�|� ��s�dSdS)NTz
iso-8859-1z
rF����zHTTP/�/r	�.r
zBad request version (%r))r	r	zHTTP/1.1)r
rzInvalid HTTP version (%s)zBad request syntax (%r)ZGETzBad HTTP/0.9 request type (%r)z//)Z_classz
Line too longzToo many headers�
Connection��closez
keep-aliveZExpectz100-continue)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
startswith�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr(�wordsZbase_version_numberZversion_numberr!r1�errZconntype�expectrrr�
parse_request
s�












z$BaseHTTPRequestHandler.parse_requestcCs|�tj�|��dS)NT)�send_response_onlyrZCONTINUE�end_headers)rrrrr:wsz(BaseHTTPRequestHandler.handle_expect_100c
Cs�y�|j�d�|_t|j�dkr@d|_d|_d|_|�tj	�dS|jsPd|_
dS|��s\dSd|j}t||�s�|�tj
d|j�dSt||�}|�|j��Wn6tjk
r�}z|�d|�d|_
dSd}~XYnXdS)NiirTZdo_zUnsupported method (%r)zRequest timed out: %r)r5�readliner&r*r(r#r!r/rZREQUEST_URI_TOO_LONGr$r?�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushrZtimeout�	log_error)rZmname�method�errr�handle_one_request�s4


z)BaseHTTPRequestHandler.handle_one_requestcCs&d|_|��x|js |��qWdS)NT)r$rK)rrrr�handle�szBaseHTTPRequestHandler.handleNcCsy|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|�d||�|�||�|�dd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d�}|�d	d
�}|�d|j
�|�dtt|���|��|jd
k�r|�r|j�|�dS)N)z???z???zcode %d, message %srr ��F)�quote)�code�message�explainzUTF-8�replacezContent-TypezContent-LengthZHEAD)�	responses�KeyErrorrH�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer%r*rAr!rF�write)rrOrPrQZshortmsgZlongmsgZbodyZcontentrrrr/�s4
z!BaseHTTPRequestHandler.send_errorcCs:|�|�|�||�|�d|���|�d|���dS)NZServerZDate)�log_requestr@rV�version_string�date_time_string)rrOrPrrrrU�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|j�d|j||f�dd��dS)NzHTTP/0.9rr�_headers_bufferz
%s %d %s
zlatin-1�strict)r#rSrCra�appendr0r[)rrOrPrrrr@�s


z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|j�d||f�dd��|��dkrh|��dkrVd|_n|��d	krhd
|_dS)NzHTTP/0.9raz%s: %s
zlatin-1rbZ
connectionr Tz
keep-aliveF)r#rCrarcr[r9r$)r�keyword�valuerrrrVs

z"BaseHTTPRequestHandler.send_headercCs"|jdkr|j�d�|��dS)NzHTTP/0.9s
)r#rarc�
flush_headers)rrrrrAs
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|j�d�|j��g|_dS)Nra�)rCrFr]�joinra)rrrrrfs
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|�d|jt|�t|��dS)Nz
"%s" %s %s)�
isinstancerre�log_messager(r%)rrO�sizerrrr^s
z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)N)rk)r�format�argsrrrrH*sz BaseHTTPRequestHandler.log_errorcCsi|]}d|d��|�qS)z\xZ02xr)�.0�crrr�
<dictcomp>:sz!BaseHTTPRequestHandler.<dictcomp>� ��z\\�\cGs2||}tj�d|��|��|�|j�f�dS)Nz%s - - [%s] %s
)�sys�stderrr]�address_string�log_date_time_string�	translate�_control_char_table)rrmrnrPrrrrk=s
z"BaseHTTPRequestHandler.log_messagecCs|jd|jS)N� )�server_version�sys_version)rrrrr_Wsz%BaseHTTPRequestHandler.version_stringcCs |dkrt��}tjj|dd�S)NT)Zusegmt)�time�email�utilsZ
formatdate)rZ	timestamprrrr`[sz'BaseHTTPRequestHandler.date_time_stringc	CsBt��}t�|�\	}}}}}}}}	}
d||j|||||f}|S)Nz%02d/%3s/%04d %02d:%02d:%02d)rZ	localtime�	monthname)rZnowZyearZmonthZdayZhhZmm�ss�x�y�z�srrrryas
z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)Nr)�client_address)rrrrrxosz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCsi|]}|j|jf|�qSr)�phrase�description)ro�vrrrrq~s)NN)N)N)riri)N)1rrrrvr;r)r~�__version__r}�DEFAULT_ERROR_MESSAGErX�DEFAULT_ERROR_CONTENT_TYPEr\r"r?r:rKrLr/rUr@rVrArfr^rHr%�	maketrans�	itertools�chain�ranger{�ordrkr_r`ryZweekdaynamer�rxr0r3r4ZHTTPMessager6r�__members__�valuesrSrrrrr�sBij%
5


"
	cs�eZdZdeZdd��fdd�
Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Ze
jshe
��e
j��Ze�ddddd���ZS)rzSimpleHTTP/N)�	directorycs(|dkrt��}||_t�j||�dS)N)�os�getcwdr��super�__init__)rr�rn�kwargs)�	__class__rrr��sz!SimpleHTTPRequestHandler.__init__cCs.|��}|r*z|�||j�Wd|��XdS)N)�	send_head�copyfilerFr )r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|��}|r|��dS)N)r�r )rr�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADcCs>|�|j�}d}tj�|�r�tj�|j�}|j�d�s�|�t	j
�|d|d|dd|d|df}tj�|�}|�d|�|�
�dSx6dD]$}tj�||�}tj�|�r�|}Pq�W|�|�S|�|�}yt|d	�}Wn$tk
�r|�t	jd
�dSX�yt�|���}d|jk�r�d|jk�r�ytj�|jd�}	Wnttttfk
�r`YnxX|	j dk�r~|	j!t"j#j$d
�}	|	j t"j#j$k�r�t"j"�%|j&t"j#j$�}
|
j!dd�}
|
|	k�r�|�t	j'�|�
�|�(�dS|�t	j)�|�d|�|�dt*|d��|�d|�+|j&��|�
�|S|�(��YnXdS)Nrrr	r
r�ZLocation)z
index.htmlz	index.htm�rbzFile not foundzIf-Modified-Sincez
If-None-Match)�tzinfo)ZmicrosecondzContent-typezContent-Length�z
Last-Modified),�translate_pathr1r��isdir�urllib�parseZurlsplit�endswithrUrZMOVED_PERMANENTLYZ
urlunsplitrVrArh�exists�list_directory�
guess_type�open�OSErrorr/�	NOT_FOUND�fstat�filenor7r�r�Zparsedate_to_datetime�	TypeErrorr.�
OverflowErrorr,r�rR�datetimeZtimezoneZutcZ
fromtimestamp�st_mtimerWr �OKr%r`)rr1r��partsZ	new_partsZnew_url�indexZctypeZfsZimsZ
last_modifrrrr��sl



z"SimpleHTTPRequestHandler.send_headc
	Cs�yt�|�}Wn"tk
r0|�tjd�dSX|jdd�d�g}ytjj	|j
dd�}Wn"tk
r~tj�	|j
�}YnXtj
|dd�}t��}d	|}|�d
�|�d�|�d|�|�d
|�|�d|�|�d�x~|D]v}tj
�||�}|}	}
tj
�|��r$|d}	|d}
tj
�|��r:|d}	|�dtjj|
dd�tj
|	dd�f�q�W|�d�d�|��|d�}t��}|�|�|�d�|�tj�|�dd|�|�dtt|���|��|S)NzNo permission to list directorycSs|��S)N)r9)�arrr�<lambda>rgz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass)�errorsF)rNzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperzContent-typeztext/html; charset=%szContent-Length) r��listdirr�r/rr��sortr�r��unquoter1�UnicodeDecodeErrorrYrZrv�getfilesystemencodingrcrhr��islinkrNr[�io�BytesIOr]�seekrUr�rVr%r*rA)
rr1�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr��s\







z'SimpleHTTPRequestHandler.list_directorycCs�|�dd�d}|�dd�d}|���d�}ytjj|dd�}Wn tk
rbtj�|�}YnXt�|�}|�d�}t	d|�}|j
}x8|D]0}tj�
|�s�|tjtjfkr�q�tj�||�}q�W|r�|d7}|S)N�?r	r�#rr�)r�)r)r'r�r�r�r�r��	posixpath�normpath�filterr�r�r1�dirname�curdir�pardirrh)rr1Ztrailing_slashr<Zwordrrrr�1s$	



z'SimpleHTTPRequestHandler.translate_pathcCst�||�dS)N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�Osz!SimpleHTTPRequestHandler.copyfilecCsLt�|�\}}||jkr"|j|S|��}||jkr>|j|S|jdSdS)Nr)r��splitext�extensions_mapr9)rr1�baseZextrrrr�_s



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)rz.pyz.cz.h)rrrr�r}r�r�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��update�
__classcell__rr)r�rr�s"
	O:
c	Cs�|�d�\}}}tj�|�}|�d�}g}x<|dd�D],}|dkrN|��q8|r8|dkr8|�|�q8W|r�|��}|r�|dkr�|��d}q�|dkr�d}nd}|r�d�||f�}dd�|�|f}d�|�}|S)Nr�rrz..rr)�	partitionr�r�r�r)�poprcrh)	r1�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_path�s.


r�cCsptrtSyddl}Wntk
r(dSXy|�d�daWn.tk
rjdtdd�|��D��aYnXtS)Nrr�nobodyr
r	css|]}|dVqdS)r
Nr)ror�rrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>)r��pwd�ImportError�getpwnamrT�maxZgetpwall)r�rrr�
nobody_uid�s r�cCst�|tj�S)N)r��access�X_OK)r1rrr�
executable�sr�c@sReZdZeed�ZdZdd�Zdd�Zdd�Z	d	d
gZ
dd�Zd
d�Zdd�Z
dS)r�forkrcCs$|��r|��n|�tjd�dS)NzCan only POST to CGI scripts)�is_cgi�run_cgir/rrD)rrrr�do_POST�s

zCGIHTTPRequestHandler.do_POSTcCs|��r|��St�|�SdS)N)r�r�rr�)rrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|�dd�}|d|�||dd�}}||jkrL||f|_dSdS)Nrr	TF)r�r1�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr��s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)N)r�)rr1rrr�
is_executablesz#CGIHTTPRequestHandler.is_executablecCstj�|�\}}|��dkS)N)z.pyz.pyw)r�r1r�r9)rr1r�r�rrr�	is_pythonszCGIHTTPRequestHandler.is_pythonc)	Cs�|j\}}|d|}|�dt|�d�}x`|dkr�|d|�}||dd�}|�|�}tj�|�r�||}}|�dt|�d�}q,Pq,W|�d�\}}}	|�d�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|�|�}tj�|��s|�	t
jd|�dStj�|��s2|�	t
j
d|�dS|�|�}
|j�sJ|
�sl|�|��sl|�	t
j
d|�dSt�tj�}|��|d	<|jj|d
<d|d<|j|d
<t|jj�|d<|j|d<tj�|�}||d<|�|�|d<||d<|	�r�|	|d<|jd|d<|j� d�}|�r�|�!�}t|�dk�r�ddl"}ddl#}|d|d<|d�$�dk�r�y"|d�%d�}|�&|��'d�}Wn|j(t)fk
�r�Yn&X|�!d�}t|�dk�r�|d|d<|j� d�dk�r�|j�*�|d<n|jd|d<|j� d�}|�r||d<|j� d �}|�r ||d!<g}xN|j�+d"�D]>}|dd�d#k�rX|�,|�-��n||d$d��!d%�}�q2Wd%�.|�|d&<|j� d'�}|�r�||d(<t/d|j�0d)g��}d*�.|�}|�r�||d+<xd,D]}|�1|d��q�W|�2t
j3d-�|�4�|	�5d.d/�}|j�r,|
g}d0|k�r(|�,|�t6�}|j7�8�t�9�}|dk�r�t�:|d�\}}x0t;�;|j<gggd�d�r�|j<�=d��s\P�q\W|�r�|�>d1|�dSy\yt�?|�Wnt@k
�r�YnXt�A|j<�B�d�t�A|j7�B�d�t�C|||�Wn(|j�D|jE|j�t�Fd2�YnX�n�ddlG} |g}!|�|��r�tHjI}"|"�$��Jd3��rt|"dd4�|"d5d�}"|"d6g|!}!d0|	k�r�|!�,|	�|�Kd7| �L|!��ytM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d8�}$|j�$�d9k�r|#dk�r|j<�=|#�}%nd}%x4t;�;|j<jRgggd�d�rL|j<jR�Sd��sP�qW|$�T|%�\}&}'|j7�U|&�|'�rz|�>d:|'�|$jV�W�|$jX�W�|$jY}(|(�r�|�>d1|(�n
|�Kd;�dS)<Nrr	rr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationr
Z	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE)r�ZREMOTE_HOSTrr	r
rzScript output follows�+r|�=zCGI script exit status %#xrszw.exe������z-uzcommand: %s)�stdin�stdoutrw�envZpostz%szCGI script exited OK)Zr�r�r*r�r�r1r�r�r�r/rr��isfileZ	FORBIDDENr��	have_forkr�r�Zdeepcopy�environr_Zserverrr0r%rr!r�r�r�r�r7r8r)�base64�binasciir9r[Zdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersrc�striprhr�Zget_all�
setdefaultrUr�rfrRr�rFrGr��waitpid�selectr5�readrH�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrvr�r�rkZlist2cmdliner-r�r,�Popen�PIPEZ_sockZrecvZcommunicater]rwr r�
returncode))r�dir�restr1�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyrZuqrestrrr�lengthrr�lineZua�coZ
cookie_str�kZ
decoded_queryrnr��pid�stsr#ZcmdlineZinterp�nbytes�p�datarrw�statusrrrr�s2


























zCGIHTTPRequestHandler.run_cgiN)rrrrCr�rZrbufsizer�r�r�r�r�r�r�rrrrr�s
zHTTP/1.0i@rc		Cs�||f}||_|||��b}|j��}d}t|j|d|dd��y|��Wn&tk
rttd�t�d�YnXWdQRXdS)Nz>Serving HTTP on {host} port {port} (http://{host}:{port}/) ...rr	)rrz&
Keyboard interrupt received, exiting.)	r0rZgetsockname�printrmZ
serve_forever�KeyboardInterruptrv�exit)	�HandlerClassZServerClassZprotocolr�bindrZhttpdZsaZ
serve_messagerrr�test�s
r9�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�default�metavarr=z--directoryz-dz9Specify alternative directory [default:current directory])r>r=r�storer�z&Specify alternate port [default: 8000])r<r>�type�nargsr=)r�)r7rr8)6r��__all__r�r�Zemail.utilsr�rYZhttp.clientr3r�r�r�r�r�rr�rrrvrZurllib.parser��	functoolsrrr�r�rrZThreadingMixInrZStreamRequestHandlerrrr�r�r�r�rr9r�argparse�ArgumentParser�parser�add_argumentr�r-�
parse_argsrnZcgiZ
handler_classr�rr8rrrr�<module>Sszs0



Hacked By AnonymousFox1.0, Coded By AnonymousFox