All Projects β†’ hexhacking β†’ xDL

hexhacking / xDL

Licence: MIT license
πŸ”₯ xDL is an enhanced implementation of the Android DL series functions.

Programming Languages

c
50402 projects - #5 most used programming language
CMake
9771 projects
python
139335 projects - #7 most used programming language
java
68154 projects - #9 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to xDL

Facebook ssl pinning
Bypassing SSL Pinning in Facebook Android App
Stars: ✭ 95 (-18.8%)
Mutual labels:  native, bypass
symdl
symdl is a simple little tool, its function is very similar to dlsym, with symdl, you can pass any global C function name string, so as to achieve the dynamic call of C function.
Stars: ✭ 49 (-58.12%)
Mutual labels:  dlopen, dlsym
byopen
πŸŽ‰A dlopen library that bypasses mobile system limitation
Stars: ✭ 241 (+105.98%)
Mutual labels:  dlopen, dlsym
rust-dlopen
Rust library for opening and working with dynamic link libraries.
Stars: ✭ 130 (+11.11%)
Mutual labels:  dlopen
graderjs
πŸ’¦ Turn your full-stack NodeJS application into a downloadable cross-platform binary. Also works for SPAs, or regular web-sites.
Stars: ✭ 147 (+25.64%)
Mutual labels:  native
IPC.Bond
IPC.Bond is an extension of IPC library that provides inter-process communication using shared memory on Windows with Bond serialization.
Stars: ✭ 26 (-77.78%)
Mutual labels:  native
native-xr-for-web
Add iOS and Android build with AR capabilities to your website or web-based app.
Stars: ✭ 27 (-76.92%)
Mutual labels:  native
requests-ip-rotator
A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.
Stars: ✭ 323 (+176.07%)
Mutual labels:  bypass
mjuzik
Curated Music app build on React Native
Stars: ✭ 44 (-62.39%)
Mutual labels:  native
opensea automatic uploader
(Bypass reCAPTCHAs) A Selenium Python bot to automatically and bulky upload and list your NFTs on OpenSea (all metadata integrated - Ethereum and Polygon supported); reCAPTCHA solver & bypasser included.
Stars: ✭ 205 (+75.21%)
Mutual labels:  bypass
tasit-sdk
A JavaScript / TypeScript SDK for making native mobile Ethereum dapps using React Native
Stars: ✭ 93 (-20.51%)
Mutual labels:  native
symbolator
HDL symbol generator
Stars: ✭ 123 (+5.13%)
Mutual labels:  symbol
Tsunami
An official Fog Network proxy site, made to access the blocked web. Surf without web filters or restrictions. Made with style, Tsunami is a rather fancy service dedicated to protecting your freedom from censorship
Stars: ✭ 44 (-62.39%)
Mutual labels:  bypass
kotlin-native-mobile-multiplatform-example
Code sharing between iOS and Android with Kotlin native
Stars: ✭ 52 (-55.56%)
Mutual labels:  native
windigo
Windows API and GUI in idiomatic Go.
Stars: ✭ 187 (+59.83%)
Mutual labels:  native
native-java-examples
Native Java Apps with Micronaut, Quarkus, and Spring Boot
Stars: ✭ 44 (-62.39%)
Mutual labels:  native
titanium-arkit
Use the iOS 11 ARKit API in Axway Titanium
Stars: ✭ 28 (-76.07%)
Mutual labels:  native
auth0-ios-swift-sample
Auth0 Integration Samples for iOS Swift
Stars: ✭ 55 (-52.99%)
Mutual labels:  native
wxWidgetsTemplate
A template project for wxWidgets C++, with pre-set files and IDE projects, and allows for easy updates to wxWidgets
Stars: ✭ 13 (-88.89%)
Mutual labels:  native
dicom-dimse-native
node js native addon for dimse services
Stars: ✭ 33 (-71.79%)
Mutual labels:  native

xDL

xDL is an enhanced implementation of the Android DL series functions.

README δΈ­ζ–‡η‰ˆ

