text
stringlengths
0
1.99k
| `- corpus_0.bin
`- ...
````````````````````````````````````````````````````````````````````````````
This is a suggested structure for the IOKit MAP. Feel free to organize the
data as you like; it’s just how I categorize information for my fuzzer.
=============
--[ 2.1 - KEXT Analysis
============================================================================
Kernel extensions (KEXTs) are loaded into a kernel cache. Their source
directories are in: /System/Library/Extensions. To get the actual binaries,
decompress the kernel cache:
````````````````````````````````````````````````````````````````````````````
ipsw kernel dec $(ls
/System/Volumes/Preboot/*/boot/*/System/Library/Caches/com.apple.kernelcache
s/kernelcache) -o kernelcache
````````````````````````````````````````````````````````````````````````````
Then extract all KEXTs from the decompressed kernel cache:
````````````````````````````````````````````````````````````````````````````
ipsw kernel extract $(kernelcache.decompressed) --all
````````````````````````````````````````````````````````````````````````````
Alternatively, download the latest IPSW manually:
````````````````````````````````````````````````````````````````````````````
ipsw dl appledb --os macOS --latest --kernel
````````````````````````````````````````````````````````````````````````````
Then extract KEXTs as before:
````````````````````````````````````````````````````````````````````````````
ipsw kernel extract kernelcache.release.* --all
````````````````````````````````````````````````````````````````````````````
Each KEXT includes an Info.plist file, which helps with mapping. Unlike
binaries, these files are found at:
````````````````````````````````````````````````````````````````````````````
/System/Library/Extensions/KEXT_BUNDLE_NAME/Contents/Info.plist
````````````````````````````````````````````````````````````````````````````
For more, see: "Kernel Extensions on macOS"[28] (not required to follow
the rest of this paper).
============
--[ 2.1.1 - Bundle Names
============================================================================
We need these names, because they represent binaries. Having all
binaries ensures we won't miss any exposed external methods. There are many
KEXTs, but we are only interested in drivers. These typically contain
"driver" or "iokit" in their bundle names.
To list them from the extracted kernel cache (Sequoia returns 304 names):
````````````````````````````````````````````````````````````````````````````
/bin/ls -1
kernelcache/System/Volumes/Preboot/*/boot/*/System/Library/Caches/com.apple.
kernelcaches/ | grep ".iokit.\|.driver."
...
com.apple.driver.AppleALSColorSensor
com.apple.driver.AppleANELoadBalancer
com.apple.driver.AppleAOPAudio
...
com.apple.iokit.IOStreamFamily
com.apple.iokit.IOSurface
com.apple.iokit.IOThunderboltFamily
...
````````````````````````````````````````````````````````````````````````````
Another method is to use kextstat, but it only displays currently loaded
KEXTs. On Sequoia 15.4.1, this returns 220 entries:
````````````````````````````````````````````````````````````````````````````
kextstat | grep ".iokit.\|driver" | awk '{print $6}'
...
com.apple.iokit.IOGraphicsFamily
com.apple.driver.DiskImages
com.apple.iokit.IOKitRegistryCompatibility
...
````````````````````````````````````````````````````````````````````````````
To get the complete list, use the first method.
============
--[ 2.1.2 - Driver Names
============================================================================
To interact with a driver using IOServiceOpen, we must know the name of
an instantiated IOService object it creates. These names typically come
from the IOKitPersonalities section of the driver's Info.plist, where each
key or value under fields like IOClass, IOProviderClass, IOName, or
IONameMatch can indicate a potential service name. To enumerate all
potential service names defined in the Info.plist, the following command
extracts relevant fields:
````````````````````````````````````````````````````````````````````````````
plutil -convert json -o -
/System/Library/Extensions/KEXT_NAME/Contents/Info.plist \
| jq -r '
.IOKitPersonalities
| to_entries[]
| [
.key,
.value.IOClass,
.value.IOProviderClass,
.value.IONameMatch,
.value.IOName
]
| flatten