Wednesday, May 4, 2011

Virus Removing Script


There is a set of folders that were affected by virus from a Windows environment. The viruses are in the form of various windows executable formats like .bat, .com and .exe. What separates them from safe windows executables is that malicious ones have same name as their parent directory. Remove all such occurrences. (There can be many levels of folders)

find ./* | while read f
do
        if [ -d $f ]; then
                name=${f##*/}
                if [ -e $f/$name.exe ]; then
                        rm -f $f/$name.exe
                fi
                if [ -e $f/$name.com ]; then
                   rm -f $f/$name.com
                fi
                if [ -e $f/$name.bat ]; then
                    rm -f $f/$name.bat
                fi
        fi
done

No comments:

Post a Comment