Features

  • Enhanced dlopen() + dlsym() + dladdr().
    • Bypass the restrictions of Android 7.0+ linker namespace.
    • Lookup dynamic link symbols in .dynsym.
    • Lookup debuging symbols in .symtab and ".symtab in .gnu_debugdata".
  • Enhanced dl_iterate_phdr().
    • Compatible with Android 4.x on ARM32.
    • Including linker / linker64 (for Android <= 8.x).
    • Return full pathname instead of basename (for Android 5.x).
    • Return app_process32 / app_process64 instead of package name.
  • Support Android 4.1 - 12 (API level 16 - 31).
  • Support armeabi-v7a, arm64-v8a, x86 and x86_64.
  • MIT licensed.

Artifacts Size

If xDL is compiled into an independent dynamic library:

ABI Compressed (KB) Uncompressed (KB)
armeabi-v7a 7.0 13
arm64-v8a 7.7 17
x86 7.9 16
x86_64 7.9 17

Usage

1. Add dependency in build.gradle

xDL is published on Maven Central, and uses Prefab package format for native dependencies, which is supported by Android Gradle Plugin 4.0+.

allprojects {
    repositories {
        mavenCentral()
    }
}
android {
    buildFeatures {
        prefab true
    }
}

dependencies {
    implementation 'io.hexhacking:xdl:1.1.3'
}

2. Add dependency in CMakeLists.txt or Android.mk

CMakeLists.txt

find_package(xdl REQUIRED CONFIG)

add_library(mylib SHARED mylib.c)
target_link_libraries(mylib xdl::xdl)

Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE           := mylib
LOCAL_SRC_FILES        := mylib.c
LOCAL_SHARED_LIBRARIES += xdl
include $(BUILD_SHARED_LIBRARY)

$(call import-module,prefab/xdl)

3. Specify one or more ABI(s) you need

android {
    defaultConfig {
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
        }
    }
}

4. Add packaging options

If you are using xDL in an SDK project, you may need to avoid packaging libxdl.so into your AAR, so as not to encounter duplicate libxdl.so file when packaging the app project.

android {
    packagingOptions {
        exclude '**/libxdl.so'
    }
}

On the other hand, if you are using xDL in an APP project, you may need to add some options to deal with conflicts caused by duplicate libxdl.so file.

android {
    packagingOptions {
        pickFirst '**/libxdl.so'
    }
}

There is a sample app in the xdl-sample folder you can refer to.

API

#include "xdl.h"

1. xdl_open() and xdl_close()

#define XDL_DEFAULT           0x00
#define XDL_TRY_FORCE_LOAD    0x01
#define XDL_ALWAYS_FORCE_LOAD 0x02

void *xdl_open(const char *filename, int flags);
void *xdl_close(void *handle);

They are very similar to dlopen() and dlclose(). But xdl_open() can bypass the restrictions of Android 7.0+ linker namespace.

Depending on the value of the flags parameter, the behavior of xdl_open() will have some differences:

  • XDL_DEFAULT: If the library has been loaded into memory, xdl_open() will not dlopen() it again. (But it will still return a valid handle)
  • XDL_TRY_FORCE_LOAD: If the library has not been loaded into memory, xdl_open() will try to dlopen() it.
  • XDL_ALWAYS_FORCE_LOAD: xdl_open() will always dlopen() the library.

If xdl_open() really uses dlopen() to load the library, xdl_close() will return the handle from linker (the return value of dlopen()), and then you can decide whether and when to close it with standard dlclose(). Otherwise, NULL will be returned.

filename can be basename or full pathname. However, Android linker has used the namespace mechanism since 7.0. If you pass basename, you need to make sure that no duplicate ELF is loaded into the current process. xdl_open() will only return the first matching ELF. Please consider this fragment of /proc/self/maps on Android 10:

756fc2c000-756fc7c000 r--p 00000000 fd:03 2985  /system/lib64/vndk-sp-29/libc++.so
756fc7c000-756fcee000 --xp 00050000 fd:03 2985  /system/lib64/vndk-sp-29/libc++.so
756fcee000-756fcef000 rw-p 000c2000 fd:03 2985  /system/lib64/vndk-sp-29/libc++.so
756fcef000-756fcf7000 r--p 000c3000 fd:03 2985  /system/lib64/vndk-sp-29/libc++.so
7571fdd000-757202d000 r--p 00000000 07:38 20    /apex/com.android.conscrypt/lib64/libc++.so
757202d000-757209f000 --xp 00050000 07:38 20    /apex/com.android.conscrypt/lib64/libc++.so
757209f000-75720a0000 rw-p 000c2000 07:38 20    /apex/com.android.conscrypt/lib64/libc++.so
75720a0000-75720a8000 r--p 000c3000 07:38 20    /apex/com.android.conscrypt/lib64/libc++.so
760b9df000-760ba2f000 r--p 00000000 fd:03 2441  /system/lib64/libc++.so
760ba2f000-760baa1000 --xp 00050000 fd:03 2441  /system/lib64/libc++.so
760baa1000-760baa2000 rw-p 000c2000 fd:03 2441  /system/lib64/libc++.so
760baa2000-760baaa000 r--p 000c3000 fd:03 2441  /system/lib64/libc++.so

