Skip to content

Instantly share code, notes, and snippets.

@leiless
Last active January 28, 2019 07:34
Show Gist options
  • Save leiless/a870ea84e346b9a2639575224f4fec6b to your computer and use it in GitHub Desktop.
Save leiless/a870ea84e346b9a2639575224f4fec6b to your computer and use it in GitHub Desktop.
Resolve XNU kernel programming interfaces(KPIs)
#!/bin/sh
#
# Created 18H21
#
if [ $# -ne 1 ]; then
cat << EOL
Usage: $(basename $0) symbol ...
EOL
exit 1
fi
SYM="$1"
SYSKEXTDIR=/System/Library/Extensions/System.kext/PlugIns
[ ! -d $SYSKEXTDIR ] && echo "$SYSKEXTDIR not found" && exit 1
for KEXT in $SYSKEXTDIR/*.kext; do
EXEC=$(basename $KEXT .kext)
if [ -f "$KEXT/$EXEC" -a -x "$KEXT/$EXEC" ]; then
nm "$KEXT/$EXEC" | grep -iq "$SYM" || continue
echo "$EXEC:"
nm "$KEXT/$EXEC" | grep -i "$SYM" && echo
INFO="$KEXT/Info.plist"
if [ -f "$INFO" ]; then
cat "$INFO" | grep CFBundleIdentifier -A 1 | tail -1 | sed 's/<.*>\(.*\)<\/.*>/\1/'
cat "$INFO" | grep OSBundleCompatibleVersion -A 1 | tail -1 | sed 's/<.*>\(.*\)<\/.*>/\1/'
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment