views:

37

answers:

2

So I just got my sorry ass hacked, the hack put some obscure string in almost every one of the php files on my website. How can I remove every instance that line occurs?

The code it added started with <?php so therefore I cannot simply replace it with blank, I need to delete it and move up the actual relevant code up one line as <?php cannot start on a white space...

+3  A: 

Try this:

find ./ -type f -name *.php -exec sed -i 's/stringtofind/stringtoreplacewith/g' {} \;

or this:

perl -p -i -e 's/stringtofind/stringtoreplacewith/g' `grep -ril stringtofind *`
Rufinus
+1  A: 

Your favourite IDE probably already have a find/replace in files/project function. If not try Notepad++ Press Ctrl-Shift-F to open the Find in Files dialog where you can specify the root folder, a *.php file filter and then use either the regular expression option or extended code option to zap the unwanted code. If you post a sample of a hacked file we might be able to help you with the exact string to specify.

JannieT