Primary Knowledge - Crypto
Task
Surrounded by an untamed forest and the serene waters of the Primus river, your sole objective is surviving for 24 hours. Yet, survival is far from guaranteed as the area is full of Rattlesnakes, Spiders and Alligators and the weather fluctuates unpredictably, shifting from scorching heat to torrential downpours with each passing hour. Threat is compounded by the existence of a virtual circle which shrinks every minute that passes. Anything caught beyond its bounds, is consumed by flames, leaving only ashes in its wake. As the time sleeps away, you need to prioritise your actions secure your surviving tools. Every decision becomes a matter of life and death. Will you focus on securing a shelter to sleep, protect yourself against the dangers of the wilderness, or seek out means of navigating the Primusβ waters?
Solution
We get two files source.py
and output.txt
. The first one contains the flag encryption code:
The content of the Python script indicates that ciphertext is calculated in the standard for the RSA algorithm way. Let's take a look at the output.txt
file. In this file, we can find the values of N, e, and c. The last one is a ciphertext and contains an encrypted flag. The values contained in this file are as follows:
The given value of N turns out to be a prime number. RSA security is based on the problem of factoring N and therefore N should never be a prime number. Knowing that N is a prime number, we should be able to calculate the private key and decrypt the message.
We know from the way the RSA algorithm works that N should be computed as:
Message decryption is performed using the private key in the following way:
Ο(N) calculation in the RSA algorithm is based on this transformation. Based on the above formulas and knowing that N is a prime number then:
So we can calculate the Eulerβs Totient Function for prime N as:
After substituting into the formula we get:
It follows that we can calculate the public key as:
We will use that transformation to calculate the private key. A simple Python script that calculates the value of the private key and decrypts the message:
After executing the script, we receive a flag.
Flag:
Last updated