2. xdl_sym() and xdl_dsym()

void *xdl_sym(void *handle, const char *symbol, size_t *symbol_size);
void *xdl_dsym(void *handle, const char *symbol, size_t *symbol_size);

They are very similar to dlsym(). They all takes a "handle" of an ELF returned by xdl_open() and the null-terminated symbol name, returning the address where that symbol is loaded into memory.

If the symbol_size parameter is not NULL, it will be assigned as "the bytes occupied by the content corresponding to the symbol in the ELF". If you don't need this information, just pass NULL.

xdl_sym() lookup "dynamic link symbols" in .dynsym as dlsym() does.

xdl_dsym() lookup "debuging symbols" in .symtab and ".symtab in .gnu_debugdata".

Notice:

  • The symbol sets in .dynsym and .symtab do not contain each other. Some symbols only exist in .dynsym, and some only exist in .symtab. You may need to use tools such as readelf to determine which ELF section the symbol you are looking for is in.
  • xdl_dsym() needs to load debuging symbols from disk file, and xdl_sym() only lookup dynamic link symbols from memory. So xdl_dsym() runs slower than xdl_sym().
  • The dynamic linker only uses symbols in .dynsym. The debugger actually uses the symbols in both .dynsym and .symtab.

3. xdl_addr()

typedef struct
{
    const char       *dli_fname;
    void             *dli_fbase;
    const char       *dli_sname;
    void             *dli_saddr;
    size_t            dli_ssize;
    const ElfW(Phdr) *dlpi_phdr;
    size_t            dlpi_phnum;
} xdl_info;

int xdl_addr(void *addr, xdl_info *info, void **cache);
void xdl_addr_clean(void **cache);

xdl_addr() is similar to dladdr(). But there are a few differences:

  • xdl_addr() can lookup not only dynamic link symbols, but also debugging symbols.
  • xdl_addr() uses the xdl_info structure instead of the Dl_info structure, which contains more extended information: dli_ssize is the number of bytes occupied by the current symbol; dlpi_phdr points to the program headers array of the ELF where the current symbol is located; dlpi_phnum is the number of elements in the dlpi_phdr array.
  • xdl_addr() needs to pass an additional parameter (cache), which will cache the ELF handle opened during the execution of xdl_addr(). The purpose of caching is to make subsequent executions of xdl_addr() of the same ELF faster. When you do not need to execute xdl_addr(), please use xdl_addr_clean() to clear the cache. For example:
void *cache = NULL;
xdl_info info;
xdl_addr(addr_1, &info, &cache);
xdl_addr(addr_2, &info, &cache);
xdl_addr(addr_3, &info, &cache);
xdl_addr_clean(&cache);

4. xdl_iterate_phdr()

#define XDL_DEFAULT       0x00
#define XDL_FULL_PATHNAME 0x01

int xdl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), void *data, int flags);

xdl_iterate_phdr() is similar to dl_iterate_phdr(). But xdl_iterate_phdr() is compatible with android 4.x on ARM32, and always including linker / linker64.

xdl_iterate_phdr() has an additional "flags" parameter, one or more flags can be bitwise-or'd in it:

  • XDL_DEFAULT: Default behavior.
  • XDL_FULL_PATHNAME: Always return full pathname instead of basename.

These flags are needed because these capabilities require additional execution time, and you don't always need them.

Support

Contributing

License

xDL is MIT licensed, as found in the LICENSE file.

History

xCrash 2.x contains a very rudimentary module xc_dl for searching system library symbols, which has many problems in performance and compatibility. xCrash 2.x uses it to search a few symbols from libart, libc and libc++.

Later, some other projects began to use the xc_dl module alone, including in some performance-sensitive usage scenarios. At this time, we began to realize that we need to rewrite this module, and we need a better implementation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].