Custom agent with Java bridge
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
Where does this frida_java_bridge come from? I would like a copy too.
@jie64 You can generate it from https://github.com/frida/frida-java-bridge. Or you could take it from some other project, for example https://github.com/Ch0pin/medusa/blob/master/libraries/js/frida_java_bridge.js.