# macOS 기본 샌드박스 디버그 {{#include ../../../../banners/hacktricks-training.md}} 이 페이지에서는 기본 macOS 샌드박스 내에서 임의의 명령을 실행하는 앱을 만드는 방법을 찾을 수 있습니다: 1. 애플리케이션 컴파일: ```objectivec:main.m #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; } ``` `clang -framework Foundation -o SandboxedShellApp main.m`를 실행하여 컴파일합니다. 2. `.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. 권한 정의 {{#tabs}} {{#tab name="sandbox"}} ```bash cat << EOF > entitlements.plist com.apple.security.app-sandbox EOF ``` {{#endtab}} {{#tab name="sandbox + downloads"}} ```bash cat << EOF > entitlements.plist com.apple.security.app-sandbox com.apple.security.files.downloads.read-write EOF ``` {{#endtab}} {{#endtabs}} 4. 앱 서명 (키체인에서 인증서를 생성해야 함) ```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 ``` {{#include ../../../../banners/hacktricks-training.md}}