当前位置: 首页>>代码示例>>Golang>>正文


Golang Client.ScanFile方法代码示例

本文整理汇总了Golang中github.com/williballenthin/govt.Client.ScanFile方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.ScanFile方法的具体用法?Golang Client.ScanFile怎么用?Golang Client.ScanFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/williballenthin/govt.Client的用法示例。


在下文中一共展示了Client.ScanFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	flag.Parse()
	if file == "" {
		fmt.Println("-file=<fileToScan.ext> fehlt!")
		os.Exit(1)
	}
	c := govt.Client{Apikey: apikey, Url: apiurl}

	// get a file report
	r, err := c.ScanFile(file)
	check(err)
	//fmt.Printf("r: %s\n", r)
	j, err := json.MarshalIndent(r, "", "    ")
	fmt.Printf("FileReport: ")
	os.Stdout.Write(j)

}
开发者ID:postfix,项目名称:govt-1,代码行数:17,代码来源:vtFileScan.go

示例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")
}
开发者ID:postfix,项目名称:govt-1,代码行数:64,代码来源:vtFileKnownBySymantec.go


注:本文中的github.com/williballenthin/govt.Client.ScanFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。