CA MARCHE
This commit is contained in:
parent
8fe90ac427
commit
5c3394c28e
@ -12,12 +12,12 @@ try:
|
|||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from Crypto.PublicKey import RSA as RSA
|
from Crypto.PublicKey import RSA as RSA
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from Crypto.Cipher import PKCS1_OAEP
|
from Crypto.Cipher import PKCS1_OAEP as PKCS1_OAEP
|
||||||
|
|
||||||
pycryptodome = False
|
pycryptodome = False
|
||||||
except ModuleNotFoundError: # Pycryptodomex
|
except ModuleNotFoundError: # Pycryptodomex
|
||||||
from Cryptodome.PublicKey import RSA as RSA
|
from Cryptodome.PublicKey import RSA as RSA
|
||||||
from Cryptodome.Cipher import PKCS1_OAEP
|
from Cryptodome.Cipher import PKCS1_OAEP as PKCS1_OAEP
|
||||||
|
|
||||||
pycryptodome = True
|
pycryptodome = True
|
||||||
|
|
||||||
@ -82,7 +82,6 @@ class MainThread(threading.Thread):
|
|||||||
rsa = self.RsaGenThread(self)
|
rsa = self.RsaGenThread(self)
|
||||||
rsa.start()
|
rsa.start()
|
||||||
rsa.join()
|
rsa.join()
|
||||||
print(type(self.rsa))
|
|
||||||
self.clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.clientSocket.connect((HOST, PORT))
|
self.clientSocket.connect((HOST, PORT))
|
||||||
self.initialisation()
|
self.initialisation()
|
||||||
@ -93,7 +92,7 @@ class MainThread(threading.Thread):
|
|||||||
self.send(header + content)
|
self.send(header + content)
|
||||||
data = self.receive_rsa()
|
data = self.receive_rsa()
|
||||||
header = self.extract_header(data[:BUFFER_SIZE])
|
header = self.extract_header(data[:BUFFER_SIZE])
|
||||||
if header["type"] != b"init":
|
if header[b"type"] != b"init":
|
||||||
debug("Incorrect request type, end of connection")
|
debug("Incorrect request type, end of connection")
|
||||||
return
|
return
|
||||||
self.aes_key = data[BUFFER_SIZE:]
|
self.aes_key = data[BUFFER_SIZE:]
|
||||||
@ -115,7 +114,7 @@ class MainThread(threading.Thread):
|
|||||||
if data_lines[0] != VERSION:
|
if data_lines[0] != VERSION:
|
||||||
raise ValueError("Version is incorrect.")
|
raise ValueError("Version is incorrect.")
|
||||||
return {
|
return {
|
||||||
l.split(b": ")[0]: l.split(b": ")[1] for l in data_lines
|
l.split(b": ")[0]: l.split(b": ")[1].rstrip(b";") for l in data_lines[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -133,7 +132,6 @@ class MainThread(threading.Thread):
|
|||||||
:rtype: bytes"""
|
:rtype: bytes"""
|
||||||
if type_ not in REQUEST_TYPE:
|
if type_ not in REQUEST_TYPE:
|
||||||
raise ValueError("Unknown request type")
|
raise ValueError("Unknown request type")
|
||||||
return
|
|
||||||
header = VERSION + b"\ntype: " + type_
|
header = VERSION + b"\ntype: " + type_
|
||||||
if to_:
|
if to_:
|
||||||
header += b"\nto: " + to_
|
header += b"\nto: " + to_
|
||||||
@ -143,7 +141,7 @@ class MainThread(threading.Thread):
|
|||||||
|
|
||||||
class RsaGenThread(threading.Thread):
|
class RsaGenThread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, client_, difficulty=4):
|
def __init__(self, client_, difficulty=2):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.client = client_
|
self.client = client_
|
||||||
self.difficulty = difficulty
|
self.difficulty = difficulty
|
||||||
@ -182,12 +180,11 @@ class MainThread(threading.Thread):
|
|||||||
cipher_rsa = PKCS1_OAEP.new(recipient_key)
|
cipher_rsa = PKCS1_OAEP.new(recipient_key)
|
||||||
raw = self.receive()
|
raw = self.receive()
|
||||||
content = b""
|
content = b""
|
||||||
for to_send_text in [raw[i:i + CHUNK_SIZE] for i in range(0, len(raw), CHUNK_SIZE)]:
|
for to_decrypt in [raw[i:i + self.rsa.publickey().size_in_bytes()] for i in range(0, len(raw), self.rsa.publickey().size_in_bytes())]:
|
||||||
print(content)
|
content += cipher_rsa.decrypt(to_decrypt)
|
||||||
content += cipher_rsa.decrypt(to_send_text)
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
############################################ COMMUNICATION WITHOUT CRYPTING ########################################
|
############################################ COMMUNICATION WITHOUT CRYPTING ############################################
|
||||||
|
|
||||||
def receive(self):
|
def receive(self):
|
||||||
"""Receive message from connection
|
"""Receive message from connection
|
||||||
@ -204,8 +201,8 @@ class MainThread(threading.Thread):
|
|||||||
if chunk != END_MESSAGE:
|
if chunk != END_MESSAGE:
|
||||||
# Get content part
|
# Get content part
|
||||||
# int.from_bytes(chunk[:2], byteorder='big') == Get content size
|
# int.from_bytes(chunk[:2], byteorder='big') == Get content size
|
||||||
content += chunk[2:int.from_bytes(chunk[:2], byteorder='big')+2]
|
content += chunk[2:int.from_bytes(chunk[:2], byteorder='big') + 2]
|
||||||
debug(b"Received : " + content)
|
debug(b"Received: " + content)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def send(self, to_send):
|
def send(self, to_send):
|
||||||
|
@ -1,63 +1,57 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
MIILaQIBAAKCAoEAmoi9rbZ6kiCZMaLeX46SKQ+hN8kkt/d6VV6pH7n8Mw9Di4xc
|
MIIKSQIBAAKCAkEAyCjkX4LpaXrvh8oeVq6rdNLNpVBUiJxSX8CJizqB6Z/m8/4Z
|
||||||
2dvosVGwBVvsDzYC4sS5+orU76ps0uvELZgQQ8++2bfXXeRYWeucrZSA850vfokV
|
R69V0H/MzVjngnczA9Z2ITsIJ3ZLpGxL5TNC4Kv5q3LKsvhuSWMTq97q2bKaeCBr
|
||||||
KDTjkNVCJoOUGBeNgVxh2I8Mzn8logyFvbP6TQKRz+lY+ah7uKA2bp3PTr7uNrB4
|
ROOurG5FxWrTqLHbs5U47kJEDKH6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C KEY-----
|
-----END PUBLIC KEY-----
|
@ -129,7 +129,6 @@ class ClientThread(threading.Thread):
|
|||||||
if header[b"type"] == b"RSASend":
|
if header[b"type"] == b"RSASend":
|
||||||
self.type = T_CLIENT if header[b"from"] == b"client" else T_NODE
|
self.type = T_CLIENT if header[b"from"] == b"client" else T_NODE
|
||||||
debug("Réception de la clef RSA de %s", self.ip)
|
debug("Réception de la clef RSA de %s", self.ip)
|
||||||
print(content)
|
|
||||||
self.rsa_client = content
|
self.rsa_client = content
|
||||||
header = self.gen_header(b"init")
|
header = self.gen_header(b"init")
|
||||||
content = self.aes_key
|
content = self.aes_key
|
||||||
@ -152,7 +151,7 @@ class ClientThread(threading.Thread):
|
|||||||
if data_lines[0] != VERSION:
|
if data_lines[0] != VERSION:
|
||||||
raise ValueError("Version is incorrect.")
|
raise ValueError("Version is incorrect.")
|
||||||
return {
|
return {
|
||||||
l.split(b": ")[0]: l.split(b": ")[1] for l in data_lines[1:]
|
l.split(b": ")[0]: l.split(b": ")[1].rstrip(b";") for l in data_lines[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -225,9 +224,7 @@ class ClientThread(threading.Thread):
|
|||||||
if chunk != END_MESSAGE:
|
if chunk != END_MESSAGE:
|
||||||
# Get content part
|
# Get content part
|
||||||
# int.from_bytes(chunk[:2], byteorder='big') == Get content size
|
# int.from_bytes(chunk[:2], byteorder='big') == Get content size
|
||||||
content += chunk[2:int.from_bytes(chunk[:2], byteorder='big')] #+2] # Avec le +2 il me mange plus les caractères mais je sais pas pourquoi @suwako
|
content += chunk[2:int.from_bytes(chunk[:2], byteorder='big')+2]
|
||||||
print(chunk[2:int.from_bytes(chunk[:2], byteorder='big')])
|
|
||||||
print(content[:BUFFER_SIZE])
|
|
||||||
debug(b"Received from" + bytes(str(self.ip), 'ascii') + b" : " + content)
|
debug(b"Received from" + bytes(str(self.ip), 'ascii') + b" : " + content)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user