python實(shí)現(xiàn)上傳樣本到virustotal并查詢掃描信息的方法
本文實(shí)例講述了python實(shí)現(xiàn)上傳樣本到virustotal并查詢掃描信息的方法。分享給大家供大家參考。具體方法如下:
import simplejson import urllib import urllib2 import os MD5 = "5248f774d2ee0a10936d0b1dc89107f1" MD5 = "12fa5fb74201d9b6a14f63fbf9a81ff6" #do not have report on virustotal.com ######################################################################## APIKEY = "e0a50a50e77fxxxxxxxxxxxxxx4f17e31 這里用你自己在virustotal上申請(qǐng)的賬號(hào)的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
返回的結(jié)果為:{u'Sophos': u'Sus/Behav-1010'},如果有掃描出的結(jié)果的話..
調(diào)用的方法如下:
MD5 = "12fa5fb74201d9b6a14f63fbf9a81ff6" #do not have report on virustotal.com MD5 = "5248f774d2ee0a10936d0b1dc89107f1" FILE_PATH = r"D:\backSample\10\9af41bc012d66c98ca2f9c68ba38e98f_ICQLiteShell.dll" from getVirusTotalInfo import VirusTotal #得到掃描結(jié)果并打印出來(lái) virus_total = VirusTotal(MD5) print virus_total.get_report_dict() #提交文件到掃描,以后就可以根據(jù)這個(gè)MD5取掃描結(jié)果了 virus_total.submit_md5(FILE_PATH)
希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。
- 如何使用VSCode配置Rust開(kāi)發(fā)環(huán)境(Rust新手教程)
- 教你使用RustDesk?搭建一個(gè)自己的遠(yuǎn)程桌面中繼服務(wù)器
- 完美解決node.js中使用https請(qǐng)求報(bào)CERT_UNTRUSTED的問(wèn)題
- IntelliJ安裝并使用Rust IDE插件
- Rust 連接 SQLite 數(shù)據(jù)庫(kù)的過(guò)程解析
- python實(shí)現(xiàn)封裝得到virustotal掃描結(jié)果
- rustysun同學(xué)ASP代碼書(shū)寫(xiě)規(guī)范
- Rust 中的文件操作示例詳解
- 用rust?寫(xiě)一個(gè)jar包?class沖突檢測(cè)工具
相關(guān)文章
使用Selenium控制當(dāng)前已經(jīng)打開(kāi)的chrome瀏覽器窗口
有時(shí)通過(guò)selenium打開(kāi)網(wǎng)站時(shí),發(fā)現(xiàn)有些網(wǎng)站需要掃碼登錄,就很頭疼,導(dǎo)致爬蟲(chóng)進(jìn)展不下去,下面這篇文章主要給大家介紹了關(guān)于使用Selenium控制當(dāng)前已經(jīng)打開(kāi)的chrome瀏覽器窗口的相關(guān)資料,需要的朋友可以參考下2022-07-07Python自動(dòng)安裝第三方庫(kù)的小技巧(pip使用詳解)
很多朋友私信小編Python安裝第三方庫(kù)安裝技巧,在這就不一一回復(fù)大家了,今天小編給大家分享一篇教程關(guān)于Python自動(dòng)安裝第三方庫(kù)的小技巧,本文以安裝plotly為例給大家詳細(xì)講解,感興趣的朋友跟隨小編一起看看吧2021-05-05使用OpenCV實(shí)現(xiàn)仿射變換—旋轉(zhuǎn)功能
這篇文章主要介紹了在OpenCV里實(shí)現(xiàn)仿射變換——旋轉(zhuǎn)功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08python日志通過(guò)不同的等級(jí)打印不同的顏色(示例代碼)
這篇文章主要介紹了python日志通過(guò)不同的等級(jí)打印不同的顏色,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-01-01Python 使用xlwt模塊將多行多列數(shù)據(jù)循環(huán)寫(xiě)入excel文檔的操作
這篇文章主要介紹了Python 使用xlwt模塊將多行多列數(shù)據(jù)循環(huán)寫(xiě)入excel文檔的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-11-11關(guān)于tensorflow softmax函數(shù)用法解析
這篇文章主要介紹了關(guān)于tensorflow softmax函數(shù)用法解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-06-06保姆級(jí)官方y(tǒng)olov7訓(xùn)練自己的數(shù)據(jù)集及項(xiàng)目部署詳解
最近使用了YOLOv7訓(xùn)練自己的數(shù)據(jù)集,接下來(lái)簡(jiǎn)單記錄一下項(xiàng)目的部署,這篇文章主要給大家介紹了關(guān)于保姆級(jí)官方y(tǒng)olov7訓(xùn)練自己的數(shù)據(jù)集及項(xiàng)目部署的相關(guān)資料,需要的朋友可以參考下2022-08-08