Brilliant Javascript Obfuscation Technique

One of the guys over at BreakingPoint Systems detailed a cool, new Javascript obfuscation technique. You can click here to view his blog post.

The technique he described is based on Javascript’s toString method and a base 36 radix. For those of you who don’t know, the toString function allows you to convert a number object into a string. Here’s an example:

What I didn’t know was that you can do this with it:

Isn’t that clever?! With this technique, you can hide key functions like “eval” in plain sight!

Now that you know how this technique works, you can practice what you’ve learned in a Javascript obfuscation contest. BreakingPoint will be giving you a chance to win an iPad if you can deobfuscate their script. You have until September 14, so get cracking! Here’s the link to their contest!

By the way, their obfuscated script is pretty challenging. You can crack it with a debugger but notepad and IE works just fine too.

Update (5/21/16): Greek translation provided by Nikolaos Zinas

Posted in Malscript | Tagged , , | 5 Comments

Unknown Exploit Pack Gets Updated

I tracked this exploit pack back in November. Several months later, the pack re-emerged but seemed to have been updated.

This is what the obfuscated Javascript looked like back then. The top part had this gibberish, the middle section contain a lot of arrays, and at the end, the Javascript code concatenated the parts after doing some XOR’ing. Back then, it used PDF, Java, Real, HCP, and WMV exploits.

Here’s what it looks like this time around. It looks familiar.

The middle section contains variables instead of arrays. The bottom portion was the script that converted that middle section to another set of Javascript code.

This new code decrypted the gibberish up at the top. Just paste that portion onto the bottom like so:

Now you can get to see the final code which contains the exploits.

Unfortunately, I wasn’t able to grab these other files to see exactly which exploits were being used but since there was a lot of code overlap from the previous version, I’m sure most are the same.

Here’s the login screen to the panel.

Anyone know what pack this is?

Posted in Exploit Packs | Tagged , | 1 Comment

Wild Wild West – 09/2011

added Micro-Pack Exploit System and Punchy-Pack Exploit System

 

Posted in Exploit Packs | Leave a comment

Converter Tool Released

I’ve received a ton of requests for the Converter tool. I use this tool a lot to help me analyze and reverse obfuscated Javascript (among other things) and I hope you will find it useful yourself.

I haven’t encountered any major bugs but it doesn’t mean it doesn’t exist. 😉 This software is being made available as-is without any warranties. The original executable is 1.34MB so I packed it with UPX down to 65KB and as a result, it may trigger some AV (VirusTotal does show three hits but it’s not at all malicious; Anubis confirms this). If you are worried, analyze it in a VM or simply don’t use it.

If you have requests or found bugs, I’ll try to look at them but no promises. I have quite enough on my plate as it is!

Download: http://www.mediafire.com/?5dz26rqx5qcac3e
MD5: 33e8c227764148440e5729c599c989f2

Posted in Tools | 4 Comments

A Tricky Obfuscated JavaScript

A reader sent in obfuscated Javascript code that he needed some help to decipher. I’m sure he was very close to solving it but it looked interesting enough that I thought I would have a go at it and detail how I deobfuscated it.

If you search for certain parts of the script, you’ll find the complete version here which was uploaded to Pastebin back on June 8, 2011.

This is a very long script but basically it decrypts obfuscated code and then attaches the resulting script to the DIV containers that you see at the top of the page. All of the functions call one routine to deobfuscate and another to attach itself to the DIV. Since this is such a long piece of code, I won’t go through it all but instead step through the main deobfuscation routine and then show you how to get to the decrypted exploit code in one pass.

The deobfuscation function is called “fez” and it’s a rather clever routine actually. To call it, the script passes two arguments over to it, a string of characters and a number. Let’s look at an example:

hoe = ‘efB58194A8onn871k0L02U’;
pus = 16;
luv = fez(hoe, pus);

Here’s the function in question (I’ve included the input field which I’ll explain why in a minute);

The first part of the function defines some variables. There’s an eval statement which assigns the document object to a variable. This is here to break tools that can’t handle “evals”. Next comes the first of two for-loops.

This routine will loop through the length of variable “hoe” that we passed to variable “l”. It then gets the character at position 0 of “hoe” which is “e”. The letter “e” is then searched for in the decryption key. Where’s the key? It’s the value of the hidden input field up at the top. The result is “20” because the letter “e” is at the 20th position. The value 20 is then added to the value we first passed to this function which is 16 (the “pus” variable).

20 + 16 = 36 and 36 mod 31 (which is the length of the key) is 5 (which is held now in variable “a”). It then looks up the 5th position of the key and gets that character which is “6”. Keep looping until you’re done and you’ll end up with this result: “6a617661456e61626c6564”

Now we get to the second for-loop. This routine loops the length of “hoe” as well. The variable “v” gets assigned: 6a617661456e61626c6564[substr](s,q). The variable “s” is the number of times we’ve looped which is 0. The variable of “q” has been defined earlier as “2”. So this statement basically extracts the first two characters of the result which is “6a”. This hex value is then converted to decimal which is 106. And finally this decimal value is converted to text which is the letter “j”. Loop through the rest and you’ll get the final result of: “javaEnabled”

Whew! But that was fun, wasn’t it?

The rest of the script works the same way and you just have to do it in segments and join the strings together to get the sum. If you’re impatient and want to see the whole thing then you need a way to trap the deobfuscated script up at the DIVs. Normally you can do it like this.

Change this:
<div id=”nun”></div>

To this:
<textarea id=”nun”></textarea>

This works if the script attaches to the ID value of “nun” in this instance (e.g. getElementById). However, this script specifically looks for DIVs so this won’t work (e.g. getElementsByTagName).

After fiddling a bit, I found a new way to do this (new to me anyway)…

Change this:
<div id=”nun”></div>

To this:
<textarea div id=”nun”></textarea>

Here’s how it looks before and after:

And then when you run through the script, the deobfuscated script shows up in the respective text boxes:

Just select and copy to Notepad so you can see the script in its entirety:

This method works great in Firefox and Chrome but not IE. For IE, you need to do it the old fashion way which is to loop through all the DIV tags then capture the innerHTML in a textarea like so:

You’ll end up with the same result above.

This looks like the work of an exploit pack, a new pack that I haven’t seen before. If anyone knows from which pack, I’d be very curious to find out.

Posted in Malscript | Tagged | 2 Comments