# macOS Default Sandbox Debug
{% hint style="success" %}
Aprenda e pratique Hacking AWS:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Aprenda e pratique Hacking GCP: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* 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.
{% 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
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
CFBundleIdentifier
com.example.SandboxedShellApp
CFBundleName
SandboxedShellApp
CFBundleVersion
1.0
CFBundleExecutable
SandboxedShellApp
EOF
```
3. Defina as permissões
{% tabs %}
{% tab title="sandbox" %}
```bash
cat << EOF > entitlements.plist
com.apple.security.app-sandbox
EOF
```
{% endtab %}
{% tab title="sandbox + downloads" %}
```bash
cat << EOF > entitlements.plist
com.apple.security.app-sandbox
com.apple.security.files.downloads.read-write
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:[**HackTricks Treinamento AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Aprenda e pratique Hacking GCP: [**HackTricks Treinamento GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Suporte ao HackTricks
* 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).
{% endhint %}