Identifying the NDK Version of a .so File

Introduction

This blog post aims to provide a method for accurately identifying the version of the NDK (Native Development Kit) used in a .so file within the Android platform.

Methodology

In certain situations, it becomes necessary to confirm the specific NDK version utilized in the .so files of an APK. Once achieve this, we can compile our own binary code using the same NDK version and subsequently patch the resulting binary into the .so files in order to accomplish our objectives. It is crucial to note that using a different version of the NDK may lead to ABI (Application Binary Interface) incompatibility issues with our binary.

Test Case: “Rise of Saiyan” Android Game

For the purpose of illustration, we will employ the Android game called “Rise of Saiyan.” You may download the game from the following link: Rise of Saiyan. Within this game, there exists a shared library file named libcocos2dlua.so.

Locating the Magic Word

The initial step involves finding the magic word, which in this case is “Android”. We can accomplish this by executing the following command:

1
2
$ strings -tx libcocos2dlua.so | grep "Android$"
13ab850 Android

As demonstrated, we successfully discovered the magic word located at offset 0x13ab850.

Extracting the NDK Version String

Next, we proceed to extract the NDK version string by hexdumping the content beginning from the identified offset:

1
2
3
4
$ hexdump -C -n 30 -s $((0x13ab850)) libcocos2dlua.so
013ab850 41 6e 64 72 6f 69 64 00 15 00 00 00 72 32 31 65 |Android.....r21e|
013ab860 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |..............|
013ab86e

By analyzing the hexdump, we successfully identified the NDK version string as r21e. This information allows us to download the corresponding NDK version.

Conclusion

In conclusion, this blog post presents a straightforward method for identifying the NDK version string within a .so file. By following the outlined steps, developers can accurately determine the NDK version and proceed with their required tasks effectively and efficiently.