TSG CTF 2020 Modulus Amittendus Writeup
Problem
The flag encrypted with RSA and its public key are given.
But we are given instead of , by bug. Additionally, the coefficient is leaked.
The problem is to restore the plaintext from these information.
Solution
First, we have to restore .
From , for some integer , holds true. Then from , we can observe and we can brute-force the which satisfies that condition. Now we got .
Let's think about . Here:
and then,
and if we multiply both sides by ,
can be obtained. So is a multiple of . We can calculate this and put it as .
By the way, from Euler's theorem in number theory, the following holds for any integer that is prime to and each other.
In particular, since is a multiple of , will also become a multiple of .
Now if we calculate the following:
the result will be also a multiple of since the modulo and the original number is a mulitple of .
In this formula we can get a multiple of as many as we like, by changing the value of . So we can obtain by getting GCD of these values.
From we can get , so all the information needed to decrypt RSA is given. Then we can get the flag.
Appendix
By the way, after we got it seems we can obtain by not using Euler's theorem and by using Coppersmith's Attack on the formula:
But this must be impossible. The following is the proof.
With Coppersmith's Attack, the condition required to get the solution of n-variable non-identical linear equations
from , a multiple of and , the lower boundary and , the upper boundary of is
In our situation , so by sorting out the formula we get
Then we can evaluate that , and we get . Then if we put , the lower boundary of is:
and we can assume .
And from :
Considering the above, the above condition will become
which is clearly not satisfied even after considering the error.