所以我得到了这个
public class VirusTotal
{
public string APIKey;
string scan = "https://www.virustotal.com/api/scan_file.json";
string results = "https://www.virustotal.com/api/get_file_report.json";
public VirusTotal(string apiKey)
{
ServicePointManager.Expect100Continue = false;
APIKey = apiKey;
}
public string Scan(string file)
{
var v = new NameValueCollection();
v.Add("key", APIKey);
var c = new WebClient() { QueryString = v };
c.Headers.Add("Content-type", "binary/octet-stream");
byte[] b = c.UploadFile(scan, "POST", file);
var r = ParseJSON(Encoding.Default.GetString(b));
if (r.ContainsKey("scan_id"))
{
return r["scan_id"];
}
throw new Exception(r["result"]);
}
public string GetResults(string id)
{
Clipboard.SetText(id);
var data = string.Format("resource={0}&key={1}", id, APIKey);
var c = new WebClient();
string s = c.UploadString(results, "POST", data);
var r = ParseJSON(s);
foreach (string str in r.Values)
{
MessageBox.Show(str);
}
if (r["result"] != "1")
{
throw new Exception(r["result"]);
}
return s;
}
private Dictionary<string, string> ParseJSON(string json)
{
var d = new Dictionary<string, string>();
json = json.Replace("\"", null).Replace("[", null).Replace("]", null);
var r = json.Substring(1, json.Length - 2).Split(',');
foreach (string s in r)
{
d.Add(s.Split(':')[0], s.Split(':')[1]);
}
return d;
}
}
但是如果我输入了 URL 我会认为它是扫描的,但是我如何检索扫描回来并开始扫描过程
抱歉,我是 api 新手,我并没有真正得到 webclient thx 的帮助