-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
66 lines (58 loc) · 1.22 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/famasoon/crtsh/crtlog"
"github.com/famasoon/crtsh/parser"
)
func showUsage() {
fmt.Println("This tool shows the result of crt.sh")
fmt.Println("Option:")
fmt.Println(" -q Query")
fmt.Println(" -i Min Cert ID")
fmt.Println(" -cn Common Name")
fmt.Printf("Usage: %s -q example.com\n", os.Args[0])
os.Exit(0)
}
func run() error {
var (
query string
certID int
onlyDomainFlag bool
commonName string
)
flag.StringVar(&query, "q", "", "Query String")
flag.BoolVar(&onlyDomainFlag, "o", false, "Print only domains")
flag.IntVar(&certID, "i", 0, "Min Cert ID")
flag.StringVar(&commonName, "cn", "", "Query string for common name")
flag.Parse()
if query == "" && certID == 0 && commonName == "" {
showUsage()
}
if query != "" {
err := crtlog.QueryCrt(query, onlyDomainFlag)
if err != nil {
return err
}
} else if certID != 0 {
fmt.Printf("CertID: %d\n", certID)
err := parser.ParseCTLog(certID)
if err != nil {
return err
}
} else {
err := crtlog.SearchCommon(commonName, onlyDomainFlag)
if err != nil {
return err
}
}
return nil
}
func main() {
err := run()
if err != nil {
log.Fatal(err)
}
}