当前位置: 首页>>代码示例>>Python>>正文


Python virus_total_apis.PublicApi类代码示例

本文整理汇总了Python中virus_total_apis.PublicApi的典型用法代码示例。如果您正苦于以下问题:Python PublicApi类的具体用法?Python PublicApi怎么用?Python PublicApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PublicApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_scan_url

    def test_scan_url(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.scan_url('www.wired.com'), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例2: test_get_domain_report

    def test_get_domain_report(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.get_domain_report('www.wired.com'), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例3: test_rescan_file

    def test_rescan_file(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.rescan_file(EICAR_MD5), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例4: test_scan_file_stream

    def test_scan_file_stream(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.scan_file(EICAR, from_disk=False), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例5: test_sha256_hash

    def test_sha256_hash(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.get_file_report(EICAR_SHA256), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例6: test_hash_found

    def test_hash_found(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.get_file_report('44cda81782dc2a346abd7b2285530c5f'), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例7: test_scan_file_stringio

    def test_scan_file_stringio(self):
        vt = PublicApi(API_KEY)

        try:
            print json.dumps(vt.scan_file(StringIO.StringIO(EICAR)), sort_keys=False, indent=4)
        except Exception as e:
            self.fail(e)
开发者ID:John-Lin,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例8: test_hash_not_found

    def test_hash_not_found(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.get_file_report('A' * 32), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例9: test_md5_hash

    def test_md5_hash(self):
        vt = PublicApi(API_KEY)

        try:
            print json.dumps(vt.get_file_report(EICAR_MD5), sort_keys=False, indent=4)
        except Exception as e:
            self.fail(e)
开发者ID:John-Lin,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例10: test_scan_file_binary

    def test_scan_file_binary(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.scan_file('virus_total_apis/test/test.exe'), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例11: check_virustotal

    def check_virustotal(self, cr, uid, ids, context=None):

        config_obj = self.pool.get('antivir.config')
        config_ids = config_obj.search(cr, uid, [('active_config', '=', True)], context=context)

        if config_ids:
            config = config_obj.browse(cr, uid, config_ids, context=context)

            if config[0].virustotal_api_url and config[0].virustotal_api_key:
                quarantine_item = self.browse(cr, uid, ids, context=context)
                vt = VirusTotalPublicApi(config[0].virustotal_api_key)
                response = vt.get_file_report(quarantine_item[0].SHA256)
                scans = response['results'].get('scans')

                if scans:
                    scans_results = ["<li>[{}] detected:{} result:{}</li>".format(str(key), str(val.get('detected')),
                                                                                  str(val.get('result')))
                                     for key, val in scans.iteritems()]

                    virustotal_summary = "<ul>{}</ul>".format(''.join(scans_results))
                else:
                    virustotal_summary = _("Couldn't fetch virustotal_summary, try again later.")

                self.write(cr, uid, ids, {'virustotal_summary': virustotal_summary}, context=context)
        else:
            raise ConfigError(_("There is no active config."))
开发者ID:nuncjo,项目名称:Odoo-antivirus,代码行数:26,代码来源:quarantine.py

示例12: test_get_ip_report

    def test_get_ip_report(self):
        vt = PublicApi(API_KEY)

        try:
            print(json.dumps(vt.get_ip_report('23.6.113.133'), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例13: test_put_comments

 def test_put_comments(self):
     vt = PublicApi(API_KEY)
     comment = 'This is just a test of the virus-total-api. https://github.com/blacktop/virustotal-api'
     try:
         print(json.dumps(vt.put_comments(resource=EICAR_MD5, comment=comment), sort_keys=False, indent=4))
     except Exception as e:
         self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:7,代码来源:test_virustotal_api.py

示例14: _lookup_iocs

    def _lookup_iocs(self):
        """Caches the OpenDNS info for a set of domains"""
        vt = PublicApi(self._api_key)

        for ioc in self._all_iocs:
            report = vt.get_file_report(ioc)
            self._threat_info_by_iocs[ioc] = report
            sleep(15)
开发者ID:cephurs,项目名称:osxcollector,代码行数:8,代码来源:virustotal_hashes.py

示例15: processZipFile

def processZipFile(filename):

	"""Extract files from a ZIP archive and test them against VT"""

	zf = zipfile.ZipFile(filename)
	for f in zf.namelist():
		try:
			data = zf.read(f)
		except KeyError:
			writeLog("Cannot extract %s from zip file %s" % (f, filename))
			return
		fp = open(os.path.join(generateDumpDirectory(args.directory), f), 'wb')
		fp.write(data)
		fp.close()
		md5 = hashlib.md5(data).hexdigest()
		if dbMD5Exists(md5):
			writeLog("DEBUG: MD5 %s exists" % md5)
			continue

		writeLog("DEBUG: Extracted MD5 %s from Zip" % md5)
		vt = VirusTotalPublicApi(config['apiKey'])
		response = vt.get_file_report(md5)
		writeLog("DEBUG: VT Response received")

		if config['esServer']:
			# Save results to Elasticsearch
			try:
				response['@timestamp'] = time.strftime("%Y-%m-%dT%H:%M:%S+01:00")
				res = es.index(index=config['esIndex'], doc_type="VTresult", body=json.dumps(response))
			except:
				writeLog("Cannot index to Elasticsearch")
		writeLog("DEBUG: Step1")

		# DEBUG
		fp = open('/tmp/vt.debug', 'a')
		fp.write(json.dumps(response, sort_keys=False, indent=4))
		fp.close()
		writeLog("DEBUG: Step1: %s" % response['results']['response_code'])

		if response['response_code'] == 200:
			if response['results']['response_code']:
				positives = response['results']['positives']
				total = response['results']['total']
				scan_date = response['results']['scan_date']

				writeLog('File: %s (%s) Score: %s/%s Scanned: %s (%s)' %
					(f, md5, positives, total, scan_date, timeDiff(scan_date)))
			else:
				submit2vt(os.path.join(generateDumpDirectory(args.directory), f))
				writeLog('File: %s (%s) not found, submited for scanning' %
					(f, md5))
			dbAddMD5(md5,f)
		else:
			writeLog('VT Error: %s' % response['error'])

		# Analyze OLE documents if API is available
		parseOLEDocument(os.path.join(generateDumpDirectory(args.directory), filename))
	return
开发者ID:cudeso,项目名称:mime2vt,代码行数:58,代码来源:mime2vt.py


注:本文中的virus_total_apis.PublicApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。