[Q] Xposed use classes obfuscated with proguard - Xposed General

Hi,
I just started using Xposed Framework and I think it is really cool tool! For now I am just trying to learn the API and how to do the things. I am trying to change some values returned by functions by an app, but the decompiled code is obfuscated and all class names and methods are with one or two letters. For example :
Code:
if(!p.a().h() && ae1.c() > 500F){
com.bones.modes.cn.a(com.bones.modes.cl.a(b)).b().a("New message");
}
So what I need is a way to change return value of
Code:
p.a().h()
and
Code:
ae1.c()
which are located in different package than
Code:
com.bones.modes
.
Any idea how to achieve this?

Why decompile when you can compile from source or directly edit source
check repositories under this user : https://github.com/rovo89
if you find your changes could benifit others submit a change request.

anantshri said:
Why decompile when you can compile from source or directly edit source
check repositories under this user : rovo89
if you find your changes could benifit others submit a change request.
Click to expand...
Click to collapse
I decompiled application just to find class names and methods so I can inject code and make some changes, but don't know how to deal with obfuscated code and Xposed. I've tried to hook method found using dex2jar, but it's throwing an exception
Code:
NoSuchMethodError
.

hardartcore said:
Hi,
I just started using Xposed Framework and I think it is really cool tool! For now I am just trying to learn the API and how to do the things. I am trying to change some values returned by functions by an app, but the decompiled code is obfuscated and all class names and methods are with one or two letters. For example :
Code:
if(!p.a().h() && ae1.c() > 500F){
com.bones.modes.cn.a(com.bones.modes.cl.a(b)).b().a("New message");
}
So what I need is a way to change return value of
Code:
p.a().h()
and
Code:
ae1.c()
which are located in different package than
Code:
com.bones.modes
.
Any idea how to achieve this?
Click to expand...
Click to collapse
Hook the application's package (application package != Java package), then hook the class name you want using its full name (e.g. com.bones.modes.ClassName, or com.otherpackage.something.ClassName).
If that doesn't help, post the code you're trying with (and more information about the "different package").
anantshri said:
Why decompile when you can compile from source or directly edit source
check repositories under this user : https://github.com/rovo89
if you find your changes could benifit others submit a change request.
Click to expand...
Click to collapse
He's talking about something entirely different.

GermainZ said:
Hook the application's package (application package != Java package), then hook the class name you want using its full name (e.g. com.bones.modes.ClassName, or com.otherpackage.something.ClassName).
If that doesn't help, post the code you're trying with (and more information about the "different package").
He's talking about something entirely different.
Click to expand...
Click to collapse
I've already fixed it. I realise that the method which I was trying to override takes params and I wasn't pointing them in declaration of hook method.

Related

compiling error kernel

