How to RESET iPhone/iTouch R00t Passwd.

Hmmmm, so you unlocked your new 1.1.4 iPhone and started playing around with various applications. Have you ever been in a situation where you installed OpenSSH ( Usually no need to install it manually, most of the jailbreaking tools will installed it for you ), and logged in from some remote machine and tried to change its default root password by using regular ‘passwd’ command and it caused underlaying BSD Substem to Crash?

The same thing happened with me also in the recent past. After changing the root password, i happily closed the SSH connection and started to browse and make some calls. I changed the summerboard theme and restarted SpringBoard to apply changes; thats it, my iphone went in endless loop, never allowed me to even open any of the applications. It restored my cool wallpaper to the original one (earth) and was looking like this –
If same thing has happened with you too, then read on or even if not still read on ๐Ÿ˜‰
There is a bug in the encryption logic of ‘passwd’ command which changes the /etc/master.passwd file. The only way to recover from this crash is to restore back the iPhone.

Format of Sample /etc/master.passwd file:
##
# User Database
#
# Note that this file is consulted when the system is running in single-user
# mode. At other times this information is handled by lookupd. By default,
# lookupd gets information from NetInfo, so this file will not be consulted
# unless you have changed lookupd’s configuration.
##
nobody:*:-2:-2::0:0:Unprivileged User:/var/empty:/usr/bin/false
root:someJunkChars:0:0::0:0:System Administrator:/var/root:/bin/sh
mobile:someJunkChars:501:501::0:0:Mobile User:/var/mobile:/bin/sh
daemon:*:1:1::0:0:System Services:/var/root:/usr/bin/false
unknown:*:99:99::0:0:Unknown User:/var/empty:/usr/bin/false
_securityd:*:64:64::0:0:securityd:/var/empty:/usr/bin/false


How to change the deafult r00t password?
====================================
Instead of using ‘passwd‘ command, use following manual steps.

1) On Terminal use any one of the following way to generate cypto password.

root@iBughira:~# perl -e ‘print crypt(“myPasswd”, “XX”).”\n”‘
OR
root@iBughira:~# openssl passwd -salt “XX” “myPasswd”
XXd3otv/H89.E
root@iBughira:~# openssl passwd -salt “XX” “myPasswd123”
Warning: truncating password to 8 characters
XXd3otv/H89.E
root@iBughira:~#
Where, Password must be <= 8 chars
XX = 2 char Salt.
OR
Click here to generate the new crypt password online.
2) Copy the output of this command.
3) Login to your iPhone using SSH.
4) Open the /etc/master.passwd file in vi or nano editor.
5) Replace the string after root: from /etc/master.passwd. ( i.e Replace “someJunkChars” from above sample file.)
6) Save and exit the editor.

Thats it, you are done. Root password has been changed. If this helped you, do leave comment/feedback.

Advertisements

About this entry