chame1eon / jnitrace

A Frida based tool that traces usage of the JNI API in Android apps.
MIT License
1.62k stars 259 forks source link

Export the hooking logic as a library #7

Closed Ayrx closed 4 years ago

Ayrx commented 5 years ago

Are there any plans to expose the core hooking logic of this library as a NPM library that other Frida scripts can consume?

I'd love to reuse the code you have already written and a library would probably be more maintainable than copy-pasting functions. :)

chame1eon commented 4 years ago

Hi,

Thanks for your message. Yes I do want to do something like that, I have been thinking about the best way to expose it as an API. Any thoughts on how you would want to use it as an NPM package would be appreciated :).

Thanks

Ayrx commented 4 years ago

My (current) use case is pretty simple. I want to log calls to specific JNI methods in a format that other scripts can consume.

I think the ability to write a NativeCallback and tell your library to attach it to a specific JNI method on a specific library would be a good start and provides the most flexibility.

You probably would not need expose the logic where you look up method identifiers at runtime as I can statically provide the method signature of the callback.

chame1eon commented 4 years ago

Thanks. I'll take a look this week and put a prototype together. I'll message you back when I've done that to see what you think of it.

chame1eon commented 4 years ago

Hi,

I have put together an initial prototype. I decided that it would be better to split the project up and have created a jnitrace-engine which exposes the hooking logic: https://github.com/chame1eon/jnitrace-engine

I am going to modify this project to use that library when I get the chance but for right now it still have the hooking logic hard coded.

I still need to add some more documentation and clean up the jnitrace-engine library but it should work fine. Let me know if you have any thoughts/feedback. I went with the approach of trying to make it as "Frida" like as possible, so it should seem familiar to writing a Frida intercept.

Thanks.

chame1eon commented 4 years ago

Closed this now.