Virus Removal Groovy Script

[ This Blog Was Moved To : http://www.diknows.com ]


As I’m a Linux User since years ago. I faced the problem of NO Viruses at my PC, but tons of viruses on my Flash Memory ( USB Stick ), due to copying files to/from windows machines.

Actually, I was never affected by these viruses on my own, but I do NOT want to be a transportation facility for the virus to spread across other machines.

I noticed that there are two simple types of viruses that usually get attached to the memory stick.

  1. A .inf file and a .exe file that ofcourse got a strange name that I can visually detect and manually remove at linux.
  2. A .exe file gets the name of the super directory with the addition of the extension .exe. Which was usually easy to detect visually but hard to remove manually due to the amount of folders on the memory.

So, to fasten the process of  removing the second virus, I wrote this simple Groovy script ( which is in fact a reflection of  an old Java program that I created for the same virus years ago )

// Searchs for the .exe Virus that has the same name of its parent directory
checkVirus = { folder ->
    folder.eachFile{ file ->
        if(file.isDirectory()){
            checkVirus(file)
        }else if ("${folder.name}.exe" == file.name ){
            it.delete()
        }
    }
}
checkVirus (new File('/media/disk/'))

And this is it. Any enhancements or suggestions will be great.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: