Je vais me coucher
This commit is contained in:
parent
c844449871
commit
5535702c78
@ -286,6 +286,8 @@ Cette requête est utilisé pour initialiser la communication crypté entre deux
|
||||
|
||||
Requête envoyée en réponse à RSASend pour initialiser la connection cryptée en AES.
|
||||
|
||||
|
||||
|
||||
### Error ###
|
||||
|
||||
Error
|
||||
|
@ -85,9 +85,7 @@ key = RSA.generate(BUFFER_SIZE)
|
||||
private_key = key.export_key()
|
||||
file_out = open("private.pem", "wb")
|
||||
file_out.write(private_key)
|
||||
|
||||
public_key = key.publickey().export_key()
|
||||
|
||||
file_out = open("receiver.pem", "wb")
|
||||
file_out.write(public_key)
|
||||
to_send = public_key.ljust(BUFFER_SIZE, b';')
|
||||
@ -96,25 +94,32 @@ clientSocket.send(BEGIN_MESSAGE)
|
||||
clientSocket.send(HEADER)
|
||||
clientSocket.send(to_send)
|
||||
clientSocket.send(END_MESSAGE)
|
||||
|
||||
print('ok')
|
||||
# BEGIN
|
||||
chunk = clientSocket.recv(BUFFER_SIZE)
|
||||
print(chunk)
|
||||
# HEADER
|
||||
crypted = clientSocket.recv(BUFFER_SIZE).rstrip(b';')
|
||||
# AESKEY
|
||||
for i in range(60):
|
||||
crypted += clientSocket.recv(BUFFER_SIZE).rstrip(b";")
|
||||
# END
|
||||
chunk = clientSocket.recv(BUFFER_SIZE)
|
||||
print(chunk)
|
||||
|
||||
# HEADER+AES key are encypted in same time, so decrypt thme at same time
|
||||
# HEADER+AES key are encypted in same time, so decrypt time at same time
|
||||
cipher_rsa = PKCS1_OAEP.new(key)
|
||||
texte_to_decrypt = b''
|
||||
|
||||
for ligne in [crypted[i:i + BUFFER_SIZE] for i in range(0, len(crypted), BUFFER_SIZE)]:
|
||||
to_decrypt = ligne[2:]
|
||||
print(ligne)
|
||||
print(int.from_bytes(ligne[:2], byteorder='big'))
|
||||
to_decrypt = to_decrypt[:int.from_bytes(ligne[:2], byteorder='big')]
|
||||
texte_to_decrypt += to_decrypt
|
||||
texte = b''
|
||||
for to_decrypt in [crypted[i:i + int(BUFFER_SIZE/8)] for i in range(0, len(crypted), int(BUFFER_SIZE/8))]:
|
||||
for to_decrypt in [texte_to_decrypt[i:i + int(BUFFER_SIZE/8)] for i in range(0, len(texte_to_decrypt), int(BUFFER_SIZE/8))]:
|
||||
texte += cipher_rsa.decrypt(to_decrypt)
|
||||
print(texte.decode('ascii'))
|
||||
print(texte)
|
||||
|
||||
|
||||
|
||||
|
@ -1,51 +1,51 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIJKQIBAAKCAgEArUCxN8128/Zck+vS0xtRwvQFhsl44wV8I5987RNdU/sYFkoG
|
||||
CkMLFiXXhrcsYhzEEyKQ6ci+4OtwPtXuY9hE8XWnmd16T6ypct41oRoCVzrlrwMs
|
||||
Z1rg4M5ZnuQIb+7DJmIDHn3LjYF1yDC1XhoG1DZn+tWK1XPyCpWzjYHyUyocWiHK
|
||||
0lxxE3lLYj2okaWYjuwv+stt7ClpqPMjog2eg51H99rxKEEhlt+lDYXPEfWaPB4l
|
||||
WjlrophFqvndnYtZMJJfHwDyysQSvcwGL01KwKYR+URM5Lr8Zxj9xBP1v5NsxBTE
|
||||
1imZQ/cF7Nat4A/RCycHB4CrgtgtwlcHPJQWF4WxJN6+THM698oNQ8jKAwIuMPHR
|
||||
8XHkRU6A4tPHcOgDR4Sj3WKC3Q6Cv1PvMhU8bgfuqHk3eMCIiZNdBEn3Cl7bpvyn
|
||||
qiIvL75pXpMsqAwzNPq5Zw7k0dTXx/yz7zDo3mLG9BrZ3SzvWcB53hgk6K/dMY+/
|
||||
Y9fhwqkwzgyQ5pYMTs5lqP6qxbn+fhICEwroeFx34QXlq/RpsxVxC4KuJ3sTrQ5c
|
||||
r/aZsZSQFabJYXUeev15gLeqRBTuEr+5K1WrFRIRomItyTeudn412nyZcd/tOakZ
|
||||
5X9k2eb/xuM0gsmoe9Ern1Z9OaUTHmolAK/Ez0AzpZR3VID1JVgUhpqsA1UCAwEA
|
||||
AQKCAgAjgIWw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
||||
jO3Fj8oND9Mjf/r4ODLZgst5L1hFaUFOT/WrMJ6NgewuSG0j21NbIpcMKs0/tj9V
|
||||
Uq32eVgrDJYs5z5yMfgFwq1Cx7gtTiAWyRqPBfPAzj99ikoYDSGYllS8VZflkCPN
|
||||
72kP/8SdutuCJt4dCRtwQoe8YbHrxTPvFeiwON0pJV0+UB2DcYAbzoNNCbFTwzSU
|
||||
IKDH7HCVwsvDH8SctZXoK+s5H4ko75zc/ABivefP47jiBWnQal8cRPov2Q0fn3PB
|
||||
W+W34nrUVdRsSrc07mthyiy36w9xuZUCggEBAJ60bcwD/LHVaeThNiQjg0pzP9KY
|
||||
4014ZBymVvCX7dXhrpLoaQztGP8MN0YBoTMNZ5MMFE27zU7h09QPBSv+/t5x380c
|
||||
PfRiJHaMbcY3sdm3Gdx0DAlfYhSJ5btdXPRV2/QWACZD7VwE0/X/m9NDdbTKL6Uo
|
||||
+Fqt8jPkYdcurSg77XImY7H2rEfhhrdqLbUdxAA5OU7QVU1KMyAeykqJ8lo236bu
|
||||
3XssfMVmKQKv8T2/1TVqCLmnVQLYye1yl06ld+9F6h7L+KkXjmyi8cANplpFKfHf
|
||||
1zVQUv+TIsU03aWzXyj7WvyOF9osqtIO+xDhc58WZ0YP73WBSgFBsihaqoo=
|
||||
-----END RSA PRIVATE KEY-----
|
@ -1,14 +1,14 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEArUCxN8128/Zck+vS0xtR
|
||||
wvQFhsl44wV8I5987RNdU/sYFkoGCkMLFiXXhrcsYhzEEyKQ6ci+4OtwPtXuY9hE
|
||||
8XWnmd16T6ypct41oRoCVzrlrwMsZ1rg4M5ZnuQIb+7DJmIDHn3LjYF1yDC1XhoG
|
||||
1DZn+tWK1XPyCpWzjYHyUyocWiHK0lxxE3lLYj2okaWYjuwv+stt7ClpqPMjog2e
|
||||
g51H99rxKEEhlt+lDYXPEfWaPB4lWjl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o/G1EIfQHn/D/Yt6q/b7n96fVFJye3oXikgab31msXpCGXQnGAkbnlwbSyjx
|
||||
98P7Lqg+zCFOMTu7panp0hELQRrCWJEuoDiPvOuFRLVdvYj1KocfUWKdZ0ljNMNu
|
||||
0c4Ebmc8MW31WDvGWhbIsCmKg+GtYODDYIvVqEl5WnYRxLtj8ml2wq4gNRn9Y8rq
|
||||
mhOXHwEoRIGKsIGSgKZrFVkCAwEAAQ==
|
||||
-----END PUBLIC KEY-----
|
@ -8,7 +8,6 @@ import os
|
||||
import socket
|
||||
import threading
|
||||
|
||||
|
||||
#### logging ####
|
||||
# json decoder for int keys
|
||||
from Crypto.Cipher import PKCS1_OAEP
|
||||
@ -82,7 +81,6 @@ VERSION = "EICP2P2 V1"
|
||||
DONE = 0
|
||||
ERROR = 1
|
||||
|
||||
|
||||
#### Socket ####
|
||||
main_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
main_socket.bind((HOST, PORT))
|
||||
@ -174,13 +172,14 @@ class clientThread(threading.Thread):
|
||||
def send(self, to_send):
|
||||
self.client.send(BEGIN_MESSAGE)
|
||||
i = 0
|
||||
for to_send_text in [to_send[i:i + BUFFER_SIZE] for i in range(0, len(to_send), BUFFER_SIZE)]:
|
||||
self.client.send(to_send_text.ljust(BUFFER_SIZE, b";"))
|
||||
for to_send_text in [to_send[i:i + BUFFER_SIZE - 2] for i in range(0, len(to_send), BUFFER_SIZE - 2)]:
|
||||
print((len(to_send_text)).to_bytes(2, byteorder='big'))
|
||||
print((len(to_send_text)).to_bytes(2, byteorder='big') + to_send_text.ljust(BUFFER_SIZE, b";"))
|
||||
self.client.send((len(to_send_text)).to_bytes(2, byteorder='big') + to_send_text.ljust(BUFFER_SIZE - 2, b";"))
|
||||
i += 1
|
||||
print(i)
|
||||
self.client.send(END_MESSAGE)
|
||||
|
||||
|
||||
def run(self): # main de la connection du client
|
||||
"""Run thread mainloop
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user