天天看点

socks5 helloworld

SOCKS is an Internet protocol that exchanges network packets between a client and server through a proxy server. SOCKS5 optionally provides authentication so only authorized users may access a server. Practically, a SOCKS server proxies TCP connections to an arbitrary IP address, and provides a means for UDP packets to be forwarded.

SOCKS5/Sokets5,可通过它的去间接的访问网络,相当于一个中转站。一般的代理协议比如Http代理都是工作在应用层的,效率比较低。而Socks代理协议提供一种通用的代理服务,工作在应用层和传输层之间,只是传递传输层网络数据包TCP/UDP,而不关心应用层的协议,该协议不包含加密。针对建立独立的网络非常有价值。

rfc1928:29.zip

socks5 is a small module SOCKS version 5 library written fom scratch in Python, which is highly inspired by h11 and hyper-h2. It's a "bring-your-own-IO" library; that is socks5 module does not contain any network related code. socks5 only deal with the parsing and state management of the socks5 connection, the underlying IO part is not cover in the internal code.

Currently, socks5 module support the following protocol and rfc.

socks4

socks4a

socks5 : rfc 1928

socks5 username/password authentication: rfc 1929

pip install PySocks
# / requesocks           

复制

import socket
import socks
import requests

socks.set_default_proxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
socket.socket = socks.socksocket
print(requests.get('http://www.baidu.com').text)           

复制

Close your local proxy first

https://baike.baidu.com/item/SOCKS5%E4%BB%A3%E7%90%86

https://blog.csdn.net/qq_42679379/article/details/88067821

https://github.com/mike820324/socks5

https://zhuanlan.zhihu.com/p/30670193

上一篇: 别了,2020