Ron was wrong, Whit is right
2 minutes to read
We are given the source code used to encrypt the flag:
#!/usr/bin/env python
from Crypto.Util import number
flag = open("flag.txt", "rb").read()
m = number.bytes_to_long(flag)
e = 65537
for _ in range(1336):
q = number.getPrime(1024)
p = number.getPrime(1024)
n = p * q
c = pow(m, e, n)
print(f"{n},{c}")
We also have the output (1336 pairs of n
and c
).
RSA background
Let’s review how RSA works:
The decryption process needs
Performing the attack
This time, we have so many different public modulus
The idea is to compute the Greatest Common Divisor (GCD) between each pair of public modulus and check if the output is not
Flag
So, after coding a solution script in Python, we can decrypt RSA and find the flag:
$ python3 solve.py
ictf{bad_prngs_can_cause_collisions_349d}
The full script can be found in here: solve.py
.