2
所以我得到這個VirusTotal Api的用法?
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我會awsume它的掃描,但我怎麼retrive掃描回來,這一點,開始掃描proccess
抱歉,但即時通訊新在apis和我真的沒有得到webclient thx爲我的幫助
Im仍然困惑我puted我的網址在你的文件名在這裏+我的api密鑰在這裏你的api鍵 – PenguinSmex
你想從url掃描一個文件嗎?然後,您需要:1)將文件下載到本地硬盤驅動器,並在指定掃描路徑時指定路徑或2)使用VT API的另一個功能,特別設計用於掃描URL(請參閱[文檔](https:/ /www.virustotal.com/documentation/public-api/),部分「發送和掃描網址」) –
我想掃描一個網址,我不想使用網頁瀏覽器,我希望它能夠檢測到它是否被檢測到 – PenguinSmex