Malta CTF 2025
Very fun chall
Name
Category
1
Grammar Nazi
from Crypto.Util.number import *
FLAG = 'maltactf{???????????????????????????????}'
assert len(FLAG) == 41
p = getPrime(128)
q = getPrime(128)
N = p * q
e = 65537
m = f'The flag is {FLAG}'
c = pow(bytes_to_long(m.encode()), e, N)
# ERROR: Sentences should end with a period.
m += '.'
c += pow(bytes_to_long(m.encode()), e, N)
# All good now!
print(f'{N = }')
print(f'{c = }')
'''
N = 83839453754784827797201083929300181050320503279359875805303608931874182224243
c = 32104483815246305654072935180480116143927362174667948848821645940823281560338
'''c1 = M^e mod N
c2 = (256 * M + '.')^e mod N
csum = c1 + c2Solving the challenge :
m^e + (256 * m + 46)^e - csum = 0 mod Nm^e + (256 * m + 46)^e - csum = 0 mod P
Where
f(m) = m^e + (256 * m + 46)^e - csum = 0h(m) = m^p - mg(m) = gcd(f(m), h(m))
g(m) = 0 mod p
Last updated