theflagishere!

CATEGORY - REVERSING

Introduction

In this reversing challenge, I was given a Python compiled .pyc file. The description hinted that the program was supposed to determine the flag, but it didn't explicitly display it. My task was to reverse-engineer the file and extract the correct flag.

Steps

Step 1: Decompiling the .pyc file

Since a .pyc file is a compiled Python file, I needed to decompile it back to readable Python code. To do this, I used an online tool: lddgo.net Python Decompilerarrow-up-right. I uploaded the .pyc file, and it provided me with the following Python script:

Step 2: Identifying Issues in the Code

After analyzing the decompiled code, I noticed a few issues:

  • The what_do_i_do function contained a return inside a loop that would never execute properly.

  • There were several unnecessary function calls that seemed misleading.

  • Some of the flag extraction logic seemed obfuscated but could be simplified

I corrected the function:

Step 3: Extracting the Flag

After fixing the logic, I reconstructed the flag by calling the appropriate functions in sequence:

Running the script printed the final flag:

That’s how I solved this challenge. Thanks for reading!

Last updated