hi guys....i've downloaded the last kernel sources of franciscofranco 2.35.10 kernel....i've added the sippolo's workaround and then increase the HZ value of the kernel(set at 500) for my custom rom.....after i've done
Code:
make thunderg-perf_defconfig
make zImage -j4
it stuck at this error
Code:
drivers/input/touchscreen/mcs6000_ts.c: In function ‘mcs6000_ts_ioctl_down’:
drivers/input/touchscreen/mcs6000_ts.c:430:6: error: implicit declaration of function ‘gpio_configure’
drivers/input/touchscreen/mcs6000_ts.c: In function ‘mcs6000_ts_probe’:
drivers/input/touchscreen/mcs6000_ts.c:733:25: warning: unused variable ‘hw_ver’
drivers/input/touchscreen/mcs6000_ts.c:733:17: warning: unused variable ‘fw_ver’
make[3]: *** [drivers/input/touchscreen/mcs6000_ts.o] Errore 1
i don't understand why......i think it is a lib problem.....but seems that all libraries are imported!!!can anyone help me??? thnx in advice
Which toolchain?
Sent from my LG-P500 using XDA Premium App
lupohirp said:
hi guys....i've downloaded the last kernel sources of franciscofranco 2.35.10 kernel....i've added the sippolo's workaround and then increase the HZ value of the kernel(set at 500) for my custom rom.....after i've done
Code:
make thunderg-perf_defconfig
make zImage -j4
it stuck at this error
Code:
drivers/input/touchscreen/mcs6000_ts.c: In function ‘mcs6000_ts_ioctl_down’:
drivers/input/touchscreen/mcs6000_ts.c:430:6: error: implicit declaration of function ‘gpio_configure’
drivers/input/touchscreen/mcs6000_ts.c: In function ‘mcs6000_ts_probe’:
drivers/input/touchscreen/mcs6000_ts.c:733:25: warning: unused variable ‘hw_ver’
drivers/input/touchscreen/mcs6000_ts.c:733:17: warning: unused variable ‘fw_ver’
make[3]: *** [drivers/input/touchscreen/mcs6000_ts.o] Errore 1
i don't understand why......i think it is a lib problem.....but seems that all libraries are imported!!!can anyone help me??? thnx in advice
Click to expand...
Click to collapse
.35 kernel have new GPIO library, you should code sippolo's workaround into new driver, do not replace whole file.
mik_os said:
.35 kernel have new GPIO library, you should code sippolo's workaround into new driver, do not replace whole file.
Click to expand...
Click to collapse
Aaaaa i don't know that thanks now it works ;-) now the next step i'm ttying to port the acer liquid multitouch fix thanks mik
Sent from my LG-P500 using XDA App
If you can fix also the tethering and the random bugs
use pdanet for tethering
now i'm stucking at this error...((
arch/arm/mm/built-in.o: In function `__flush_icache_all':
/home/pasquale/Scrivania/Franco.Kernel/2.6.35/arch/arm/include/asm/cacheflush.h:402: undefined reference to `swapper_space'
arch/arm/mm/built-in.o: In function `____atomic_set_bit':
/home/pasquale/Scrivania/Franco.Kernel/2.6.35/arch/arm/include/asm/bitops.h:46: undefined reference to `swapper_space'
arch/arm/mm/built-in.o: In function `spin_unlock':
/home/pasquale/Scrivania/Franco.Kernel/2.6.35/include/linux/spinlock.h:324: undefined reference to `swapper_space'
mm/built-in.o: In function `sync_page':
/home/pasquale/Scrivania/Franco.Kernel/2.6.35/mm/filemap.c:190: undefined reference to `swapper_space'
mm/built-in.o: In function `set_page_dirty':
/home/pasquale/Scrivania/Franco.Kernel/2.6.35/mm/page-writeback.c:1181: undefined reference to `swapper_space'
mm/built-in.o:/home/pasquale/Scrivania/Franco.Kernel/2.6.35/mm/page-writeback.c:1335: more undefined references to `swapper_space' follow
make: *** [.tmp_vmlinux1] Errore 1
Click to expand...
Click to collapse
seems another time a library problem... anyone can help me??
lupohirp said:
now i'm stucking at this error...((
seems another time a library problem... anyone can help me??
Click to expand...
Click to collapse
What have you patched?
It just says it's missing the swapper_space function header, it's not defined.
franciscofranco said:
What have you patched?
Click to expand...
Click to collapse
nothing franco....i've only added sippolo's workaround for base to port acer liquid multitouch fix and set kernel to 500hz i've worked only on mcs6000_ts......but it stuck at this error i don't know why!!! i think it is a library problem....something that is missing...but i don't know what are the libraries that i must install if it is this the problem!(
You downloaded the latest sources? Because I haven't compiled it, I just merged the patches, I might have forgot to apply something. In this case it says it misses the swapper_space reference.
http://lxr.free-electrons.com/source/mm/swap_state.c#L40
http://lxr.free-electrons.com/source/include/linux/mm.h#L771
http://lxr.free-electrons.com/source/include/linux/swap.h#L319
Add the swapper_space code to those files and compile again.
franciscofranco said:
You downloaded the latest sources? Because I haven't compiled it, I just merged the patches, I might have forgot to apply something. In this case it says it misses the swapper_space reference.
http://lxr.free-electrons.com/source/mm/swap_state.c#L40
http://lxr.free-electrons.com/source/include/linux/mm.h#L771
http://lxr.free-electrons.com/source/include/linux/swap.h#L319
Add the swapper_space code to those files and compile again.
Click to expand...
Click to collapse
yes franco i've downloaded latest sources! thanks now i'm going to add it and then try!
franco the swapper_space code that you posted is already there in the three files((
I dunno, I have to leave now, I'll look at it later.
I'm sorry to disappoint you, but there ain't a problem with the kernel, I just compiled it without any modification, just like it is in the sources and it compiles fine. Try to make clean and make distclean, then compile again.
franciscofranco said:
I'm sorry to disappoint you, but there ain't a problem with the kernel, I just compiled it without any modification, just like it is in the sources and it compiles fine. Try to make clean and make distclean, then compile again.
Click to expand...
Click to collapse
yeah franco i know.....i think it is a libraries problem on my linux distro.....but i have installe all the binutils and the header files yesterday also i have tried a dirty hack i tried to set CONFIG_SWAP=n in the thunderg_perf_defconfig configuration file....compiled succesfully but the phone doesn't started ...thanks anyway franco!

[Q]Building From Source (Single Modules / Bare Minimum Version)

My Question to the Dev's is is there a Guide on How to Build Single APP Packages eg Calculator from Source Without building the entire android from Source is possible to build eg libjpeg from source as a single module.
i have tried the mmm command all it did was spit out errors you fix one get ten more and so on
I also tried using NDK by inserting the open source libs into a jni folder and modifying Android.mk to look similar to the sample jni resulted in errors this is the only Guide i can't find as there many on building entire android but sometime one only needs specific modules and not entire build.
If above not possible is there a bare minimum version where it only builds android core frameworks and like one lib /app ?
i did not try this .
u can download the package like if u want trebucket launcher then download full android_packages_apps_trebuckhet.
recompile it to get the trebucket apk
once againg i did not try this out
defcomg said:
My Question to the Dev's is is there a Guide on How to Build Single APP Packages eg Calculator from Source Without building the entire android from Source is possible to build eg libjpeg from source as a single module.
i have tried the mmm command all it did was spit out errors you fix one get ten more and so on
I also tried using NDK by inserting the open source libs into a jni folder and modifying Android.mk to look similar to the sample jni resulted in errors this is the only Guide i can't find as there many on building entire android but sometime one only needs specific modules and not entire build.
If above not possible is there a bare minimum version where it only builds android core frameworks and like one lib /app ?
Click to expand...
Click to collapse
Mmm won't help as it needs to link against other parts of the system. That's why you need to do a full build before you can mmm
In theory you can take the app and try to import it into eclipse, and regard it just as an app project.

Get App version before hooking.

Hi all,
My Xposed module deals with different versions of an app. Different versions means different hooks, so my question is: how can I get the application version during the handleLoadPackage execution? I mean... getPackageManager requires a context which I do not have *or* I don't know how to find out...
Any clues, guys?
Thanks.
From memory, I believe you can use the appInfo field in LoadPackageParam: lpparam.appInfo.
Otherwise you can get a context with AndroidAppHelper.currentApplication()
GermainZ said:
From memory, I believe you can use the appInfo field in LoadPackageParam: lpparam.appInfo.
Otherwise you can get a context with AndroidAppHelper.currentApplication()
Click to expand...
Click to collapse
No luck!
AndroidAppHelper.currentApplication() returns null and lpparam.appInfo does not appear to be a Context object...
Any other idea?
slvrbllt said:
No luck!
AndroidAppHelper.currentApplication() returns null and lpparam.appInfo does not appear to be a Context object...
Any other idea?
Click to expand...
Click to collapse
lpparam.appInfo = ApplicationInfo, not Context. It might have the version, but I can't recall if it does or check it right now.
GermainZ said:
lpparam.appInfo = ApplicationInfo, not Context. It might have the version...
Click to expand...
Click to collapse
I couldn't see anything in the ApplicationInfo object that could be related to the version number of the package...
I assume you're placing your hooks in handleLoadPackage(). The Context/Application isn't created yet at that time. I think some modules managed to get a system context via reflection, but I don't know which ones. Maybe you can find something via the search function.
Just another idea: Instead of comparing versions, you might be able to achieve the same by checking whether certain classes/methods exist.
rovo89 said:
I assume you're placing your hooks in handleLoadPackage(). The Context/Application isn't created yet at that time. I think some modules managed to get a system context via reflection, but I don't know which ones. Maybe you can find something via the search function.
Just another idea: Instead of comparing versions, you might be able to achieve the same by checking whether certain classes/methods exist.
Click to expand...
Click to collapse
Thanks for your reply, mate.
You are correct! handleLoadPackage is where I placed my hooks.
As per your suggestion, I will try to find any other existing module that does what I'm looking for.
Unfortunately I need to identify the package version in any reliable way but classes/methods existence check.
The app is obfuscated... method a.a.b could be a.b.c in another version while method a.a.b could still exist but with different implementation.
Is there any other way to retrieve the installed version of a package, given it's package name?
Thanks.
slvrbllt said:
Is there any other way to retrieve the installed version of a package, given it's package name?
Click to expand...
Click to collapse
Apart from using the system context to access the package manager, you could try to parse the package yourself. There is a PackageParser class which is hidden from the SDK, but if you manage to call parsePackage() via reflection (or by referencing a JAR which includes the hidden APIs as well, like XposedBridge does), then you can use it with ApplicationInfo.sourceDir and get the version numbers from the result. Not sure how expensive that operation is, but if you execute it just once, it should be ok.
rovo89 said:
[...] if you manage to call parsePackage() via reflection (or by referencing a JAR which includes the hidden APIs as well, like XposedBridge does), then you can use it with ApplicationInfo.sourceDir and get the version numbers from the result.[...]
Click to expand...
Click to collapse
I will definitely give it a try.
Thanks!
For anyone wondering the snippet we used up until now is "deprecated" in Android 11 and totally gone in 12 (S). You can use the code below to get the version code for your app:
Java:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Class<?> pkgParserClass = XposedHelpers.findClass("android.content.pm.PackageParser", lpparam.classLoader);
Object packageLite = XposedHelpers.callStaticMethod(pkgParserClass, "parsePackageLite", apkPath, 0);
versionCode = XposedHelpers.getIntField(packageLite, "versionCode");
} else {
Class<?> parserCls = XposedHelpers.findClass("android.content.pm.PackageParser", lpparam.classLoader);
Object pkg = XposedHelpers.callMethod(parserCls.newInstance(), "parsePackage", apkPath, 0);
versionCode = XposedHelpers.getIntField(pkg, "mVersionCode");
}
Massi-X said:
For anyone wondering the snippet we used up until now is "deprecated" in Android 11 and totally gone in 12 (S). You can use the code below to get the version code for your app:
Java:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Class<?> pkgParserClass = XposedHelpers.findClass("android.content.pm.PackageParser", lpparam.classLoader);
Object packageLite = XposedHelpers.callStaticMethod(pkgParserClass, "parsePackageLite", apkPath, 0);
versionCode = XposedHelpers.getIntField(packageLite, "versionCode");
} else {
Class<?> parserCls = XposedHelpers.findClass("android.content.pm.PackageParser", lpparam.classLoader);
Object pkg = XposedHelpers.callMethod(parserCls.newInstance(), "parsePackage", apkPath, 0);
versionCode = XposedHelpers.getIntField(pkg, "mVersionCode");
}
Click to expand...
Click to collapse
Thank you so much broo

Porting AOSP from source

ok, i'm trying to port and boot the AOSP source from google for 4.1.2 JB x86, first of all, i follow the next guide to build my own compiling machine http://forum.xda-developers.com/showthread.php?t=2762390 but i download in the step 12 the repo of google AOSP (repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.2_r2.1 & repo sync)
Start the enviroment with: . build/envsetup.sh
and download download the source from motorola to get some propertary files http://sourceforge.net/projects/razr-i.motorola/files/LATAM/9.8.2I-50_SML-29/
now, the git have some instructions like you see in the README file inside the source, this say:
1. Create a workspace containing "vanilla" JB release from Google.
Done
Click to expand...
Click to collapse
ou may need to apply the following change in build repo to prevent the build from aborting when unexpected user tag is found on some modules:
[SOURCE] diff --git a/core/base_rules.mk b/core/base_rules.mk
index 3c11673..ecf611d 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -99,7 +99,7 @@ ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
$(warning * PRODUCT_PACKAGES section of)
$(warning * build/target/product/core.mk)
$(warning * )
- $(error user tag detected on new module - user tags are only supported on legacy modules)
+ $(warning user tag detected on new module - user tags are only supported on legacy modules)
endif
endif [/SOURCE]
i'm trying to do this step, but nothings seems happen...
The second step says that all we need is overlaying the Motorola repos on top of the AOSP repos, but in the Terminal i don't know some commands ('cause always i work on Windows ).
i need just a little help in here, i'm tryin to compare both sources, but in windows i've a tool called WINMERGE, in linux i don't know if we have something like that. I don't wanna overlay the repos, i want to compare the files and re-write the AOSP source with some parts of the motosource and get AOSP software with motorola hardware working.
thks to all, sorry for my bad english, i don't use translator
I always used meld. Meld is an 2to3 way comparing tool, that compares folders (date), files (versions) and text. It is almost like winmerge, just a little bit different. U can look it up in the app store of whatever ubuntu/linux version you have.
As for the defferences between aosp and moto. There are a number of differences. The most can be located in the system/core where moto has changed the behavior of how init works and some x86 implementations (especially pixelflinger). The next BIG thing is the bionic (libc). It has many x86 implementations and i am not sure if u can overlay them without trouble into aosp source.
Good luck!
Hazou said:
I always used meld. Meld is an 2to3 way comparing tool, that compares folders (date), files (versions) and text. It is almost like winmerge, just a little bit different. U can look it up in the app store of whatever ubuntu/linux version you have.
Click to expand...
Click to collapse
yeah, i'm using meld, it's amazig 'cause i can copy the files from one to another place, by the way, i'm using Ubuntu 14.04, with JVM 1.70 but 've some errors in the moment to build ...
As for the defferences between aosp and moto. There are a number of differences. The most can be located in the system/core where moto has changed the behavior of how init works and some x86 implementations (especially pixelflinger). The next BIG thing is the bionic (libc). It has many x86 implementations and i am not sure if u can overlay them without trouble into aosp source.
Good luck!
Click to expand...
Click to collapse
yeah, i see the both codes and check the changes, in some lines the works of moto it's amazing, but whe need more dev's to check all the changes to implement for porting ROMS
Lenovo has recently provided a software update which upgrades Android to version 4.3 for the k900, so i'm going to download the repo AOSP from google and later try to port 4.3

[Q] Importing XposedBridgeAPI in Android Studio

I'm having problems in creating an Xposed module, especially in importing the XposedBridgeAPI in Android Studio.
Since the development tutorial is made for Eclipse, I don't have any reference points...
At first, I tried to import it the "normal" way in gradle build script, with different locations for the XposedBridgeApi.jar, first in libs/ folder, then outside the project folder, both times including it in build.gradle with:
Code:
compile files('libs/XposedBridgeApi-54.jar')
It built successfully, and I could install and activate in Xposed Installer, but after rebooting the module didn't work and I got a "java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation".
I googled it, and found this: Same problem, @rovo89's answer.
So I tried to find a different way of including the XposedBridgeApi, without including it into the apk, and found this: Link
Sadly, it didn't work, I couldn't do the last step with compileSdkVersion, it said the this target isn't available...
So, is anyone successfully using Android Studio for making Xposed modules? Anybody having same problem?
Cheers, and thanks in advance,
Max
Replace "compile" with "provided".
GermainZ said:
Replace "compile" with "provided".
Click to expand...
Click to collapse
Oh my god that is simple...why I didn't find that? Thank you very much, you're the best!

Categories

Resources