Hacker News
3 months ago by yasoob

APKTool is amazing! I wrote an article on how to do end-to-end reverse engineering of Android apps using APKTool: https://yasoob.me/posts/reverse-engineering-android-apps-apk...

I love using Jadx (https://github.com/skylot/jadx) to get a better understanding of the code in Java and then use APKTool to reverse engineer, decompile and recompile the app

If you are interested, Frida is also an amazing tool that makes certain type of reverse engineerings a lot easier compared to using APKTool. I wrote an article on that as well: https://yasoob.me/posts/reverse-engineering-nike-run-club-us...

Reverse engineering is a very exciting field and the moment you learn and figure out one concept you realize there is a lot more out there for you to figure out.

3 months ago by elliottcarlson

I wrote a script a few years back to automate decompiling, and weaving in code in to an APK, then recompiling it using a recipe type structure -- https://github.com/elliottcarlson/Otto -- kind of abandoned it sadly, but figure it's worth sharing in case anyone has value in it.

3 months ago by mmastrac

You might like the work the guys at Fullstory are doing. When I worked there on the mobile product, we were basically doing this professionally.

3 months ago by stuaxo

You probably cant answer this here at least:

Several UK TV apps are available on fire stick but not Android TV.

I've seen people de-Amazonify older versions of these, would Apktool be a good place to do this myself ?

I really just want to watch programs I already have access to on pretty similar hardware (Android TV), but getting more hardware for that just seems wasteful.

3 months ago by l-albertovich

Not OP but thought I could help :

To some degree yes, apktool will unpack the apk and disassemble the dex files in a way in which you can modify them and then compile the project again, sign it and deploy it (as long as your device supports it).

In this case you would have to either modify the smali code itself to make those changes.

When the modifications are basic such as changing a few instructions to avoid checks or adding simplistic payloads writing them in smali is just fine but if your modifications are more substantial I'd suggest creating a placeholder java project, decompiling it and adapting that smali so it's less of a pain in the neck.

Another valid approach would be embedding a custom shared object or fridas gadget with a configuration file to run a payload on start.

As for understanding what you need to change and how, jadx is the way to go most of the times but for some nastier code you can either use dex2java and then jd on the converted file or just go straight to the smali code (honestly that's not that usual)

Also, while testing your patched version I'd suggest heavily using and abusing frida in a rooted device if possible.

Note : I don't usually use the "create a java project" option so your mileage might vary but I recon it's probably the easiest.

3 months ago by eixiepia

This is the best article on Android app reverse engineering I have read. Thanks.

Some more details on this step would be nice:

> I currently have an iPhone so I installed the Android Emulator on my Linux machine and install the app on that. Then I launched mitmproxy and started intercepting the traffic from the emulator.

Is this also the emulator from Android Studio? It would be very nice to intercept app traffic, without the need for a real device, but I have never been able to get it working.

3 months ago by l-albertovich

Not OP but thought I could help :

Usually you have to use (or create) an unpinner frida script. In my experience it's been easier to just write down custom dumpers to avoid having to deal with that and also modifying the request (at least some time ago mitmproxy downgraded http/2 to http) which would result in the endpoint being able to detect the tampering.

As for the emulator, I haven't ever used the official one to work, I know some people who used Anbox in Linux but I don't have much to say because I use a real device most of the times (although I pleayer with ldplayer, bluestacks and genymotion all of which behaved nicely to some extent).

3 months ago by mhils

FWIW mitmproxy shouldn't downgrade HTTP/2, at least if you have a version that was released in 2016 or later. If that's not the case please feel free to file a bug and I'll look into it. :)

3 months ago by iotku

This looks like a pretty decent write up at a quick glance, thanks!

I've been toying around in the space a little bit (primarily around patching stuff to get past https pinning) but I've been meaning to get a better understanding on how stuff works rather than just throwing darts at the wall.

3 months ago by undefined
[deleted]
3 months ago by martythemaniak

APKTool is so great. Earlier versions Android were way more loose with everything, there were tons of undocumented APIs, permissions weren't granular, didn't map to things that well, etc.

2012-2013 I wrote a parental control app for Android that "locked" down the device so you could give it to your kid and it would only run what you wanted it to run for however long you wanted, like "30 mins of games per day". To do this properly, you needed a task manager, ability to kill other apps, guard against being uninstalled, etc. This was not possible with the permissions that were available by being an app on Google Play, it was possible only if your APK was signed by Google or the carrier with system-level permissions.

Nevertheless, I cobbled together a collection of tricks that managed to do it well enough - my app was a home launcher and when it detected a game running past allowed time, it would "kill" the app by pressing the home button, thus brining itself to the front. It had to take over the status bar to prevent you from swiping down to access settings, etc.

Anyway, I relied on APKTool a lot to disassemble other apps which were doing things that I needed (like drawing over the status bar), because they had already figured out how to use these undocumented APIs. I could not have done it without APKTool.

3 months ago by deadclementine

Do you still have the code for this app? I was thinking of making something similar.

3 months ago by martythemaniak

It's been offline since like 2014, so probably wouldn't even work on newer Android versions. But we did have competition, so it seems like there should be equivalent functionality today.

3 months ago by pfyra

Have a look at "Family Link". It is not perfect, but it can limit usage of apps and the whole device to specific times (and more).

3 months ago by deadclementine

I have used family link, it's kind of all or nothing deal. I want the ability to define block schedules.

I want to be able to put some sort of delay when opening time wasting website so that it is not as addictive.

3 months ago by longnguyen

APKTool is amazing. I used it to reverse engineer an old version of Netflix to allow it running on my Xiaomi projector. I no longer need it now as the projector is now Netflix-certified but it was incredibly useful to me in the earlier days.

If your devices support Widevine L1 but not certified to run Netflix, you could use this little patch.

https://github.com/longseespace/netflix_patch

3 months ago by joenathanone

I used to use this to decompile the Netflix app and others to allow screen rotation back when Android tablets were brand new and unsupported.

Edit, found the thread https://forum.xda-developers.com/t/rotation-lock-removal-req...

3 months ago by guipsp

Weird how the names aren't obfuscated at all.

3 months ago by grishka

I used this to remove ads from Instagram. It's a wonderful tool that gives you godlike powers over other people's apps when you know what you're doing.

3 months ago by terrycody

but how you did this? Recompile and then compile to a customized APK?

3 months ago by grishka

Yes. I injected my own code in there that intercepts HTTP responses and rewrites them as needed before giving them to the rest of the app. I was able to do this in a way that's portable across versions because they use an HTTP client written in C++, which needs JNI bindings, which can't be obfuscated.

3 months ago by chenxiaolong

apktool is such a wonderful tool. As a side note, with newer versions of Android, it's no longer necessary to extract bytecode from odex/vdex files to disassemble systems apps or frameworks too. The apk/jar files all contain `classes<n>.dex` now (this was changed when A/B partitioning was introduced, I believe).

3 months ago by 3np

Does anyone have any stories to share involving apktool?

Random note: It's curious how the homepage and the linked repo are on GitHub but the binary downloads are served from bitbucket.

3 months ago by iBotPeaches

When I moved the project from Google Code to GitHub, GitHub did not allow binary downloads. So I used Bitbucket, changing the download location again after moving did not seem right. So it has just been maintained since the switch. Now in present day they are also uploaded to GitHub and another mirror I host.

3 months ago by Kipters

Got a bug report about an app I did nothing about (used by some partners to check certain kinds of tickets). No one else knew anything about it. I couldn't find it on our Gitlab nor in our legacy Bitbucket. Turns out the source code was lost a long time ago, but a partner still had the APKs (there were two versions, one in English and another slightly more advanced in Italian).

Using APKTool I managed to decompile the app, add some printf logging to figure out the issue, fix it in the Italian/more advanced one, merge it with the English one and rebuild it.

The only issue is that the signing key was lost too, so partners had to uninstall and reinstall, but nothing I could do about it.

Oh, and another time I cracked the in-app purchase for the password manager I was using on a spare Android device while my Lumia was in RMA (it had separate purchases for each platform). Of course I bought it once I let go of Windows Phone and moved to Android permanently.

3 months ago by rwestergren

Back from 2015, bypassing an APK signature check: https://randywestergren.com/reverse-engineering-the-yik-yak-...

3 months ago by toomanybeersies

At one of my former jobs, I was working on an automated testing product that could MITM requests (for testing analytics, etc.)

Android has this really annoying feature where apps don't trust self-signed CA certs (but Chrome & webviews do, strangely). You either need to need to add it to the app's network_security_config.xml, or root the device and add it as a system CA.

I looked into using apktool as part of a pipeline to inject our self-signed CA as a custom trust anchor when customers uploaded their APK for testing. But in the end, we found it was easier and simpler to just add a the cert as a system CA on a custom rooted AVD.

That whole project really made me appreciate that no matter how shit I feel web dev is some days, at least I'm not an android developer.

3 months ago by brookmg

APKTool is amazing and have used it before to check the security on some apps. But it doesn't do much when it comes to apps made using flutter as the code is stored in a binary form. Wish if they consider adding a way to decompile that as well.

3 months ago by Schinken_

I've played with the idea of modding some apks by replacing some .so files on them. Wood APKTool work for this?

Daily Digest

Get a daily email with the the top stories from Hacker News. No spam, unsubscribe at any time.