2

不幸的是,我再次处理 Linux Plesk 服务器上的一个被黑站点。虽然问题已通过更改 FTP 访问得到解决(它归结为 PC 上著名的 Filezilla FTP 代码黑客攻击),但我很高兴知道如何编辑文件,因为可能需要一个多小时才能将站点恢复到最近的备份我们有,我很高兴能更快地重新上线。hack 相当简单:在站点的许多 index*(似乎只有 index.php)文件中插入了一个 javascript 代码。我正在寻找一种大规模编辑被黑文件的方法,我知道即使目标 javascript 代码是相同的,它也是从许多可能也被黑的网站调用的。因此,虽然我的合法索引文件曾经以

<?php

现在开始像

<script type="text/javascript" src="http://(RANDOMDOMAINHERE)/facebook.php"></script><?php

由于该链包含一个变量,您能帮我找到一个可靠的方法来编辑所有更改的索引文件(找到大约 80 个)吗?我以前使用过 SED 替换,但这次替换链的一部分有所不同,所以我可以使用通配符吗?最好的问候,谢谢你的光!

4

3 回答 3

3
find -name 'index.php' -print0 |
    xargs -0 sed -i '1s#^<script type="text/javascript" src="http://.*\?/facebook.php"></script>##g'

应该创造奇迹

sed 命令:

  • 1 (匹配第一行)
  • s#pattern#replacement#g(通过替换替换模式,并不是说后者是空的)
  • ^必须在行首匹配
  • .*\?接受任意长度的字符序列;但是,如果可以对整个模式进行多个匹配,则只匹配它的最短可能变体

干杯

于 2011-04-21T22:39:39.683 回答
1

I sincerely hope your not actually adminning a production domain. You should inform your users, get the problem fixed, offer the users to go back to a recent backup that hasn't got the problem.

There is no telling what else has been tampered with.

I'm glad my VPS is somewhere else!

于 2011-04-21T22:11:06.060 回答
-1

I would fix the Cross side scripting exploit before this problem is addressed or it will all be in vain. When thats done a simple search and replace of blocks of script that contain a common string should be sufficient.

于 2011-04-21T22:09:54.337 回答