【问题标题】:How to run subprograms with root permissions on iOS?如何在 iOS 上以 root 权限运行子程序?
【发布时间】:2014-02-10 11:56:39
【问题描述】:

使用 Android SDK,我可以通过调用 su 以超级用户身份运行进程,然后运行我的代码。我怎样才能在 iOS 上做同样的事情?

这是我在 Android 上使用的:

// Elevate to root
Process localProcess = Runtime.getRuntime().exec( "su");

// Now run some command as root
DataOutputStream localDataOutputStream = new DataOutputStream( localProcess.getOutputStream());
localDataOutputStream.writeBytes( "chmod 666 file.name\n");
localDataOutputStream.writeBytes( "exit\n");
localDataOutputStream.flush();

我尝试了以下 C 命令,但收到一条错误消息,指出我的密码不正确。

system( "ls -l /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist"); // read start permissions
system( "sudo -s alpine | chmod 666 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist"); // trying change permissions
system( "ls -l /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist"); // read changes

日志如下所示:

-rw-r--r-- 1根轮7813 Dec 16 10:47 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist

chmod:更改`/System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist'的权限:不允许操作

我们相信您已经收到了本地系统的常规讲座 行政人员。通常归结为以下三点:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

密码:

-rw-r--r-- 1根轮7813 Dec 16 10:47 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist

如何在 iOS 上以编程方式运行任何具有 root 权限的脚本?我正在寻找一个适用于越狱设备的答案,但如果可能的话,我会对也适用于库存设备的东西感到满意。

【问题讨论】:

  • 越狱:很容易,没有越狱:绝不。
  • @H2CO3 请提供任何越狱示例和问题:在 android 中我需要安装超级用户应用程序才能运行此代码。在 iOS 中我必须先安装任何程序?
  • @Moshe 感谢您编辑我的初学者英语
  • 你没有机会走合法的路。 Apple 商店中没有此类应用程序。还有什么,出于安全原因,非常好。为什么查看类别在这么深的层次?
  • 我不明白为什么我的问题有很多反对意见!!???这个问题我没有违反任何规则。而且我认为回答“越狱:很容易,没有越狱:绝不”并且不给出示例答案的人是一个大洪水。

标签: ios objective-c permissions sudo su


【解决方案1】:

IOS 的一个主要功能是沙盒,这意味着应用程序驻留在自己的文件系统中,其他应用程序不可见。你想做的事情违背了IOS的安全设计。

如果您需要做的是允许一组应用程序相互通信并共享数据,则可以通过共享文档类型、导出的 UTI 和 DocumentInteraction 类来实现此目的,

【讨论】:

  • 我知道很少有具有 sudo 权限的应用程序。例如,iFile。这个应用程序可以像我需要的那样具有类似的功能。我需要做什么才能获得 iFile 等应用程序的权限?
  • 是的,我知道越狱。我问:如何在越狱的 iOS 上以编程方式运行具有 SUDO 权限的脚本?
【解决方案2】:

您的sudo 命令格式错误:

sudo -s alpine | chmod 666 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist

解释为:

sudo -s <sudo-command> | <non-sudo-command>

这是尝试使用sudo 运行alpine 命令,并通过管道传输其输出 到chmod 这没有意义。由于chmod 没有以root 身份运行,它输出:

chmod: changing permissions of `/System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist': Operation not permitted

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

由于没有为sudo 提供密码(-S 参数),它 通过输出提示输入密码:

Password:

我想你打算这样做:

echo <password> | sudo -S <command>

我相信您打算使用 alpine 作为密码,然后是:

echo 'alpine' | sudo -S chmod 666 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist

有关sudo 的更多信息,请参阅man(8) sudo

【讨论】:

  • 我正在尝试运行以下命令并遇到一些错误,请告诉我如何解决此问题
  • system("echo 'alpine' | sudo -S tcpdump -c 20 -i en1 -vvv -A host www.facebook.com");
  • 错误:我们相信您已经收到了本地系统管理员的常规讲座。它通常归结为以下三件事:#1) 尊重他人的隐私。 #2) 打字前三思。 #3) 权力越大,责任越大。密码:手机不在 sudoers 文件中。将报告此事件。
  • @PalchuriSudheerKumar 你真的应该把它作为一个新问题发布。
猜你喜欢
  • 2013-04-04
  • 1970-01-01
  • 2014-09-16
  • 1970-01-01
  • 2016-05-20
  • 1970-01-01
  • 1970-01-01
  • 2011-09-01
  • 1970-01-01
相关资源
最近更新 更多