mirror of
https://github.com/carlospolop/hacktricks
synced 2024-12-25 20:43:29 +00:00
135 lines
4.7 KiB
Markdown
135 lines
4.7 KiB
Markdown
# macOS Default Sandbox Debug
|
|
|
|
{% hint style="success" %}
|
|
Aprenda e pratique Hacking AWS:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Aprenda e pratique Hacking GCP: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Support HackTricks</summary>
|
|
|
|
* Confira os [**planos de assinatura**](https://github.com/sponsors/carlospolop)!
|
|
* **Junte-se ao** 💬 [**grupo do Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo do telegram**](https://t.me/peass) ou **siga**-nos no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Compartilhe truques de hacking enviando PRs para o** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repositórios do github.
|
|
|
|
</details>
|
|
{% endhint %}
|
|
|
|
Nesta página você pode encontrar como criar um aplicativo para lançar comandos arbitrários de dentro do sandbox padrão do macOS:
|
|
|
|
1. Compile o aplicativo:
|
|
|
|
{% code title="main.m" %}
|
|
```objectivec
|
|
#include <Foundation/Foundation.h>
|
|
|
|
int main(int argc, const char * argv[]) {
|
|
@autoreleasepool {
|
|
while (true) {
|
|
char input[512];
|
|
|
|
printf("Enter command to run (or 'exit' to quit): ");
|
|
if (fgets(input, sizeof(input), stdin) == NULL) {
|
|
break;
|
|
}
|
|
|
|
// Remove newline character
|
|
size_t len = strlen(input);
|
|
if (len > 0 && input[len - 1] == '\n') {
|
|
input[len - 1] = '\0';
|
|
}
|
|
|
|
if (strcmp(input, "exit") == 0) {
|
|
break;
|
|
}
|
|
|
|
system(input);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
```
|
|
{% endcode %}
|
|
|
|
Compile-o executando: `clang -framework Foundation -o SandboxedShellApp main.m`
|
|
|
|
2. Construa o pacote `.app`
|
|
```bash
|
|
mkdir -p SandboxedShellApp.app/Contents/MacOS
|
|
mv SandboxedShellApp SandboxedShellApp.app/Contents/MacOS/
|
|
|
|
cat << EOF > SandboxedShellApp.app/Contents/Info.plist
|
|
<?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">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>CFBundleIdentifier</key>
|
|
<string>com.example.SandboxedShellApp</string>
|
|
<key>CFBundleName</key>
|
|
<string>SandboxedShellApp</string>
|
|
<key>CFBundleVersion</key>
|
|
<string>1.0</string>
|
|
<key>CFBundleExecutable</key>
|
|
<string>SandboxedShellApp</string>
|
|
</dict>
|
|
</plist>
|
|
EOF
|
|
```
|
|
3. Defina as permissões
|
|
|
|
{% tabs %}
|
|
{% tab title="sandbox" %}
|
|
```bash
|
|
cat << EOF > entitlements.plist
|
|
<?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">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>com.apple.security.app-sandbox</key>
|
|
<true/>
|
|
</dict>
|
|
</plist>
|
|
EOF
|
|
```
|
|
{% endtab %}
|
|
|
|
{% tab title="sandbox + downloads" %}
|
|
```bash
|
|
cat << EOF > entitlements.plist
|
|
<?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">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>com.apple.security.app-sandbox</key>
|
|
<true/>
|
|
<key>com.apple.security.files.downloads.read-write</key>
|
|
<true/>
|
|
</dict>
|
|
</plist>
|
|
EOF
|
|
```
|
|
{% endtab %}
|
|
{% endtabs %}
|
|
|
|
4. Assine o aplicativo (você precisa criar um certificado no chaveiro)
|
|
```bash
|
|
codesign --entitlements entitlements.plist -s "YourIdentity" SandboxedShellApp.app
|
|
./SandboxedShellApp.app/Contents/MacOS/SandboxedShellApp
|
|
|
|
# An d in case you need this in the future
|
|
codesign --remove-signature SandboxedShellApp.app
|
|
```
|
|
{% hint style="success" %}
|
|
Aprenda e pratique Hacking AWS:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Treinamento AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Aprenda e pratique Hacking GCP: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Treinamento GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Suporte ao HackTricks</summary>
|
|
|
|
* Confira os [**planos de assinatura**](https://github.com/sponsors/carlospolop)!
|
|
* **Junte-se ao** 💬 [**grupo do Discord**](https://discord.gg/hRep4RUj7f) ou ao [**grupo do telegram**](https://t.me/peass) ou **siga**-nos no **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Compartilhe truques de hacking enviando PRs para os repositórios do** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud).
|
|
|
|
</details>
|
|
{% endhint %}
|