0. ubuntu 20.04.4 LTS x64

1. 의존 패키지 설치 Install Dependent Packages (defconfig 및 menuconfig 빌드를 위함)
sudo apt-get install build-essential libncurses5-dev python

2. 커널 소스 다운로드 Download the appropriate kernel source for your device.
Galaxy Tab S6 Lite : git clone https://github.com/LineageOS/android_kernel_samsung_gta4xl

3. 크로스 컴파일러 다운로드 후 경로 설정 Set path after downloading cross-compiler
git clone https://github.com/Shubhamvis98/toolchains

export PATH="/home/code/toolchains/clang-r428724/bin:/home/code/toolchains/aarch64-linux-android-4.9/bin:$PATH"
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-android-
export CLANG_TRIPLE=aarch64-linux-gnu-

4. 커널 소스 디렉토리로 이동 Go to the kernel source path
make clean
make mrproper
make exynos9611-gta4xlwifi_defconfig
make menuconfig  -> 실행 후 <Save> 클릭 

5. 컴파일 Build it
make -j16 CC=clang

6. 커널 소스 수정 (오류 발생 시) Modifying kernel sources (in case of error)
Open Makefile


KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
   -fno-strict-aliasing -fno-common -fshort-wchar \
   -Werror-implicit-function-declaration \
   -Wno-format-security \
   -Werror \    <------------- 해당 라인 삭제 delete this line
   -std=gnu89

    private boolean checkRootMethod1() {
        for (String str : new String[]{"/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su"}) {
            if (new File(str).exists()) {
                return true;
            }
        }
        return false;
    }

exist() -> /apex/com.android.art/lib64/libjavacore.so에서 access()를 호출함

access() 후킹 코드 작성으로 우회 가능

int (*Org_access)(const char* __path, int __mode);
int hook_access(const char* __path, int __mode)
{
    register uint64_t result;

    __asm volatile ("MOV %0, LR\n" : "=r" (result));

    LOG("access path - %s %lx", __path, result);
    if (strstr(__path, "su"))
    {
        return -1;
    }
    return Org_access(__path, __mode);
}
A64HookFunction((void*)access, (void*)hook_access, (void**)&Org_access);

https://github.com/codetronik/AArch64Hook_android

테스트 환경 : 갤럭시 S6 Lite (android 11 : P610XXU2CUC3 (2021.03) 펌웨어)

android 7에서 통했던 /system/lib 폴더에 so를 복사하는 방법이 더이상 안됨

아래와 같은 에러 발생함.

dlopen failed: library "/system/lib64/libinject.so" needed or dlopened by "(unknown)" is not accessible for the namespace "classloader-namespace"

심지어 기존에 있던 시스템 라이브러리를 인젝션해도 동일 에러 발생.

해결 방법은 /data/user/0/app name/files/ 에 so를 복사함.

넷플릭스,정부24앱에서 인젝션 테스트 완료

+ Recent posts