You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET(C#)调用VirusTotal扫描文件后无法获取报告求助

正确获取VirusTotal文件扫描报告的方法

核心问题修正

你误用了URL扫描的报告接口,文件扫描对应的报告接口是file/report,而非url/report,这是导致「资源不存在」的根本原因。

正确接口调用说明

  1. 接口地址:https://www.virustotal.com/vtapi/v2/file/report
  2. 必填参数:
    • apikey:你的VirusTotal API密钥
    • resource:提交文件扫描后返回的scan_id,或者文件的SHA-256/SHA-1/MD5哈希值(两种方式都可查询报告)
  3. 可选参数:
    • allinfo:设为true可获取完整扫描详情,默认false仅返回基础检测结果

C#后端代码示例(适配你的VirusTotal类)

修改你的GetResults方法,调用file/report接口:

public async Task<string> GetFileScanReport(string scanIdOrFileHash, string apiKey)
{
    using (var httpClient = new HttpClient())
    {
        var requestUrl = $"https://www.virustotal.com/vtapi/v2/file/report?apikey={Uri.EscapeDataString(apiKey)}&resource={Uri.EscapeDataString(scanIdOrFileHash)}";
        var response = await httpClient.GetAsync(requestUrl);
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync();
    }
}

调用时直接传入提交扫描后得到的scan_id即可。

正确的curl请求示例

curl "https://www.virustotal.com/vtapi/v2/file/report?apikey=你的API密钥&resource=你的scan_id或文件哈希"

关键注意事项

  • 扫描请求入队后需要等待一段时间(几秒到数分钟),立即查询会返回"response_code": -2(表示结果仍在队列中),需要轮询直到response_code为1(结果就绪)。
  • 免费API有请求频率限制(每分钟最多4次请求,每天最多500次),不要高频调用。
  • 确认scan_id或哈希值无拼写错误,避免多余空格或特殊字符未转义。

内容的提问来源于stack exchange,提问作者James

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:19:53