macOS Default Sandbox Debug
macOS默认沙箱调试
在本页面中,您可以找到如何创建一个应用程序,从默认的macOS沙箱中启动任意命令:
编译应用程序:
#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;
}运行以下命令进行编译:clang -framework Foundation -o SandboxedShellApp main.m
构建
.appbundle
定义授权
```bash cat << EOF > entitlements.plist com.apple.security.app-sandbox com.apple.security.files.downloads.read-write EOF ``` 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
最后更新于