• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现上传样本到virustotal并查询扫描信息的方法

python实现上传样本到virustotal并查询扫描信息的方法

作者:shichen2014 字体:[增加 减小] 来源:互联网

shichen2014 通过本文主要向大家介绍了virustotal,virustotal官方网站,www.virustotal.com,virustotal.com,virustotal uploader等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python实现上传样本到virustotal并查询扫描信息的方法。分享给大家供大家参考。具体方法如下:

import simplejson 
import urllib 
import urllib2 
import os  
 
MD5 = "5248f774d2ee0a10936d0b1dc89107f1" 
MD5 = "12fa5fb74201d9b6a14f63fbf9a81ff6" #do not have report on virustotal.com 
       
######################################################################## 
APIKEY = "e0a50a50e77fxxxxxxxxxxxxxx4f17e31 这里用你自己在virustotal上申请的账号的KEY" 
 
 
class VirusTotal: 
  """""" 
 
  def __init__(self, md5): 
    """Constructor""" 
    self._virus_dict = {} 
    self._md5 = md5 
     
     
  def repr(self): 
    return str(self._virus_dict) 
   
  def submit_md5(self, file_path): 
    import postfile                                      
    #submit the file 
    FILE_NAME = os.path.basename(file_path)  
               
                                                  
    host = "www.virustotal.com"                                
    selector = "https://www.virustotal.com/vtapi/v2/file/scan"                 
    fields = [("apikey", APIKEY)] 
    file_to_send = open(file_path, "rb").read()                        
    files = [("file", FILE_NAME, file_to_send)]                        
    json = postfile.post_multipart(host, selector, fields, files)               
    print json 
    pass 
   
  def get_report_dict(self): 
    result_dict = {} 
     
    url = "https://www.virustotal.com/vtapi/v2/file/report" 
    parameters = {"resource": self._md5, 
            "apikey": APIKEY} 
    data = urllib.urlencode(parameters) 
    req = urllib2.Request(url, data) 
    response = urllib2.urlopen(req) 
    json = response.read() 
     
    response_dict = simplejson.loads(json) 
    if response_dict["response_code"]: #has result  
      scans_dict = response_dict.get("scans", {}) 
      for anti_virus_comany, virus_name in scans_dict.iteritems(): 
        if virus_name["detected"]: 
          self._virus_dict.setdefault(anti_virus_comany, virus_name["result"]) 
    return self._virus_dict 

</div>

返回的结果为:{u'Sophos': u'Sus/Behav-1010'},如果有扫描出的结果的话..

调用的方法如下:

MD5 = "12fa5fb74201d9b6a14f63fbf9a81ff6" #do not have report on virustotal.com 
MD5 = "5248f774d2ee0a10936d0b1dc89107f1" 
FILE_PATH = r"D:\backSample\10\9af41bc012d66c98ca2f9c68ba38e98f_ICQLiteShell.dll" 
 
from getVirusTotalInfo import VirusTotal 
#得到扫描结果并打印出来 
virus_total = VirusTotal(MD5) 
print virus_total.get_report_dict() 
 
#提交文件到扫描,以后就可以根据这个MD5取扫描结果了 
virus_total.submit_md5(FILE_PATH) 

</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • python实现封装得到virustotal扫描结果
  • python实现上传样本到virustotal并查询扫描信息的方法
  • python实现封装得到virustotal扫描结果
  • python实现上传样本到virustotal并查询扫描信息的方法

相关文章

  • Python网络爬虫项目:内容提取器的定义
  • 分析Python中设计模式之Decorator装饰器模式的要点
  • 从零学python系列之数据处理编程实例(一)
  • Python使用MONGODB入门实例
  • 使用tensorflow DataSet实现高效加载变长文本输入
  • Python学习资料
  • 安装ElasticSearch搜索工具并配置Python驱动的方法
  • 探究Python的Tornado框架对子域名和泛域名的支持
  • python字典基本操作实例分析
  • python如何在终端里面显示一张图片

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python写入数据到MP3文件中的方法
    • python使用三角迭代计算圆周率PI的方法
    • Python简单获取自身外网IP的方法
    • 使用Python下载Bing图片(代码)
    • python写入xml文件的方法
    • Python中Collection的使用小技巧
    • python爬虫scrapy运行ImportError: No module named win32api错误
    • 用实例说明python的*args和**kwargs用法
    • Python中列表元素转为数字的方法分析
    • Python实现图像几何变换

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有