Sequences are known to be good solutions, but are they good problems?
Files given:
f = [int(x) for x in bin(int(FLAG.hex(), 16))[2:]]
f.insert(0, 0)
for i in range(len(f)-1): f[i] += f[i+1]
a = nextPrime(len(f))
b = nextPrime(a)
g, h = [[_ for i in range(x) for _ in f] for x in [a, b]]
c = nextPrime(len(f) >> 2)
for _ in [g, h]:
for __ in range(c): _.insert(0, 0)
for i in range(len(_) - c): _[i] += _[i+c]
g, h = [int(''.join([str(_) for _ in __]), 5) for __ in [g, h]]
for _ in [g, h]:
if _ == g:
fname = 'g'
else:
fname = 'h'
of = open(f'{fname}.enc', 'wb')
of.write(long_to_bytes(_))
of.close()
One important observation is that the flag length uniquely determine the length of g.enc
and h.enc
, so by binary searching the flag length by running the script, one finds that the flag has 32 characters. Once we get this,
Solution at solve.py
Flag:
CCTF{_how_finD_7h1s_1z_s3cr3T?!}