Dex/Apk file PatchTest example
Happy Halloween everyone! As promised I’ve written up a small example program to show how to patch the android dex file, repackage as an apk and get it to work on your android device or emulator. This is actually extremely easy once you understand the steps, or have the tools to do it for you!
For an example program I’ve attached “PatchTest.rar” and “PatchTest.apk”. These are both the original *unpatched* programs we are going to use. The rar file contains the source and project files so you can load them up in Eclipse and play around with them yourself. Both of these files have been tested in the emulator and on the G1 hardware device and work fine. Here is the bulk of the code in which we are looking at though:
So essentially this program starts, calls the “registered” function, if it returns true then it will change our TextView to “Registered!” and that is what we want. If we look at the registered function, it simple initializeds two values, performs a modulus operation on the two and judges the result. This means the program should never return the result true, so we should never have the program show the text “Registered!”
Patchtest.apk - MD5: AF65D0D7399D3F1D4768AFB523981666
Patchtest.rar - MD5: B60FF4BE1B680365F483EB288278F8E5
Next up I’ll post the patched .apk file and an explanation on how to do it. Until then, try it yourself and use the tools I provided in previous posts to see if you can do it yourself! It has also been submitted to crackmes.de by a friend, maybe someone there will also have fun with it.