-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhofautoscan.py
89 lines (65 loc) · 2.37 KB
/
hofautoscan.py
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
#!/usr/bin/env python
# halloffame.py - automated check for reported vulns (Hall Of Fame)
"""
Check Hall OF Fame vulnerabilities
Use for automation of scan
Author: Emilien LE JAMTEL
CERT-EU - version 1.0
30/05/2016
"""
import sys
import requests
import json
import datetime
from hofscanner import checkvuln
######### Functions calling checkvuln function on selected vulnerability (full, unpatched od incident_number)
def full_scan(hof):
hof_updated = hof
for i in range (len(hof)):
hof_updated[i] = checkvuln(hof[i])
return hof_updated
def unpatched_scan(hof):
hof_updated = hof
for i in range (len(hof)):
if hof[i]["patched"] == 'no':
hof_updated[i] = checkvuln(hof[i])
return hof_updated
## function returning list for specific Incident Number
def incident_scan (hof,incident_number):
hof_updated = hof
for i in range (len(hof)):
if hof[i]["Incident"] == incident_number:
hof_updated[i] = checkvuln(hof[i])
return hof_updated
#################################################################################
######## Functions to read/write the halloffame ########
def load_hof(json_file):
with open(json_file, 'r') as data:
halloffame = json.load(data)
return halloffame
def write_hof(hof,json_file):
with open(json_file, 'w') as data:
data.write(json.dumps(hof, indent=4))
############### Main ###############
if len(sys.argv) != 3:
print ('Usage: python halloffame.py [JSON file] [option]')
print ('options are:')
print ('fullscan = scan all entries in the halloffame.json file')
print ('unpatched = scan all unpatched vulnerabilities in the halloffame.json file')
print ('123456 = scan all vulnerabilities related to incident number 123456')
sys.exit()
halloffame_json = sys.argv[1]
option = sys.argv[2]
halloffame = load_hof(halloffame_json)
## make a backup
write_hof(halloffame,halloffame_json + '.save')
## based on the option, we will replace the actual halloffame
if str(option) == 'fullscan':
halloffame_updated = full_scan(halloffame)
elif str(option) == 'unpatched':
halloffame_updated = unpatched_scan(halloffame)
else:
halloffame_updated = incident_scan(halloffame,option)
######### Overwriting the json file ###############
write_hof(halloffame_updated,halloffame_json)
###################################################