#!/usr/bin/env python
import os, hashlib, sys, socket, string
for root, dir, files in os.walk(str(sys.argv[1])):
		for fp in files:
			try:
				fn = root+fp
				infile = open(fn, "rb")
				content = infile.read()
				infile.close()
				m = hashlib.md5()
				m.update(content)
				hash = m.hexdigest()
				try:
					mhr = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
				except:
					print "imposible crear el socket"
				try:
					mhr.connect(("hash.cymru.com", 43))
				except:
					print u"conexión imposible"
				mhr.send(str(hash + "\r\n"))
				response = ''
				
				print "solicitud para " + fp
				while True:
					d = mhr.recv(4096)
					response += d
					if d == '':
						break
				if "NO_DATA" not in response:
					print "<INFECTED>:"+str(fn)
			except:
				print u"excepción"
				pass

