#!/usr/bin/python
######################################################
# Script for virus cleaner                           #
# Version : 1.1                                      #
# By : HOSSAM                                        #
# Site  : www.tl4s.com.sa                            #
# Email : hossam@tl4s.com                            #
######################################################
#
import sys, os, fileinput

V = "Version 1.1"
if len(sys.argv) <2:
        while True:
                choose_vcode = raw_input("\nPut the virus code : ")
		print "\nAre you sure this is right virus code ?"
		print "Put \033[32m[yes]\033[0m to continue or \033[32m[no]\033[0m to retry."
                choose_confirm = raw_input("Enter : ")
                if choose_confirm == "yes":
			break
                elif choose_confirm == "no":
                        print "\033[31mTry again\033[0m"
                        continue
                else:
                        continue

	while True:
		print "\nPut the path to scan\nFor example : /home/user/public_html"
		choose_path = raw_input("Put the path : ")
		if len(choose_path) <= 3:
			print "\033[31mNot valid input\033[0m"
			continue
		elif os.path.exists(choose_path):
			for (path, dirs, files) in os.walk(choose_path):
				for file in files:
					filename = os.path.join(path, file)
					for line in fileinput.FileInput(filename, inplace=1):
						line = line.replace(choose_vcode, "")
						print line,
			print "\n\033[32mdone\033[0m\n"
			print "Notice : For more information use --help\nFor example : vscan --help\n"
			sys.exit()
		else:
			print "\033[31mPut valid Path\033[0m"
			continue

####################################
##--[  Information and options ]--##

if sys.argv[1].startswith("-"):
        option = sys.argv[1][2:]
        if option == "v":
                print "\nVirus Cleaner : %s\n" % (V)
                sys.exit()
	elif option == "author":
		print "\nThis script by HOSSAM\nSite : http://www.tl4s.com.sa\n"
	elif option == "about":
		print "\nThis Script Python programing language .. for virus clean up.\nWorking on Linux/Unix servers.\n"
	elif option == "help":
		print '''\nOptions include:
		--v      : Prints the version number.
		--author : About script author.
		--about  : Information about script.
 		--help   : For help.\n'''
        else:
                print "\nUnknown option.\nUse --help .. to find out what options.\n"
                sys.exit()
