[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.21.12.193: ~ $


"�@Wu�@s�dZdZddlZddlZddlmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZd	ZZd
ZZdZZded
edeiZeeej�ej���ZejZZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$Gdd�de�Z%dddd d!d"iZ&d	d#d
d$dd%d&d'd(d)d*d+d,d-d.d/iZ'ed0ed0ed1iZ(dddd2ddd3d4�Z)e)Z*d5d6�Z+e+Z,d7d8�Z-e-Z.dddd2dddddd9d:�	Z/Gd;d<�d<ej�Z0d=d>�Z1xUdED]MZ2e3e0e2d�Z4e5e4e
�se0j6j7e2�e8e0e2e1e2��qWGdCdD�dDe0�Z9dS)Fa�

SocksiPy - Python SOCKS module.
Version 1.5.7

Copyright 2006 Dan-Haim. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
3. Neither the name of Dan Haim nor the names of his contributors may be used
   to endorse or promote products derived from this software without specific
   prior written permission.

THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.


This module provides a standard socket-like interface for Python
for tunneling connections through SOCKS proxies.

===============================================================================

Minor modifications made by Christopher Gilbert (http://motomastyle.com/)
for use in PyLoris (http://pyloris.sourceforge.net/)

Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/)
mainly to merge bug fixes found in Sourceforge

Modifications made by Anorov (https://github.com/Anorov)
-Forked and renamed to PySocks
-Fixed issue with HTTP proxy failure checking (same bug that was in the old ___recvall() method)
-Included SocksiPyHandler (sockshandler.py), to be used as a urllib2 handler,
 courtesy of e000 (https://github.com/e000): https://gist.github.com/869791#file_socksipyhandler.py
-Re-styled code to make it readable
    -Aliased PROXY_TYPE_SOCKS5 -> SOCKS5 etc.
    -Improved exception handling and output
    -Removed irritating use of sequence indexes, replaced with tuple unpacked variables
    -Fixed up Python 3 bytestring handling - chr(0x03).encode() -> b""
    -Other general fixes
-Added clarification that the HTTP proxy connection method only supports CONNECT-style tunneling HTTP proxies
-Various small bug fixes
z1.5.7�N)�
EOPNOTSUPP�EINVAL�EAGAIN)�BytesIO)�SEEK_CUR)�Callable)�	b64encode����SOCKS4�SOCKS5�HTTPc@s1eZdZdZddd�Zdd�ZdS)�
ProxyErrorz>
    socket_err contains original socket.error exception.
    NcCs4||_||_|r0|jdj|�7_dS)Nz: {0})�msg�
socket_err�format)�selfrr�r�	/socks.py�__init__Ns		zProxyError.__init__cCs|jS)N)r)rrrr�__str__UszProxyError.__str__)�__name__�
__module__�__qualname__�__doc__rrrrrrrJsrc@seZdZdS)�GeneralProxyErrorN)rrrrrrrrXsrc@seZdZdS)�ProxyConnectionErrorN)rrrrrrrrYsrc@seZdZdS)�SOCKS5AuthErrorN)rrrrrrrrZsrc@seZdZdS)�SOCKS5ErrorN)rrrrrrrr[src@seZdZdS)�SOCKS4ErrorN)rrrrrrrr \sr c@seZdZdS)�	HTTPErrorN)rrrrrrrr!]sr!�[zRequest rejected or failed�\zLRequest rejected because SOCKS server cannot connect to identd on the client�]zPRequest rejected because the client program and identd report different user-idszGeneral SOCKS server failurez!Connection not allowed by rulesetzNetwork unreachable�zHost unreachable�zConnection refused�zTTL expired�z(Command not supported, or protocol error�zAddress type not supportedi8i�TcCsC|||||r|j�nd|r3|j�ndft_dS)z�
    set_default_proxy(proxy_type, addr[, port[, rdns[, username, password]]])

    Sets a default proxy which all further socksocket objects will use,
    unless explicitly changed. All parameters are as for socket.set_proxy().
    N)�encode�
