NOTE: Exploit Kit sample used in this post was captured in September 2014. Taking the ever changing nature of EKs, the described below might not be applicable to the newer variants.
'Nuclear launch detected'
I'll be using Nuclear EK landing page sample here. Note a huge blob of numbers stored in 'G4Ah' variable and a string stored in 'qjv' variable. The string serves as a lookup key and the numbers blob is actually a sequence of 2 digit numbers that are used to find a character in 'lookup key' at the position = 2 digits value. The JavaScript on the landing page does quite a simple job - it splits the blob into 2 digits chunks, loops through each chunk value to find the corresponding character in the 'lookup key' and adds the found character to a string. This might sound a bit confusing, so let's translate it into a Python script to better understand it.
lookupKey = "LOOKUP_KEY_GOES_HERE" encodedString = "NUMBERS_BLOB_GOES_HERE" listOfValues = map(''.join, zip(*[iter(encodedString)]*2)) decodedString = "" for index in range(len(listOfValues)): if int(listOfValues[index]) < 10: element = int(listOfValues[index]) else: element = int(listOfValues[index]) - 2 decodedElement = lookupKey[element] decodedString += decodedElement print(decodedString)
You'll notice an 'if' condition in the 'lookup' loop - for any value greater than 10 subtract 2 from it and then perform the lookup. This is done to compensate for the escape '\' characters in the lookup key. I'm not entirely sure why '10', but assume the code logic that generates the key will not include characters that require escaping into the first 10 character positions of the key.
Before we can run the script we need to put the values into 'lookupKey' and 'encodedString'. Where the value for 'encodedString' is hard to miss in the landing page code, the value for 'lookupKey' might be challenging. From my personal experience with Nuclear EK landings, I found that the characters positions in the key are random, but its size is always 95 characters. The simplest, but not always reliable way to find the lookup key is to search for a variable assigned a long string value. If this method fails you'll have to follow the JavaScript code to find it.
Now, if we use the corresponding values from our landing page sample and run the script, we get the following output.
Another KISS approach to data obfuscation. Happy deobfuscation!
No comments:
Post a Comment