Mike, the System Administrator, thought it would be a good idea to implement his own Elliptic Curve Diffie Hellman key exchange using unnamed curves to use across the network. We managed to capture network traffic of the key exchange along with an encrypted file transfer. See if you can read the contents of that file.
Note: The password to the AES192-CBC encrypted file is the shared key x and y coordinates from the key exchange concatenated together. (e.g. sharedKey = (12345,67890) password = “1234567890”)
Difficulty: hard
Edit: 02/23/2019 14:33 Changed AES256-CBC to AES192-CBC
Solution
The file we have is key_exchange.pcap. Here we can find three streams: the two certificates and the encrypted file. For example, one of the certificates is the following:
p = 412220184797 A = 10717230661382162362098424417014722231813 B = 22043581253918959176184702399480186312 (xP, yP) = (56797798272, 349018778637) (xQ_a, yQ_a) = (61801292647, 228288385004) (xQ_b, yQ_b) = (196393473219, 35161195210) P = [xP, yP] Q_a = [xQ_a, yQ_a] Q_b = [xQ_b, yQ_b] F = FiniteField (p) E = EllipticCurve (F , [A ,B]) P = E.point(P) Q_a = E.point(Q_a) Q_b = E.point(Q_b) n = E.order() m = ceil(sqrt(n)) R = P precomputed = {P : 1} for a in range(2, m): R = R + P precomputed[R] = a R = Q_a S = (-m) * P found=False for b in range(m): try: a = precomputed[R] except KeyError: pass else: k_a = a + m * b found = True print(k_a) print(k_a * P == Q_a) break R = R + S R = Q_b S = (-m) * P found=False for b in range(m): try: a = precomputed[R] except KeyError: pass else: k_b = a + m * b found = True print(k_b) print(k_b * P == Q_b) break R = R + S ifnot found: print("Log not found") else: S=k_a * k_b * P print(S)
Now, the hardest part (for me) was to extract the AES-encrypted file from the pcap file. After several attempts, I managed to have my copy of that file. With the following script I decrypted the file: