Native hooking in Android Client

2020-08-22 07:55发布

问题:

I am trying to hook the native libraries in Android. Basically I am trying to hook the socket calls in libjavacore.so file.

Similar Approach as mentioned here

For example:

  1. Get socket address (dlsym()) in libc.so.

  2. Then search for the socket address in libjavacore.so file in sections like .got, .plt, .dlsym, .dynamic.

  3. Replace the actual socket address with custom socket address at the location where actual socket address is present in memory.

The above approach is working for me in case of 32 bit Android devices. But is not working for me in case of 64 bit Android devices. Tried using proper data types like uint_ptr so that it will get auto adjusted. But still failing. When I further debugged found that libjavacore.so file is of 32 bit ELF running on 64 bit system. So, tried using uint32_t and uint64_t types as well and trying with both. But still failing.