cryptofreeeasy

Quantum Safe

HackTheBox

The challenge provides two files: 1. `source.sage` — SageMath encryption script 2. `output.txt` — 47 lines of encrypted vectors

$ ls tags/ techniques/
matrix_inversionnoise_brute_forceknown_plaintext_constraints

$ cat /etc/rate-limit

Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.

Quantum Safe — HackTheBox

Description

"I heard Shor's algorithm can do all sorts of nasty things to RSA, so I've decided to be super modern and protect my flag with cool new maffs!"

The challenge provides two files:

  1. source.sage — SageMath encryption script
  2. output.txt — 47 lines of encrypted vectors

source.sage

r = vector(ZZ, [randint(0, 10) for _ in range(3)]) FLAG = open('flag.txt').read() pubkey = Matrix(ZZ, [ [47, -77, -85], [-49, 78, 50], [57, -78, 99] ]) with open('output.txt', 'w') as f: for c in FLAG: f.write(f'{vector([ord(c), randint(0, 100), randint(0, 100)]) * pubkey + r}\n')

output.txt (47 lines)

(171, -237, -634)
(7806, -11691, 89)
(5350, -7653, 4362)
(6225, -9858, -7129)
(7872, -12129, -4390)
(3597, -4626, 9221)
(2277, -3485, -1777)
(5120, -7602, 193)
(6043, -9414, -4797)
(1316, -1742, 2350)
(5340, -8077, -1501)
(6195, -8818, 5672)
(7777, -11758, -1389)
(5205, -7837, -1114)
(1126, -1719, -1137)
(4341, -6498, -25)
(5725, -8950, -4953)
(4012, -6519, -6987)
(3787, -5249, 5061)
(9244, -13999, -1935)
(2742, -4203, -1816)
(3674, -5274, 2113)
(4577, -6762, 628)
(3418, -4686, 4965)
(4764, -7624, -6487)
(6343, -9249, 2736)
(2305, -2756, 8256)
(4350, -7144, -8395)
(6159, -8820, 4997)
(4412, -7000, -5342)
(4506, -6673, 293)
(894, -1119, 2189)
(5405, -7543, 6421)
(-200, 597, 2991)
(6043, -8945, 981)
(3465, -5212, -853)
(-428, 1056, 4500)
(4300, -6356, 318)
(5483, -8170, 166)
(9765, -14705, -904)
(3935, -5811, 256)
(4014, -5487, 6392)
(4847, -7699, -5897)
(9675, -14553, -664)
(3081, -4314, 3461)
(4317, -6160, 3437)
(5628, -8530, -1879)

Analysis

Encryption Scheme

Each flag character c is encrypted as:

ct = [ord(c), rand1, rand2] × pubkey + r

...

$ grep --similar

Similar writeups

  • [crypto][free]RSAisEasyHackTheBox
  • [crypto][Pro]worrierhxp_39c3
  • [crypto][Pro]Chillvolgactf
  • [crypto][Pro]RSA?grodno_new_year_2026
  • [crypto][free]MadMathhackthebox