I have a virus that has infected thousands of files on one of my client’s server.
Fortunately, I have dealt with a lot of other malware on this guy’s server and this one looks easy to do simple regex on (he put all his websites on the same account 🙁 but I’m working with him to resolve that).
Basically though, unlike most malware I have seen where it injects php BEFORE the closing ?> of the GOOD code (making it very hard to determine whats good code/bad code), this current malware ALWAYS adds a new <?php ... malware ... ?>
.
So basically, say there’s good code here:
<?php
require('./wp-blog-header.php');
?>
Instead of adding some kind of base64_decode eval immediately after the require statement but before the ?> (which can make removal difficult when the page happens to end in a conditional/complex statement), this will always add the following code with a NEW <?php ... ?>
like so:
<?php
require('./wp-blog-header.php');
?><?php ... malware ...?>
I don’t want to put any malicious code up here but, this is how the malicious code always starts:
<?php @error_reporting(0); if (!isset($eva1fYlbakBcVSir)) {$eva1fYlbakBcVSir = "tons and tons of characters";$eva1tYlbakBcVSir = "x633514433x6f1534x70170x65";$SNIPSNIPSNIPSNIP;} ?>
I’d like to search every file for <?php @error_reporting(0); if (!isset
and if it’s the last PHP statement on the page, then delete everything within the
Here is how you clean the entire project with pure php.
Good Luck.
UPDATE (With Regex):
So far this is the closest (thank you mvds)
sed -e "s/<?php @error_reporting.*?>//g" --in-place=_cleaned *
although –in-place=_cleaned is giving the error
sed: illegal option -- -