在 iOS 上获取 NSFileManager 的 root 权限(越狱)
我正在尝试将文件写入设备的根分区。它是一个越狱应用程序,因此安装在/Applications 中。使用 NSFileManager
写入根文件系统时,写入失败并出现“权限被拒绝”错误。
看来我的应用程序没有以 root 身份运行。但它安装在 /Applications 中。我的应用程序如何成为root?
I am trying to write file to the root partition of the device. It is a Jailbreak app so it is installed in /Applications. When writing to the root filesystem using NSFileManager
the write fails with a "Permission Denied" error.
It seems like my app is not running as root. It is installed in /Applications though. How can my app become root?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确实,应用程序必须以 root 身份运行才能访问非移动目录。经过与 Optimo 和 Saurik 讨论后,我终于找到了获得 root 权限的正确方法。
setuid(0);
和setgid(0);
打开原始可执行文件并将其内容替换为以下脚本:
<前><代码>#!/bin/bash
目录=$(目录名“$0”)
执行“${dir}”/COPIED_EXECUTABLE_NAME“$@”
在 iOS 上直接启动根应用程序失败。因此,我们将应用程序的主可执行文件替换为启动根可执行文件的脚本。
在终端中,导航到应用程序包。
chmod 0775
原始可执行文件和chmod 6775
复制的可执行文件。It is true, the app has to run as root to access non mobile directories. After discussing this with Optimo and Saurik I finally found the right way to get root privileges.
setuid(0);
andsetgid(0);
Open the original executable file and replace its content with this script:
Directly launching a root app fails on iOS. Therefore we replace the app's main executable with a script that launches the root executable.
In terminal, navigate to the app bundle.
chmod 0775
the original executable file andchmod 6775
the copied executable file.