3
Injecting code into DEX Files

Injecting code plausible and possible!

Injecting code plausible and possible!


Success! It seems completely possible, though quiet a pain to inject new code into existing dex files. This doesn’t not appear like it would easily be done ON a device, though in the development setting it seems perfectly possible and completely do-able.

I’m working on a nice proof-of-concept example to show, though I don’t think this is a “backdoor” to malware. Android has been set up well enough that to properly inject things it would require many things to be done, making it in my opinion extremely hard to do it on the fly on the device. I had to inject the code directly to the dex, resigned both the signature and hash makings for the file, then resign the whole package before reinstalling (after a complete uninstall since we don’t have the same keys as the original package) onto the device. This is a long way away from actually being able to do nasty things with it, which is clearly a good thing, since we don’t want that to happen. This does have practical uses of course, though it seems Google has done security rather well so that this process would most likely only be done by an actual developer for a user to not notice an injected file… Otherwise they would have to allow unknown sources, packages would complain about key, so on and so on…

Hopefully more to come on this subject soon!

Tim
3 Comments
  1. Your title – strazzere.com » Blog Archive » Injecting code into DEX Files – caught my eye on the google blogsearch page. Just goes to show you how important good titles are! ;-) I’ve added strazzere.com to my reader, so I can see what else you come up with

  2. Good to know people actually read stuff I write once and a while! Thanks for the comment, hope you see more stuff you like!

  3. hey are you able to do it successfully?
    we are a group of researchers and we really need this for our project

Your Name Email Website