- Computers & Software
Help! I forgot my Mac OSX Password!
Resetting or Recovering your Mas OSX Password
Yesterday, I did something stupid. I changed all my passwords to something snarky to keep my newly ex’d girlfriend from logging into my accounts and… promptly forgot my own snarkiness the next day: I was locked out of my desktop MacPro computer.
I had two options: I could simply change the admin password in about 2 minutes, or I could recover the password I had actually created so that I could use it for all my other accounts that I had also changed.
If you own a Mac 10.4+ (Tiger, Leopard and Snow Leopard), merely changing your admin password is easy.
Option 1: Changing your Mac computer’s admin password when you’re locked out:
(1) Restart your Mac and press CMD + s as it’s booting up. This gets you into Single User Mode. If you did this correctly, you’ll see a black screen with a bunch of text.
(2) At the prompt, type fsck –fy
(3) Type mount -uw /
(4) Type launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
(5) If you don’t know the short form of your admin username, type ls /Users (list everything in the Users directory) and this will give you a list of all user shortnames.
(6) Type dscl . -passwd /Users/UserName newpassword (replace UserName with the short form of your admin username and change newpassword with your new password).
Now, in my instance, I had changed everything with my snarky bad temper including some accounts that didn’t have password recovery features: I needed to recover the password, not just change it.
This is a lot more complicated and time consuming. Get a pen and paper. You’re going to need it.
Option 2: Recovering your Mac Password without changing it
(1) Restart the target computer while pressing CMD + s to go into Single User Mode.
(2) If you’re using Mac OS 10.4 (Tiger), you need to type the following at the command prompt:
niutil –readprop ./users/<username> generateduid
If you’re on Mac OS 10.5 or higher (leopard and snow leopard), however, do NOT type the above command, but rather the following:
dscl localhost -read /Search/Users/<username> | grep GeneratedUID | cut -c15-
This will return a long string of random letters and numbers separated by dashes. This is your GUID and you need to write down: You’ll need it in a later step.
(3) Type cat /var/db/shadow/hash/<TheGUID> replacing <TheGUID> with the string you copied down from Step 2, above. This will return a different, very long string of numbers without hyphens. Copy this second hash the way you did with the GUID. You’ll need it.
(4) At this point, you can choose to do the rest of the steps on another computer, altogether. If you don’t have access to about a day or more of access to another computer, you can use your target by creating a new admin using the instructions, below. In any case, you’re going to be doing a brute force decryption using an application called John The Ripper, which you can download, here: http://www.openwall.com/john/
(5) For ease of use, after unzipping John The Ripper, I moved the extracted folder to the root. In any case, copy the hash from step 3, above, to a text file in the following format:
username:<hash> replacing <hash> with the long string you copied in Step 3.
(6) Save it in the extracted John folder as sha1.txt in the extracted folder.
(7) In Terminal, type: ./john sha1.txt and, depending on how complex your password is, you should see the result in anywhere from minutes to a couple of days. It’s probably the one time when you probably wish you didn’t have a long, complex password.
Creating a temporary Admin when you’re locked out of your Mac OS 10.4 – 10.6.x
Sometimes, it’s necessary to create a new admin from Single User Mode and if you’re trying to hack your own password, it may be that the computer you’re trying to hack is the one you have long term access to.
No problem! Creating a new admin when you’re locked out of your Mac OS X computer takes about a minute. Here’s how it’s done:
(1) Restart your computer and hold down the CMD + s buttons as it’s rebooting. You should get a black screen with a bunch of white text.
(2) Type: fsck –fy
(3) Type: mount -uw /
(4) Type: rm /var/db/.applesetupdone
(5) Type: reboot
Your computer will shut down. When you restart it, you’ll need to go through the whole video thing as you did when you first bought your Mac. Set your language, etc. and make sure you don’t choose migrating information. When you have the option to create a new user account, make sure you do not name it the same as the account you’re trying to recover.
Viola! New admin account! Now you can use John the Ripper to brute force your password hash.