歡迎使用Virustotal CLI,該工具專門為那些喜歡Virustotal和命令行界面的人設計。使用此工具,您可以使用Virustotal的網頁來完成通常會做的所有事情,包括:
還有更多...
由於此工具在引擎蓋下使用Virustotal API,因此您需要一個Virustotal API鍵。通過註冊ViruStotal,您將收到免費的API密鑰,但是,免費的API鍵每分鐘的請求有限,並且他們無法訪問某些高級功能,例如搜索和文件下載。如果您有興趣使用這些高級功能,請與我們聯繫。
安裝工具有兩種方法:通過使用我們的預編譯二進製文件或自己構建它之一。
可以在版本頁面上找到預編譯的二進製文件。有用於Windows,Linux和Mac OS X的二進製文件。要使用它們,只需下載文件,解壓縮並將其放在您認為更方便使用的目錄中。
要編譯程序,您需要在系統中安裝1.14.x或更高版本,然後鍵入以下命令:
$ git clone https://github.com/VirusTotal/vt-cli
$ cd vt-cli
$ make install
注意:為了使用vt
二進制,請確保GOBIN
是PATH
Env變量的一部分:
$ export GOBIN= ` go env GOPATH ` /bin
$ export PATH= $PATH : $GOBIN
對於Mac OS用戶,有一個釀造公式可用。請注意,這不是由Virustotal維護的。
$ brew install virustotal-cli
對於Windows用戶,有一個Winget清單可用。請注意,這不是由Virustotal維護的。
winget install VirusTotal.vt - cli
還支持巧克力(也不由Virustotal維護):
choco install vt - cli
如果您計劃定期在Windows中使用vt-cli
,我們強烈建議您避免使用標準的Windows控制台,然後使用Cygwin。打印大量文本(如vt-cli
通常使用)時,Windows控制台非常慢,而Cygwin的性能要好得多。此外,您可以從Cygwin對Command Auto-Completion的支持中受益,這是Windows控制台不提供的方便功能。為了利用自動完成功能,請確保在安裝Cygwin時包含bash-completion
包。
安裝了VT-CLI工具後,您可能需要使用API鍵進行配置。這不是嚴格必要的,因為您每次使用--apikey
選項( -k
以簡短的形式)調用該工具時,您可以提供API密鑰,但是如果您要經常使用該工具,這有點麻煩(我們敢打賭,你會這樣做!)。用於配置API密鑰,只需鍵入:
$ vt init
此命令將要求您的API密鑰,並將其保存到主目錄中的配置文件(〜/.vt.toml)中。您還可以使用VTCLI_APIKEY
環境變量指定API密鑰。如果您以多種方式指定API密鑰,則--apikey
選項將具有最高優勢,其次是VTCLI_APIKEY
環境變量,配置文件中的API鍵將用作最後一個度假勝地。
如果您在HTTP代理後面,則可以通過多種方式告訴您是代理服務器的地址的vt-cli
。一種是使用--proxy
選項,例如:
$ vt --proxy http://myproxy.com:1234 < command >
您還可以使用VTCLI_PROXY
環境變量,或將以下行添加到配置文件:
proxy= " http://myproxy.com:1234 "
如果要經常使用此工具,則可能需要具有命令自動完成。它可以節省寶貴的時間和擊鍵。但是請注意,在遵循下面列出的步驟之前,您必須按照上一節中所述配置API。 API對於確定您可以訪問的命令是必需的。
Linux:
$ vt completion bash > /etc/bash_completion.d/vt
Mac OS X:
$ brew install bash-completion
$ vt completion bash > $( brew --prefix ) /etc/bash_completion.d/vt
將以下行添加到~/.bash_profile
:
if [ -f $( brew --prefix ) /etc/bash_completion ] ; then
. $( brew --prefix ) /etc/bash_completion
fi
Cygwin:
確保安裝了bash-completion
軟件包(Cygwin不會默認不安裝它)並鍵入:
$ vt completion bash > /usr/share/bash-completion/completions/vt
❗您可能需要重新啟動外殼,以使自動完成開始工作。
vt completion zsh
的輸出腳本需要放在$fpath
目錄下的某個位置。例如, .oh-my-zsh/completions
目錄:
$ mkdir /Users/ $USERNAME /.oh-my-zsh/completions
$ vt completion zsh > /Users/ $USERNAME /.oh-my-zsh/completions/_vt
重新啟動外殼。
獲取有關文件的信息:
$ vt file 8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85
獲取有關文件格式的文件的信息:
$ vt file 8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85 --format json
獲取文件的特定分析報告:
$ # File analysis IDs can be given as `f-<file_SHA256_hash>-<UNIX timestamp>`...
$ vt analysis f-8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85-1546309359
$ # ...or as a Base64 encoded string, retrieved from the `vt scan file` command:
$ vt scan file test.txt
test.txt MDJiY2FiZmZmZmQxNmZlMGZjMjUwZjA4Y2FkOTVlMGM6MTU0NjQ1NDUyMA==
$ vt analysis MDJiY2FiZmZmZmQxNmZlMGZjMjUwZjA4Y2FkOTVlMGM6MTU0NjQ1NDUyMA==
- _id: " MDJiY2FiZmZmZmQxNmZlMGZjMjUwZjA4Y2FkOTVlMGM6MTU0NjQ1NDUyMA== "
_type: " analysis "
date: 1546454520 # 2019-01-02 13:42:00 -0500 EST
stats:
failure: 0
harmless: 0
malicious: 0
suspicious: 0
timeout: 0
type-unsupported: 0
undetected: 0
status: " queued "
下載文件給定文件列表,在文本文件中,每行哈希列表:
$ cat /path/list_of_hashes.txt | vt download -
獲取有關URL的信息:
$ vt url http://www.virustotal.com
獲取服務於URL的IP地址:
$ vt url last_serving_ip_address http://www.virustotal.com
搜索文件:
$ vt search " positives:5+ type:pdf "
掃描文件:
$ vt scan file < yourfile >
< yourfile > ZDZiOTcxY2JhNDE0MWU5ZWRjN2JjNGQ2NTdhN2VjODU6MTU3MDE3Mjg1NQ==
$ vt analysis ZDZiOTcxY2JhNDE0MWU5ZWRjN2JjNGQ2NTdhN2VjODU6MTU3MDE3Mjg1NQ==
- _id: " ZDZiOTcxY2JhNDE0MWU5ZWRjN2JjNGQ2NTdhN2VjODU6MTU3MDE3Mjg1NQ== "
_type: " analysis "
date: 1570172855 # 2019-10-04 09:07:35 +0200 CEST
stats:
failure: 0
harmless: 0
malicious: 0
suspicious: 0
timeout: 0
type-unsupported: 0
undetected: 0
status: " queued "
從CSV格式的搜索中導出文件的檢測和標籤:
$ vt search " positives:5+ type:pdf " -i sha256,last_analysis_stats.malicious,tags --format csv
從JSON格式的搜索中導出文件檢測和標籤:
$ vt search " positives:5+ type:pdf " -i sha256,last_analysis_stats.malicious,tags --format json
當您詢問有關文件,URL,域,IP地址或Virustotal中任何其他對象的信息時,您會獲得大量數據(默認情況下,YAML格式)通常比您需要的更多。您可以通過使用--include
和--exclude
-i
行選項(以簡短的形式-x
縮小VT -CLI工具顯示的信息。
這些選項接受與組成數據的字段相匹配的模式,並允許您僅包含其中的一個子集,或者排除對您不有趣的任何字段。讓我們使用有關http://www.virustotal.com
的數據來看看它的工作原理:
$ vt url http://www.virustotal.com
- _id: 1db0ad7dbcec0676710ea0eaacd35d5e471d3e11944d53bcbd31f0cbd11bce31
_type: " url "
first_submission_date: 1275391445 # 2010-06-01 13:24:05 +0200 CEST
last_analysis_date: 1532442650 # 2018-07-24 16:30:50 +0200 CEST
last_analysis_results:
ADMINUSLabs:
category: " harmless "
engine_name: " ADMINUSLabs "
result: " clean "
AegisLab WebGuard:
category: " harmless "
engine_name: " AegisLab WebGuard "
result: " clean "
AlienVault:
category: " harmless "
engine_name: " AlienVault "
result: " clean "
last_http_response_code: 200
last_http_response_content_length: 7216
last_http_response_content_sha256: " 7ed66734d9fb8c5a922fffd039c1cd5d85f8c2bb39d14803983528437852ba94 "
last_http_response_headers:
age: " 26 "
cache-control: " public, max-age=60 "
content-length: " 7216 "
content-type: " text/html "
date: " Tue, 24 Jul 2018 14:30:24 GMT "
etag: " " bGPKJQ " "
expires: " Tue, 24 Jul 2018 14:31:24 GMT "
server: " Google Frontend "
x-cloud-trace-context: " 131ac6cb5e2cdb7970d54ee42fd5ce4a "
x-frame-options: " DENY "
last_submission_date: 1532442650 # 2018-07-24 16:30:50 +0200 CEST
private: false
reputation: 1484
times_submitted: 213227
total_votes:
harmless: 660
malicious: 197
請注意,返回的數據通常遵循層次結構,其中一些頂級字段可能包含子字段,這些字段又可能包含自己的子字段。在上面的示例中, last_http_response_headers
具有子字段age
, cache-control
, content-length
等,而total_votes
具有harmless
和malicious
。為了參考層次結構中的特定字段,我們可以使用路徑,類似於我們在計算機中識別文件的方式,但是在這種情況下,我們將使用dot字符(。)作為路徑組件的分離器,而是大多數文件系統使用的斜線(或反斜線)。以下是我們示例結構的有效途徑:
last_http_response_headers.age
total_votes.harmless
last_analysis_results.ADMINUSLabs.category
last_analysis_results.ADMINUSLabs.engine_name
--include
和--exclude
所接受的過濾器是我們可以使用*
和**
作為一個和許多路徑元素的佔位符的路徑。例如foo.*
匹配foo.bar
但不能匹配foo.bar.baz
,而foo.**
匹配foo.bar
, foo.bar.baz
和foo.bar.baz.qux
。 foo.bar.baz.qux
, foo.*.qux
匹配foo.bar.qux
and foo.baz.qux
,但不匹配foo.bar.baz.qux
,而foo.**.qux
路徑以foo
開頭,以qux
結尾。
對於僅挑選您想要的字段的櫻桃,您應該使用--include
隨後是上述路徑模式。您還可以通過多次使用--include
參數或與逗號分隔的模式列表一起使用多種模式。以下兩個選項是等效的:
$ vt url http://www.virustotal.com --include=reputation --include=total_votes. *
$ vt url http://www.virustotal.com --include=reputation,total_votes. *
在這裡,您有不同的示例及其輸出(假設vt url http://www.virustotal.com
返回上面顯示的結構):
$ vt url http://www.virustotal.com --include=last_http_response_headers.server
- last_http_response_headers:
server: " Google Frontend "
$ vt url http://www.virustotal.com --include=last_http_response_headers. *
- last_http_response_headers:
age: " 26 "
cache-control: " public, max-age=60 "
content-length: " 7216 "
content-type: " text/html "
date: " Tue, 24 Jul 2018 14:30:24 GMT "
etag: " " bGPKJQ " "
expires: " Tue, 24 Jul 2018 14:31:24 GMT "
server: " Google Frontend "
x-cloud-trace-context: " 131ac6cb5e2cdb7970d54ee42fd5ce4a "
x-frame-options: " DENY "
$ vt url http://www.virustotal.com --include=last_analysis_results. **
- last_analysis_results:
ADMINUSLabs:
category: " harmless "
engine_name: " ADMINUSLabs "
result: " clean "
AegisLab WebGuard:
category: " harmless "
engine_name: " AegisLab WebGuard "
result: " clean "
AlienVault:
category: " harmless "
engine_name: " AlienVault "
result: " clean "
$ vt url http://www.virustotal.com --include=last_analysis_results. * .result
- last_analysis_results:
ADMINUSLabs:
result: " clean "
AegisLab WebGuard:
result: " clean "
AlienVault:
result: " clean "
$ vt url http://www.virustotal.com --include= ** .result
- last_analysis_results:
ADMINUSLabs:
result: " clean "
AegisLab WebGuard:
result: " clean "
AlienVault:
result: " clean "
另請注意, _id
和_type
也是字段名稱,因此您可以在過濾器中使用它們:
$ vt url http://www.virustotal.com --include=_id,_type, ** .result
- _id: " 1db0ad7dbcec0676710ea0eaacd35d5e471d3e11944d53bcbd31f0cbd11bce31 "
_type: " file "
last_analysis_results:
ADMINUSLabs:
result: " clean "
AegisLab WebGuard:
result: " clean "
AlienVault:
result: " clean "
--exclude
選項的工作原理類似於--include
,但不包括輸出中的匹配字段,而是包括匹配字段以外的所有內容。當您要保留大多數字段時,您可以使用此選項,但會忽略其中一些不有趣的選項。如果您同時使用--include
和--exclude
--include
首先進入行動,其中僅包括匹配--include
模式的字段,而--exclude
在此之後出現,刪除與--exclude
匹配的任何其餘字段模式。