socksocket�
default_proxy)�
proxy_type�addr�port�rdns�username�passwordrrr�set_default_proxyssr3cCstjS)z>
    Returns the default proxy, set by set_default_proxy.
    )r+r,rrrr�get_default_proxy�sr4cCs(tjrt|j_ntd��dS)a"
    Attempts to replace a module's socket library with a SOCKS socket. Must set
    a default proxy using set_default_proxy(...) first.
    This will only work on modules that import socket directly into the namespace;
    most of the Python Standard Library falls into this category.
    zNo default proxy specifiedN)r+r,�socketr)�modulerrr�wrap_module�s	r7c
Cs�|\}
}|
jd�r*|
jd�}
|rN|jd�rN|jd�}d}xEtj||dtj�D](}
|
\}}}}}d}y�t|||�}|	dk	r�x|	D]}|j|�q�Wt|tt	f�r�|j
|�|dk	r|j||||||�|dk	r3|j|�|j
|
|f�|SWqptjk
r�}z'|}|dk	r�|j�d}WYdd}~XqpXqpW|dk	r�|�tjd��dS)a�create_connection(dest_pair, *[, timeout], **proxy_args) -> socket object

    Like socket.create_connection(), but connects to proxy
    before returning the socket object.

    dest_pair - 2-tuple of (IP/hostname, port).
    **proxy_args - Same args passed to socksocket.set_proxy() if present.
    timeout - Optional socket timeout value, in seconds.
    source_address - tuple (host, port) for the socket to bind to as its source
    address before connecting (only for compatibility)
    �[z[]Nrzgai returned empty list.)�
startswith�stripr5�getaddrinfo�SOCK_STREAMr+�
setsockopt�
isinstance�int�float�
settimeout�	set_proxy�bind�connect�error�close)�	dest_pairr-�
proxy_addr�
proxy_portZ
proxy_rdnsZproxy_usernameZproxy_password�timeout�source_addressZsocket_optionsZremote_hostZremote_port�err�r�familyZsocket_type�proto�	canonname�sa�sock�opt�errr�create_connection�s>"




rUc@s+eZdZdZdd�Ze�ZdS)�_BaseSocketzJAllows Python 2's "delegated" methods such as send() to be overridden
    cOsZtj|||�t�|_x4|jD])}t||�|j|<t||�q)WdS)N)�_orig_socketr�dict�
_savedmethods�
_savenames�getattr�delattr)r�pos�kw�namerrrr�s
z_BaseSocket.__init__N)rrrrr�listrZrrrrrV�srVcs�fdd�S)Ncs|j�||�S)N)rY)rr]r^)r_rr�<lambda>�sz_makemethod.<locals>.<lambda>r)r_r)r_r�_makemethod�srb�sendto�send�recvfrom�recvc@sceZdZdZdZejejddd�Zdd�Z	ddddddd	d
�Z
e
Zdd�Zd
d�Z
ddd�Zddd�Zdd�Zdd�Zdd�ZeZdd�ZeZdd�ZeZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zeeeee eiZ!d)d*�Z"d+d,�Z#dS)-r+a2socksocket([family[, type[, proto]]]) -> socket object

    Open a SOCKS enabled socket. The parameters are the same as
    those of the standard socket init. In order for SOCKS to work,
    you must specify family=AF_INET and proto=0.
    The "type" argument must be either SOCK_STREAM or SOCK_DGRAM.
    NrcOs�|tjtjfkr3d}t|j|���tj||||||�d|_|jrp|j|_	n	d|_	d|_
