I decided to write this post in English because I’ve received lots of emails regarding Dexer.
Dexer is an open source framework, written in C#. With Dexer, you can load, update then write back “.DEX” files used by Android (inside “.APK” packages).
Dexer is different than other tools like the famous Smali/Baksmali because all is done directly inside its object model. Dexer was inspired by Mono.Cecil that I’m very familiar with (Cecil targets .NET assemblies).
Dexer is a framework, not an application. Perhaps I will make an advanced GUI like Reflexil, but not yet, I spent too many nights on this one:).
Let’s see how it works with a simple Android application (Java):
Here is the result:
And here is the code of the main method inside the Dexer object model:
Now let’s go back to C# to play a little with this application by changing a string constant and an opcode (adding instead of multiplying):
Here is the result:
Now let’s call a method to change the title color:
Here is the result:
As you can see, altering DEX files is quite easy with Dexer. In order to rebuild APK packages, I’ve used ApkTool and JarSigner (with the default debug key generated by the Android SDK).
apktool d -s -f DexerPOC.apk output I: Copying raw classes.dex file... I: Loading resource table... I: Decoding resources... I: Copying assets and libs... apktool b output DexerPOC.new.apk I: Copying classes.dex file... I: Checking whether resources has changed... I: Building resources... I: Building apk file... jarsigner -keystore .\.android\debug.keystore -storepass android -keypass android DexerPOC.new.apk androiddebugkey adb install DexerPOC.new.apk 586 KB/s (12609 bytes in 0.021s) pkg: /data/local/tmp/DexerPOC.new.apk Success.
You can get up-to-date Dexer sourcecode here.
Commentaires