Code Blue CTF 2018 - Lagalem Writeup
We’re given a piece of Python code and the result of the encryption of the flag:
1 | from Crypto.Util.number import * |
Code Analysis
Analyzing the code we have:
, random primes such that random values random that is the flag , , , that are the encryption results
Attack
We’re given
Now recalling Fermat’s little theorem: if
Noticing that
The Python code to perform this attack is the following:
1 | def tobytes(n): #long to bytes |
that prints out the flag: CBCTF{183a3ce8ed93df613b002252dfc741b2}