qilingframework / qiling

A True Instrumentable Binary Emulation Framework
https://qiling.io
GNU General Public License v2.0
5.14k stars 744 forks source link

Make symbolic link for Android #1459

Open ytournier opened 8 months ago

ytournier commented 8 months ago

Using Android binaries found in the rootfs, the readlink syscall does not find the binaries associated with file descriptors 3 and 4 which are libdl.so and libc.so respectively.

Here's the warning message raise during the execution:

linker: readlink("/proc/self/fd/3") failed: Operation not permitted [fd=3]
linker: warning: unable to get realpath for the library "/system/lib64/libdl.so". Will use given path.
linker: readlink("/proc/self/fd/4") failed: Operation not permitted [fd=4]
linker: warning: unable to get realpath for the library "/system/lib64/libc.so". Will use given path.
propClient: PropClient failed to load

Creating symbolic links as shown below is enough to satisfy the linker:

mkdir -p rootfs/arm64_android/proc/self/fd
ln -sf rootfs/arm64_android/system/lib64/libdl.so rootfs/arm64_android/proc/self/fd/3
ln -sf rootfs/arm64_android/system/lib64/libc.so rootfs/arm64_android/proc/self/fd/4
DiamondHunters commented 7 months ago

When u open a file , /proc/pid/fd/[N] will be a symbol link to the file which is opened with fd [N]. It's done by linux kernel. But qiling's procfs is not consistent with the real environment. You can mock procfs by Hijacking VFS objects