Example #1
0
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)
	}
}
Example #2
0
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")
}