Skip to content
Snippets Groups Projects
Commit 143e7a50 authored by Boris LONJON's avatar Boris LONJON
Browse files

qsd

parent d5295cfb
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ from binascii import hexlify
MAC_LABEL_CONST = 'mac1----'.encode('utf-8')
CLIENT_1_PUBKEY = '85Ey6fLDcFadWd+MRPHAuBEAHJ6MIUbl2jNsCZJXmRI='
CLIENT_2_PUBKEY = 'gtPyxcaZzC7LkLq/QGzvVLEHaIOfdJ6nb79wx8C7YT8='
SERVER_PUBKEY = '+O7mAJK0m7Ts62WuP1Et1/RanAq5yFPAgDxuyR9TtD4='
def signal_handler(sig, frame):
......
#!/usr/bin/env python
from io import BytesIO
import signal
import sys
from base64 import b64decode
from binascii import hexlify
from scapy.all import sniff, IP, UDP, Raw
from hashlib import blake2s
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from Crypto.PublicKey import ECC
# Creating an in-memory byte stream
in_memory_stream = BytesIO()
CONSTRUCTION = "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s".encode('utf-8')
IDENTIFIER = "WireGuard v1 zx2c4 Jason@zx2c4.com".encode('utf-8')
# Writing to the in-memory stream
in_memory_stream.write(b"Hello, World!")
CLIENT_1_PUBKEY = b64decode('85Ey6fLDcFadWd+MRPHAuBEAHJ6MIUbl2jNsCZJXmRI=')
CLIENT_2_PUBKEY = b64decode('gtPyxcaZzC7LkLq/QGzvVLEHaIOfdJ6nb79wx8C7YT8=')
SERVER_PUBKEY = b64decode('+O7mAJK0m7Ts62WuP1Et1/RanAq5yFPAgDxuyR9TtD4=')
# Reading from the in-memory stream
in_memory_stream.seek(0)
data = in_memory_stream.read()
print("Data from in-memory stream:", data)
\ No newline at end of file
def kdf(n, key, input):
t0 = hmac(key, input)
t1 = hmac(t0, b'0x01')
t2 = hmac(t0, t1 + b'0x02')
if n == 1:
return t1
if n == 2:
returns (t1, t2)
def hmac(input, key):
return blake2s(input, key=key, digest_size=16).digest()
def hash(input):
return blake2s(input, digest_size=32).digest()
# Diffie Helmann
def dh():
pass
# server_pubkey = decode_pubkey(SERVER_PUBKEY)
# client1_pubkey = decode_pubkey(CLIENT_1_PUBKEY)
print("CONSTRUCTION : ", hexlify(CONSTRUCTION))
Ci = hash(CONSTRUCTION)
print("Ci : ", hexlify(Ci))
Hi = hash(Ci + IDENTIFIER)
print("Hi : ", hexlify(Hi))
Hi = hash(Hi + SERVER_PUBKEY)
print("SERVER_PUBKEY : ", hexlify(SERVER_PUBKEY))
print("Hi : ", hexlify(Hi))
ephemeral_privkey = ECC.generate(curve='Ed25519')
ephemeral_pubkey = ephemeral_privkey.public_key()
ephemeral = ephemeral_pubkey.export_key(format='raw')
# print(ephemeral_privkey.export_key(format='PEM'))
# print(ephemeral_pubkey.export_key(format='PEM'))
# print(hexlify(ephemeral_privkey.export_key(format='raw')))
print("PUBKEY : ", hexlify(ephemeral))
print('\nPoints de la courbe et Seed')
print(ephemeral_privkey)
print(ephemeral_pubkey)
Ci = kdf(1, ephemeral, Ci)
print("Ci : ", hexlify(Ci))
# ephemeral = ephemeral
Hi = hash(Hi + ephemeral)
print("Hi : ", hexlify(Hi))
(Ci, k) = kdf(2, dh(ephemeral_privkey, SERVER_PUBKEY), Ci)
# msg_static = aead(k, 0, , Hi)
# Hi = hash(Hi + msg_static)
# (Ci, k) = kdf(2, dh(CLIENT_1_PUBKEY, SERVER_PUBKEY), Ci)
# msg_timestamp = aead(k, 0, timestamp(TAI64N), Hi)
# Hi = hash(Hi + msg_timestamp)
\ No newline at end of file
scapy
\ No newline at end of file
scapy
aead
pycryptodome
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment