OwlCyberSecurity - MANAGER
Edit File: sockshandler.cpython-36.pyc
3 �2;Za������������������@���s"��d�Z�ddlZyddlZddlZW�n(�ek rH���ddljZddljZY�nX�ddl Z dd��Z G�dd��dej�ZG�dd��dej �ZG�d d ��d ejej�Zedk�rddlZyeejd��ZW�n�eefk r����d ZY�nX�ejee jde��Zedejd�j��j�����edejd�j��j�����dS�)z� SocksiPy + urllib2 handler version: 0.3 author: e<e@tr0ll.in> This module provides a Handler which you can use with urllib2 to allow it to tunnel your connection through a socks.sockssocket socket, with out monkey patching the original socket... �����Nc�������������C���s���|�j���}|j|��|S�)N)�copy�update)�a�b�d��r����"/usr/lib/python3.6/sockshandler.py� merge_dict���s���� r ���c���������������@���s���e�Zd�Zddd�Zdd��ZdS�)�SocksiPyConnectionNTc������� ������O���s*���||||||f|�_�tjj|�f|�|��d�S�)N)� proxyargs�httplib�HTTPConnection�__init__) �self� proxytype� proxyaddr� proxyport�rdns�username�password�args�kwargsr���r���r���r������s����zSocksiPyConnection.__init__c�������������C���sP���t�j��|�_|�jj|�j���t|�j�ttfkr8|�jj |�j��|�jj |�j|�jf��d�S�)N) �socks� socksocket�sock�setproxyr����type�timeout�int�float� settimeout�connect�host�port)r���r���r���r���r!������s ���� zSocksiPyConnection.connect)NTNN)�__name__� __module__�__qualname__r���r!���r���r���r���r���r ������s��� r ���c���������������@���s���e�Zd�Zddd�Zdd��ZdS�)�SocksiPyConnectionSNTc������� ������O���s*���||||||f|�_�tjj|�f|�|��d�S�)N)r���r����HTTPSConnectionr���) r���r���r���r���r���r���r���r���r���r���r���r���r���'���s����zSocksiPyConnectionS.__init__c�������������C���s\���t�j��}|j|�j���t|�j�ttfkr2|j|�j��|j |�j |�jf��tj ||�j|�j�|�_d�S�)N)r���r���r���r���r���r���r���r���r ���r!���r"���r#����sslZwrap_socketZkey_fileZ cert_filer���)r���r���r���r���r���r!���+���s����zSocksiPyConnectionS.connect)NTNN)r$���r%���r&���r���r!���r���r���r���r���r'���&���s��� r'���c���������������@���s$���e�Zd�Zdd��Zdd��Zdd��ZdS�)�SocksiPyHandlerc�������������O���s���||�_�||�_tjj|���d�S�)N)r����kw�urllib2�HTTPHandlerr���)r���r���r���r���r���r���r���4���s����zSocksiPyHandler.__init__c����������������s���d��fdd� }��j�||�S�)Nr���c����������������s(���t���j|�}t��j|�||d�|��}|S�)N)r"���r#���r���)r ���r+���r ���r���)r"���r#���r���r���r+����conn)r���r���r����build:���s����z(SocksiPyHandler.http_open.<locals>.build)Nr���)�do_open)r����reqr/���r���)r���r���� http_open9���s����zSocksiPyHandler.http_openc����������������s���d��fdd� }��j�||�S�)Nr���c����������������s(���t���j|�}t��j|�||d�|��}|S�)N)r"���r#���r���)r ���r+���r'���r���)r"���r#���r���r���r+���r.���)r���r���r���r/���A���s����z)SocksiPyHandler.https_open.<locals>.build)Nr���)r0���)r���r1���r/���r���)r���r���� https_open@���s����zSocksiPyHandler.https_openN)r$���r%���r&���r���r2���r3���r���r���r���r���r*���3���s���r*����__main__����iZ#��Z localhostzHTTP: zhttp://httpbin.org/ipzHTTPS: zhttps://httpbin.org/ip) �__doc__r)���r,���r����ImportErrorZurllib.requestZrequestZhttp.clientZclientr���r ���r ���r ���r(���r'���r-���ZHTTPSHandlerr*���r$����sysr����argvr#���� ValueError� IndexErrorZbuild_openerZPROXY_TYPE_SOCKS5�opener�print�open�read�decoder���r���r���r����<module> ���s*���