Twice the Trouble

بسم الله الرحمن الرحيم

challenge

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.

Let's analyze the code

The provided Python script consists of several functions:

  1. xor_encrypt_decrypt(input_str, key):

    • This function performs the XOR operation on each character of the input string using a given key.

  2. 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.

  3. 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.

  4. 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.

Solving the Challenge

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.

Flag Retrieval

When the condition is met, the program will call get_flag(), which returns the decoded flag.

Flag

QUESTCON{d0ubl3_tr0ubl3}

Last updated