Post

HackTheBox RsaCtfTool Writeup

Explore the basics of cybersecurity in the RsaCtfTool Challenge on Hack The Box. This easy-level Challenge introduces encryption reversal and file handling concepts in a clear and accessible way, perfect for beginners.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from Crypto.Util.number import bytes_to_long, long_to_bytes
from Crypto.Cipher import AES
from hashlib import sha256

N = pow(10410080216253956216713537817182443360779235033823514652866757961082890116671874771565125457104853470727423173827404139905383330210096904014560996952285911, 3)
d = 129275315911223317359903751663807516352090026808195570114389567583720564611378335627134085402837298827247544997735787221623420069090831026403341043627337118073514316414863510575197151252044137503590414785481554107787977492191190932914467213110568469344259204522660239854742719334572977699979751357274672629248833545002097445009562614595500619383316585368090022534207869125569280525912198666917266810668438225654808711335777444218772562879952971915504193507508773
c = 0x13822f9028b100e2b345a1ad989d9cdedbacc3c706c9454ec7d63abb15b58bef8ba545bb0a3b883f91bf12ca12437eb42e26eff38d0bf4f31cf1ca21c080f11877a7bb5fa8ea97170c932226eab4812c821d082030100030d84ebc63fd8767cde994e0bd1a1f905c27fb0d7adb55e3a1f101d8b5b997ba6b1c09a5e1cc65a9206906ef5e01f13d7beeebdf389610fb54676f76ec0afc51a304403d44bb3c739fd8276f0895c3587a710d15e43fc67284070519e6e0810caf86b134f02ec54018
m = pow(c, d, N)
key = long_to_bytes(m)
print("Decrypted key:", key)
with open("flag.txt.aes", mode='rb') as file:
  data = file.read()
aes = AES.new(key, AES.MODE_ECB)
plantext = aes.decrypt(data[:32])
print("FLAG:", plantext)

Summary

The RsaCtfTool Challenge on Hack The Box is an easy-level challenge that introduces RSA and AES decryption. Users decrypt an RSA-encrypted message to reveal an AES key, which is then used to decrypt a flag. This challenge is ideal for beginners looking to learn encryption reversal and file handling.

This post is licensed under CC BY 4.0 by the author.