Skip to content

Commit 7b5eb95

Browse files
carlospolopgitbook-bot
authored andcommittedMay 6, 2024
GITBOOK-4328: No subject
1 parent 8acbebc commit 7b5eb95

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎macos-hardening/macos-security-and-privilege-escalation/macos-proces-abuse/macos-ipc-inter-process-communication/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,9 @@ For more information about how this **communication work** on how it **could be
10341034

10351035
## MIG - Mach Interface Generator
10361036

1037-
MIG was created to **simplify the process of Mach IPC** code creation. It basically **generates the needed code** for server and client to communicate with a given definition. Even if the generated code is ugly, a developer will just need to import it and his code will be much simpler than before.
1037+
MIG was created to **simplify the process of Mach IPC** code creation. This is because a lot of work to program RPC involves the same actions (packing arguments, sending the msg, unpacking the data in the server...).
1038+
1039+
MIC basically **generates the needed code** for server and client to communicate with a given definition (in IDL -Interface Definition language-). Even if the generated code is ugly, a developer will just need to import it and his code will be much simpler than before.
10381040

10391041
For more info check:
10401042

‎macos-hardening/macos-security-and-privilege-escalation/macos-proces-abuse/macos-ipc-inter-process-communication/macos-mig-mach-interface-generator.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,27 @@ Other ways to support HackTricks:
1414

1515
</details>
1616

17+
## Basic Information
18+
1719
MIG was created to **simplify the process of Mach IPC** code creation. It basically **generates the needed code** for server and client to communicate with a given definition. Even if the generated code is ugly, a developer will just need to import it and his code will be much simpler than before.
1820

21+
The definition is specified in Interface Definition Language (IDL) using the `.defs` extension.
22+
23+
These definitions have 5 sections:
24+
25+
* **Subsystem declaration**: The keyword subsystem is used to indicate the **name** and the **id**. It's also possible to mark it as **`KernelServer`** if the server should run in the kernel.
26+
* **Inclusions and imports**: MIG uses the C-prepocessor, so it's able to use imports. Moreover, it's possible to use `uimport` and `simport` for user or server generated code.
27+
* **Type declarations**: It's possible to define data types although usually it will import `mach_types.defs` and `std_types.defs`. For custom ones some syntax can be used:
28+
* \[i`n/out]tran`: Function that needs to be trasnlated from an incoming or to an outgoing message
29+
* `c[user/server]type`: Mapping to another C type.
30+
* `destructor`: Call this function when the type is released.
31+
* **Operations**: These are the definitions of the RPC methods. There are 5 different types:
32+
* `routine`: Expects reply
33+
* `simpleroutine`: Doesn't expect reply
34+
* `procedure`: Expects reply
35+
* `simpleprocedure`: Doesn't expect reply
36+
* `function`: Expects reply
37+
1938
### Example
2039

2140
Create a definition file, in this case with a very simple function:
@@ -37,7 +56,9 @@ simpleroutine Subtract(
3756
```
3857
{% endcode %}
3958
40-
Now use mig to generate the server and client code that will be able to comunicate within each other to call the Subtract function:
59+
Note that the first **argument is the port to bind** and MIG will **automatically handle the reply port** (unless calling `mig_get_reply_port()` in the client code). Moreover, the **ID of the operations** will be **sequential** starting by the indicated subsystem ID (so if an operation is deprecated it's deleted and `skip` is used to still use its ID).
60+
61+
Now use MIG to generate the server and client code that will be able to communicate within each other to call the Subtract function:
4162
4263
```bash
4364
mig -header myipcUser.h -sheader myipcServer.h myipc.defs

0 commit comments

Comments
 (0)
Please sign in to comment.