Running su on Android root - android

Hi so my application runs some commands using the su in android root.
It works fine in JellyBean on the Galaxy Nexus but when I try to run it on the LG Nexus 5 (kitkat), I get an error saying:
su: uid 10069 not allowed to su
I'm not really sure what I'm missing here. I have root access (it runs su fine on the Galaxy Nexus).
Basically the application reads in a command from a TextEdit, strips it, appends the necessary parameters etc. and then calls the script which is put on the phone. I use the ProcessBuilder to build the call for the script.
Any fixes or ideas as to where I should look would be appreciated. Thank you

The issue was SuperSu not being properly installed and granting permission to the application. Once I changed that there were no permissions issues.

If you have problem with rooting to super user.
You can use "run-as" command to access files of your application.
ex: run-as com.your.package
It will drop you to the shell#android:/data/data/com.your.package $
now you can use commands ls
Then it will display the list of file folders
cache
databases
lib
shared_prefs

Related

How to root or GPIO access on custom android-based development board

I have this development board Open-Q 820
It is running an Android 7.0 based on some sources from CodeAurora (that seem based on AOSP sources). Seems it uses proprietary bootloader that can not be changed. I need to access GPIO (/system/class/gpio) from my android app to control an external device. Problem is I can not do this from android app - seems only root can access this files.
I can call "adb root" command from PC and then call from "adb shell" something like
echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
echo 1 > /sys/class/gpio/gpio0/value
and it is working. But I need to do the same from my android app. I know how to access terminal and su from android app. I just dont know how to root custom device. I tried to install SuperSU.apk app and its corresponding su native app manually. It starts and says it need to update su binaries. After installing binaries and reboot the system then it becomes broken - infinite android logo. If I not install binaries update then SuperSU can grant permissions to my app but actully app still can not use su (I dont know why - I use this library inside my app: https://github.com/Chrisplus/RootManager). And after reboot SuperSU not working longer.
So may be you know some SuperSU alternatives (Knigroot not working too) or steps how to correctly install some superuser management app. Or may be I can use su directly (I tried but my app has not rights to access /system/xbin/su). Or may be I can make /sys/class/gpio accessible by android apps somehow (I tried chmod 777 on it - not works). May be some SElinux rights, but I have no experience with this.
Thank you
Magisk helped me. Since it is have option to patch custom boot image. I used this option and now root access works.

Installing Superuser on Android User Debug Build (no su binary found)

I'm currently doing lab work on an upcoming device and I've hit a wall on this particular one.
I can't say the model number, but it's running Android 5.1 and the build is LMY47D
It's a user debug build - so I have the SU binary and busybox installed, and I am perfectly capable of running any and all su commands.
I have the SU binary located in "system/bin/" and it's linked to "/system/xbin/." It has root access and the correct privileges (I think). Also you can see that busybox is installed.
Where I am having the problem is installing superuser and a few other apps.
I installed the apps to the "system/app/" folder with the privileges 755 along with appdel.apk and appdel2.apk (The ones that I need to give root access too)
Here is a snapshot of the "/System/app" folder.
As you can see, everything is there with root privileges, but when I try to access the application, nothing is working.
How do I give these applications Root Access?
As a side note, I can't flash or reload this ROM. Kingo root and IRoot just about bricked the phone. The superuser that I am trying to install is 2.46, which is the same superuser that the guys at Nexus Root are using on their LMY47D devices.
This is one of the guides that I have been following (among others): http://pocketnow.com/2012/10/10/root-without-unlocking
Thank you guys

Android: adbd cannot run as root in production builds

I have an Android-based phone (2.3.6) with unlocked root privileges.
Since i'd like to have access to my phone through my computer, today i've installed QtAdb and Android SDK.
If i open a command prompt and i do
adb shell su
i get
#
And so I am able to copy, remove, push files on my phone (on the phone i get a notification using the app "SuperSU".)
But if i launch QtAdb - under Windows 7 - i get the following error: "adbd cannot run as root in production builds". I miss something? There's something wrong with QtAdb?
The problem is that, even though your phone is rooted, the 'adbd' server on the phone does not use root permissions. You can try to bypass these checks or install a different adbd on your phone or install a custom kernel/distribution that includes a patched adbd.
Or, a much easier solution is to use 'adbd insecure' from chainfire which will patch your adbd on the fly. It's not permanent, so you have to run it before starting up the adb server (or else set it to run every boot). You can get the app from the google play store for a couple bucks:
https://play.google.com/store/apps/details?id=eu.chainfire.adbd&hl=en
Or you can get it for free, the author has posted a free version on xda-developers:
http://forum.xda-developers.com/showthread.php?t=1687590
Install it to your device (copy it to the device and open the apk file with a file manager), run adb insecure on the device, and finally kill the adb server on your computer:
% adb kill-server
And then restart the server and it should already be root.
For those who rooted the Android device with Magisk, you can install adb_root from https://github.com/evdenis/adb_root. Then adb root can run smoothly.
Use adb shell; su;
I still have not found any other solution for android 12 rooted with magisk. adb_root does not work with android 12. adbd insecure does not work for me and throws error could not patch adbd.
if anyone is still having issues, heres how i fixed it
you have to start the shell with the phone and go into the magisk app and in the superuser tab (bottom) you have to enable root access for the shell and it works!
You have to grant the Superuser right to the shell app (com.anroid.shell).
In my case, I use Magisk to root my phone Nexsus 6P (Oreo 8.1). So I can grant Superuser right in the Magisk Manager app, whih is in the left upper option menu.

Can I use sqlite 3 on non rooted device

Hi all, I am aware how to use sqlite3 on emulator to monitor data of app. Is it possible to use on a real device?
My device is Nexus S when I try on my device it says sqlite3 is not found. Is it compulsory to sqlite 3 device must be a rooted one? My device is not a rooted device.
I am aware of other mechanism of looking data for example dump db file in SD card then use third party SQL browser to look into the data.
U cant use Sqlite3 instead u can do this.
The following solution works only for apps that are debuggable. It may not work well on all devices, since ​​run-as command doesn't work on some devices, especially with Jelly Bean.
​Create a *.bat or a *.sh file and copy the following scripts ​​
adb shell run-as [package] chmod 777 /data/data/[package]/databases/
adb shell run-as [package] chmod 777 data/data/[package]/databases/[db_file_name]
adb shell cp /data/data/[package]/databases/[db_file_name] /sdcard/
adb pull /sdcard/[db_file_name]
​Change [package] to the desired application package
Change [db_file_name] to the desired db name Run the bat file and
you should see the copied database in the same folder as the bat
file
If you're asking about using sqlite3 on shell (terminal), then no -- first you can't access the databases folder in your app because of permissions. second there's probably no sqlite3 installed in your non-rooted phone.
lucky enough, your nexus s, being a nexus device, is one of the easiest devices to root. there's even a tool created to root any nexus device - get it here.
After rooting, follow instructions on the third post here to install sqlite.

Run adb pull and push command from inside an application programmatically

I am developing an application in which I have to put as well as get some files from Computer(i.e Windows system) using USB.
I searched the web but didn't get anything helpful. I have an idea about command line so I am able to do this by using commands like
./adb -s emulator-5554 pull /sdcard/juned.jpg c:/user/juned/images/
It will copy juned.jpg file in specified directory of system, but is it possible to run same command programmatically ?
Till now I got one sample application in Android Samples named AdbTest which is available under /root/android-sdks/samples/android-18/legacy/USB/ directory, I have tried to compile that application but it shows nothing.
In that application under xml directory device_filter.xml file is there. In that file
<resources>
<usb-device class="255" subclass="66" protocol="1" />
</resources>
What value should I provide to make it working with my device ?
And is it possible to run adb commands from indide an application programmatically?
Edit
So far I came to know that, adb command can not be executed in non rooted devices, so is there any other way to transfer files using USB ?
Its not possible for Devices which are not rooted
Since to run your command it requires Su permission (Super User) .
Your command will be system/bin/ Su / -command
non rooted device don't have access to system/bin/ Su
you can root your emulator by Installing Superuser.apk
or try How to get root access on Android emulator?

Categories

Resources