Skip to content

Custom agent with Java bridge #265

@rloretan

Description

@rloretan

Hi,
So with Frida 17, runtime bridges, such as the Java runtime bridge, must be added manually to a custom agent script.

This works for me when concatenating the bridge code with whatever other Frida script I want to load, and then calling script.load from python.
The problem is that it's harder to debug bugs in a Frida script, when the error message points to line ~13'000, because the buggy Frida script was appended to the bridge script. Is there a way to load the bridge script separately?

The following script shows the problem:

import frida
import os
import time

process = "SOME APP"
device = frida.get_usb_device()

pid = device.get_process(process).pid

session = device.attach(pid)

with open('/home/user/frida_java_bridge.js', 'r') as bridgefile:
    bridge_source = bridgefile.read()

script1_source = """
console.log('hello form script1')
"""

script2_source = """
console.log('hello form script2a');
Java.perform(function() {console.log('inside Java runtime')});
console.log('hello form script2b');
"""

bridge= session.create_script(bridge_source)
script1 = session.create_script(script1_source)
script2 = session.create_script(script2_source)

print("one by one:")

bridge.load()
script1.load()
script2.load()

print("concatenated:")
script3 = session.create_script(bridge_source + script2_source)
script3.load()

output:

one by one:
hello form script1
hello form script2a

concatenated:
hello form script2a
inside Java runtime
hello form script2b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions