Rooting VS permissions - android

first of all, I'm not involved in any kind of Android development. I'm only curious.
The question is: does an app obtaining root privileges still need to declare its required permissions in the manifest?
I mean, if my app doesn't declare that it needs to acquire camera input, can it invoke some APIs or executable and acquire camera after becoming root?
I know this could sound stupid but I repeat, I'm just curious about Android features.

On your typical rooted Android device, (which would use the Superuser application and its corresponding su binary) applications which request root access can only run commands as root via the su binary.
So yes, in that the application itself still runs as a underprivileged user process, so anything it needs to do using the "normal" APIs still need the correct permissions. So if you want to (as in your example) access the camera using the normal Java API, you can't do that unless you have declared that permission.
But no, in that if your application requests and receives root privileges via the su binary, you can do anything you want within that command. So if you wrote a special binary or script that can access the camera outside of the normal API methods, that might work. (I suspect this would be more trouble than it's worth.)

Related

Can I Use Superuser Permissions To See All Apps Currently Running

I want to make an app that essentially mines every bit of data that it can from a phone for a university research project. For this, I will need to know what apps are open (all of them) and it seems that, as of API 21, just listing the current app is a rather tricky endeavor. If the user grants superuser access requested via:
<uses-permission android:name="android.permission.ACCESS_SUPERUSER">
</permission>
can I get around Googles obvious attempts to make it harder to get even tiny bits of information out of the phone. Or have they gone as far as making superuser access not so super anymore?
Also, I know I can just root the device, but this application will be installed on other peoples devices (data will be stored locally). As I understand it, non rooted devices can still grant superuser access upon permission (or via toast message if permissions are not listed in the manifest)
EDIT: apparently, as of android 5.0, SU is no longer available to non rooted devices...
Thanks

detect when application using permissions ~ Android

I list all permissions of the new installed application on Android device. But I want to detect when an application uses these permission. For example, I installed an app and it uses READ_CALENDAR permission. It is not always read my calendar data. I want to detect the time it reads my calendar data. Is it possible?
No, I don't think this is possible. You would need to be able to monitor each external app, and you don't have the ability to know what they are doing (due to security restrictions on Android). In other words, your app doesn't have the ability to monitor the actions of other apps (not written by you) on the device.
I don't think you have access to the system at the level you would need to perform this (this may be possible on a Rooted phone, but I think that would still be difficult).
When you write an app you have to insert in the android manifest all the possible "uses permissions", for all the functionality that your app will use.
When someone installs your app, before the installation procedure, he can read all the permissions used from the app. If you accept to install it, the app will use all those permissions listed.

How to run Android system app without root permission?

Is there any way to run Android system app without root permission? I can execute system app via adb such as:
adb shell /system/bin/screencap -p /sdcard/screen.png
In my own application, I wanna run a shell command like that without "su" command. Is there any way? How does android prevent user apps to execute system app?
You should be able to run this command in java code:
Runtime.getRuntime().exec("screencap -p /sdcard/screen.png");
There are some shell commands you can execute without having root. So you don't need to run "su". I'm not sure if you can execute screencap. Certainly you need permission to write to the SD_CARD in your app.
android.permission.WRITE_EXTERNAL_STORAGE
But why you don't use the Android API to make your screenshot? For more information read this post on stackoverflow: How to programmatically take a screenshot in Android?
Androids security model bases on user ids, like Linux does. Each app gets his own user id. So your app has a userid like 1001. If your user is allowed to run the command you can, otherwise you will receive an error.
EDIT:
You need root to take screenshots or be a system application. There is a permission READ_FRAME_BUFFER but you only can obtain it when you are a system application. Its a security problem when an app could take screenshots of your device.
I've found this API http://code.google.com/p/android-screenshot-library/ which promises to take screenshots without root. I didn't test it. The library starts a native service which then takes the screenshots for you.
But you have to run the service each time your phone boots. So it gets the system privileges. That's not really comfortable...
Conclusion: There is no nice way to take screenshots without root from code...
Is there any way to run android system app without root permission?
It have to be NO, but some times, some functions which are not for public use still can be used. I've seen examples using java reflection.
I can execute system app via adb such as: ...
In my own application, I wanna run a shell command like that without
"su" command. Is there any way? How does android prevent user apps to
execute system app?
I think, no.
The thing is adb shell and user app have different security levels based on User and Group IDs (UID and GID).
More info: http://android-dls.com/wiki/index.php?title=Android_UIDs_and_GIDs
Besides, there are limitations via app permissions and hiden & internal classes, procedures, etc which made for internal use.
P.S.: About screenshots. On android market (google play) there are few apps which provide screenshots without ROOT access. So, it's possible.
Although, since Android 4.0 screenshots are available "from box".

How to run an application a system / root in android

I've been searching about this topic but I haven't found a clear solution yet. As far as I know, you can specify different protectionLevel in your AndroidManifest.xml, those permissions allow other applications to interact with the one you are developing. As an example, imagine that I want to kill a processes, that is not mine (from another package) or that I want to install a driver I've developed. In both cases the problem is the same, those things need to be run as a system / root. How can I develop programs that require system / root permissions, do I need an special license?
Note: Please, note that granting the permission:
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
Using android:sharedUserId="android.uid.system" does not work either.
Also, consider that I cannot ask the users to have their mobiles "rooted".
Thanks in advance.
Use
Process myprocess = Runtime.getRuntime().exec("su");
to request root access.
This is not possible.
Either you ask your users to root their devices or you limit your applications abilities to the things you can do without root access.
It is possible to not displaying the GUI of requesting root authorization from the user? in a rooted device, installed as a system application under /system/app

How android/linux sets whether the root user is logged in or a normal user is logged in?

It seems almost every android device comes without root permission, so some people provide a new ROM to root it. How do they achieve it? (Do they change anything in init process, or do they change some apps' access attributes on the storage, such as launcher or toolkit, or some process's uid/gid?)
I have a non-root mobile and another rooted one. I can't find the difference between them. The launcher are both with a uid/gid exceeding 10000.
In Linux desktop, this is controlled through the login process. But I still don't know the key reason.
It's confusing.
On a rooted Android, you can install apps that require special access (like the hardware)
Because the hardware manufacturers and the developers at Google did not want to let users tweak the hardware, the root user is blocked.
For example you can run softwares like Titanium backup (for making backups of application data), SetCPU (for overclocking your Android) and LES (Linux enhancement suite) if you have a rooted phone. Note that the rooted phone will allow apps to run through root only when asked for. Otherwise all the apps will work as the normal user.
In Linux, you can use the su command to get ALL the root permissions or sudo to get minimal root permissions (controlled su)
You can get the superuser permissions by rooting the phone, installing a terminal (Better Terminal Emulator) and typing "su" into the console. (Click "yes" if Superuser asks for permission)

Categories

Resources