-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
executable file
·90 lines (79 loc) · 2.6 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"flag"
"strings"
"github.com/kopolindo/cve-scraper/db"
_ "github.com/mattn/go-sqlite3"
)
const banner = `
#### # # ###### #### #### ##### ## ##### ###### #####
# # # # # # # # # # # # # # # # #
# # # ##### ##### #### # # # # # # # ##### # #
# # # # # # ##### ###### ##### # #####
# # # # # # # # # # # # # # # # #
#### ## ###### #### #### # # # # # ###### # #
|Version: {{.Ver}}
|Commit: {{.Commit}}
|Build: {{.Build}}
`
type Version struct {
Ver string
Build string
Commit string
}
var (
fieldsToPrint []string
AllowedFields = []string{"Cve", "CveDesc", "Cwe", "CweDesc", "Exploit", "Refs", "Cvssv2", "Cvssv3", "Software", "Version"}
ActualVersion = Version{"0.1", "Developing", "de9bd41fa1450f6a5bbb667567040615c945c0c6"}
output bool
//FLAGS
cve = flag.String("cve", "", "CVE-ID to look for (at least year in format YYYY and ID number)")
sw = flag.String("sw", "", "Software name to look for")
swVersion = flag.String("swv", "", "Software version (Exact search by default)\n\t~ Generic search (looks for any similar string in the version field)")
fields = flag.String("fields", "", "Fields to print, comma separated\n[Cve,CveDesc,Cwe,CweDesc,Exploit,Refs,Cvssv2,Cvssv3,Software,Version]")
write = flag.String("write", "", "Output file (csv)")
header = flag.Bool("header", false, "Print header: false by default. If CSV output desired header is true by default")
version = flag.Bool("version", false, "Print version and exit")
)
/************************
* MAIN FUNCTION *
************************/
func main() {
var (
resArray []db.Results
res db.Results
count int = 0
)
Init()
if *cve != "" {
cve := ValidateCve()
for _, c := range cve {
i := 0
res, i = db.CveSearch(c)
if i != 0 {
resArray = append(resArray, res)
count += i
}
}
}
if *sw != "" {
if *swVersion == "" {
for _, singleSw := range strings.Split(*sw, ",") {
tmp := db.SwSearch(singleSw)
for _, element := range tmp {
resArray = append(resArray, element)
}
}
}
if *swVersion != "" {
for _, singleSw := range strings.Split(*sw, ",") {
tmp := db.SwVSearch(singleSw, *swVersion)
for _, element := range tmp {
resArray = append(resArray, element)
}
}
}
}
WriteCsv(resArray)
PrintResults(resArray, fieldsToPrint)
}