-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapt-get-vulnerable.py
96 lines (77 loc) · 2.56 KB
/
apt-get-vulnerable.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
90
91
92
93
94
95
96
#!/usr/bin/python
#Covered by GPL V2.0
import getopt
import sys
import functions
import report
import cache
import debian
import raspianfast
def get_system_link(system_string):
if system_string == 'debian':
return debian
elif system_string == 'raspianfast':
return raspianfast
#elif system_string == 'raspian':
#return raspina
#elif system_string == 'ubuntu':
#return ubuntu
else:
print system_string + " is not supported as a system."
return sys.exit()
def usage():
print "apt-get-vulnerable -s system -d distrib -i input-file1 -j input-file2 -o output"
print " input-file1 is the return of 'apt-get --simulate upgrade'"
print " input-file2 is the return of 'dpkg -l'"
print ""
print "system: debian (default), raspianfast"
print "distrib: squeeze (default), wheezy, jessie"
###Main###
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "s:d:i:j:o:h")
except getopt.GetoptError as err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
system = debian
distrib = "squeeze"
firstinput = ""
secondinput = ""
output = "Security-update-analysis"
for o, a in opts:
if o in ("-h"):
usage()
sys.exit()
elif o in ("-s"):
system = get_system_link(a)
elif o in ("-d"):
distrib = a
elif o in ("-i"):
firstinput = a
elif o in ("-j"):
secondinput = a
elif o in ("-o"):
output = a
else:
usage()
sys.exit()
if cache.init_cache_folders(system, distrib) is False:
print "Error with cache function"
return 1
if not firstinput or not secondinput:
print "Params i and j are mandatory"
usage()
sys.exit()
packet_list_to_update = functions.get_update_list(firstinput)
packet_list_to_update = system.clean(packet_list_to_update)
packet_list = functions.get_packet_dict(secondinput)
packet_update_info = []
for packet in packet_list_to_update:
#for packet in packet_list:
packet_update_info.append(functions.analyse_packet(system, distrib, packet[0], packet_list[packet[0]], packet[1]))
source_packet_update_info = functions.get_update_packet_list_by_source_packet(system, distrib, packet_update_info)
return report.export_to_html(source_packet_update_info, output)
if __name__ == "__main__":
main()