d|_dS)Nz0Socket type must be stream or datagram, not {!r})NNNNNN)r5r<�
SOCK_DGRAM�
ValueErrorrrVr�
_proxyconnr,�proxy�proxy_sockname�proxy_peername)rrN�typerO�args�kwargsrrrrr�s				zsocksocket.__init__cCsXd}xKt|�|krS|j|t|��}|sFtd��||7}q	W|S)z�
        Receive EXACTLY the number of bytes requested from the file object.
        Blocks until the required number of bytes have been received.
        �zConnection closed unexpectedly)�len�readr)r�file�count�data�drrr�_readallszsocksocket._readallTcCsC|||||r|j�nd|r3|j�ndf|_dS)a�set_proxy(proxy_type, addr[, port[, rdns[, username[, password]]]])
        Sets the proxy to be used.

        proxy_type -    The type of the proxy to be used. Three types
                        are supported: PROXY_TYPE_SOCKS4 (including socks4a),
                        PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
        addr -        The address of the server (IP or DNS).
        port -        The port of the server. Defaults to 1080 for SOCKS
                       servers and 8080 for HTTP proxy servers.
        rdns -        Should DNS queries be performed on the remote side
                       (rather than the local side). The default is True.
                       Note: This has no effect with SOCKS4 servers.
        username -    Username to authenticate with to the server.
                       The default is no authentication.
        password -    Password to authenticate with to the server.
                       Only relevant when username is also provided.
        N)r*rj)rr-r.r/r0r1r2rrrrBszsocksocket.set_proxycOs>|j\}}}}}}|s4|jtjkrGtj|||�S|jrbtjtd��|t	kr�d}	tjt
|	��tj|||�|j�\}
}d|f}t�|_|j
�}
|jj|
�d}|j|j||�\}
}|
\}}
|\}
}tj|||f�d|_dS)	zm
        Implements proxy connection for UDP sockets,
        which happens during the bind() phase.
        z"Socket already bound to an addressz'UDP only supported by SOCKS5 proxy type�0s�0.0.0.0rN)ryr)rjrmr5rgrWrCrirErr
rrV�getsockname�_proxy_addrrD�_SOCKS5_requestrk)rr]r^r-rHrIr0r1r2r�_r/�dstrjZ
UDP_ASSOCIATEZrelay�hostrrrrC*s(	zsocksocket.bindc
Os�|jtjkr(tj||||�S|js>|jd�|d}|dd�}t�}d}|j|�d}|j|�|j	||�tj
||j�|||�}	|	|j�S)	N�rr	ss)r�r���r�)
rmr5rgrVrcrirCr�write�_write_SOCKS5_addressrd�getvalue�tell)
r�bytesrnro�address�flags�headerZRSVZ
STANDALONE�sentrrrrcNs	

	

"zsocksocket.sendtocKsE|jtjkr+|j|||j|�Stj||||�SdS)N)rmr5rgrcrlrVrd)rr�r�rorrrrdaszsocksocket.sendc	Cs|jtjkr%tj|||�S|js;|jd�ttj|||��}|j	dt
�|jd�}t|�r�t
d��|j|�\}}|jr�|j\}}||ks�|d|fkr�tjtd��|j�||ffS)	Nr�rr
r	zReceived UDP packet fragmentzPacket filtered)r�rr
)rmr5rgrVrerirCrrf�seekrrr�ord�NotImplementedError�_read_SOCKS5_addressrlrEr)	r�bufsizer��bufZfragZfromhostZfromportZpeerhostZpeerportrrrregs	
	zsocksocket.recvfromcOs|j||�\}}|S)N)re)rr]r^r�r}rrrrf{szsocksocket.recvcCs#|jr|jj�tj|�S)N)rirFrV)rrrrrFs	
zsocksocket.closecCs|jS)zL
        Returns the bound IP address and port number at the proxy.
        )rk)rrrr�get_proxy_sockname�szsocksocket.get_proxy_socknamecCs
tj|�S)z>
        Returns the IP and port number of the proxy.
        )rV�getpeername)rrrr�get_proxy_peername�szsocksocket.get_proxy_peernamecCs|jS)z�
        Returns the IP address and port number of the destination
        machine (note: get_proxy_peername returns the proxy)
        )rl)rrrr�get_peername�szsocksocket.get_peernamecGs+d}|j|||�\|_|_dS)zI
        Negotiates a stream connection through a SOCKS5 server.
        sN)r|rlrk)r�	dest_addrZCONNECTrrr�_negotiate_SOCKS5�s	zsocksocket._negotiate_SOCKS5cCs�|j\}}}}}}	|jd�}
