Bash循环通过URL问题

时间:2016-09-18 18:52:55

标签: bash curl

我使用cURL请求谷歌安全浏览API来检查我所请求的任何网站是否是恶意的。当我发出以下命令时

$curl -H "Content-Type: application/json" -X POST -d ' { "client": { "clientId": "Test", "clientVersion": "1.0.0" }, "threatInfo": { "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING","THREAT_TYPE_UNSPECIFIED","UNWANTED_SOFTWARE","POTENTIALLY_HARMFUL_APPLICATION"], "platformTypes": ["WINDOWS","PLATFORM_TYPE_UNSPECIFIED","ANY_PLATFORM"], "threatEntryTypes": ["URL"], "threatEntries": [ {"url":"hxxp://bookmyroom.pk/assets/timepicker/f.exe"} ] } }' https://safebrowsing.googleapis.com/v4/threatMatches:find?key=AIzaSyD1IMgjaHEza6e9m_jwtjBgPmJX0IMKKIs

Caution: I have "xx"ed instead "tt" for the http string. This site might be a potential malicious site.So do not open it using browser.

我将JSON响应视为

{
  "matches": [
    {
      "threatType": "UNWANTED_SOFTWARE",
      "platformType": "ANY_PLATFORM",
      "threat": {
        "url": "hxxp://bookmyroom.pk/assets/timepicker/f.exe"
      },
      "cacheDuration": "300.000s",
      "threatEntryType": "URL"
    }
  ]
}

Caution: I have "xx"ed instead "tt" for the http string. This site might be a potential malicious site.So do not open it using browser.

当我在循环中做同样的事情时

#check.sh

for i in $(cat malsite.txt); do
        content="$(curl -H "Content-Type: application/json" -X POST -d ' { "client": { "clientId": "Test", "clientVersion": "1.0.0" }, "threatInfo": { "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING","THREAT_TYPE_UNSPECIFIED","UNWANTED_SOFTWARE","POTENTIALLY_HARMFUL_APPLICATION"], "platformTypes": ["WINDOWS","PLATFORM_TYPE_UNSPECIFIED","ANY_PLATFORM"], "threatEntryTypes": ["URL"], "threatEntries": [ {"url":"$i"} ] } }' https://safebrowsing.googleapis.com/v4/threatMatches:find?key=AIzaSyD1IMgjaHEza6e9m_jwtjBgPmJX0IMKKIs)"
        echo "$i"
        echo "$content"
done

#malsite.txt

"hxxp://bookmyroom.pk/assets/timepicker/f.exe"

Caution: I have "xx"ed instead "tt"ing for the http string.This site might be a potential malicious site.So do not open it using browser.

我没有得到任何结果。它只返回空结果。

#Result of /.check.sh :
{}

不确定,我在哪里犯错误。有什么想法吗 ?

0 个答案:

没有答案