All Projects → hack0z → byopen

hack0z / byopen

Licence: Apache-2.0 license
🎉A dlopen library that bypasses mobile system limitation

Programming Languages

c
50402 projects - #5 most used programming language
java
68154 projects - #9 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to byopen

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 (-79.67%)
Mutual labels:  dlopen, dlsym
xDL
🔥 xDL is an enhanced implementation of the Android DL series functions.
Stars: ✭ 117 (-51.45%)
Mutual labels:  dlopen, dlsym
Jpegkit Android
Efficient JPEG operations for Android without the risk of an OutOfMemoryException.
Stars: ✭ 154 (-36.1%)
Mutual labels:  ndk
Cargo Ndk
Compile Rust projects against the Android NDK without hassle
Stars: ✭ 141 (-41.49%)
Mutual labels:  ndk
opencv android setup tutorial
Tutorial on OpenCV for Android with Android Studio
Stars: ✭ 32 (-86.72%)
Mutual labels:  ndk
Mwengine
Audio engine and DSP for Android, written in C++ providing low latency performance in a musical context, supporting both OpenSL and AAudio.
Stars: ✭ 190 (-21.16%)
Mutual labels:  ndk
PersonDemo
🔥 一些个人学习中备份的技术方案
Stars: ✭ 16 (-93.36%)
Mutual labels:  ndk
ZeeArchiver
Zee is an efficient and simple to use Android Archiver and decompressor. It can decompress and compress from-to all the formats supported by the well known 7zip utility. Copyright © 2018 Mahmoud Galal , for support contact me:[email protected]
Stars: ✭ 35 (-85.48%)
Mutual labels:  ndk
SecuritySample
(Android) Hide encrypted secret API keys in C/C++ code, retrieve and decrypt them via JNI. Google SafetyNet APIs example.
Stars: ✭ 49 (-79.67%)
Mutual labels:  ndk
Android Disassembler
Disassemble ANY files including .so (NDK, JNI), Windows PE(EXE, DLL, SYS, etc), linux binaries, libraries, and any other files such as pictures, audios, etc(for fun)files on Android. Capstone-based disassembler application on android. 안드로이드 NDK 공유 라이브러리, Windows 바이너리, etc,... 리버싱 앱
Stars: ✭ 250 (+3.73%)
Mutual labels:  ndk
Sol2
Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
Stars: ✭ 2,791 (+1058.09%)
Mutual labels:  ndk
Appaddupdate
Android app 增量更新
Stars: ✭ 192 (-20.33%)
Mutual labels:  ndk
Android-Code-Demos
📦 Android learning code demos.
Stars: ✭ 41 (-82.99%)
Mutual labels:  ndk
Hidex Hack
anti reverse by hack dex file
Stars: ✭ 160 (-33.61%)
Mutual labels:  ndk
Tango-C-NDK-Tutorial
Helping those who want to get involved in the realm of Augmented Reality
Stars: ✭ 16 (-93.36%)
Mutual labels:  ndk
Androidsecurity
Android安全实践
Stars: ✭ 150 (-37.76%)
Mutual labels:  ndk
Relinker
A robust native library loader for Android.
Stars: ✭ 2,612 (+983.82%)
Mutual labels:  ndk
ChangeVoice
NDK语音消息的变声处理
Stars: ✭ 33 (-86.31%)
Mutual labels:  ndk
libandroidjni
Android JNI bindings library
Stars: ✭ 66 (-72.61%)
Mutual labels:  ndk
UseCmakeBuildLib
用Cmake的方式构建a静态库,so动态库,且集成到项目中
Stars: ✭ 46 (-80.91%)
Mutual labels:  ndk

dyOpen

A dlopen library that bypasses mobile system limitation

简介

byOpen是一个绕过移动端系统限制的增强版dlfunctions库。

支持特性

Android

支持App中加载和使用Android系统库接口(即使maps中还没有被加载也支持)。

Android 7以上dlopen, System.load都是被限制调用的,虽然目前网上有Nougat_dlfunctions等库通过从maps中找so库来绕过加载限制。

不过对于app中还没被加载到maps的so库,这种方式就不行了。

