│ Category: Cryptography
│ Author: Imattas aka Zemi
│ Flag: byuctf{P3M_f0rm4t_1s_k1ng}
│ Source Path: crypto/pem
────────────────────────────────────────────────────────────────────────────────
--[ Challenge Description ]--
-- text --
`$flag \in \sqrt N$`
[ssh_host_rsa_key.pub]
────────────────────────────────────────────────────────────────────────────────
--[ Provided Materials ]--
- Repository folder https://github.com/BYU-CSA/BYUCTF-2025/tree/main/crypto/pem
- crypto/pem/README.md
https://github.com/BYU-CSA/BYUCTF-2025/blob/main/crypto/pem/README.md
- crypto/pem/sshhostrsa_key.pub
https://github.com/BYU-CSA/BYUCTF-2025/blob/main/crypto/pem/ssh_host_rsa_key.pub
- crypto/pem/solve.sage
https://github.com/BYU-CSA/BYUCTF-2025/blob/main/crypto/pem/solve.sage
────────────────────────────────────────────────────────────────────────────────
--[ Recon / Initial Analysis ]--
This page imports the BYUCTF 2025 source material for the Cryptography challenge
PEM. The prompt is kept separate from the solve notes, and upstream artifacts
are linked so the challenge can be replayed from the original repository.
────────────────────────────────────────────────────────────────────────────────
--[ Vulnerability / Observation ]--
The useful observation comes from the imported solve notes below. I kept the
original technical path intact while normalizing the page metadata, challenge
grouping, and author attribution for the Volume 2 writeup archive.
────────────────────────────────────────────────────────────────────────────────
--[ Exploitation / Solution ]--
Source: crypto/pem/README.md
https://github.com/BYU-CSA/BYUCTF-2025/blob/main/crypto/pem/README.md
Flag is just in the sqrt of N. So you can extract N using a number of tools and
just decode those numbers to get the flag.
See solve.sage.
Flag - byuctf{P3M_f0rm4t_1s_k1ng}
────────────────────────────────────────────────────────────────────────────────
--[ Full Exploit Script ]--
Source: crypto/pem/solve.sage
https://github.com/BYU-CSA/BYUCTF-2025/blob/main/crypto/pem/solve.sage
-- python --
from Crypto.PublicKey import RSA
from Crypto.Util.number import long_to_bytes
from base64 import b64decode
with open("ssh_host_rsa_key.pub", "r") as f:
key = RSA.importKey(f.read())
n = key.n
flag = long_to_bytes(int(sqrt(n)))
print(flag.decode())
────────────────────────────────────────────────────────────────────────────────
--[ Key Takeaways ]--
- The BYUCTF 2025 challenge material is preserved with local archive formatting.
- The page author is normalized to Imattas aka Zemi.
- The source repository remains linked for handouts, services, and solve
artifacts.