My CMS is full of SPAM scripts and they are almost in every folder. I figured out, that I can find those scripts by using this find/grep command:
sudo find . -type f \( -name '*.php' -or -name '*.node' \) -exec grep -i "eval(base64_decode" {} +
Well some of the files just contain the spam-script and they are between 300 - 302 Bytes.
But some other files, which are been used by the CMS, are also infected. They should not be deleted completely, just everything from the first character untill the first php closing ("?>").
First I used the "delete" command and wrote this:
sudo find . -type f \( -name '*.php' -or -name '*.node' \) -exec grep -i "eval(base64_decode" {} + -delete
But that was a big mistake because I deleted all my important files. Before I delete more files, I just wanted to ask how to do it?
Something like: Get every file the code above finds and check if it is between 300 - 302 bytes, if yes -> delete it. If no -> Delete the first PHP section. But important!!! Not deleting the rest! The file is like:
<?php ?> ... <?php ?> ... <?php ?>"
only the first PHP block is infected.
Please can you help me? There are hundreds of files and I don't wanna do this by my own.
Thanks a lot in advanced!