Skip to main content

ROSAL

PyPI - Version

ROSAL (Reverse Obfuscated Standard Android Libraries) helps reverse-engineer Android applications by mapping obfuscated classes from an APK to their plain-text equivalents in the declared standard libraries (androidx, core, ...).

It helps recover actual names for classes like RecyclerView, LiveData, Fragment, CompatActivity, and so on, partly automating the manual process of reverse engineering and allowing for an easier Static Analysis of Android apps.

The mapping is limited to the classes from the standard libraries: it does not involve the mapping of the proprietary classes of the app.

Fully deterministic, no heuristics. No AI is involved in the process.

!!!! DISCLAIMER !!!!
This software is intended for research and for testing on authorized targets EXCLUSIVELY.
Any other purpose is not supported or endorsed by the creators by any means.
Don't be a cunt.

How it works

R8/ProGuard can rename any class, method or field that belongs to the app itself, but cannot rename references to platform APIs (android/*, java/*, javax/*). Those symbols must stay intact to be resolved by the OS at runtime.

Rosal treats every reference to a platform API found inside a method (a call, a parameter type, an annotation type, a superclass) as an anchor = something that the obfuscator can't touch. Two methods that share the exact same set of anchors are, with very high confidence, the same method.

The standard libraries used in the matching process are not a fixed set of references. Instead, rosal uses the META-INF/*.version markers embedded in the APK to know exactly which group/artifact/version was bundled, so the matching library .dex files are fetched from the same Maven repositories the original build used.

Getting started

Prerequisites & Dependencies

Dependencies on Androguard, loguru and tqdm should be resolved automatically during installation... If not, install manually.

The tool relies on the Android SDK. You'll definitely need D8 and platform-tools.

Install it in ~/Android/Sdk ( <<-- please use this exact path, otherwise things will break)

https://developer.android.com/tools/releases/build-tools
https://developer.android.com/tools/releases/platform-tools

Java is also required. Install it if you haven't already.

Installing from local repository

Clone the repository, then cd to its directory and:

python -m pip install .
pip install rosal

Run

# (Optional) Define APK path
export APK=...

Basic usage:

rosal --apk "$APK" # or <path_to_apk>

The command runs the fetch, extraction, catalog, matching and mapping stages in sequence.

By default, intermediate files and matches.tiny are written to ~/rosal. Use --work-dir to specify another directory:

rosal --apk "$APK" --work-dir ./anything_you_want

Relevant sample outputs

matches.json

{
  "matches": [
    {
      "library_class": "Landroidx/activity/Api34Impl;",
      "target_class": "Landroidx/activity/a;",
      "provenance": "androidx.activity_activity-1.8.1.dex",
      "methods": [
        {
          "library_name": "createOnBackEvent",
          "target_name": "a",
          "library_descriptor": "(FFFI)Landroid/window/BackEvent;",
          "target_descriptor": "(FFFI)Landroid/window/BackEvent;"
        },
        {
          "library_name": "progress",
          "target_name": "b",
          "library_descriptor": "(Landroid/window/BackEvent;)F",
          "target_descriptor": "(Landroid/window/BackEvent;)F"
        },
        {
          "library_name": "swipeEdge",
          "target_name": "c",
          "library_descriptor": "(Landroid/window/BackEvent;)I",
          "target_descriptor": "(Landroid/window/BackEvent;)I"
        },
        {
          "library_name": "touchX",
          "target_name": "d",
          "library_descriptor": "(Landroid/window/BackEvent;)F",
          "target_descriptor": "(Landroid/window/BackEvent;)F"
        },
        {
          "library_name": "touchY",
          "target_name": "e",
          "library_descriptor": "(Landroid/window/BackEvent;)F",
          "target_descriptor": "(Landroid/window/BackEvent;)F"
        }
      ],
      "fields": []
    },
    ...

matches.tiny

tiny	2	0	obf	named
c	androidx/activity/a	androidx/activity/Api34Impl
	m	(FFFI)Landroid/window/BackEvent;	a	createOnBackEvent
	m	(Landroid/window/BackEvent;)F	b	progress
	m	(Landroid/window/BackEvent;)I	c	swipeEdge
	m	(Landroid/window/BackEvent;)F	d	touchX
	m	(Landroid/window/BackEvent;)F	e	touchY
c	androidx/activity/p	androidx/activity/ComponentActivity
c	androidx/activity/q	androidx/activity/ComponentDialog
c	androidx/activity/s	androidx/activity/OnBackPressedCallback
c	androidx/activity/w	androidx/activity/OnBackPressedDispatcher$Api33Impl

Files and Directories involved

With the exception of matches.tiny, these files are intermediates that can end up being quite large. Feel free to delete them if you don't need them for further analysis.

markers_file = work_dir / "markers.txt"
library_dex_dir = work_dir / "library_dex"
target_dex_dir = work_dir / "target_dex"
features_file = work_dir / "features.ndjson"
matches_file = work_dir / "matches.json"
mapping_file = work_dir / "matches.tiny"

Applying the matches.tiny file

Once the command has (hopefully) run successfully, you can apply the generated matches.tiny to an instance of jadx / jadx-gui

jadx-gui --mappings-path <path_to>/matches.tiny "$APK"

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Metadata

Release files for rosal 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rosal 0.1.1
File Size Uploaded
rosal-0.1.1.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rosal 0.1.1
File Interpreter ABI Platform
rosal-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / rosal-0.1.1.tar.gz

Download URL rosal-0.1.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
51e8412e5bf12d5e14a73d0041f78f7bf27d66118a294393d494d830edc9afe5
BLAKE2b-256 checksum
How to use checksums
d6585bf829b19294a976aaea3486ed5b26de687fab1abf6e892a453eed0b3c5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / rosal-0.1.1-py3-none-any.whl

Download URL rosal-0.1.1-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b358edde92e60b8271c7292bb2494c7bc41dc49e770f9d6b8f9fe51ce2a113c
BLAKE2b-256 checksum
How to use checksums
2d1997db23f5c6f6fae7416aa817ab623d5db28b8faa7c74c5d681cbf13155cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page