【问题标题】:Google safe browse API lookup Node.js谷歌安全浏览 API 查找 Node.js
【发布时间】:2016-05-20 21:57:57
【问题描述】:

我无法让 Google 安全搜索查找正常工作。这是我正在尝试的代码,我总是在响应中得到{}

var request = require("request-promise")

var body = {
  "client": {
    "clientId":      "myclientid",
    "clientVersion": "1.0"
  },
  "threatInfo": {
    "threatTypes":      ["MALWARE"],
    "platformTypes":    ["WINDOWS", "LINUX"],
    "threatEntryTypes": ["URL"],
    "threatEntries": [
      {"url": "http://some-malicious-url"}
    ]
  }
}

var options = {
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  method: "POST",
  url: "https://safebrowsing.googleapis.com/v4/threatMatches:find?key=my-api-key",
  form: body
}


request(options).then(function (data){
  console.log(data)
})

不确定我是否正确理解了文档,或者我的请求中是否遗漏了任何参数。我尝试过使用不同的网址。尝试从网络中搜索被我的浏览器识别为恶意的恶意网址,但这些网址也返回空白响应。这是我关注的documentation

我也试过他们的threatLists:list API,但总是报错

curl -XGET https://safebrowsing.googleapis.com/v4/threatLists:list?key=my_api_key

这是我得到的输出:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/v4/threatLists:list?key=my_api_key</code> was not found on this server.  <ins>That’s all we know.</ins>

【问题讨论】:

    标签: node.js safe-browsing


    【解决方案1】:

    threatLists 工作示例:

    threatLists 可以在没有 :list 的情况下工作。例如curl https://safebrowsing.googleapis.com/v4/threatLists?key=YOUR_KEY

    threatMatches 工作示例:

    方法:POST

    内容类型:应用程序/json

    https://safebrowsing.googleapis.com/v4/threatMatches:find?key=YOUR_KEY

    身体: { "client": { "clientId": "testing", "clientVersion": "0.0.1" }, "threatInfo": { "threatTypes": ["MALWARE","SOCIAL_ENGINEERING","UNWANTED_SOFTWARE","MALICIOUS_BINARY"], "platformTypes": ["ANY_PLATFORM"], "threatEntryTypes": ["URL"], "threatEntries": [ {"url": "http://goooogleadsence.biz/"} ] } }

    【讨论】:

      【解决方案2】:

      代码是正确的。我也一样……

      Chrome 浏览器似乎有另一个(更准确的)安全浏览来源。也许他们专门为某些特定客户保留这些新数据。 结果与您可以使用的任何查找协议版本相同。 如果您使用更新 API,这也是一样的。

      如果有人真的知道,为什么……我对这些信息非常感兴趣。

      【讨论】:

      • 但是到目前为止我还没有能够识别出任何恶意网址。此外,他们的threatLists:list API 总是会出错。有什么想法吗?
      • 终于可以使用几个网址了。我发现它没有多大用处,因为它无法检测到 Chrome 可以检测到的大多数恶意网址
      【解决方案3】:

      请确保您在请求的 URL 中附加了“/”。这样做很重要。

      在这种情况下,您的 URL 将变为 http://some-malicious-url/

      让我知道这是否有效!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多