Skip to content

Conversation

@bernhste
Copy link
Collaborator

@bernhste bernhste commented Jan 6, 2026

This PR closes #3451

Description

The for the demos, the script was compiled using string concatenation. Also, all decoders were implemented in one file (decoders.js).

I refactored the code base to use frida-compiler. Now the decoders are decoupled and easier to maintain. They are all in the folder ./utils/frida/android/decoders. One module for each type, a util module and a module which assigns the decoders to the type.

The base script always only used decodeArguments(). This does not change.

I tested the refactored code with all demos which use this frida.re script so far (MASTG-DEMO-0058, MASTG-DEMO-0059, MASTG-DEMO-0060, MASTG-DEMO-0081). They all produce the same output.

The base script itself did change slightly (now using modules). Other than that, no changes. So this should not conflict with #3584.

This should make it much easier maintaining and adding decoders and tests, which I would like to implement.


AI Tool Disclosure

  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: kagi assistant
    • LLMs and versions: claude sonnet 4.5
    • Prompts: take this code <code> and decouple modules for each decoder type (all the cases in the big switch case). make a file for each type. name the files so that it is clear what type it decodes (example: java.io.File.js) name the decode function accordingly (example decodeJavaSecurityPrivateKey()) ONLY export decodeArguments() some of the functions are not type decoder, collect them in a util module. don't change anything at the code nor the comments they should remain as they are fully.

[x] I have read the contributing guidelines.

Stefan Bernhardsgrütter added 3 commits January 6, 2026 14:15
@bernhste bernhste changed the title Refactor frida compiler Decouple frida.re script (now uses frida-compiler) Jan 6, 2026
Copy link
Collaborator

@Diolor Diolor left a comment

Choose a reason for hiding this comment

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

Briefly, lgtm. @bernhste let me know once all todos are ready and I could give it a test


# create temporary work folder
randomNumber=$RANDOM
workDir=/tmp/frida_$randomNumber
Copy link
Collaborator

Choose a reason for hiding this comment

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

Potentially out of scope, but let's better use a project-local temporary folder and not a computer global one?
Plus add it on.gitignore

I could do it in #3584 but then we would conflict

* @returns {string} The decoded rows and columns.
*/
function decodeAndroidDatabaseCursor(value) {
let out = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

some lets could be consts, + other files

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.

Improve Frida util: Use frida-compiler for code generation

2 participants