Skip to content

Conversation

@xukunzh
Copy link
Owner

@xukunzh xukunzh commented Aug 9, 2025

Done:

  1. Implement APK hash extraction in apk_meta_extractor.py as a separate step.
    python apk_meta_extractor.py --package com.app --apk /path/to/app.apk

  2. And apk_meta.json temp file also includes package name, users didn't provide it upfront before.

  3. Add Frida-compile step to import Java bridge.

  4. The automation part is in main.py. with auto Android emulator creation now.

  5. To fix some TS type information issues caused by Frida-compile, switch to using TypeScript to avoid errors.

# jinja2 pydantic could be added to requirements.txt later

# Python packages
pip install frida==17.2.15 frida-tools jinja2 pydantic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pydantic should be part of capa dependencies, shich should be already installed by capa.

Maybe you can have an "optional" step: install capa if not already.

# Start Frida server on device
adb shell su -c "/data/local/tmp/frida-server &"
```
# Disable SELinux enforcement (resets on reboot)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to mention "Cold Reboot" using emualtor

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick though: In this file, I think it is better for sub-functions to raise exceptions, and you only catch the exceptions in main and print the error once and suggest users to try manual steps.

print("Installing frida-server to device...")
subprocess.run(["adb", "root"], check=True)
subprocess.run(["adb", "push", frida_server_path, "/data/local/tmp/frida-server"], check=True)
subprocess.run(["adb", "shell", "chmod", "755", "/data/local/tmp/frida-server"], check=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to reboot?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no need. These only change files and permissions in /data partition, and those should persist across reboots until the files are deleted.

All Frida doc I saw follows this same process: install frida-server, set permissions, then directly start it.

Copy link
Owner Author

@xukunzh xukunzh Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But will mention cold boot to manual users.

I find rooting changes might be lost because system modifications like Magisk need a full cold boot to apply and persist root changes. Google Play systems need it to stay rooted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Use exceptions?

check=True,
)

subprocess.run(["adb", "shell", "setenforce 0"], capture_output=True, check=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. reboot?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that setenforce resets after any restart, so users have to run it every time.

Copy link
Collaborator

@mike-hunhoff mike-hunhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work @xukunzh , I've left comments for us to chat about.


# Python packages
pip install frida==17.2.15 frida-tools jinja2 pydantic
pip install capa[frida]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is installing capa as a library required? Can't users simply download and use the standalone binary for the final processing step?

### (Optional) Create emulator and start frida-server
We can auto-create an rooted emulator with frida-server for you.
But you can manully setup your own emualtor/device.
For more details, see our [manual setup guide](setup.md) and
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe both of these documents outline essentially the same process? If so, let's combine the bare minimum into a single .md file and include it in this repo.

# Tools → Device Manager → find 'frida-emulator' and start it"

## Complete Workflow
python main.py --package com.scottyab.rootbeer.sample
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command assumes the APK is already loaded onto the device? Otherwise, we'd also need to specify the local APK to load into the emulator? This step confused me a bit and I had to continue reading further down to understand which command flags to use. Also, is it absolutely necessary for users to specify the package name? Or could be simplify and only require users to specify the APK file name?

I ask, because initially I did not know of a quick way to find the package name for an unknown APK file, searched for it, and found the following command:

$ aapt d badging /path/to/apk | grep "package"

If we need to require the package, ndb, but let's add documentation for how to find it, covering both scenarios when user has local APK file and the APK file is already loaded onto the device.

- Linux: `~/Android/Sdk`
- Windows: `~\AppData\Local\Android\Sdk`

### 2. Install Dependencies
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of dependencies here is heavy, do we absolutely need all of these? I've left comments below for some of these that I don't think are needed, based on my understanding, e.g. node, flare-capa, etc.. I've learned over the years that the more dependencies you have, the less likely your project will get used, so let's do our best to keep it minimal.


# Python packages
pip install frida==17.2.15 frida-tools jinja2 pydantic
pip install capa[frida]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pip install capa[frida]
pip install flare-capa[frida]

@xukunzh xukunzh changed the title Add APK hashes support to Frida extractor Add APK hashes extraction and Add automation workflow Aug 26, 2025
@xukunzh xukunzh merged commit edbf385 into master Aug 26, 2025
@xukunzh xukunzh mentioned this pull request Aug 28, 2025
xukunzh added a commit that referenced this pull request Aug 29, 2025
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.

4 participants