首页 文章

如何在iOS上运行具有root权限的子程序?

提问于
浏览
-5

使用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年12月16日10:47 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist chmod:更改`/ System / Library / TextInput / TextInput_zh的权限 . bundle / Keyboard-zh.plist':不允许操作我们相信您已收到本地系统管理员的常规讲座 . 它通常归结为这三件事:#1)尊重他人的隐私 .
#2)在打字之前先想想 .
#3)强大的力量带来了巨大的责任 .
密码:-rw-r - r-- 1根轮7813年12月16日10:47 /System/Library/TextInput/TextInput_zh.bundle/Keyboard-zh.plist

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

2 回答

  • 4

    IOS的一个主要功能是沙盒,这意味着应用程序驻留在自己的文件系统中,而其他应用程序无法看到它们 . 您想要做的是违反IOS的安全设计 .

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

  • 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 .

相关问题