我有一些網站已遭到攻擊並感染了惡意軟件。Linux使用字符串查找文件並替換
有800多個文件需要更新,並且每個文件中的字符串完全相同。
我想要做的是找到所有具有惡意軟件的文件,然後從文件中刪除有問題的字符串。
我已經發現了一些當上基本字符串測試其做工精細的命令行腳本:
perl -pi -w -e 's/string_to_find//g;' test-file.php
,當組合成find命令:
發現。 -type f | xargs grep'string_to_find'-sl | xargs perl -pi -w -e's/string_to_find // g;'
現在,我的問題就是如何讓這對這是一個非常漫長而複雜的字符串,字符串工作:
<?php @error_reporting(0); if (!isset($eva1fYlbakBcVSir)) {$eva1fYlbakBcVSir = "random_string_7365_characters_long";$eva1tYlbakBcVSir = "string_of_encoded_characters";$eva1tYldakBcVSir = "string_of_encoded_characters";$eva1tYldakBoVS1r = "string_of_encoded_characters";$eva1tYidokBoVSjr = "string_of_encoded_characters";$eva1tYldokBcVSjr=$eva1tYldakBcVSir($eva1tYldakBoVS1r);$eva1tYldakBcVSjr=$eva1tYldakBcVSir($eva1tYlbakBcVSir);$eva1tYidakBcVSjr = $eva1tYldakBcVSjr(chr(2687.5*0.016), $eva1fYlbakBcVSir);$eva1tYXdakAcVSjr = $eva1tYidakBcVSjr[0.031*0.061];$eva1tYidokBcVSjr = $eva1tYldakBcVSjr(chr(3625*0.016), $eva1tYidokBoVSjr);$eva1tYldokBcVSjr($eva1tYidokBcVSjr[0.016*(7812.5*0.016)],$eva1tYidokBcVSjr[62.5*0.016],$eva1tYldakBcVSir($eva1tYidokBcVSjr[0.061*0.031]));$eva1tYldakBcVSir = "";$eva1tYldakBoVS1r = $eva1tYlbakBcVSir.$eva1tYlbakBcVSir;$eva1tYidokBoVSjr = $eva1tYlbakBcVSir;$eva1tYldakBcVSir = "string_of_encoded_characters";$eva1tYlbakBcVSir = "string_of_encoded_characters";$eva1tYldakBoVS1r = "string_of_encoded_characters";$eva1tYldakBcVSir = "";$eva1tYldakBoVS1r = $eva1tYlbakBcVSir.$eva1tYlbakBcVSir;$eva1tYidokBoVSjr = $eva1tYlbakBcVSir;} ?>
現在,當我嘗試搜索,並與完整的字符串替換(轉義所有的特殊字符)我得到這樣的結果:
Possible unintended interpolation of @error_reporting in string at -e line 1.
Name "main::error_reporting" used only once: possible typo at -e line 1.
是否有可能做什麼,我試圖做的或者說是不可能的字符串來捕捉?我需要以不同的方式轉義@符號嗎? (我逃過了\和沒有工作)
任何幫助 - 我使用bash和Perl
FAQ http://learn.perl.org/faq/perlfaq6.html#How-can-I-quote-a-variable-to-use-in-a-regex- – daxim 2012-03-27 22:21:04
感謝daxim - 我沒有想學perl – 2012-03-28 01:17:05