【问题标题】:Bash script to query VirusTotal用于查询 VirusTotal 的 Bash 脚本
【发布时间】:2020-10-15 13:15:30
【问题描述】:

我有一个包含多个 md5 哈希的哈希文件。 我想创建一个 bash 脚本来 curl virustotal 以检查哈希是否已知。

#!/bin/bash

for line in "hash.txt";
do
    echo $line; curl -s -X GET --url 'https://www.virustotal.com/vtapi/v2/file/report?apikey=a54237df7c5c38d58d2240xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcc0a0d7&resource='$line'';
done

但不工作。

你能帮帮我吗?

【问题讨论】:

标签: bash loops


【解决方案1】:

最好使用 while 循环。您的 for 循环只会运行一次,因为 bash 将其解释为一个值,而不是一个文件。试试这个:

while read -r line; do

  echo "$line"
  curl -s -X GET --url "https://www.virustotal.com/vtapi/v2/file/report?apikey=a54237df7c5c38d58d2240xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcc0a0d7&resource=$line"

done <"/path/to/hash.txt"

【讨论】:

  • 很好的第一个贡献!虽然在 Bash 中循环文件内容的问题已经有了答案,所以这可能会在一段时间内结束。
猜你喜欢
  • 1970-01-01
  • 2021-02-08
  • 2023-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-21
  • 1970-01-01
  • 2017-01-02
相关资源
最近更新 更多