Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to delete a php code on all my php files on my debian server. indeed I would like to get rid of a line:

eval(base64_decode("DQplcnJvcl9yZXBvcnR"));

It's present in many of my phpfiles. That's why I would like to find a script which is going to look it up in all my php files and replace itwith nothing? Do you have any idea how i could do that ? I know how to do it on windows with some software (notepad++ is very useful) but no idea how can I do that in a command line through ssh

Thanks for your answer.

share|improve this question
add comment

1 Answer 1

In C shell, you could do something like this:

foreach i ( `find -name "*.php"` )
   sed '/^eval(base64_decode("DQplcnJvcl9yZXBvcnR"));$/d' $i > $i.new
   mv $i.new $i
end

In bash, it would look like this:

for i in $(find -name "*.php"); do
   sed '/^eval(base64_decode("DQplcnJvcl9yZXBvcnR"));$/d' $i > $i.new
   mv $i.new $i
done
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.