forked from williballenthin/govt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtDomainReport.go
48 lines (42 loc) · 1.12 KB
/
vtDomainReport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// vtDomainReport.go - fetches and shows a VirusTotal Domain Report.
// usage:
// vtDomainReport.go -domain=scusiblog.org
//
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"github.com/williballenthin/govt"
)
var apikey string
var apiurl string
var domain string
// init - initializes flag variables.
func init() {
flag.StringVar(&apikey, "apikey", os.Getenv("VT_API_KEY"), "Set environment variable VT_API_KEY to your VT API Key or specify on prompt")
flag.StringVar(&apiurl, "apiurl", "https://www.virustotal.com/vtapi/v2/", "URL of the VirusTotal API to be used.")
flag.StringVar(&domain, "domain", "", "a domain to ask information about from VT.")
}
// check - an error checking function
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
flag.Parse()
if domain == "" {
fmt.Println("-domain=<domainname> missing!")
os.Exit(1)
}
c, err := govt.New(govt.SetApikey(apikey), govt.SetUrl(apiurl))
check(err)
// get a domain report (passive dns info)
d, err := c.GetDomainReport(domain)
check(err)
j, err := json.MarshalIndent(d, "", " ")
fmt.Printf("DomainReport: ")
os.Stdout.Write(j)
}