Common Factor

52 solves/ 383 points

Source files and Solve Script: TMUCTF/Common%20Factor

Factoring N:

If we look closely at the first hint, we can find one of the factors of N,

n=p1p2p3p4p5x2+x3+y1=p22+p1p2+p12p2+p22p1=p2(p1+p2)(p1+1)=h1(say)p2=gcd(n,h1)\begin{align} n &= p_1 \cdot p_2 \cdot p_3 \cdot p_4 \cdot p_5 \\ x_2 + x_3 + y_1 &= p_2^2 + p_1p_2 + p_1^2p_2 + p_2^2p_1 = p_2 (p_1 + p_2)(p_1 + 1) = h_1 (say) \tag{1} \\ \therefore p_2 &= \gcd(n, h_1) \end{align}

From here, we can proceed to find another prime by solving the quadratic from (1)

p12p2+(p22+p2)p1+(p2h1)=0 p1=(p22+p2)±(p22+p2)24p2(p2h1)2p2p_1^2p_2 + (p_2^2+p_2)p_1 + (p_2 - h1) = 0 \\~\\ \therefore p_1 = \frac{-(p_2^2+p_2) \pm \sqrt{(p_2^2+p_2)^2 - 4p_2(p_2-h1)}}{2p_2}

From the 2nd hint, we can find another factor

y2+y3=p22(p3+1)1+p1p2(p3+1)1=h2(say)h2+2=(p3+1)(p22+p1p2)p3=(h2+2)(p22+p1p2)1\begin{align} y_2 + y_3 &= p_2^2 \cdot (p_3 + 1) - 1 + p_1 \cdot p_2 \cdot (p_3 + 1) - 1 = h_2 (say) \\ h_2 + 2 &= (p_3 + 1) \cdot (p_2^2 + p_1 \cdot p_2) \\ p_3 &= \frac{(h_2 + 2)}{(p_2^2 + p_1 \cdot p_2)} - 1 \end{align}

At this point, we have 3/5 primes and I don't know how to find the other 2. Then I had a wild thought that if the flag is small enough i.e. Flag32048  bitsFlag \leq 3*2048 \;bits then we can decrypt it with these 3 primes we found!

So, I used N=p1p2p3N = p_1 \cdot p_2 \cdot p_3 and got the flag!

Note:

The flag is small enough(423 bits only). Thus we can use only one prime to solve this challenge!

Last updated

Was this helpful?