DEADFACE CTF 2024: Discreet Logging
DEADFACE is running a server that is used to crack encryption of some sort. They didn’t secure their log server, so we have their logs. Please find out what key they cracked.
File, SHA1:
00e5caccac909f3a518a4e7a932370a324aca82f
ecdh_crack_20241013.log
computing discrete log for prime: 191
discrete log found: 25
computing discrete log for prime: 1621
discrete log found: 293
computing discrete log for prime: 61
discrete log found: 49
computing discrete log for prime: 2447
discrete log found: 2105
computing discrete log for prime: 991
discrete log found: 564
computing discrete log for prime: 1297
discrete log found: 50
computing discrete log for prime: 47
discrete log found: 13
computing discrete log for prime: 1049
discrete log found: 21
computing discrete log for prime: 347
discrete log found: 229
computing discrete log for prime: 283
discrete log found: 257
computing discrete log for prime: 2617
discrete log found: 307
computing discrete log for prime: 1429
discrete log found: 511
computing discrete log for prime: 167
discrete log found: 124
computing discrete log for prime: 307
discrete log found: 7
computing discrete log for prime: 431
discrete log found: 63
computing discrete log for prime: 683
discrete log found: 476
computing discrete log for prime: 1627
discrete log found: 1054
computing discrete log for prime: 17
discrete log found: 2
computing discrete log for prime: 827
discrete log found: 793
computing discrete log for prime: 97
discrete log found: 60
computing discrete log for prime: 523
discrete log found: 270
computing discrete log for prime: 151
discrete log found: 145
computing discrete log for prime: 37
discrete log found: 32
computing discrete log for prime: 2269
discrete log found: 796
computing discrete log for prime: 1733
discrete log found: 1041
computing discrete log for prime: 3
discrete log found: 1
computing discrete log for prime: 19
discrete log found: 9
computing discrete log for prime: 439
discrete log found: 60
We have a bunch of primes and discrete logarithms. My intuition was screaming Chinese Remainder Theorem. And it was right.
I just got out some code I already had from CryptoHack and used some text editor magic to copy-paste in the numbers from the log:
def bezout(a,b):
r = [a,b]
s = [1,0]
t = [0,1]
R = b
while R != 0:
Q = r[-2] // R
R = r[-2] - Q*R
r.append(R)
s.append(s[-2] - Q*s[-1])
t.append(t[-2] - Q*t[-1])
return s[-2], t[-2]
a = [25, 293, 49, 2105, 564, 50, 13, 21, 229, 257, 307, 511, 124, 7, 63, 476, 1054, 2, 793, 60, 270, 145, 32, 796, 1041, 1, 9, 60]
n = [191, 1621, 61, 2447, 991, 1297, 47, 1049, 347, 283, 2617, 1429, 167, 307, 431, 683, 1627, 17, 827, 97, 523, 151, 37, 2269, 1733, 3, 19, 439]
N = 1
for v in n: N *= v
m = [N//v for v in n]
uv = [bezout(n[i],m[i]) for i in range(len(m))]
e = [uv[i][1]*m[i] for i in range(len(m))]
x = sum([a[i]*e[i] for i in range(len(m))])
print((x%N).to_bytes(32, 'big'))
Flag: flag{ch1n3s3-r3mAind3r-D-l0g}
Home About Contact