VirusTotal Intelligence 允許用戶在其龐大的數據集中進行搜索,以查找符合特定條件的文件,例如哈希值、殺毒引擎檢測結果、元數據信息、提交時的文件名、文件結構特征、文件大小等。可以說,它幾乎是惡意軟件領域的“谷歌搜索引擎”。
網頁使用
通過哈希值檢索文件:要搜索具有特定 MD5、SHA1 或 SHA256 值的文件,只需在主搜索框中輸入相應的哈希值即可。例如,若要查找 SHA256 為
142b638c6a60b60c7f9928da4fb85a5a8e1422a9ffdc9ee49e17e56ccca9cf6e
的文件,只需輸入該哈希值進行搜索,搜索結果如下所示。
通過運算符搜索文件:該查詢語言支持一些布爾運算符,并允許使用括號將查詢中的部分內容進行分組。支持的布爾運算符包括 AND、OR 和 NOT。
# 搜索所有包含無效 XREF 表的 PDF 文件
type:pdf tag:invalid-xref
type:pdf AND tag:invalid-xref# 搜索所有 DLL 文件或可執行文件(EXE)
type:pedll OR type:peexe# 搜索至少被一個殺毒軟件識別為“zbot”家族
# 但沒有被標記為“corrupt”(即不是損壞文件,能夠在真實系統中運行)
engines:zbot NOT tag:corrupt# 搜索所有屬于 Zbot、Dyreza 或 Dridex 家族
# 且文件未損壞的可執行銀行木馬樣本
(engines:zbot OR engines:sinowal) NOT (tag:corrupt)
API使用
通過API上傳文件:實現該功能需要補充 api_key 與所上傳文件對應的位置,其python實現如下所示:
import requestsurl = "https://www.virustotal.com/api/v3/files"
api_key = "" headers = {"x-apikey": api_key
}# 要上傳的文件路徑
file_path = "./142b638c6a60b60c7f9928da4fb85a5a8e1422a9ffdc9ee49e17e56ccca9cf6e"proxies = {"http": "http://127.0.0.1:7890","https": "http://127.0.0.1:7890"
}with open(file_path, "rb") as f:files = {"file": f}response = requests.post(url, headers=headers, files=files, proxies=proxies)print(response.status_code)
print(response.json())
通過API分析上傳的文件:實現該功能需要補充 api_key 與上一步返回的樣本 id,其python實現如下所示:
import requestsurl = "https://www.virustotal.com/api/v3/analyses/MTI2MDJkZTY2NTlhMzU2MTQxZTc0NGJmNTY5ZTdlNTY6MTc0NzEyMzQ1MQ=="
api_key = "" headers = {"accept": "application/json","x-apikey": api_key
}proxies = {"http": "http://127.0.0.1:7890","https": "http://127.0.0.1:7890"
}response = requests.get(url, headers=headers, proxies=proxies)print(response.status_code)
print(response.json())
通過API獲取樣本的報告:實現該功能需要補充 api_key 與樣本的哈希,其python實現如下所示:
import pdb
import json
import requestsurl = "https://www.virustotal.com/api/v3/files/142b638c6a60b60c7f9928da4fb85a5a8e1422a9ffdc9ee49e17e56ccca9cf6e"
api_key = ""headers = {"accept": "application/json","x-apikey": api_key
}proxies = {"http": "http://127.0.0.1:7890","https": "http://127.0.0.1:7890"
}response = requests.get(url, headers=headers, proxies=proxies)print(response.status_code)
print(response.json())if response.status_code == 200:try:response_data = response.json() # 獲取JSON數據# 將返回的JSON內容保存到文件with open('sample_report.json', 'w', encoding='utf-8') as json_file:json.dump(response_data, json_file, ensure_ascii=False, indent=4)print("響應內容已保存到 'virustotal_response.json'")except ValueError:print("返回的內容不是有效的 JSON 格式")
else:print(f"請求失敗,狀態碼:{response.status_code}")