Xcode - Passing Bash Commands With A Jailbroken Device - iphone

I'd like to know how it would be possible to execute bash commands on a jailbroken iOS device with Xcode? I'm not bothered about the code signing process because I already have a developer account.
I've tried using these 2 commands:
system("cd /var/mobile/Documents");
system("mkdir myNewFolder");
But Xcode returns "Cannot create directory, permission denied".
I know for definite that this is possible. Basically, I want to be using commands such as dpkg and apt commands.
Thanks in advance,
Declan

In UNIX like OS's like iOS you can use the 'Sudo' command to run as root.
To use in one line you need to use UNIX pipes like this:
system("echo yourPassword | sudo -S yourCommand");
You need to make sure sudo is installed on your device, not sure if it is by default.
Some more info here: On a jailbroken iPhone, how can I run commands as root?

Related

.sh script that executes command as "real" root

I want to write a .sh-script that sends a message to my ejabberd-account. (the script is "called" by the apache2 standard-user "www-data").
The script should execute the following command: ejabberdctl send_message chat admin#my-domain user#my-domain "title" "my message"
However, I can't run any ejabberdctl command without "being" root. So sudo ejabberdctl is not working (in terminal or any .sh-script). I can only do sudo -s followed by ejabberdctl my-command, which doesn't work in .sh-scripts (or am I wrong?).
(I've installed ejabberd 20.07 on ubuntu 20.04 with the help of this tutorial: Install Ejabberd...)
Is there a way to run a command in a .sh-script as "real root" or to create a root-session and run the command there (like I do manually with sudo -s ...)?
Is there any solution to my problem or should I install ejabberd the "normal way"?
When ejabberd is compiled and installed from source code, it's possible to prepare it with something like
./configure -–enable-group=ejagroup
Then, you can simply create the system group ejagroup, and add the www-data user to that ejagroup.
See https://docs.ejabberd.im/admin/installation/#options
In your case, that you use the Debian package from ProcessOne, I see the tutorial mentions that you create a system account called ejabberd. Maybe you can run ejabberdctl from that account, no need to be root?
I still don't know why I can only run ejabberdctl when I'm "logged-in" as root (sudo ejabberdctl is still not working)
Is my .bashrc file wrong? (last line: PATH=$PATH:/opt/ejabberd-20.07/bin/)
Anyway, at least I can run sudo /opt/ejabberd-20.07/bin/ejabberdctl my_command with any user, like they did here: Ejabberd sbin/ejabberdctl start (No such file or directory)
Has someone else experienced this weird behavior with sudo: any_command: not found ?
Let me know if you have a more "elegant" solution to my problem.

Installing Meteor - Couldn't write the launcher script

I am front-end developer attempting to crossover into the world of web app development. I've come a long way in learning Javascript, and now I'm looking to toy around with frameworks.
I still have a bit to learn about using the OSX terminal, but I was hoping somebody could help me with this first stumble I'm having....
I try to install meteor using:
$ curl https://install.meteor.com | /bin/sh
Then I get the following:
Meteor 0.6.4 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.
cp: /usr/local/bin/meteor: No such file or directory
Couldn't write the launcher script. Please either:
(1) Run the following as root:
cp ~/.meteor/tools/latest/launch-meteor /usr/bin/meteor
(2) Add ~/.meteor to your path, or
(3) Rerun this command to try again.
Then to get started, take a look at 'meteor --help' or see the docs at
docs.meteor.com.
If it's still helpful to anyone, going into /usr/local/bin, running "sudo rm meteor" then running the install gets it to work for me
Yeah try one of the three suggestions or:
sudo curl https://install.meteor.com | /bin/sh
I had the same problem heres how I fixed it!
Delete all meteor folders
In finder (cmd +shft+g)
type in "~/.meteor"
on the top of the finder window where is has the folder.meteor click and drag folder to trash
In finder (cmd +shft+g) type in "/usr/bin/meteor" then drag the meteor folder to trash
3.In /usr/ create a new folder "local" (password required) and inside "local" create a folder "bin"
Go back to terminal a run curl https://install.meteor.com | /bin/sh

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

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

How do I use Gnome's sudo dialog from perl?

I need to run a privilegied command on a gtk2-perl user program. I'm googling about how to use the default dialog for getting root privilegies on Gnome, but can find an answer.
The only approach I have is to ask the password and use in a command
"echo $passwod | sudo -S priv-command"
but it's a bit ugly. I'm looked for the old gtksudo and similar helper programs but seems that there aren't in Ubuntu 10.10
Any pointers?
Not gtksudo, but GKSu is the name. The same thing in KDE is called kdesu.
The dialog you are talking of is from PolicyKit.

iphone run app as root

I am writing a gui wrapper for gcc for a jailbroken iphone, etc. and it is almost done. However, I get this output when it is run ld: can't open output file for writing : a.out, errno=1 collect2:ld return 1 exit status.
I believe this has to do with the privelages the app runs with. I have tried the setuid trick in the cydia developer faq. Can anyone please help?
EDIT
this is the wrapper I am currently using:
#!/usr/bin/bash
dir=$(dirname "$0")
exec "${dir}"/GUI\ GCC_ "$0"
also I used chmod 4777 and changes the owner:group to root:wheel.
Am i doing everything right?
It worked when I did it like this:
setuid(0);
system("Do root stuff");
// To check who you are
system("whoami");
You can install the Package for "ps -U root" to see if you are root, or
Be sure your have your setuid binary hidden behind a wrapper that is not setuid. See Cydia or iFile for an example of how it's done.