5

Recently my company got a widespread phishing email sent to them, thankfully no one clicked the link (which is great!)

Since I'm a student and a current intern working in IT Security I wanted to see what this phishing email contained.

I started with running a cURL command on the link and got another link inside of it. Basically the link referenced the second url and refreshed every 2 seconds.

I used a cURL command on that link and got this following in the header response

(Removed link and domains to prevent infection!)

HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Sat, 21 May 2016 22:07:32 GMT
Content-Type: text/html
Content-Length: 4713
Connection: keep-alive
X-Powered-By: ARR/2.5(bb4753d98)
Set-Cookie: AFFID=370951; expires=Mon, 20-Jun-2016 22:07:26 GMT;     Max-Age=2592000; path=/; domain=.XXXXX.(com)
Set-Cookie: SID=20AAA; expires=Mon, 20-Jun-2016 22:07:26 GMT;     Max-Age=2592000; path=/; domain=.xxxxx.(com)

Inside that body, was a javascript containing this code.

var lOO = '==gCpkSKnw3JoQXasB3cuciZ0ADM1xXMzADM1xXZwF2YzVmb1xHduVWb1N2bkxnNzADM1xXZ0lmc3xnNyADM1xnchZHf5MDMwUHfyYDMwUHfjNDMwUHf8xHO3ADM1xXY2ADM1xXMyADM1xnZzADM1xHZ3ADM1xXO3ADM1xXYzADM1x3NyADM1xnZ1ADM1xnY3ADM1xHZ2ADM1xXZzADM1xnYzADM1xHO2ADM1xHZyADM1xnN3ADM1x3N3ADM1xHM3ADM1xHNzADM1xXN0ADM1xXN3ADM1xHOyADM1x3N2ADM1xXOyADM1x3Y2ADM1xHN2ADM1xnZyADM1x3M3ADM1xHZzADM1xXOwADM1xnN2ADM1xXZwF2YzV2X8FGMwATd8RzNwATd8ljMxwnM2wnN1wXZ2ADM1xXO2ADM1xXM2ADM1x3M2ADM1xXZyADM1xnM3ADM1xnMyADM1xnY2ADM1xnZ2ADM1xHMyADM1xXN2ADM1xHbhZXZ8RXasB3c8RnbJV2cyFGc8BHeFdWZSxXZk92QyFGaD12byZGfn5WayR3UvRHf3Vmb8ZWa8dmbpJHdTxHflxWaodHflNWYsBXZyxnbvlGdj5WdmxnbyVHdlJH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oUmOncyPhxzYo4mc1RXZytXKjhibvlGdj5Wdm1TZ7lCZsUGLrxyYsEGLwhibvlGdj5WdmhCbhZXZ';

    function OII(data) {
        var _1O0lOI = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
            enc = '';
        do {
            h1 = _1O0lOI.indexOf(data.charAt(i++));
            h2 = _1O0lOI.indexOf(data.charAt(i++));
            h3 = _1O0lOI.indexOf(data.charAt(i++));
            h4 = _1O0lOI.indexOf(data.charAt(i++));
            bits = h1 > 16 & 0xff;
            o2 = bits >> 8 & 0xff;
            o3 = bits & 0xff;
            if (h3 == 64) {
                enc += String.fromCharCode(o1)
            } else if (h4 == 64) {
                enc += String.fromCharCode(o1, o2)
            } else {
                enc += String.fromCharCode(o1, o2, o3)
            }
        } while (i = 0; i--) {
            ret += string.charAt(i);
        }
        return ret;
    }
    eval(OII(_1O0(lOO)));

Seeing that this is a Base64 Decode I ran it in a compiler, instead of using eval() i used console.log() to print out the results.

eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('2i(26(p,a,c,k,e,d){e=26(c){25(c35?2a.2e(c+29):c.2d(36))};2b(!\'\'.27(/^/,2a)){28(c--){d[e(c)]=k[c]||e(c)}k=[26(e){25 d[e]}];e=26(){25\'\\\\w+\'};c=1};28(c--){2b(k[c]){p=p.27(2c 2f(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c])}}25 p}(\'1p(U(p,a,c,k,e,d){e=U(c){W(c1s?1r.1m(c+1g):c.1f(1e))};1h(c--){1i(k[c]){p=p.1k(1j 1o(\\\'\\\\\\\\b\\\'+e(c)+\\\'\\\\\\\\b\\\',\\\'g\\\'),k[c])}}W p}(\\\'M I=\\\\\\\'%H%b%8%a%3%o%4%2%4%C%o%0%h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%4%u%0%p%q%3%7%c%p%5%6%3%t%5%7%b%f%6%0%4%g%y%v%9%A%9%H%g%b%8%a%3%o%4%J\\\\\\\';[removed for protection]|2Z|2M|2N|2O|2L|2K|2H|2I|2J|2P|2Q|2W|2X|30|2Y|2V|2U|2R|2S\'.2h(\'|\'),0,{}))',62,204,'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||return|function|replace|while||String|if|new|toString|fromCharCode|RegExp|parseInt|split|eval|u0065|u0020|u006f|u006b|u0022|u0072|u002e|u0063|u0061|u0069|u006e|56|62|129|u0074|u000a|_escape|u0066|u0009|u003d|u0073|u002f|u0064|u006c|u0029|u0067|u0028|u0075|u0045|u0034|u0070|u0077|u0076|u002d|u0068|u003b|u003e|u006d|u007b|u005f|u0027|u003a|u0079|u007d|u003f|u0021|u006a|u0078|||u003c|u0062|u0039|var|u0026|write|u0036|document|unescape|u0031|u004f'.split('|')))