|jdd�}z6|r[|	r[|
jd�n
|
jd�|
j�|j|d�}|dd�dkr�td	��|dd�d
kr`|
jdtt|��j�|tt|	��j�|	�|
j�|j|d�}
|
dd�dkr;td	��|
dd�dkr�t	d
��nG|dd�dkr�|dd�dkr�t	d��ntd	��|
jd|d�|j
||
�}|
j�|j|d�}|dd�dkrtd	��t|dd��}|dkrXtj
|d�}tdj||���|j|�}||fSWd|j�|
j�XdS)z�
        Send SOCKS5 request with given command (CMD field) and
        address (DST field). Returns resolved DST address that was used.
        �wb�rbrssr
r	sz%SOCKS5 proxy server sent invalid datassszSOCKS5 authentication faileds�z7All offered SOCKS5 authentication methods were rejectedrz
Unknown errorz
{0:#04x}: {1}N)rj�makefiler��flushrwr�chrrqr*rr�r��
SOCKS5_ERRORS�getrrr�rF)r�conn�cmdr~r-r.r/r0r1r2�writer�readerZchosen_authZauth_statusZresolved�resp�statusrEZbndrrrr|�sL

;


zsocksocket._SOCKS5_requestcCs�|\}}|j\}}}}}}	tjdtjdi}
x�tjtjfD]�}y`tj||�}|j|
||�tj||�}|jtjd|��||fSWqRtj	k
r�wRYqRXqRW|r|j
d�}
|jdtt|
��j
�|
�n�tj
||tjtjtjtj�}|d}|d}|dd}tj||�}|j|
||�tj||�}|jtjd|��||fS)z~
        Return the host and port packed for the SOCKS5 protocol,
        and the resolved address as a tuple object.
        ssz>H�idnasrr%)rjr5�AF_INET�AF_INET6�	inet_ptonr��	inet_ntop�struct�packrEr*r�rqr;�	AF_UNSPECr<�IPPROTO_TCP�
AI_ADDRCONFIG)rr.rsrr/r-r}r0r1r2Zfamily_to_byterN�
addr_bytesZ
host_bytesZ	addressesZtarget_addrrrrr��s0**

z socksocket._write_SOCKS5_addresscCs�|j|d�}|dkr<tj|j|d��}nu|dkru|j|d�}|j|t|��}n<|dkr�tjtj|j|d��}ntd��tjd|j|d	��d
}||fS)Nr	sr%ss�z%SOCKS5 proxy server sent invalid dataz>Hr
r)	rwr5�	inet_ntoar�r�r�rr��unpack)rrsZatypr.�lengthr/rrrr�!s$"zsocksocket._read_SOCKS5_addresscCs|j\}}}}}}|jd�}	|jdd�}
z�d}ytj|�}WnBtjk
r�|r�d}d}ntjtj|��}YnX|	jtjddd	|��|	j|�|r�|	j|�|	jd
�|r	|	j|j	d�d
�|	j
�|j|
d�}
|
dd	�d
krGtd
��t
|
d	d��}|dkr�tj|d�}tdj||���tj|
dd��tjd|
dd��df|_|r�tj|�|f|_n||f|_Wd|
j�|	j�XdS)zB
        Negotiates a connection through a SOCKS4 server.
        r�r�rFsTz>BBHr%r	sr�r)z%SOCKS4 proxy server sent invalid datar
�Zz
Unknown errorz
{0:#04x}: {1}Nz>H)rjr�r5�	inet_atonrE�
gethostbynamer�r�r�r*r�rwrr��
SOCKS4_ERRORSr�r rr�r�rkrlrF)rr��	dest_portr-r.r/r0r1r2r�r�Zremote_resolver�r�r�rErrr�_negotiate_SOCKS40sB	



<
zsocksocket._negotiate_SOCKS4cCs�|j\}}}}}}|r'|ntj|�}d|jd�dt|�j�dd|jd�g}	|r�|r�|	jdt|d|��|	jd�|jdj|	��|j	�}
|
j
�}|
j�|s�td��y|j
d	d
�\}}
}Wntk
r5td��YnX|jd�sQtd
��yt|
�}
Wntk
r�td��YnX|
dkr�dj|
|�}|
dkr�|d7}t|��d|_||f|_dS)z�
        Negotiates a connection through an HTTP server.
        NOTE: This currently only supports HTTP CONNECT-style proxies.
        sCONNECT r��:s	 HTTP/1.1sHost: sProxy-Authorization: basic s