而byOpen不仅支持fake dlopen方式从maps加载,还可以将还没加载到maps的so库绕过系统限制强行加载进来使用,实现更加通用化得dlopen。

注:目前的实现方式理论上还是比较通用的,至少我这Android 10上测试ok,但还没完整详细测试过,是否使用请自行评估。

相关原理

具体实现原理还是比较简单的,主要还是借鉴了一种绕过Android P对非SDK接口限制的简单方法的思想和实现方式。

虽然这篇文章中主要目的是为了绕过hide api,不过它里面使用的将自己假装成系统调用的方式,一样可以用到System.loadLibrary上去,让系统以为是系统自身在调用System.loadLibrary

从而绕过Android N的classloader-namespace限制,将系统/system/lib中任意so库加载到maps中,然后再通过fake dlopen的方式去dlsym。

增强版fake dlopen

关于fake dlopen的方式实现,网上已有很多实现,比如:

byOpen参考了里面的实现,重新实现了一遍,并且做了一些小改进:

  • 不在/proc/self/maps中的系统库,也能绕过限制强行加载进来使用
  • 除了从.dynsym中检索符号,还支持从.symtab中检索符号(参考:Enhanced_dlfunctions,顺带修复了里面的一些bug)
  • 整个dlopen过程只有一次malloc分配(省去整个符号表的内存分配和copy)

Android例子

Android相关测试App例子在:Android Sample

注:目前自带的App测试例子里面的系统库我写死了,有些系统版本上有可能不存在,请先改成用户自己的库和符号名,再编译测试

public class MainActivity extends AppCompatActivity {
    private static final String SYSTEM_LIBRARY = "curl";
    private static final String SYMBOL_NAME = "curl_version";

除了Native版本dlopen接口,byOpen额外提供了java版本的System.loadLibrary接口在java层直接绕过系统库加载。

关键代码如下:

static public boolean loadLibrary(String libraryName) {
    Method forName = Class.class.getDeclaredMethod("forName", String.class);
    Method getDeclaredMethod = Class.class.getDeclaredMethod("getDeclaredMethod", String.class, Class[].class);
    Class<?> systemClass = (Class<?>) forName.invoke(null, "java.lang.System");
    Method loadLibrary = (Method) getDeclaredMethod.invoke(systemClass, "loadLibrary", new Class[]{String.class});
    loadLibrary.invoke(systemClass, libraryName);
}

而native版本的dlopen_android.c实现中,我将这段绕过的系统加载的方式,通过jni重新实现了一遍,然后和fake dlopen无缝结合到了一起。

iOS

虽然ios可以直接使用dlopen,但是审核上会有风险,苹果有可能会对提交AppStore的app扫描相关dlopen/dlsym等调用,来判断是否存在一些敏感的私有调用。

为了在通过调用一些私有接口的时候避免被苹果检测到,byOpen也通过自己实现dlopen/dlsym直接从已经加载进来的images列表里面直接查找对应symbol地址来调用。

当然,为了更加安全,相关调用的库符号硬编码字符串等,用户可以自行做层变换加密,不要直接编译进app。

接口用法

相关静态库和接口在:dlopen.h

相关使用方式跟原生dlopen完全相同:

typedef by_char_t const* (*curl_version_t)();
by_pointer_t handle = by_dlopen("libcurl.so", BY_RTLD_LAZY);
if (handle)
{
    by_pointer_t addr = by_dlsym(handle, "curl_version");
    if (addr)
    {
        curl_version_t curl_version = (curl_version_t)addr;
        by_print("curl_version: %s", curl_version());
    }
    by_dlclose(handle);
}

编译

编译需要先安装:xmake

Android

直接编译库

$ xmake f -p android --ndk=~/file/android-ndk-r20b
$ xmake

通过gradle编译测试Apk

$ cd src/android
$ ./gradlew app:assembleDebug

通过xmake直接编译apk

$ xmake apk_build

通过xmake直接安装测试apk

$ xmake apk_test

iOS

直接编译库

$ xmake f -p iphoneos -a [armv7|arm64]
$ xmake

MacOS

我们也可以在macOS下编译测试,也是支持的:

$ xmake
$ xmake run
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].