The goal of this exercise is to find the square root of (n) from an ssh_host_rsa_key.pub
file.
To achieve this, we wrote a Python script that computes the integer square root of (n) and prints it in hexadecimal.
import sys
import math
from Crypto.PublicKey import RSA
with open("ssh_host_rsa_key.pub", 'r') as f:
key_data = f.read()
key = RSA.import_key(key_data)
n = key.n
root_n = math.isqrt(n)
print(hex(root_n))
Running this script yields:
$ python3 decrypt.py
0x666a61676b64666c67666b64736a6766646c74797567766a636267686a716673646a76666468626a6664206279756374667b50334d5f6630726d34745f31735f6b316e677d20636d7876626c616c736669757165756970706c76646c64626e6d6a7a787964686a676664677070736b736a71
Finally, we convert the hexadecimal output to ASCII:
$ python3 decrypt.py | xxd -r -p
fjagkdflgfkdsjgfdltyugvjcbghjqfsdjvfdhbjfd byuctf{P3M_f0rm4t_1s_k1ng} cmxvblalsfiuqeuipplvdldbnmjzxydhjgfdgppsksjq%