Loading someone else's shared library gives a segmentation fault

Viewed 43

I have a shared library (libnative-lib.so) extracted from an Android App that provides a function salt(). The return of this function is a salt for a SHA256 hash used for an API and I want to build my own API wrapper. So the goal for me is to either extract the salt from the library (maybe not the best idea since my wrapper is breaking if they change the salt and I have to do the whole thing again) or to load this library into my API wrapper and calling the function directly from the library.

I have already "decompiled" the App (unzip the .apk, "converting" the .dex files to .jar files and opening them with JD-GUI) and found the class where the library is loaded (the library also provides some other keys/salts/functions, I removed them for better readability):

package de.veedapp.veed.entities;

public final class Keys {
  public static final Keys INSTANCE = new Keys();
  
  static {
    System.loadLibrary("native-lib");
  }
  
  public final String getKey() {
    return apiKey();
  }
  
  public final String getSalt() {
    return salt();
  }
  
  public final native String apiKey();
  
  public final native String apiKeyST();
  
  public final native String salt();
  
  public final native String saltST();
}

Since I'm writing my API wrapper in Python I want to load the libnative-lib.so in Python:

from ctypes import cdll

mylib = cdll.LoadLibrary('./libnative-lib.so')

print(mylib.Java_de_veedapp_veed_entities_Keys_salt())

I have also discovered that the library has some requirements, it searches for libm.so and other libraries, so I downloaded all these libs from this repo. Putting all the libraries into the same folder and placing the python script mentioned above inside this folder too, I got a segmentation fault (core dumped) error.

If it helps, I disassembled the library with onlinedisassembler.com (there I got the function name Java_de_veedapp_veed_entities_Keys_salt() from). A friend of mine also tried to load this library with C and got the same error (his repo).

I would be really happy if someone could help me!

0 Answers
Related