-
Notifications
You must be signed in to change notification settings - Fork 4
/
rc_colas.py
executable file
·37 lines (30 loc) · 1.46 KB
/
rc_colas.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
#!/usr/bin/python
"""Given sha1's of expected rc's, report on any altered or others w/ rc prefix."""
import glob
import hashlib
def main():
"""gimme some main"""
expected_rc_colas = {"/etc/rc.common" : ['c2c9d79c11496a2bd59b9cec11bc5b6817098303',
'bcfb18ba7fc1b8b6568370cd790ac1be9c0fb6dd'],
"/etc/rc.common~previous" : ['c2c9d79c11496a2bd59b9cec11bc5b6817098303'],
"/etc/rc.deferred_install" : ['0c64ec4dfe03ccc8523a5872acf1bbcf48199f6a'],
"/etc/rc.imaging" : ['6d67f95a31b36116c5e4d1d09ff4cc03e046db60'],
"/etc/rc.netboot" : ['471e633b1f6bb3de9a48147ebfa5858f71ab0c32',
'a4c7e86cf6f00c1c9bb3b82e1d470d153bba23b5'],
"/etc/rc.server" : ['6dba02aa6e6f5eb9d9dc97bdd3dcef256a698163'],}
present_rcs = glob.glob('/etc/rc*')
caught_rcs = []
for cola in present_rcs:
with open(cola, 'rb') as sha_me:
found_sha = hashlib.sha1(sha_me.read()).hexdigest()
if found_sha in expected_rc_colas.get(cola):
pass
else:
caught_rcs.append(cola + ' sha: ' + found_sha[:7])
if caught_rcs:
result = "Caught 'off' rc, investigate: " + "\n".join(*[caught_rcs])
else:
result = "No unexpected or altered rc's present."
print "<result>%s</result>" % result
if __name__ == '__main__':
main()