Twice the Trouble
بسم الله الرحمن الرحيم
Last updated
بسم الله الرحمن الرحيم
Last updated
In this challenge, we are provided with a Python script that encrypts a flag using the XOR operation. The task is to decipher the flag by satisfying a mathematical condition based on user input.
The provided Python script consists of several functions:
xor_encrypt_decrypt(input_str, key)
:
This function performs the XOR operation on each character of the input string using a given key.
get_flag()
:
This function contains the encoded flag represented as a list of integers. It uses an XOR key (13) to decode the flag and returns it.
compare_numbers(num1, num2)
:
This function compares the magnitudes of two numbers. It checks if the absolute value of the first number is exactly twice the absolute value of the second number.
main()
:
The entry point of the program. It generates random numbers, takes user input for two numbers, and calls the compare_numbers
function. If the comparison is successful, it reveals the flag.
To successfully retrieve the flag, we need to provide two numbers (num1
and num2
) such that: abs(num1)=2×abs(num2)\text{abs(num1)} = 2 \times \text{abs(num2)}abs(num1)=2×abs(num2)
For example, if we choose:
num1 = 10
num2 = 5
This satisfies the condition since 10 = 2 * 5
.
When the condition is met, the program will call get_flag()
, which returns the decoded flag.