Repackaging Mobile app which resists repackaging - General Questions and Answers

I tried repackaging an Android app but after installation, when I launch that app, the app is getting crashed immediately.
This is the exception I am getting when I decompile this application using `apktool` and rebuild this application using apktool irrespective of any modifications done at the **smali level** or not.
exalvxhzn.█: 01
at exalvxhzn.▃.─(Unknown Source:68)
at exalvxhzn.▃.━(Unknown Source:0)
at java.lang.Runtime.nativeLoad(Native Method)
at java.lang.Runtime.loadLibrary0(Runtime.java:1014)
at java.lang.System.loadLibrary(System.java:1669)
at exalvxhzn.╿.│(Unknown Source:43)
at exalvxhzn.┇.─(Unknown Source:13)
at exalvxhzn.┇.━(Unknown Source:24)
at exalvxhzn.┇.━(Unknown Source:6)
at androidx.core.app.CoreComponentFactory.<clinit>(Unknown Source:0)
at java.lang.Class.newInstance(Native Method)
at android.app.LoadedApk.createAppFactory(LoadedApk.java:229)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:733)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:812)
at android.app.LoadedApk.getResources(LoadedApk.java:1034)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2357)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5821)
at android.app.ActivityThread.access$1200(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
When we launch an app, the flow of execution is
`application` sub-class `constructor` -> applications sub-class `onCreate()` launcher's activity `onCreate()` method.
I tried few code injections at the starting of the `onCreate()` as well as at the constructor level. The code injections, I did is regarding
- Insertion of Toast message
- A basic file creation at the internal storage (After installing , I gave the storage permission before launching the app)
I know that there are some **anti-repackaging** techniques which is applied on the app which resists repackaging.
My questions are about:
1. Even if an app has depolyed some **anti-repackaging** technqiues, then even if I am inserting a code (`Toast` message/file creation) at the **beginning** of Application's sub-class `onCreate()` method, then also shall I be able to see impact of the code modifications? For e.g. Will I be able to see my Toast messages or the file creation at the internal storage?
2. Can I apply **anti-repackaing** technique, if I am only having the apk and not the source code?Like for e.g consider I have an Amazon apk, can I apply **anti-repackaging** technique on the Amazon apk?
3. When we decompile an application, at **smali** level, which is the 1st function which gets executed when the app is launched?
4. Is it like by applying an anti-repackaging technique, then instead of `onCreate()`, some other method gets called first when we open the app?
5. Why the above exception is coming even if I haven't done any code modifications at the smali level?
6. At Smali level, which is the constructor which gets called first, is it the `static constructor` or `non-static constructor`?
It will be a big help if someone could give their valuable inputs on this. Thanks!!

Related

[Q] Connecting to DBUS API on unrooted Android phone to connect an HID device

Hi everyone,
I'm trying to write an android program which will allow users to connect to an HID device. The device captures external pen strokes and I would like to retrieve this data and make a basic whiteboard app.
I've made some progress so far: if I use adb push to put the "hidd" daemon on a rooted phone and use hidd --connect, then I can open up hcidump and see the raw data appearing when the pen is used, so I know such a connection is possible.
I'm still a beginner at Android development, but I've learned that app communication with the bluetooth facilities is done via the dbus API. So, I wrote a simple test program using the NDK that tries to make a connection to the system dbus, based on some bluetooth-related code in mydroid/bin/frameworks/base/core/jni:
DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
On my non-rooted phone, this results in the error "VERBOSE/JNI1Activity_DEBUG(3226): Result: Could not get onto the system bus: Failed to connect to socket /dev/socket/dbus: Permission denied."
If I go ahead and do chmod 666 on /dev/socket/dbus on my rooted phone, then the connection can be made without error.
So, my question is this--first of all, am I going about this the right way? If so, is there some way that an application can get permission to talk to dbus on a non-rooted phone?
(If I can get this working, I think the next step would be to try and package/build in the needed parts of hidd to include with my app...)
Many thanks for any help,
Tom
Hi pyro777,
I was wondering if you received any replies on your query?
I also have a similar problem -- my android app accesses Dbus via a JNI, but I am getting the same permissions problem. I can use your workaround of explicitly setting the permissions on /dev/socket/dbus, but that solution can't be used for production code.
My Android java app as BLUETOOTH permissions, but this doesn't appear to be applied across the JNI boundary (as my experience indicates) into the JNI c++ library (*.so).
Does anyone have more info on this issue?
Thanks in advance,
robin
Hi evodevo,
No, no such luck so far if you figure it out I'd be happy to hear.
Strange, if this fails how does the normal Bluetooth java API it?
Perhaps certain permissions need to be set on your app? BLUETOOTH_ADMIN or so?
question 4 u: which libraries do you include when doing dbus stuff I get undefined references the whole time?

[Q] How to write to Settings.Secure?

I want my app (PerApp) to write to Settings.Secure on rooted devices, but without having the app to be installed in /system/app.
Any suggestions on how to do it?
One possibility is to launch a component of the app with root privileges via app_process, and then have the component with a static main() use reflection to access Settings.Secure. The latest version of my Force2SD does that successfully to access hidden functions of the packagemanager. However, the problem is that the standard API for Settings.Secure needs a Context, and I don't know how to gain a working Context for something that starts from the commandline with a static main().
I could include a sqlite3 binary, but I am concerned about the stability issued with writing directly to the settings database on the fly, and don't know if the OS will register the changes immediately. Moreover, loading a large binary like sqlite3 will slow things down.

Accessing Textfile from Xposed module

I trying to develop an Xposed module that would profile power and time consumption of apps on Method level so What I have for the user side is a simple list with check-boxes once and each list Item represents an App once an App is checked I get The dexfiles get all classes in the main package and get all methods as well all of this is then saved to a textile (tried using sharedprefrences but couldn't because of mode_world_readble throughing security issue ) what I want to do is to open the text file from the xposed class and read the save class names and method names to set hooks dynamically but I don't know where to place my code in xposed to make sure that the arraylist I've retrieved from the file is available i tried even leaving the code in "handleLoadPackage" without any conditions just to see what will happen some packages manged to read the file others failed not sure why I'm guessing it's something to do with permissions but not sure how to solve

App for automated processes? (Navigate through other apps, fill in text fields, ...)

Hi Guys,
I'm currently looking for a possibly very special app and can't find anything but the usual suspects like Tasker that don't seem to meet my requirements.
I'm looking for an automation app that allows me to navigate in apps, fill in text fields, if possible, transfer predefined data into the text fields for each run and wait for text to be entered at certain points.
For a better explanation:
I would like to test 2 apps and their behavior. Reset smartphones should be used for this. The automation app should run through the following steps:
- Step 1: The app creates an account with Gmail. As soon as the SMS code has been requested, the app should interrupt so that I can enter the SMS code. After confirmation, the app should continue to go through its routine.
- Step 2: Another app is to be opened that has a longer waiting time before it starts. Then text fields should again be filled in with predefined data.
- Step 3: Finally, the app should go to the settings and delete the G-Mail account.
I don't care how the whole thing is realized. Either macro recording again or using symbols as with Tasker. The main thing is that it works properly. I am not familiar with such an app. Just such simple apps as Tasker that work with if and while and are not sufficient for my purposes.
Otherwise, I had the idea to use Python to implement my dream routine. A few days ago I discovered a Python SDK for Android. If I understand correctly, the SDK is based on Python 3. I just can't estimate how well the programming is going or whether scripts can be executed 1: 1 as on the PC. What do you all mean? Do you know of an app that meets my expectations or should I deal directly with the Python method?
Nobody has an idea? Or is my text not understandable?
I know you said no "Tasker" like apps, but this app called Automate can definitely achieve what you outlined without any other apps (or with them). You only need android 7 or above and These function blocks:
The app uses a flowchart logical system (essentially the basis of all programming languages) and can even execute shell scripts with/without root privileges. You can also install Termux (a terminal emulator) and use the command:
Code:
pkg install python
To install python3.7, from there the world is in your hands, provided you have sufficient java/kotlin knowledge and an understanding for android processes.
Also please tick the check mark next to my answer if I solved your question, so that others can find the solution.
Thank you Slim K. Automate looks good at the first look. I'll give that app a chance and otherwise test thy python way with termux.
If there are other ways to solve the problem, let me know.

Giving permission not declared in AndroidManifest

Hi! So Im creating a Theft Protection Profile for Tasker so you need only to download the script.
This entire profile is self-sufficient so after importing it will auto start. Most Android phones, MIUI in this example, has the ability to set the time for auto booting if in power off state, I managed to decompile the Settings app and used Java Function in Tasker for calling the system methods. I need to call setWakeUpTimeBoot() but I receive an error saying that the current app has no permission for "com.miui.permission.MANAGE_BOOT_TIME".
How can I add this permission to an app even if is not declared in his AndroidManifest?
Root (Magisk): Yes, Xposed: Yes, any ideas?

Categories

Resources