本文整理匯總了Golang中github.com/williballenthin/govt.Client.GetFileReport方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.GetFileReport方法的具體用法?Golang Client.GetFileReport怎麽用?Golang Client.GetFileReport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/williballenthin/govt.Client
的用法示例。
在下文中一共展示了Client.GetFileReport方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
flag.Parse()
apikey := getApiKeyFromEnv()
c := govt.Client{Apikey: apikey, Url: apiurl}
r, err := c.GetFileReport(rsrc)
check(err)
if r.ResponseCode == 0 {
//fmt.Println( r.VerboseMsg )
fmt.Println(rsrc + " NOT KNOWN by VirusTotal")
} else {
//fmt.Println(rsrc + "["+r.Positives+"/"+r.Total+"] IS KNOWN by VirusTotal")
fmt.Printf("%s [%d/%d] IS KNOWN by VirusTotal\n", rsrc, r.Positives, r.Total)
//j, err := json.MarshalIndent(r, "", " ")
//fmt.Printf("FileReport: ")
//os.Stdout.Write(j)
}
}
示例2: main
func main() {
flag.Parse()
//log.Printf("flags parsed")
if file != "" {
//log.Printf("param 'file' is set")
md5s := &bytes.Buffer{}
w := bufio.NewWriter(md5s)
//bw, err := fmt.Fprintf(w, "%x", calcMd5(file) )
_, err := fmt.Fprintf(w, "%x", calcMd5(file))
w.Flush()
check(err)
//fmt.Printf("%d bytes written to buffer\n", bw)
//fmt.Printf("buffer as string: '%s'\n", md5s.String() )
//fmt.Println("md5s.String():", md5s.String() )
//os.Exit(1)
rsrc = md5s.String()
} else {
//log.Printf("param 'file' not set")
file = "/path/to/" + rsrc
}
apikey := getApiKeyFromEnv()
//log.Printf("APIKEY is: %s", apikey)
c := govt.Client{Apikey: apikey, Url: apiurl}
r, err := c.GetFileReport(rsrc)
check(err)
//log.Printf("GetFile response was: %s", r.VerboseMsg)
//log.Printf("GetFile response was: %#v", r)
if r.ResponseCode == 0 {
//log.Println("ResponseCode was '0'")
//fmt.Println( r.VerboseMsg )
fmt.Println(rsrc + " NOT KNOWN by VirusTotal")
if vtUpload == true {
r, err := c.ScanFile(file)
check(err)
j, err := json.MarshalIndent(r, "", " ")
fmt.Printf("FileReport: ")
os.Stdout.Write(j)
} else {
fmt.Println("For uploading to VT use vtFileScan -file=" + file)
}
} else {
//log.Println("ResponseCode was NOT '0'")
//fmt.Println(rsrc +" IS KNOWN by VirusTotal")
sr := r.Scans["Symantec"]
if sr.Detected == true {
fmt.Printf("%s detected by Symantec Version %s as %s since update %s\n", rsrc, sr.Version, sr.Result, sr.Update)
} else {
fmt.Printf("%s NOT detected by Symantec; Detection Rate: [%d/%d]\n", rsrc, r.Positives, r.Total)
fmt.Printf("If you want to upload this file to VT use: 'vtFileScan -file=%s'\n", file)
fmt.Printf("If you want to submit it to Symantec use: 'symantecUpload -file=%s'\n", file)
for s := range r.Scans {
if r.Scans[s].Detected == true {
//log.Printf("detected by: '%s'\n", s)
} else {
continue
}
}
}
//j, err := json.MarshalIndent(r, "", " ")
//fmt.Printf("FileReport: ")
//os.Stdout.Write(j)
}
//log.Println("End of Execution")
}