Created
April 5, 2019 15:37
-
-
Save patrickgill/f13f3688645537416b2eee3f33875877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kext info dump | |
# (c) Patrick Gill, 2019 | |
first_arg, *the_rest = ARGV | |
Dir.chdir "/Volumes/Macintosh HD/System/Library/Extensions" | |
# Dir.chdir "/Library/Extensions" | |
puts "#Path, " + Dir.pwd | |
def kext_ident(path) | |
if File.exist?(path + "/Contents/Info.plist") | |
plistpath = path + "/Contents/Info.plist" | |
elsif File.exist?(path + "/Info.plist") | |
plistpath = path + "/Info.plist" | |
else | |
plistpath = "unknown" | |
end | |
unless plistpath == "unknown" | |
info_plist = File.read(plistpath) # read binary plist | |
IO.popen('plutil -convert xml1 -r -o - -- -', 'r+') {|f| | |
f.write(info_plist) | |
f.close_write | |
info_plist = f.read # xml plist | |
} | |
# Now info_plist is an xml string. To quickly extract one property you can use regex: | |
app_bundle = info_plist.scan(/<key>CFBundleIdentifier<\/key>\s+<string>(.+)<\/string>/).flatten.first | |
else | |
app_bundle = "unknown" | |
end | |
return app_bundle | |
end | |
Dir.glob("*.kext") {|item| | |
next if item == '.' or item == '..' | |
# do work on real items | |
puts item + ", " + kext_ident(item) | |
# Contents | |
} | |
# puts first_arg + "\t\t" + kext_ident(first_arg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment