Frida 1.6.0 Released ∞
release
As some of you may have noticed, Frida recently got brand new Android support, allowing you to easily instrument code just like on Windows, Mac, Linux and iOS. This may sound cool and all, but Android does run a lot of Java code, which means you’d only be able to observe the native side-effects of whatever that code was doing. You could of course use Frida’s FFI API to poke your way into the VM, but hey, shouldn’t Frida just do that dirty plumbing for you? Of course it should!
Here’s what it looks like in action:
The Dalvik.perform()
call takes care of attaching your thread to the VM,
and isn’t necessary in callbacks from Java. Also, the first time you call
Dalvik.use()
with a given class name, Frida will interrogate the VM and
build a JavaScript wrapper on-the-fly. Above we ask for the
Activity
class and replace its implementation of onResume
with our own version,
and proceed to calling the original implementation after sending a message
to the debugger (running on your Windows, Mac or Linux machine). You could
of course choose to not call the original implementation at all, and emulate
its behavior. Or, perhaps you’d like to simulate an error scenario:
So there you just instantiated a Java Exception and threw it straight from
your JavaScript implementation of Activity.onResume
.
This release also comes with some other runtime goodies:
Memory.copy(dst, src, n)
: just like memcpyMemory.dup(mem, size)
: short-hand forMemory.alloc()
followed byMemory.copy()
Memory.writeXXX()
: the missingMemory.read()
counterparts: S8, S16, U16, S32, U32, S64, U64, ByteArray, Utf16String and AnsiStringProcess.pointerSize
to make your scripts more portableNativePointer
instances now have a convenientisNull()
methodNULL
constant so you don’t have to doptr("0")
all over the placeWeakRef.bind(value, fn)
andWeakRef.unbind(id)
for the hardcore: The former monitorsvalue
sofn
gets called as soon asvalue
has been garbage-collected, or the script is about to get unloaded. It returns an id that you can pass tounbind()
for explicit cleanup. This API is useful if you’re building a language-binding, where you need to free native resources when a JS value is no longer needed.
Enjoy!