Logo manbolq's Blog
  • Home
  • Recent Posts
  • Posts
  • Docs
  • Dark Theme
    Light Theme Dark Theme System Theme
Logo Inverted Logo
  • Posts
  • CryptoCTF - 2025
    • Vinad
    • Interpol
    • Mechanic
    • Mancity
    • Vainrat
    • Matemith
    • Sobata
    • ASIS Primes
    • Silky
    • Toffee
    • Ikkyu San
    • Lowdown
    • Mechanic II
    • Phoney
    • Mitram
    • Snails
Hero Image
Matemith - CryptoCTF

For this challenge, we are given a matemith.sage and a output.txt. The challenge starts by splitting the flag into 6 parts (the number of parts can be later seen in the code): l, flag = 14, flag.lstrip(b'CCTF{').rstrip(b'}') FLAG = [flag[l * i:l * (i + 1)] for i in range(len(flag) // l)] M = [bytes_to_long(_) for _ in FLAG] Then, 6 polynomials in $\mathbb{Q}[u, v, w, x, y, z]$ are generated: p = getPrime(313) R.<u, v, w, x, y, z> = PolynomialRing(QQ) COEFS = [getRandomRange(1, p - 1) for _ in range(21)] f = COEFS[0] * u * v + COEFS[1] * u + COEFS[2] * v g = COEFS[3] * u * x * y + COEFS[3] * x + COEFS[5] * y + COEFS[6] * v h = COEFS[7] * u * w + COEFS[8] * w + COEFS[9] * u i = COEFS[10] * v * y * z + COEFS[11] * y + COEFS[12] * z + COEFS[13] * w j = COEFS[14] * v * w + COEFS[15] * v + COEFS[16] * w k = COEFS[17] * w * z * x + COEFS[18] * z + COEFS[19] * x + COEFS[20] * u f, g, h, i, j, k = R(f), R(g), R(h), R(i), R(j), R(k) Then, they are evaluated in the flag parts and printed:

Wednesday, December 24, 2025 | 5 minutes Read
Hero Image
Mechanic - CryptoCTF

For this challenge, we are given three files: mechanic.py, output.raw and flag_22.enc. This is the challenge’s code: from quantcrypt.kem import MLKEM_1024 from quantcrypt.cipher import KryptonKEM from random import randint from pathlib import * from os import urandom from flag import flag kem = MLKEM_1024() kry = KryptonKEM(MLKEM_1024) pt = Path('/Mechanic/flag.png') f = open('output.raw', 'wb') m = randint(2 ** 39, 2 ** 40) B, c = bin(m)[2:], 0 for b in B: if b == '1': pkey, skey = kem.keygen() ct = Path(f'/flag_{c}.enc') kry.encrypt(pkey, pt, ct) pt = ct c += 1 else: pkey, skey = urandom(kem.param_sizes.pk_size), urandom(kem.param_sizes.sk_size) f.write(skey) f.close() The challenge uses MLKEM-1024 to create keys and then encrypt the flag several times. Randomly, these two things may happen:

Wednesday, December 24, 2025 | 2 minutes Read
Hero Image
Vainrat - CryptoCTF

For this challenge, we are given a vainrat.sage file. Looking at the code, we see that we will be working with the field of real numbers with 440 bits o precision: nbit = 110 prec = 4 * nbit R = RealField(prec) The main function is the following: def main(): m = bytes_to_long(flag) x0 = R(10 ** (-len(str(m))) * m) while True: y0 = abs(R.random_element()) if y0 > x0: break assert len(str(x0)) == len(str(y0)) c = 0 pr(border, f'We know y0 = {y0}') while True: pr("| Options: \n|\t[C]atch the rat \n|\t[Q]uit") ans = sc().decode().strip().lower() if ans == 'c': x, y = rat(x0, y0) x0, y0 = x, y c += 1 if c <= randint(12, 19): pr(border, f'Unfortunately, the rat got away :-(') else: pr(border, f'y = {y}') elif ans == 'q': die(border, "Quitting...") else: die(border, "Bye...") And this is the rat function:

Wednesday, December 24, 2025 | 3 minutes Read
Hero Image
Vinad - CryptoCTF

This challenge is an RSA-type challenge in which we need to factor n. We are given a file vinad.py and its output in output.txt. This is the RSA key generation method implemented in vinad.py: def parinad(n): return bin(n)[2:].count('1') % 2 def vinad(x, R): return int(''.join(str(parinad(x ^ r)) for r in R), 2) def genkey(nbit): while True: R = [getRandomNBitInteger(nbit) for _ in range(nbit)] r = getRandomNBitInteger(nbit) p, q = vinad(r, R), getPrime(nbit) if isPrime(p): e = vinad(r + 0x10001, R) if GCD(e, (p - 1) * (q - 1)) == 1: return (e, R, p * q), (p, q) The parinad function computes the parity of the hamming wright of a given number. The vinad function takes a number x and an array R and computes a number by applying the parinad function to all the pairs.

Tuesday, December 23, 2025 | 2 minutes Read
  • ««
  • «
  • 1
  • 2
  • »
  • »»
Navigation
  • Recent Posts
Contact me:
  • mvicentebolanos@gmail.com
  • manbolq
  • manbolq

Toha Theme Logo Toha
© 2026 Copyright.
Powered by Hugo Logo