def do_vt(self, line): try: l = line.split(" ") if (l[0] == ""): self.help_vt() else: id = int(l[0]) body, sz = get_response_size(id, "all") name = CTCore.get_name(id) print " VirusTotal result for object {} ({}):".format( str(id), name) + newLine import hashlib hash = hashlib.md5( StringIO.StringIO(body).getvalue()).hexdigest() vtdata = CTCore.send_to_vt(hash, CTCore.APIKEY) if vtdata[0] != -1: jsonDict = vtdata[1] if jsonDict.has_key('response_code'): if jsonDict['response_code'] == 1: if jsonDict.has_key('scans') and jsonDict.has_key('scan_date') \ and jsonDict.has_key('total') and jsonDict.has_key('positives') and jsonDict.has_key('permalink'): print " Detection: {}/{}".format( jsonDict['positives'], jsonDict['total']) print " Last Analysis Date: {}".format( jsonDict['scan_date']) print " Report Link: {}".format( jsonDict['permalink']) + newLine if jsonDict['positives'] > 0: print " Scan Result:" for av in jsonDict['scans']: av_res = jsonDict['scans'][av] if av_res.has_key( 'detected') and av_res.has_key( 'version' ) and av_res.has_key( 'result' ) and av_res.has_key('update'): if av_res['detected']: print "\t{}\t{}\t{}\t{}".format( av, av_res['result'], av_res['version'], av_res['update']) else: print " Missing elements in Virus Total Response" else: print " File not found in VirusTotal" else: print " Response from VirusTotal isn't valid" else: print vtdata[1] print "" except Exception, e: print str(e)
def do_vt(self,line): try: line = str(line) l = line.split(" ") if (l[0] == ""): self.help_vt() else: if not CTCore.VT_APIKEY: print newLine + "No Virus Total API key found, please enter your API key:", CTCore.VT_APIKEY = raw_input() id = int(l[0]) body, sz = CTCore.get_response_and_size(id, "all") name = CTCore.get_name(id) self.retval = " VirusTotal result for object {} ({}):".format(str(id),name) + newLine hash = hashlib.md5(StringIO.StringIO(body).getvalue()).hexdigest() vtdata = CTCore.send_to_vt(hash, CTCore.VT_APIKEY) if vtdata[0] != -1: jsonDict = vtdata[1] if jsonDict.has_key('response_code'): if jsonDict['response_code'] == 1: if jsonDict.has_key('scans') and jsonDict.has_key('scan_date') \ and jsonDict.has_key('total') and jsonDict.has_key('positives') and jsonDict.has_key('permalink'): self.retval += " Detection: {}/{}".format(jsonDict['positives'], jsonDict['total']) self.retval += " Last Analysis Date: {}".format(jsonDict['scan_date']) self.retval += " Report Link: {}".format(jsonDict['permalink']) + newLine if jsonDict['positives'] > 0: self.retval += " Scan Result:" for av in jsonDict['scans']: av_res = jsonDict['scans'][av] if av_res.has_key('detected') and av_res.has_key('version') and av_res.has_key('result') and av_res.has_key('update'): if av_res['detected']: self.retval += "\t{}\t{}\t{}\t{}".format(av, av_res['result'], av_res['version'], av_res['update']) else: self.retval += " Missing elements in Virus Total Response" else: self.retval += " File not found in VirusTotal" else: self.retval += " Response from VirusTotal isn't valid" else: self.retval += vtdata[1] self.retval += newLine except Exception,e: self.retval = str(e)
def do_vt(self,line): try: l = line.split(" ") if (l[0] == ""): self.help_vt() else: id = int(l[0]) body, sz = get_response_size(id, "all") name = CTCore.get_name(id) print " VirusTotal result for object {} ({}):".format(str(id),name) + newLine import hashlib hash = hashlib.md5(StringIO.StringIO(body).getvalue()).hexdigest() vtdata = CTCore.send_to_vt(hash, CTCore.APIKEY) if vtdata[0] != -1: jsonDict = vtdata[1] if jsonDict.has_key('response_code'): if jsonDict['response_code'] == 1: if jsonDict.has_key('scans') and jsonDict.has_key('scan_date') \ and jsonDict.has_key('total') and jsonDict.has_key('positives') and jsonDict.has_key('permalink'): print " Detection: {}/{}".format(jsonDict['positives'], jsonDict['total']) print " Last Analysis Date: {}".format(jsonDict['scan_date']) print " Report Link: {}".format(jsonDict['permalink']) + newLine if jsonDict['positives'] > 0: print " Scan Result:" for av in jsonDict['scans']: av_res = jsonDict['scans'][av] if av_res.has_key('detected') and av_res.has_key('version') and av_res.has_key('result') and av_res.has_key('update'): if av_res['detected']: print "\t{}\t{}\t{}\t{}".format(av, av_res['result'], av_res['version'], av_res['update']) else: print " Missing elements in Virus Total Response" else: print " File not found in VirusTotal" else: print " Response from VirusTotal isn't valid" else: print vtdata[1] print "" except Exception,e: print str(e)
def do_vt(self, line): try: line = str(line) l = line.split(" ") if (l[0] == ""): self.help_vt() else: if not CTCore.VT_APIKEY: print newLine + "No Virus Total API key found, please enter your API key:", CTCore.VT_APIKEY = raw_input() id = int(l[0]) body, sz = CTCore.get_response_and_size(id, "all") name = CTCore.get_name(id) self.retval = " VirusTotal result for object {} ({}):".format( str(id), name) + newLine hash = hashlib.md5( StringIO.StringIO(body).getvalue()).hexdigest() vtdata = CTCore.send_to_vt(hash, CTCore.VT_APIKEY) if vtdata[0] != -1: jsonDict = vtdata[1] if jsonDict.has_key('response_code'): if jsonDict['response_code'] == 1: if jsonDict.has_key('scans') and jsonDict.has_key('scan_date') \ and jsonDict.has_key('total') and jsonDict.has_key('positives') and jsonDict.has_key('permalink'): self.retval += " Detection: {}/{}".format( jsonDict['positives'], jsonDict['total']) self.retval += " Last Analysis Date: {}".format( jsonDict['scan_date']) self.retval += " Report Link: {}".format( jsonDict['permalink']) + newLine if jsonDict['positives'] > 0: self.retval += " Scan Result:" for av in jsonDict['scans']: av_res = jsonDict['scans'][av] if av_res.has_key( 'detected') and av_res.has_key( 'version' ) and av_res.has_key( 'result' ) and av_res.has_key('update'): if av_res['detected']: self.retval += "\t{}\t{}\t{}\t{}".format( av, av_res['result'], av_res['version'], av_res['update']) else: self.retval += " Missing elements in Virus Total Response" else: self.retval += " File not found in VirusTotal" else: self.retval += " Response from VirusTotal isn't valid" else: self.retval += vtdata[1] self.retval += newLine except Exception, e: self.retval = str(e)