text stringlengths 0 1.99k |
|---|
--[ 1.4 - User Space Application Flow |
============================================================================ |
```````````````````````````````````````````````````````````````````````````` |
Service Discovery |
| |
v |
+-------------------+ IOServiceMatching() |
| Matching Dict |---> IOServiceGetMatchingServices() |
| "DriverName" | or IORegistryCreateIterator() |
+-------------------+ |
| |
v |
+-------------------+ IOIteratorNext() |
| Service Iterator |---> IORegistryEntryGetName() |
| Loop through all | strcmp(name, "target") |
+-------------------+ |
| |
v |
Connection Establishment |
| |
v |
+-------------------+ IOServiceOpen() |
| io_service_t |---> Creates IOUserClient |
| (Service Handle) | Returns io_connect_t |
+-------------------+ |
| |
v |
Method Invocation |
| |
v |
+-------------------+ IOConnectCallMethod() |
| io_connect_t |---> Selector + Arguments |
| Connection Handle | Routed to externalMethod() |
+-------------------+ |
User App --> I/O Registry --> IOService --> IOUserClient |
| ^ ^ | |
| | | | |
+-- Discovery --+ +-- Bridge ----+ |
| | |
+------------- IOConnectCallMethod ---------------+ |
```````````````````````````````````````````````````````````````````````````` |
=================== |
--[ 2 - IOKit Reconeiscance |
============================================================================ |
The second part of the guide shows how to map the attack surface |
properly to have a complete picture of External Methods exposed from Kernel |
Space to User Space. |
=========== |
--[ 2.0 - What to Map |
============================================================================ |
We need data from IOKit drivers, which enable targeted fuzzing and |
facilitate faster crash analysis. The result of this entire process should |
include a structured YAML (or your preferred format) file and a corpus |
directory with binary files for IOConnectCallMethod. |
Fields of interests: |
- Bundle Names : Kext identifiers containing the driver code. |
Example: com.apple.iokit.IOAVBFamily |
- Driver Names : IORegistry service names, so we can match them before |
using IOServiceOpen. Example: IOAVBNub |
- NewUserClients : Methods that handle new user client creation. |
Example: IOAVBNub::newUserClient |
- Types : Valid `type` values for IOServiceOpen. |
- External Methods : externalMethod selectors exposed by each user client. |
- Arguments : Valid scalar and struct sizes for input/output. |
- Endpoints : Selector IDs per UC, each mapped to argument sizes. |
- Corpus : Binary samples for inputStruct used by the system or |
known to be valid. |
Each driver maps to its connection types, which map to selector IDs with |
their argument layout: |
```````````````````````````````````````````````````````````````````````````` |
DriverName: |
TypeValue: |
SELECTOR_ID: [INPUT_SCALAR_CNT, INPUT_STRUCT_SIZE, OUTPUT_SCALAR_CNT, |
OUTPUT_STRUCT_SIZE] |
```````````````````````````````````````````````````````````````````````````` |
Example YAML Output Format: |
```````````````````````````````````````````````````````````````````````````` |
AFKEndpointInterface: # AFKEPInterfaceKextV2::newUserClient |
1768910955: # AFKEndpointInterfaceUserClient::externalMethod |
0: [2, 10, 16, 10] # extOpenMethod |
1: [1, 10, 1, 10] # extCloseMethod |
2: [7, 0, 0, 0] # extEnqueueCommandMethod |
... |
```````````````````````````````````````````````````````````````````````````` |
Corpus Directory Layout: |
Each selector gets a directory containing valid binary payloads. These can |
be passed directly into IOConnectCallMethod as inputStruct payloads. |
```````````````````````````````````````````````````````````````````````````` |
AFKEndpointInterface/1768910955 |
|- 0/ |
| `- corpus_0.bin |
|- 1/ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.