mirror of
https://github.com/carlospolop/hacktricks
synced 2024-12-22 02:53:28 +00:00
135 lines
4.7 KiB
Markdown
135 lines
4.7 KiB
Markdown
# Depuração do Sandbox Padrão do macOS
|
|
|
|
<details>
|
|
|
|
<summary><strong>Aprenda hacking no AWS do zero ao herói com</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
|
|
|
Outras formas de apoiar o HackTricks:
|
|
|
|
* Se você quer ver sua **empresa anunciada no HackTricks** ou **baixar o HackTricks em PDF**, confira os [**PLANOS DE ASSINATURA**](https://github.com/sponsors/carlospolop)!
|
|
* Adquira o [**material oficial PEASS & HackTricks**](https://peass.creator-spring.com)
|
|
* Descubra [**A Família PEASS**](https://opensea.io/collection/the-peass-family), nossa coleção de [**NFTs**](https://opensea.io/collection/the-peass-family) exclusivos
|
|
* **Participe do grupo** 💬 [**Discord**](https://discord.gg/hRep4RUj7f) ou do grupo [**telegram**](https://t.me/peass) ou **siga-me** no **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/carlospolopm)**.**
|
|
* **Compartilhe suas técnicas de hacking enviando PRs para os repositórios github do** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud).
|
|
|
|
</details>
|
|
|
|
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 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 os direitos
|
|
|
|
{% 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
|
|
```
|
|
<details>
|
|
|
|
<summary><strong>Aprenda hacking em AWS do zero ao herói com</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
|
|
|
Outras formas de apoiar o HackTricks:
|
|
|
|
* Se você quer ver sua **empresa anunciada no HackTricks** ou **baixar o HackTricks em PDF**, confira os [**PLANOS DE ASSINATURA**](https://github.com/sponsors/carlospolop)!
|
|
* Adquira o [**material oficial PEASS & HackTricks**](https://peass.creator-spring.com)
|
|
* Descubra [**A Família PEASS**](https://opensea.io/collection/the-peass-family), nossa coleção de [**NFTs**](https://opensea.io/collection/the-peass-family) exclusivos
|
|
* **Junte-se ao grupo** 💬 [**Discord**](https://discord.gg/hRep4RUj7f) ou ao grupo [**telegram**](https://t.me/peass) ou **siga-me** no **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/carlospolopm)**.**
|
|
* **Compartilhe suas técnicas de hacking enviando PRs para os repositórios github** [**HackTricks**](https://github.com/carlospolop/hacktricks) e [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud).
|
|
|
|
</details>
|