PicoCTF 2024: packer
Tags: community, cybersecurity, learning, writing
Published: 2024-04-05 19:13:19

This challenge's description is asking: "Reverse this linux executable?". I answer: "Challenge accepted!"

![challenge accepted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yhbemj2hjf894uenzau7.gif)

Right after downloading the **binary**, I checked what type of file it was.


![file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kx4nxdumpgnyflfuygds.png)

The next step was to verify the **strings** (strings out). It was an endless output, from which something caught my eye. 👁️🤔

![packer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acuy5o8rb7xd0f6xek42.png)
It was the 🥇st time I saw something like this. In consequence, I decided to activate my research skills 🔍.🔎

According to [this source](https://upx.github.io/):

> UPX is an advanced executable file compressor. UPX will typically reduce the file size of programs and DLLs by around 50%-70%, thus reducing disk space, network load times, download times and other distribution and storage costs.

All right, seems it works like an archiver. If something was compressed, then it can be also decompressed, right? 🤓🙌

To my curiosity, I looked for ways to decompress a UPX file.
![upx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcwvqgeci7m1d77c9pz9.png)

If you don't have it already, you can install [according to this documentation](https://www.kali.org/tools/upx-ucl/).

With that being said, let's see what we got.

![decompressed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6w0df2rczwylhdbf6dh.png)
It seems that we obtained more details after decompressing the file.
We can look for the flag either by:
🕛 using strings and look carefully after some hints
🕐 using strings and search for the text pattern
🕑 summoning Ghidra
🕒 using debuggers...

Honestly, the easiest way is using strings and grepping for flags
![strings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twdvd7qliwtrnfcdkp7z.png)

Then we take the encrypted text and use [CyberChef](https://gchq.github.io/CyberChef/) to decrypt it.

Thanks to the magic wand 🪄, we get the flag!!


![flag](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8mvnf47q0woxddu6a33.png)

On Ghidra we also obtain the same result, but it will take a bit longer until the function "main" will appear and it will not be so obvious: you should search for it.



![ghidra](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tja0k1nnkycznwr9ow0.png)

Aand using the debuggers. I used pwndbg. I put a break on the puts instruction raised 


![puts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlgotqs9vdjhz5m4uw9t.png)

and found this out:
![debug](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j7wc8pk5nnfnwh2o8cex.png)



Wait, we also have another encrypted text. Curious what's there?
![text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pa9swypdf3ci2h3h62hy.png)


![texxt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f9u6tygwokyt8bnnsi5s.png)


And that was it! A binary challenge can be solved multiple ways, there will be times when strings function will not reveal the answer, so we need to use other tools 😺.

## Congrats! 👏 What are your thoughts?🤔