• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python virus_total_apis.PublicApi类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_hash_bad_input

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

        try:
            print(json.dumps(vt.get_file_report('This is not a hash'), sort_keys=False, indent=4))
            print(json.dumps(vt.get_file_report(None), sort_keys=False, indent=4))
            print(json.dumps(vt.get_file_report(False), sort_keys=False, indent=4))
            print(json.dumps(vt.get_file_report(-1), sort_keys=False, indent=4))
        except Exception as e:
            self.fail(e)
开发者ID:blacktop,项目名称:virustotal-api,代码行数:10,代码来源:test_virustotal_api.py


示例17: get_result

def get_result(API_KEY, HASH, full=False):
	vt = VirusTotalPublicApi(API_KEY)
	response = vt.get_file_report(HASH)
	if full:
		return response
	try:
		return {
			"positives": response['results']['positives'], 
			"total": response['results']['total']
			}
	except:
		return {
			"positives": "", 
			"total": ""
			}
开发者ID:guelfoweb,项目名称:peframe,代码行数:15,代码来源:virustotal.py


示例18: vt_url

def vt_url(input):
    vt = VirusTotalPublicApi("87ab79d0a21d9a7ae5c5558969c7d6b38defa1901b77d27796ae466b3823c776")
    try:
        input_list = [input_item.strip() for input_item in input.split(",")]
        for ip in input_list:
            scan_report = vt.get_url_report(ip)
            return render_template(
                "vt-url.html",
                url_request=scan_report.get("results").get("url").replace(":", "[:]").replace(".", "[.]"),
                scan_date=scan_report.get("results").get("scan_date"),
                positives=scan_report.get("results").get("positives"),
                total=scan_report.get("results").get("total"),
                link=scan_report.get("results").get("permalink"),
            )

    except Exception as e:
        return render_template("vt-url.html", text="Error: Please try again.")
开发者ID:Chen-Zhe,项目名称:one-portal,代码行数:17,代码来源:app.py


示例19: vt_hash

def vt_hash(input):
    vt = VirusTotalPublicApi("87ab79d0a21d9a7ae5c5558969c7d6b38defa1901b77d27796ae466b3823c776")
    try:
        input_list = [input_item.strip() for input_item in input.split(",")]
        for hash in input_list:
            scan_report = vt.get_file_report(hash)
            return render_template(
                "vt-hash.html",
                sd=scan_report.get("results").get("scan_date"),
                pos=scan_report.get("results").get("positives"),
                total=scan_report.get("results").get("total"),
                md5=scan_report.get("results").get("md5"),
                sha1=scan_report.get("results").get("sha1"),
                link=scan_report.get("results").get("permalink"),
            )

    except Exception as e:
        return render_template("vt-hash.html", text="Error: Please try again.")
开发者ID:Chen-Zhe,项目名称:one-portal,代码行数:18,代码来源:app.py


示例20: link_to_virustotal

def link_to_virustotal(link, pkt):
    ''' IN CASE WE FOUND GET link, WE SCAN IT '''
    print 'SCANNING %s'%link
    virus_total_instance = PublicApi('2e1d7b6e998ed0a9830269571ecffa110e41dd8bf34b88ad41e40b4351165d18')
    REQ = virus_total_instance.scan_url(link)
    print 'Waiting for virustotal'
    while True:
        if 'Scan finished' in str(virus_total_instance.get_url_report(link)):
            print 'Scan finished!'
            REP = virus_total_instance.get_url_report(link)['results']['positives']
            break
        else:
            print 'Naaa not yet'
    if REP == '0' or REP == 0:
        print 'SCANNED %s - VERDICT OK [REP=%s]'%(link,REP)
        pkt.accept()
    else:
        print 'SCANNED %s - VERDICT KO [REP=%s]'%(link,REP)
        pkt.drop()
    '''
开发者ID:Kw3nt,项目名称:PyIPS,代码行数:20,代码来源:IDS.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python interval.IntervalIndexer类代码示例发布时间:2022-05-26
下一篇:
Python config.init_config函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap