use random iv so we finally have strong encryption now
This commit is contained in:
parent
0aa252e2b0
commit
9a6a934261
5 changed files with 65 additions and 30 deletions
11
server.py
11
server.py
|
@ -67,17 +67,17 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
|||
while True:
|
||||
r, w, e = select.select(fdset, [], [])
|
||||
if sock in r:
|
||||
data = sock.recv(4096)
|
||||
data = self.decrypt(sock.recv(4096))
|
||||
if len(data) <= 0:
|
||||
break
|
||||
result = send_all(remote, self.decrypt(data))
|
||||
result = send_all(remote, data)
|
||||
if result < len(data):
|
||||
raise Exception('failed to send all data')
|
||||
if remote in r:
|
||||
data = remote.recv(4096)
|
||||
data = self.encrypt(remote.recv(4096))
|
||||
if len(data) <= 0:
|
||||
break
|
||||
result = send_all(sock, self.encrypt(data))
|
||||
result = send_all(sock, data)
|
||||
if result < len(data):
|
||||
raise Exception('failed to send all data')
|
||||
|
||||
|
@ -95,6 +95,9 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
|||
try:
|
||||
self.encryptor = encrypt.Encryptor(KEY, METHOD)
|
||||
sock = self.connection
|
||||
iv_len = self.encryptor.iv_len()
|
||||
if iv_len:
|
||||
self.decrypt(sock.recv(iv_len))
|
||||
addrtype = ord(self.decrypt(sock.recv(1)))
|
||||
if addrtype == 1:
|
||||
addr = socket.inet_ntoa(self.decrypt(self.rfile.read(4)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue