Skip to content

Instantly share code, notes, and snippets.

@patrickgill
Created April 5, 2019 15:37
Show Gist options
  • Save patrickgill/f13f3688645537416b2eee3f33875877 to your computer and use it in GitHub Desktop.
Save patrickgill/f13f3688645537416b2eee3f33875877 to your computer and use it in GitHub Desktop.
# 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