I have A problem with Loading SO Libraries Dynamically in android and in order for people to understand why I actually need to do this and maybe suggest different ways to do it I'm going to explain briefly the project. I'm working on a research project to test the benefits of code offloading the flow that I have been working on is as follows :
The user triggers a function that was predetermined to be time-consuming the process is intercepted using Xposed Hooks, The Apk of the App is sent to server then the on the server I run the method from the APK dynamically for android nougat or even oreo this won't cause any troubles as I thought but the main problem some of the apps I'm working on use non-NDK libs and this causes some problems because the system won't allow the me to load the libraries dynamically I'm required to add these libraries to my app and this doesn't work for me because I the server app is one app fit all it receives a method name apk and package name and some parameters and it should run the function with the parameters of and return the result regardless of the apk or function name so cutting to the problem directly
I need to be able to run this code without trouble
the code :
val classLoader = DexClassLoader("/storage/emulated/0/ApkDir/base.apk", applicationContext.codeCacheDir.absolutePath,
"/storage/emulated/0/ApkDir/lib/arm64/" , this.javaClass.classLoader
The problems that the code raises for android oreo and above
01-15 03:19:22.729 10712-10712/com.sablab.myapplication W/b.myapplication: type=1400 audit(0.0:11387): avc: denied { execute } for path="/storage/emulated/0/APKDir/libs/libpngt.so" dev="fuse" ino=79 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:fuse:s0 tclass=file permissive=0
and if not this I get
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/storage/emulated/0/APKDir/libs/libpngt.so" segment 1: Permission denied
Related
I am trying to run Android application on Paired Device via Wifi and it fail to run with following error:
I guess it is due to the audit warning that it cannot read respective file in /mnt/vendor folder, but Android is not my main technology field so I am at wits end what the solution might be.
It also look like the application is not trusted, but it have all the permissions as I am using example application from someone else and the AndroidManifest.xml permissions are the same.
Thanks a lot in advance!
I want to read an Application Specific file stored in /data/data/package_name location for X package, I've found that Android JAVA provides functionalities to read Application Specific directories and files (refer doc), so I was thinking can I inject JAVA code using frida to retrieve/read file contents (example)? I don't have root access on my device.
If you don't have root access on your phone you can not use Frida to hook arbitrary apps. Frida requires frida-server which has to be started with root permissions to be able to inject code into apps.
But on a rooted device you can simply execute su and directly get access to the app-private file in /data/data/<package name>/.
The only way to inject code into an app on a non-rooted device is to modify the APK files before installation and inject frida-gdget-server into the app and force it to be executed when the app starts.
After modifying the APK you have to re-sign it with a different signature so the app can not be installed as update to the original unmodified app because of the different signature.
But if you have already modified the app you could have also modified the debuggable flag to give you full access using run-as via adb.
Conclusion: No matter what you do using Frida to get access to app-private files does not make sense.
I am working on a research project to look at malware and how to prevent it on Android. I am modifying the OS to allow my system service to record any app's attempt to access a file and report that up to a system service which will decide to grant access. I have the system service running on Android 7.1 and but I can't call the service manager which is in the android.os package in frameworks and the class I want to call from is in the java.io package in libcore-ojluni. I have the modification in java.io.FileOutputStream.java.
When I try to compile Android it gives me the error: "Package android.os does not exist"
I am thinking of using sockets to communicate to the service but that seems to slow as I would like a response before allowing access, and I don't want the process to hang.
Is there a way to include the package that I need? Is that even a good idea?
I haven't tried native services. I wanted to ask here before I try that. Is communicating up the Android OS Stack not doable?
I am facing 1 issue and could not solve it yet.
ERROR : "java.lang.RuntimeException: java.lang.SecurityException: NetworkStats: Neither user 10053 nor current process has android.permission.READ_NETWORK_USAGE_HISTORY".
I am implementing this in API 23 which is having a runtime security implementation for permission, I hope you understand what I am trying to say. I was able to add android.permission.READ_NETWORK_USAGE_HISTORY in Manifest but I am not able to add the same permission in Java file because its giving the compilation error. Could you please help ?
Below is the Manifest.xml code :- (Working fine with a waring)
Below is the Java code :- (Compilation Failed)
It allows only for System Apps not for Normal Applications. So we can't get the access for read Network Usage History.
you want access network information you should use this permission
"android.permission.ACCESS_NETWORK_STATE"
Allows applications to access information about networks.
and refer this url : https://developer.android.com/training/basics/network-ops/managing.html
Hello my problem is that when I try to change weather or not the GPS setting is enabled I get the following error 10-20 05:44:31.890: E/AndroidRuntime(889): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS while in my manifest file I do have the permission listed in the error inside my manifest file.
Manifest:
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
Any help would be appreciated
WRITE_SECURE_SETTINGS is a signatureOrSystem permission, meaning that ordinary SDK applications cannot hold it. Only apps that are related to the firmware can hold this permission.
Reading all answers for this particular issue, one way around for this is to use this code to enable the gps but it wont work, as CommonsWare pointed, the application has to be system app for getting this code to work..so one can convert the application into system app by using TitaniumBackup. THis is working perfectly fine for me now.
*Sony users will see another message "Will collect anonymous data while using gps" - to overcome this, 'Freeze' the "LEarning Client" app and everything will be fine.