/
searchIssues.go
60 lines (56 loc) · 1.67 KB
/
searchIssues.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
package nessusTools
import (
"fmt"
"os"
"strings"
)
//SearchIssues collects all issues and output from a nessus report, prunes repreating information and presents output to a user based on a specific search term.
func SearchIssues(filePath string, search string, writeToFile bool, Hosts []Host) ([]Host, error) {
for a, b := range Hosts {
Hosts[a] = b.RemoveDuplicateIssues()
}
f, err := os.Create("output") //write to a file called output
for _, a := range Hosts {
hostPrinted := 0 //Change to 1 when a hostname is printed. (resets on each new host)
for _, b := range a.issues {
if strings.Contains(b.issueName, search) {
if hostPrinted == 0 { //check if host has been printed, if not, print
if writeToFile == true {
f.Write([]byte(a.name + "\n"))
} else {
fmt.Println(a.name)
}
hostPrinted = 1 //change to 1 now hostname has been printed.
}
if writeToFile == true {
f.Write([]byte(" " + b.issueName + "\n"))
} else {
fmt.Println(" " + b.issueName)
}
list := []string{} //list for containing and manipulating nessus pluginOutput data
if search == "SSL" { //copy this block to add in new search specific criteria
for _, c := range b.output {
list = append(list, sslSearch(c)...)
}
list = RemoveDuplicates(list)
for _, a := range list {
if writeToFile == true {
f.Write([]byte(" " + a + "\n"))
} else {
fmt.Println(" " + a)
}
}
} else {
for _, c := range b.output {
if writeToFile == true {
f.Write([]byte(c + " \n"))
} else {
fmt.Println(c + " \n")
}
}
}
}
}
}
return Hosts, err
}