Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New module: jadx #1932

Merged
merged 14 commits into from
Nov 13, 2024
Merged

Conversation

domwhewell-sage
Copy link
Contributor

@domwhewell-sage domwhewell-sage commented Nov 7, 2024

This PR adds jadx to decompile apk files

I have made some changes to apkpure to set the file extension based on the Content-Disposition header as sometimes apkpure.com would redirect to download a .apk file instead of a .xapk file. As logged in #1943

@domwhewell-sage
Copy link
Contributor Author

Hmmm, the file is being detected as MS Office Open XML Format Document when it's downloaded from httpx_mock.

When I run puremagic on the .APK in the test folder it is detected correctly. So it's something about reading and serving it as content= on httpx_mock

@TheTechromancer
Copy link
Collaborator

Hmm that is strange. Maybe as part of this we should add a test that runs our helpers against that file.

@TheTechromancer
Copy link
Collaborator

TheTechromancer commented Nov 7, 2024

Here are the detections, ranked by confidence:

image

All of these signatures are identical (they just use the .zip magic bytes). So it is inferring android from the extension. This should be fixable by adding the extension and content type in the response:

headers = {
    'Content-Type': 'application/vnd.android.package-archive',
    'Content-Disposition': 'attachment; filename=myapp.apk'
}

@domwhewell-sage
Copy link
Contributor Author

Ah apkpure.py downloads it as {app_id}.xapk instead of the Content-Disposition header, and the mock file is apk not xapk which is whats confusing the detection (i.e. passing off a .apk file as a .xapk file)

These are its results: 🤷

0.4 MS Office Open XML Format Document
0.4 MS Office Open XML Format Document
0.4 MS Office Open XML Format Document
0.4 Microsoft Excel - Binary Workbook
0.4 Microsoft Excel - Macro-Enabled Template File
0.4 Microsoft Office - OOXML - Spreadsheet Template
0.4 Microsoft Excel - Add-In File
0.4 Microsoft Word - Macro-Enabled Document
0.4 Microsoft Office - OOXML - Word Document Template
0.4 Microsoft Word - Macro-Enabled Template
0.4 Microsoft PowerPoint - Macro-Enabled Presentation File
0.4 Microsoft Office - OOXML - Presentation Template
0.4 Microsoft PowerPoint - Macro-Enabled Template File
0.4 Microsoft Excel - Macro-Enabled Workbook
0.4 PKZIP Archive file
0.4 Mozilla Browser Archive
0.4 Windows Media compressed skin file
0.4 eXact Packager Models
0.4 KWord document
0.4 XML paper specification file
0.4 Java archive
0.4 OpenDocument template
0.4 OpenDocument template
0.4 OpenDocument template
0.4 OpenOffice documents
0.4 OpenOffice documents
0.4 OpenOffice documents
0.4 Android Application Package
0.4 Comic Book Archive (ZIP compression)
0.4 FictionBook 2 eBook file (Zip compressed)
0.4 FictionBook 2 eBook file (Zip compressed)
0.4 FictionBook 3 eBook file

@TheTechromancer
Copy link
Collaborator

That's really strange. What could be the difference between that and running it manually?

Copy link

codecov bot commented Nov 9, 2024

Codecov Report

Attention: Patch coverage is 89.74359% with 8 lines in your changes missing coverage. Please review.

Project coverage is 93%. Comparing base (0f1db8c) to head (6aa2a5c).
Report is 7 commits behind head on dev.

Files with missing lines Patch % Lines
bbot/modules/jadx.py 81% 8 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             dev   #1932    +/-   ##
======================================
- Coverage     93%     93%    -0%     
======================================
  Files        357     363     +6     
  Lines      27585   27844   +259     
======================================
+ Hits       25425   25651   +226     
- Misses      2160    2193    +33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@domwhewell-sage
Copy link
Contributor Author

The tests should be all good now. I had a bit of an issue with fedora where java was installed but it couldnt find the java binary, it recommends setting the JAVA_HOME env variable to fix this. But by reading through the startup script if which is installed it can use that so ive added that as a dependency only for fedora

@TheTechromancer
Copy link
Collaborator

Thanks for your work on this. I'll start reviewing today.

@TheTechromancer
Copy link
Collaborator

Nice work 🙏

@TheTechromancer TheTechromancer merged commit 154c354 into blacklanternsecurity:dev Nov 13, 2024
14 checks passed
@domwhewell-sage domwhewell-sage deleted the jadx_module branch November 13, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants