On a jailbroken iPhone, how can I run commands as root?

人走茶凉 提交于 2020-01-02 05:29:13

问题


I want to login as a root using system call in Xcode. I try this code without success:

System("su");
System("alpine");

or

System("su root");
System("alpine");

or

System("su root alpine");

When I google it I came to know that this is done using NSTask or NSPipe. Can anybody tell me how it possible to run multiple system commands using NSTask and NSPipe?

Please give me some hints about this or another method to do this. I am using this application on jailbroken iPhone.

Some more details are here.


回答1:


If you want to launch something as root you may use sudo.

Example of it's usage in one line with the password:

echo <password> | sudo -S <command>


来源:https://stackoverflow.com/questions/8516370/on-a-jailbroken-iphone-how-can-i-run-commands-as-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!