Example: Customer has been a victim of iframe code injections in multiple pages. Use 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, be sure to backup first!
this will remove all iframe injections from a particular file or wildcard set of files
usage example: ./rmcodeinjections.sh *.php
Example: Replacing /var/named domains IP addresses with perl
Sometimes you need to replace an instance of one string in a file with another string. If there’s multiple occurrences, this can be a pain. Here’s a simple example of how you can use perl to replace all instances of an IP address for a moved a domain.
To do it:
perl -i.bak -pe “s/0.0.0.0/220.127.116.11/g” /var/named/domain.com.db
This example shows how to change from IP 0.0.0.0 to 18.104.22.168
This will also makes a backup of /var/named/domain.com.db as /var/named/domain.com.db.bkp
If you’re feeling ballsy and do not want backup run:
perl -i -pe “s/0.0.0.0/22.214.171.124/g” /var/named/domain.com.db
One alternate way would be (without perl):
replace 0.0.0.0 126.96.36.199 — /var/named/domain.com.db