I ran that in http://jsbeautifier.org and got there results returned

var _escape = '%u003c%u0073%u0063%u0072%u0069%u0070%u0074%u0020%u0074%u0079%u0070%u0065%u003d%u0022%u0074%u0065%u0078%u0074%u002f%u006a%u0061%u0076%u0061%u0073%u0063%u0072%u0069%u0070%u0074%u0022%u003e%u000a%u0066%u0075%u006e%u0063%u0074%u0069%u006f%u006e%u0020%u0061%u0072%u0065%u005f%u0063%u006f%u006f%u006b%u0069%u0065%u0073%u005f%u0065%u006e%u0061%u0062%u006c%u0065%u0064%u0028%u0029%u000a%u007b%u000a%u0009%u0076%u0061%u0072%u0020%u0063%u006f%u006f%u006b%u0069%u0065%u0045%u006e%u0061%u0062%u006c%u0065%u0064%u0020%u003d%u0020%u0028%u006e%u0061%u0076%u0069%u0067%u0061%u0074%u006f%u0072%u002e%u0063%u006f%u006f%u006b%u0069%u0065%u0045%u006e%u0061%u0062%[removed for protection];
document.write(unescape(_escape));

After that I took the code replaced document.write with console.log and came back with the following javascript.

    function are_cookies_enabled() {
        var cookieEnabled = (navigator.cookieEnabled) ? true : false;

        if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
            document.cookie = "testcookie";
            cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
        }
        return (cookieEnabled);
    }
    if (are_cookies_enabled()) {
        window.location.href = 'website';
    } else {
        window.location.href = 'certain website';
    }

Seeing these two websites I used cURL on the first link and got returned this header

HTTP/1.1 301 Moved Permanently
Server: nginx/1.8.1
Date: Sat, 21 May 2016 21:42:15 GMT
Content-Type: text/html
Content-Length: 33
Connection: keep-alive
X-Powered-By: ARR/2.5(441192e35)
Location: (link to second website in javascript)

The body of this link contained a redirect to the second link. Running cURL on that I got this header response

HTTP/1.1 302 Found
Server: nginx/1.9.9
Date: Sat, 21 May 2016 21:42:38 GMT
Content-Length: 11
Connection: keep-alive
location: (link to header response from first link)

The body contained was a "redirecting". Apparently pointing back to the second link with the header cookies as seen above, setting the cookie to a domain path.

So my question is, have I de-obfuscated the code correctly? Is this malware trying to create a test cookie and redirect to another malicious website?

I just really want to understand why not just run the javascript right there instead of redirecting all over the place? And what is the purpose of setting the cookie to the domain? Is it a backdoor, botnet, ddos?

3
  • 8
    A side note concerning your method: Generally, try to run curl with an unsuspicious user agent when dealing with potential malware. Otherwise it's easy to detect that you're trying to analyze the code and they might serve you different content than to an ordinary visitor.
    – Arminius
    May 21, 2016 at 23:29
  • @Arminius thank you! that makes sense, since the website might detect im using linux instead of windows or macOS. So would spoofing the User Agent in curl with the -a command work?
    – J.Halon
    May 21, 2016 at 23:34
  • 1
    Yes, a forged user-agent header with curl -A should be fine.
    – Arminius
    May 21, 2016 at 23:39

2 Answers 2

2

There are multiple reasons for this (sending data all over the place). If you are phishing with the intent of exploiting something, you may have something like mod_redirect running in the background to target specifics. E.g.:

if UserAgent = IE && Windows 7
then
send them to this particular page with Win7 IE specific exploits

or

if UserAgent = Mozilla && OSX
then
send them to this page with OSX exploits

But let's say it's a malvertising phishing scam of sorts. An attacker could do it based on geographic location for example: "If user is coming from the US send them to a site that sells Levitra... If they are coming from the UK send them to this page that sells Viagra"

There are plenty of reasons to do it outside of detection (someone reversing the phish). "If someone is coming from a .mil && they use IE && their running WinXP" Anything that can be thought out can be a legitimate reason for an attacker to maximize their capabilities to exploit something. Even if the exploit is NOT a system based exploit. "Let's exploit the fact Levitra sells better in the US, than in the UK."

1

The Malware creator might use the various points of redirection to change the behaviour of the script after it has been deployed to its target, maybe all systems are under the attackers control and he chooses to redirect different targets to different locations. Another possible answer is that the attacker prepared for the loss of access to one of the (most probably hijacked) servers. When lost, changing the redirection to another Location is much easier than deploying another script to the target.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .