欢迎使用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
匹配的任何其余字段模式。