DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Douglas has posted 2 posts at DZone. View Full User Profile

Search & Replace Iframe Hacked Files On Webserver

  • submit to reddit
        // If you've suffered iframe injections in your index.html and index.php files then this grep/sed command will come in handy for clearing the majority of them out.
// Please be careful and test first with just the grep command to ensure you don't clear out anything you need.
// Does NOT backup files.

grep -lr -e '<iframe src="http://.*</iframe>' * | xargs sed -i 's/<iframe src="http:\/\/.*<\/iframe>//g'


Snippets Manager replied on Mon, 2012/05/07 - 2:12pm

I want to replace http:// with the actual site address for e.g. What changes needs to be done?