Initial Data
Task link crypto/ROSSAU
Description
My friend really likes sending me hidden messages, something about a public key with n = 5912718291679762008847883587848216166109 and e = 876603837240112836821145245971528442417.
What is the name of player with the user ID of the private key exponent? (Wrap with osu)
Solution
The number n is not that large. We can try to factorize it.
One option is to visit factordb.com — the divisors may already be known. We got lucky: 59644326261100157131 and 99132954671935298039 are the sought divisors.
Let’s write a simple Python program to find the secret exponent:
#!/usr/bin/ python3
n = 5912718291679762008847883587848216166109
e = 876603837240112836821145245971528442417
print(f"n={n}")
print(f"e={e}")
p = 59644326261100157131
q = 99132954671935298039
print(f"p={p}")
print(f"q={q}")
assert n == p * q
phi = (p - 1) * (q - 1)
print(f"phi={phi}")
d = pow(e, -1, phi)
print(f"d={d}")solve.py
Run the script:
[amyasnikov@ubuntu:~]$ python3 ./script.py
n=5912718291679762008847883587848216166109
e=876603837240112836821145245971528442417
p=59644326261100157131
q=99132954671935298039
phi=5912718291679762008689106306915180710940
d=124493solve-output.log
The secret exponent is found.
Now let’s find the user with that ID.
Open the page https://osu.ppy.sh/users/124493 and we see the username there. Or make a curl request and see the profile name in the title tag:
$ curl -s "https://osu.ppy.sh/users/124493" | xq -x '//title'
chocomint · player info | osu!
We get the flag osu{chocomint}.
Alternative Solutions
The secret exponent could also be found using the owiener library:
import owiener
d = owiener.attack(e, n)
Or with RsaCtfTool.
