-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlistkext.py
41 lines (27 loc) · 844 Bytes
/
listkext.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
#!/usr/bin/python
import sys
from subprocess import Popen, PIPE
import re
def nonapplekext():
# Run the kextstat command which lists *all* kernel extensions
p = Popen(["kextstat"],stdout=PIPE)
kext = [] # our list of extensions
while 1:
o = p.stdout.readline()
# keep reading lines from the kextstat command until there are no more
if o == '' and p.poll() != None:
break
# the company name starts at character 44
l = o[52:]
# get rid of the extra info at the end
t = re.sub("<.*>","", l)
# exclude all the Apple supplied extensions
if l[0:9] != "com.apple":
kext.append(t[:-2])
# return the sorted list sans the header
return sorted(kext[1:])
if __name__ == '__main__':
kext = nonapplekext()
print '\n'.join(kext)
# change to 0 for success, 1 for (partial) failure
sys.exit(0)