-
Notifications
You must be signed in to change notification settings - Fork 0
/
Driver.groovy
42 lines (33 loc) · 1.18 KB
/
Driver.groovy
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
import ScanOutputParser
static void main(String[] args) {
println('Running Nmap scan')
def nmapScanOutput = NmapScanner.runNmapScan(/Input\IPs.txt/);
println('Parsing scan results')
def scanResults = ScanOutputParser.parseNmapOutput(nmapScanOutput.toString())
println('Importing approved ports')
def approvedPorts = ApprovedPorts.getApprovedPorts(/Input\ApprovedPorts.csv/)
println('Comparing scan results to approved ports');
def newPorts = scanResults.inject([:]) {map, key, value ->
def diff = value - approvedPorts[key]
if (map[key]) {
map[key] << diff
} else if (diff) {
map[key] = diff
}
return map
}
def closedPorts = approvedPorts.inject([:]) {map, key, value ->
def diff = value - scanResults[key]
if (map[key]) {
map[key] << diff
} else if (diff) {
map[key] = diff
}
return map
}
Output.printReport('Unapproved Ports', newPorts)
Output.printReport('Closed Ports\n', closedPorts)
println('Saving reports')
Output.saveReport("Reports/UnapprovedPorts-${new Date().format('MM-dd-yyyy')}.csv", newPorts)
Output.saveReport("Reports/ClosedPorts-${new Date().format('MM-dd-yyyy')}.csv", closedPorts)
}