import vt import time import json import sys import hashlib import msvcrt as m TOKEN = "Your virustotal token" BUF_SIZE = 65536 md5 = hashlib.md5() sha1 = hashlib.sha1() client = vt.Client(TOKEN) def main(): print("**VF AntiVirus V2.0 BY Dr.Cyber32**\n\nSelect one of the options:\n\n[1] Check a hash\n[2][SOON] Check a file\n[3] Check a file from database\n[4] Check a URL\n") selection = int(input("=> ")) if selection == 1: xhash = input("Enter file hash => ") hashcheck(xhash) client.close() wait() exit() if selection == 2: xfile = input("Enter file address => ") filecheck(xfile) filecheckdb(xfile) client.close() wait() exit() if selection == 3: xfile = input("Enter file address => ") filecheckdb(xfile) client.close() wait() exit() if selection == 4: xurl = input("Enter a URL or an IP address => ") urlcheck(xurl) client.close() wait() exit() else: print("ERROR: UNKNOWN SELECTION!") client.close() wait() exit() def wait(): print("Press any key to continue...") m.getch() def hashcheck(fhash): try: file = client.get_object("/files/{}".format(fhash)) outjson = json.dumps(file.get("last_analysis_stats")) out = json.loads(outjson) print("harmless: {}\ntype unsupported: {}\nsuspicious: {}\ntimeout: {}\nfailure: {}\nmalicious: {}\nundetected: {}".format(out["harmless"], out["type-unsupported"], out["suspicious"], out["timeout"], out["failure"], out["malicious"], out["undetected"])) except: print("ERROR: HASH NOT FOUND IN THE DATABASE") def filecheck(ffile): try: with open(ffile, "rb") as f: analysis = client.scan_file(f) while True: analysis = client.get_object("/analyses/{}", print(analysis.status) if analysis.status == "completed": break time.sleep(5) except: print("UNKNOWN ERROR!") def urlcheck(furl): try: url_id = vt.url_id(furl) url = client.get_object("/urls/{}", url_id) outjson = json.dumps(url.get("last_analysis_stats")) out = json.loads(outjson) print("harmless: {}\nmalicious: {}\nsuspicious: {}\nundetected: {}".format(out["harmless"], out["malicious"], out["suspicious"], out["undetected"])) except: print("URL NOT FOUND!") def filecheckdb(xfile): try: with open(xfile, 'rb') as f: while True: data = if not data: break md5.update(data) sha1.update(data) try: print("Checking database with sha1: {}".format(sha1.hexdigest())) hashcheck(sha1.hexdigest()) except: print("\nChecking database with md5: {}".format(md5.hexdigest())) hashcheck(md5.hexdigest()) print("\n") except: print("ERROR: WE'VE GOT PROBLOM WITH READING FILE!") main()