Happy New Year 2018 – Challenge Solution

Credit to Author: SSD / Noam Rathaus| Date: Mon, 08 Jan 2018 06:15:57 +0000

Want to get paid for a vulnerability similar to this one?
Contact us at: sxsxdx@xbxexyxoxnxdxsxexcxuxrxixtxy.xcom
See our full scope at: https://blogs.securiteam.com/index.php/product_scope

In our post found here: https://blogs.securiteam.com/index.php/archives/3616, we hid a challenge.

The challenge was split into two parts:
1. Finding it
2. Solving it

Finding it wasn’t very hard, the challenge was hidden inside the image, it wasn’t anything fancy, just inside the image you had a zip file appended to the end of the file:

If you binwalk inspect the file you will see:

This looks really promising now, a ZIP file has been appended to the image, and binwalk tells us it’s located at offset 81481. We can use dd to get the archive.

Binwalk also tells us, there are two files inside the archive (challenge and README). Use unzip to get them.

(NOTE: If you downloaded the file to a Linux machine (though other machines may have also worked), and just unziped it you got two files:
1. README
2. challenge

There was no need to use dd)

The readme was pretty simple, just instructed you to make the challenge ELF binary file spit out text:

From this point the solution varied, our first solver reversed engineered the file and discovered what it does, which basically breaks down to:

The program executes the following actions:

  • Open an encrypted file named “eapfxlya” (this can be confirmed with strace)
  • Generate a 32-bit key based on “xFFx6Bx28x66xD6x35xDAx01x4Dx64x47xA3” (see function keyhash)
  • Read the contents of the opened file
  • Decode it with XOR/ADD/MUL/SHR tricks (see function decode)

The keyhash function is pretty straight-forward so let’s have a closer look at the decode function. It’s purpose is to generate a sequence of 32-bit numbers based on a linear congruential generator (aka *predictive* pseudo number generator) which takes a precomputed hash for seed. Each number of this sequence is then shifted right and used as a 8-bit xor-mask on every byte in the file stream. In conclusion, this program can be used to decode and encode any file in a symmetric way. So let’s use the happy new year string “Happy New Year! From Beyond Security SSD :)” and feed it into the reversed program.

Congratulations to: Alexandre for solving the challenge first (within 2 hours of posting it online).

A few other solutions we received included a brute forcing code (a cool one from Tukan):

Print Friendly, PDF & Email

https://blogs.securiteam.com/index.php/feed