Challenge Info
Reverse this linux executable?
Understanding the file
The file
command will give us some good foundational information as to what we’re dealing with.
1 | > file out |
For now, all we need to keep in mind:
- It’s statically linked, so all of the required libraries are included in this binary, meaning it’s all self-contained.
- The program is a 64-bit ELF (Executable and Linkable Format).
Next, we can run strings out
to try and see the text inside the binary. For this command, I won’t be showing the entire output, since most of it is gibberish, but there is one thing that should catch our eye, and it’s all the way at the bottom of the output:
1 | > strings out |
A quick google search on UPX led me to this site, the official UPX site, which states:
“UPX is a free, secure, portable, extendable, high-performance executable packer for several executable formats.“
This leads us to believe that this file has been packed using UPX, so let’s try unpacking it.
Utilizing UPX
To unpack (or uncompress) the binary, we’re obviously going to need UPX, since that’s what it was compressed with. install UPX on any APT based distros (Kali, Debian, Ubuntu, Mint, etc.), we can run sudo apt install upx-ucl
.
Now, we just need to find the command to unpack our binary. I personally ran man upx
, man
being short for manual page
- but a quick google search should yield the same result:
“ Decompress:
All UPX supported file formats can be unpacked using the -d switch, eg. upx -d
yourfile.exe will uncompress the file you’ve just compressed.”
So, let’s try it out:
1 | > upx -d out |
Finding the flag
Now that we’ve successfully unpacked the file, let’s try running strings
again, but this time we’re going to combine it with less
, a command similar to cat
, but with more features (scrolling, searching).
1 | > strings out | less |
To search for a specific string, enter a simple slash, /
, and then type what you’re looking for (less
has familiar keybinds to vim)
If you prefer grep
that’s alright too either way, we should see what we’re looking for.
1 | > strings out | grep "flag" |
Obviously, this looks nothing like our flag, so it’s likely to be an encrypted flag.
Decrypting the flag
A great tool for decryption is Cyberchef. This can put our encrypted flag in the “input” field, and under “Operations” we can search for “Magic” and drag that into the “Recipe” field.
flag: picoCTF{U9X_UnP4ck1N6_B1n4Ri3S_371aa9ff}