android-dev-ext icon indicating copy to clipboard operation
android-dev-ext copied to clipboard

[Feature Request] Work with reversed application's source

Open Anon-Exploiter opened this issue 3 years ago • 5 comments

Hi,

Is it possible to make the extension work with source of decompiled applications (apks) using jadx or d2j-dex2jar? I've been trying to make it work with apks I have but it doesn't hit the breakpoints of those.

I guess it has to do something with the path of the application etc. which isn't being satisfied.

Anon-Exploiter avatar Nov 15 '21 07:11 Anon-Exploiter

To give more details.

This (https://stackoverflow.com/a/58969794) but in VS code utilizing your extension.

Anon-Exploiter avatar Nov 15 '21 08:11 Anon-Exploiter

The issue arises in the appSrcRoot key's value. It isn't being satisfied with the decompiled code. I've shared the directory structure of an application decompiled with jadx in the screenshot.

image

It would be awesome if we can support it somehow! :)

Anon-Exploiter avatar Nov 15 '21 08:11 Anon-Exploiter

If the decompiler produces valid Java code which matches the line numbers encoded in the app debug info, I think this should work. Normally appSrcRoot is set to the root of the package folders, where AndroidManifest.xml normally lives (I don't see it in your source tree - does the decompiler not extract it?). The reason it's reporting No source files found is because it's trying to find folders matching the package names inside a well-known source folder (like 'main' or 'java').

I would suggest:

  • setting appSrcRoot to /home/umar_0x01/apk-debugging/ViewerJNI
  • rename the sources folder to java

That should be enough to allow the debugger to find the package-name folders and the java source files. If your decompiler has produced a good Java file, everything should then match up and your breakpoints should be hit.

adelphes avatar Nov 15 '21 23:11 adelphes

Thanks, I get your point. In my case, I'm using jadx which keeps AndroidManifest.xml in the resources directory and the Java source inside the sources directory.

I'm not sure if the decompiled code will have the same lines (sequence) as the original order. I think I've been having some issues in Android studio because of this as well since the bytecode doesn't match the Java code (in sequence/line numbers).

Anon-Exploiter avatar Nov 16 '21 05:11 Anon-Exploiter

Yes, it's a common problem with decompilers - the line numbers are encoded in the compiled files so the decompiled files should be formatted to match, but many don't bother which makes debugging very difficult.

It looks like there is already an issue about this in jadx: https://github.com/skylot/jadx/issues/476

adelphes avatar Nov 16 '21 11:11 adelphes