最近,看了一下Socks5的RFC,在网上找了一下Scoks5的Python实现,有几个地方自己看得不是很明白,就多查看了一下,Wireshark抓包也看了一下,稍微记录一下。
网上找的源码如下:其中我不是很明白的地方在如下:
1: #!/usr/bin/python2: # Filename s5.py3: # Python Dynamic Socks5 Proxy4: # Usage: python s5.py 10805: # Background Run: nohup python s5.py 1080 &6:7: import socket, sys, select, SocketServer, struct, time8:9: class ThreadingTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pass
10: class Socks5Server(SocketServer.StreamRequestHandler):
11: def handle_tcp(self, sock, remote):
12: fdset = [sock, remote]13: while True:14: r, w, e = select.select(fdset, [], [])15: if sock in r:
16: if remote.send(sock.recv(4096)) <=