zConnection closed unexpectedly� r
z'HTTP proxy server sent invalid responsezHTTP/z0Proxy server does not appear to be an HTTP proxyz4HTTP proxy server did not return a valid HTTP status��z{0}: {1}���za
[*] Note: The HTTP proxy server may not be supported by PySocks (must be a CONNECT tunnel proxy)�0.0.0.0rN)r�r�r�)r�r)rjr5r�r*�str�appendr�sendall�joinr��readlinerFr�splitrhr9r?r!rrkrl)rr�r�r-r.r/r0r1r2Zhttp_headersZfobjZstatus_linerOZstatus_codeZ
status_msgrErrr�_negotiate_HTTPks<(




	zsocksocket._negotiate_HTTPcCsct|�dks%|djd�r4tjd��|\}}|jtjkr�|jsh|jd�tj|�}|dkr�|r�d|_	n||f|_	dS|j
\}}}}}}	t|tt
f�st|�dks|st|t�rtd��|dkr>||_	tj|||f�dS|j�}ytj||�Wn{tjk
r�}
zX|j�|\}}d	j||�}t|}d
j||�}
t|
|
��WYdd}
~
Xn�Xy!|j|}||||�Wn_tjk
r@}
z|j�td|
��WYdd}
~
Xntk
r^|j��YnXdS)
z�
        Connects to the specified destination through a proxy.
        Uses the same API as socket's connect().
        To select the proxy server, use set_proxy().

        dest_pair - 2-tuple of (IP/hostname, port).
        r
rr8zPySocks doesn't support IPv6r�z0.0.0.0Nz0Invalid destination-connection (host, port) pairz{0}:{1}z!Error connecting to {0} proxy {1}zSocket error)r�r)rqr9r5rErmrgrirCr�rlrjr>r`�tupler?rrVrDr{rFr�PRINTABLE_PROXY_TYPESr�_proxy_negotiatorsr)rrGr�r�r-rHrIr0r1r2rEZproxy_serverZprintable_typerZ	negotiaterrrrD�sR%	
	

		"

!

zsocksocket.connectcCsL|j\}}}}}}|p-tj|�}|sBtd��||fS)zD
        Return proxy address to connect to as tuple object
        zInvalid proxy type)rj�
DEFAULT_PORTSr�r)rr-rHrIr0r1r2rrrr{�s
zsocksocket._proxy_addr)$rrrrr,r5r�r<rrwrBZsetproxyrCrcrdrerfrFr�Zgetproxysocknamer�Zgetproxypeernamer�r�r�r|r�r�r�r�rr
rr�rDr{rrrrr+�s:
$R*;7Mr+)zsendtozsendzrecvfromzrecv):r�__version__r5r��errnorrr�ior�osr�collectionsr�base64rZPROXY_TYPE_SOCKS4rZPROXY_TYPE_SOCKS5r
ZPROXY_TYPE_HTTPrZPROXY_TYPESrX�zip�values�keysr�Z
_orgsocketrW�IOErrorrrrrrr r!r�r�r�r3Zsetdefaultproxyr4Zgetdefaultproxyr7Z
wrapmodulerUrVrbr_r[�methodr>rZr��setattrr+rrrr�<module>5sl


!
7



Filemanager

Name Type Size Permission Actions
cached_property.cpython-35.opt-1.pyc File 4.52 KB 0644
cached_property.cpython-35.pyc File 4.52 KB 0644
easy_install.cpython-35.opt-1.pyc File 252 B 0644
easy_install.cpython-35.pyc File 252 B 0644
idna_ssl.cpython-35.opt-1.pyc File 865 B 0644
idna_ssl.cpython-35.pyc File 865 B 0644
pam.cpython-35.opt-1.pyc File 6.4 KB 0644
pam.cpython-35.pyc File 6.4 KB 0644
six.cpython-35.opt-1.pyc File 27.76 KB 0644
six.cpython-35.pyc File 27.76 KB 0644
socks.cpython-35.opt-1.pyc File 22.69 KB 0644
socks.cpython-35.pyc File 22.69 KB 0644
sockshandler.cpython-35.opt-1.pyc File 3.86 KB 0644
sockshandler.cpython-35.pyc File 3.86 KB 0644