Thursday, September 23, 2010

Removing malicious Code

Removing malicious Code from your pages:-

Once your server compromised or hacked, most case they have insert some malicious Codes/ scripts on all your web pages. So these following commands will help you to remove completely from your server.

First we need to identify which files are infected with malicious Code/malicious Scripts, for that we can use the following command
1. grep -Ri SEARCH WORD DIRECTORYNAME
OR
2. grep -Ri --files-with-matches 'searchword' directorname(or). for current directory

Script for searching a word in a file and delete that line

#!/bin/bash
grep -rl --include=*.{php,js,html} 123 $1 | xargs sed -i".bckp" '/123/d'
rm -f $1/*.bckp

No comments:

Post a Comment