How to Hack a Mac OS X Password

Posted on 30th April 2011 in Tutorials

I may have mentioned some time ago that I learned how to change Mac passwords without knowing the current password. Whether or not I did, I do know how to do it, and I do feel like sharing today. To be clear, this is a brief tutorial on how to change the password for one Mac user account on a computer to which you have physical access, in order to gain administrative privileges. This method doesn’t create a new user, it only changes the password of an existing one. As such, it does cause the password stored in that user’s keychains to fail, meaning that next time that user logs in, they’ll be prompted repeatedly for their newly changed password. I understand that this knowledge could pretty easily be used maliciously – have some self control, seriously. Knowing how to do it should be enough, you don’t need to break your school’s grading system or anything like that.

So before we start, you should know that there is a slight bit of prerequisite knowledge required. You should be comfortable with the command line interface, and knowing UNIX well is a big plus. I would just hate for you to try and follow this tutorial and then realize too late that you’re in over your head and accidentally breaking things. So, if you need it, here‘s a good tutorial on command line basics. Do it, and then do another, and then come back and break into your own Mac.

If the above paragraph doesn’t apply to you, let’s get started. In English, the general process for changing the password is to gain root access to the system, find the user account to change the password for, change the password, and reboot. If you were trying to do this remotely, the hardest part would be gaining root access, but as we have physical access to the computer, it’s completely trivial.

To get root access, boot into single-user mode by holding down Command+S (or Apple+S, if you prefer) as you start the computer. That is, from the shut-down state, turn on the computer while holding down Command+S. The normal boot sequence won’t happen – instead you’ll be dropped to a UNIX prompt as the root user.

As a preliminary note, the $ preceding commands represents the shell prompt.

———————————————-

It’s generally a good idea to take this opportunity to check the hard disk for errors before mounting it. I like to do it for the peace of mind. The command to check the disk is

$ /sbin/fsck -fy

This will run the same check that’s run when you click “Verify Disk” in Disk Utility. It takes a little while, and it may look like it’s frozen, but it’s really not. It just takes a while. Once it’s done, mount the filesystem with

$ /sbin/mount -uw /

The slash on the end refers to the mount point of the filesystem, meaning the root directory. Now that the filesystem is mounted, load the Apple directory services commandline utility with

$ launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist

Now you can use the dscl command to perform some simple operations on the computer’s list of users. First off, you want to see the names of all of the accounts on the system. You can get a listing easily using the following command.

$ dscl . list /Users

You’ll see a listing of all of the machine’s accounts, most of which start with an underscore. Most of these are accounts required for the proper operation of the system, but you never see them. You can ignore these. The ones you’re interested will be near the bottom of the list, without underscores. Generally, if you’re on a personal computer, you’ll be able to deduce which account has administrative rights, because it will be the one named after the person who owns the computer. If this isn’t the case, though, and you see a bunch of users with similar or ambiguous names, there’s an easy way to find out if a user has admin rights. Just enter

$ groups theusernamehere | grep admin

Replace “theusernamehere” with the name of the user you want to check admin rights for. If the command returns anything, this means that the user is an admin. You’ll also see the word “admin” among the groups in the command’s output. If not, they’re not an admin. Alternately, you can delete everything in the command after the user name and manually scan each output for the word “admin”. Use a bit of trial and error to find out who the administrator of the computer is. Once you’ve done that, changing their password is trivial. The command is

$ passwd theusernamehere

Replace “theusernamehere” with the exact username of the account you want to change. You’ll be asked to type and retype the new password for the user. Don’t be surprised that nothing appears when you type the password, that’s normal. Just reboot using

$ reboot

and log in as the user whose password you just changed. Congratulations, the system is now at your mercy.

———————————————-

As an alternative to this method, it’s possible to redo the setup that ran once when the computer was first started and create a new admin account that way. To do that, after you’ve mounted the filesystem, use

$ rm /var/db/.AppleSetupDone

to delete the file that indicates the completion of the initial setup. Then, when you reboot, you’ll go through the account creation process as if it was the first time you ever started the computer.

So there you go, be responsible with how you use this information. Try the process out though, it’s an incredible feeling the first time you break into a computer, even if it’s your own.

[insert name of beatles song here]

Posted on 24th April 2011 in Something Daily

Yesterday I got the first comment ever to be perpetrated on this blog that involved a positive reaction to one of my computer tutorials. It was the one where I explain how to make the keyboard backlight buttons work on Macbooks running Ubuntu. Surprisingly, someone actually followed the steps and it worked for them! Unexpected, for sure. Yet, of course, totally awesome.

I spent most of this wonderful afternoon in central park with my friend Sarah, just chatting and enjoying the very nice weather. I would have felt awful not spending at least part of today outside. I was tempted to wear shorts – that’s how warm it was, you guys. I got over my fear of sitting in the grass in new jeans, and I was reminded of the Tower of Terror by all the buildings surrounding central park. You know, they kind of look like this when you’re in the park and there are trees blocking the lower portions.

At least that’s what I think whenever I’m in the park. It reminds me of when we went there, and I rode that ride for the first and last time. Falling straight down isn’t really my thing. I like falling sideways, or forward.

I continued learning assembly, C, and as a result, memory architecture, today, and learned an interesting lesson in the process. Of course, this makes total sense, but I had to learn it firsthand. I’m following a tutorial that uses Linux and the GNU debugger to step through programs and teach assembly, and I decided to try it on Mac. I downloaded XCode and started running all of the tutorial examples, but soon found out that all of the register names are different under Mac. EIP wasn’t doing anything for me other than causing an unknown register error. So I examined the registers, and sure enough, they were all totally different from the Linux ones. I’m sure they have similar functions, but for now, I’m sticking to Linux, because that’s what the book I’m using covers, and it covers it very well. Interesting lesson, though. I also noted that the memory addresses that my Mac was displaying were twice as long as those on my Linux system, which makes a lot of sense as the Mac has 4GB of RAM and the Linux box only has 2GB. Hooray for learning.

Maybe I’ll go watch a movie tonight. Maybe I’ll just keep coding. Both are fun.

How to Turn off 3D dock in Mac OS X Leopard/Snow Leopard

Posted on 14th February 2011 in Tutorials

A little tip I found a while back that I very much enjoy: the default Mac OS X Leopard dock looks like glass and reflects the desktop and application icons. I wanted to turn that off (have it reflect nothing), and it turns out that this is how one does that:

In Terminal, to turn the glass dock off, type
defaults write com.apple.dock no-glass -boolean YES; killall Dock

and to turn it back on, type
defaults write com.apple.dock no-glass -boolean NO; killall Dock

You’re welcome!

comments: 0 » tags: , , ,

Let it be known: I will eat my shoe

Posted on 14th February 2011 in Something Daily

I just got a package in the mail, and when I was going to get it I was so convinced that it was going to be my Tropicana gear, but it ended up being Valentine’s Day cookies from my mom. I was really excited for the Tropicana stuff, but cookies are very awesome too. Thanks mom. I’m expecting the gear tomorrow then, or (hopefully not) the day after that. It just needs to get here already. Along with letters from my friends and the confirmation of my double major declaration. I’m waiting for a bunch of stuff in the mail. And as I do so, I’m getting pumped up by I Get Wet. I honestly used to hate that album, but it’s growing on me rather quickly. I feel the same way about it as I do about Blink-182, in a sense – I acknowledge the fact that it’s simple and kind of idiosyncratic, and then stop worrying about it and jam out.

I finally finished getting all the star coins in New Super Mario Bros. Wii, which took an ungodly long time, even with our whole suite playing in a shared account. I decided that I’d just go ahead and do it today, but level 9-7 is so unbelievably annoyingly difficult. I don’t want to talk about it. I have bad memories attached to that level. The second star coin is stupid if you don’t have the propeller hat – which I never did – and I ended up trying it about forty times. I did succeed though. This was about an hour ago.

I was playing Mario instead of doing something productive partially due to the fact that I chose today to once again reconfigure my MacBook Pro – I deleted the Ubuntu partition (decided I have enough Ubuntu on my old MacBook, and Portal 2 is coming out for Mac) and reinstalled Snow Leopard, crossing my fingers very hard that my automated backup scheme had been working correctly. Turns out it had been. It’s gone through a lot of revisions over the last few months, but it works awesomely now. I am, once again, proud of myself. Also because of that piece I wrote in LSDJ over the weekend; I still think that sounds rockin. I rerecorded the guitar since it was a little bit out of tune, it’s way more rockin now. Check it out.

And I finally preordered Portal 2 on Steam today. It comes out on a Monday, and let it now be known that I will not stop playing on that Monday until it’s finished. If I can’t, I will eat my own shoe.

MacBook Pro Backlit Keyboard in Ubuntu Maverick

Posted on 4th January 2011 in Tutorials

I was browsing around a little while ago and it occurred to me that the keyboard backlight on my MacBook Pro 5,4 wasn’t working under Ubuntu 10.10 Maverick Meerkat. I found a few resources online to help with the problem, and it ended up teaching me a lot. I wrote a script that changes the numeric string stored in /sys/class/leds/smc::kbd_backlight/brightness, then set the script to be run every time the keylight increment/decrement buttons on the keyboard are pressed. Here are the steps I took, in case you want to try this for yourself.

I worked up a shell script that, depending on the string passed from the command line, either increments, decrements, sets to zero, or sets to 100% the value of the backlight brightness.

Go ahead and use the code, or write your own, I don’t care. You can either copy and paste from here into a file called keylight in /usr/bin, or download the file here.

Once you have /usr/bin/keylight on your system, run sudo chmod +x /usr/bin/keylight to make the script executable. You’ll know that you forgot this step if you get a “command not found” error when you try to run it.

To test the script, run sudo keylight full. The keyboard backlight should come on. To turn it off, run sudo keylight off. I use an alias to avoid the necessity of sudoing every time – that is, I added the line alias keylight='sudo keylight' to the /home/emmett/.bashrc file. Still, a password is required when running the script. Since we want this to be controlled with the keyboard, we have to override that somehow. This can be accomplished by adding the following lines to /etc/sudoers (run the command sudo visudo to edit this file).

Cmnd_Alias KEY = /usr/bin/keylight
%admin ALL = (ALL) NOPASSWD: KEY

(it’s hard to see, but there is an underscore between Cmnd and Alias – that is, Cmnd_Alias)

These lines tell the computer that, when running the keylight command, members of the admin group do not need to enter a password. With that accomplished, all that’s left is to create new keyboard shortcuts for the script. In System->Preferences->Keyboard Shortcuts, click “Add”. Fill the “Name” field with something like “Keylight up”, and enter sudo keylight up into the “Command” field. (Don’t forget the sudo!) Click OK, and change the hotkey for the command to the F6 key (XF86KbdBrightnessUp). Repeat the process for keylight down, keylight full, and keylight off. I use the F5 key for down, and add Ctrl for full and off.

Follow this process, and the backlight on your keyboard should work like it does under Mac OS X. At least, it does for me. Feel free to comment with feedback, comments, or additions you make to my code. Thanks for reading!

Perfect Hair for Never

Posted on 2nd January 2011 in Something Daily

Perfect Hair Forever is sweet. I remember watching it on demand in high school and having no idea what it was. Now that I have a better sense of anime cliches, it’s just that much funnier to me. I like the guy with the huge rainbow Dragon Ball Z hair. Actually every aspect of that show is funny in its ridiculosity.

I spent another day in close proximity with my whole family today…so as some therapy in the evening I set up a dual boot of Mac OS X and Ubuntu Maverick on my MBP, the second of my two computers to get this treatment. It took a bit more extra work to set up the Pro than the standard MacBook with Ubuntu, including what seemed like a big issue with the speaker drivers but ended up being a mute button in the ALSA mixer. As a tech, I should have known that’s the first place you ever look when there’s “no sound”. I was in the middle of downloading a patch when I tried that…and then I kicked myself in the face. (Side note: I’m becoming a humongous Ubuntu fanboy (or fangirl, some might say); I can tell that I’m about to start using it far more than Mac. Of course, I still need Mac for music applications and gaming, but I’m growing tired of it.)

And I just got flash running in Ubuntu, which is how I watched Perfect Hair just moments ago. Time for some more. What a perfectly absurd show.

EDIT: I just found out there are only seven episodes! Lame!

Operating Systems Dilemma

Posted on 1st December 2010 in Something Daily

This week is becoming interesting. Mondays and Tuesdays are always pretty easy: I don’t have a lot of classes, and homework is usually due later in the week. So when I go home, I can hang out. Like how I didn’t really accomplish anything yesterday and just played New Super Mario Bros. Wii with Eric. I mean it’s a pretty good game – almost as good as being productive. Almost. We finished all the regular levels, including the crazy frantic battle at the end where giant bowser is running after you – we were all screaming. It was crazy. But now, since we apparently don’t have better things to do, we’re going through the game again and getting all of the star coins to unlock the really difficult secret levels. It’s not as bad as the replay gimmick in Super Mario Galaxy 2 that makes you play the whole game twice, but it’s similar. But who am I to complain? It’s fun – I mean I’m playing it, right? Anyway the week is getting interesting because I know that tonight is going to involve a large amount of frantic work that’s all due tomorrow. And the South Park season is over, so I don’t have that to break up the craziness tonight. But today’s the craziest. Tomorrow will be better. And now for something completely different.

Considering the process of building my own desktop computer has made me a bit uncomfortable with my affinity for Mac OS X. My original idea for a computer build was essentially “Make a computer that runs OS X”. Doing a little research, I found out about the Hackintosh community and the compendiums (compendia?) they keep of OS X compatible parts. This is all good, but doing a bit of research on the process outside of that community has led me to the realization that installing X on a non-Mac computer is ultimately more work than it’s worth. Choosing the correct parts seems to be the easy part, with the numerous lists of compatible motherboards and processors floating around the internet. The impression that I get is that hacking the OS, installing and running it successfully are the hard parts. I’m positive that it’s doable, and I’ll probably try to do it eventually. I won’t however, have a very high expectation of success, and I’ll pick hardware that’s compatible with both Ubuntu and OS X.

The thing is, I’m worried that using OS X exclusively will lead to me wasting money in the future, not to mention becoming married to one company/OS. I don’t want to have to ‘settle’ for an operating system that I’m not amazing with, or that doesn’t run the software that I need, because it doesn’t run on my hardware. My ideal situation is, of course, running OS X on non-Apple hardware, for the experience of building my own computer for a cheaper price than Apple and running the software that I know/require. I can see why Apple makes it so difficult to do this, though. They really don’t want me to do this. So I’ll try and make a Hackintosh when the time comes.

However, short of getting that to work, I’m practicing as much as I can with Linux (which isn’t a whole lot different anyway), because apparently Linux can run on tons of hardware types. I dual boot 10.6.5 and 10.10 on my white MacBook, and I pretty much only use the Linux partition these days. It’s good practice, and I love finding all of the downloadable packages for added commandline functionality that you can’t really use in OS X. It’s a great system, I just reeeeeally wish that Logic and Steam were compatible with it. If they were, I’d drop OS X in a second. Seriously. Watch, I’ll do it.

And no, I won’t use Windows. UNIX owns DOS and the system under Vista and 7.

Hey, I found a picture of young Stephen Colbert. Believe it.

Everywhere I Go I Own

Posted on 23rd November 2010 in Something Daily

I’m going to see mc chris in Brooklyn in a few minutes. I don’t know what it’s going to be like yet, but I’m definitely excited. I’ll write about it for sure, of course. I don’t know if he’ll be doing older stuff, or some things off of his new albums. I just hope he does some of the ones I like. But either way, it’ll be interesting to see what a show of his is actually like – he’s kind of mythological to me, like he doesn’t really exist. I guess I’ve felt that way about a lot of bands before I saw them. It’s a function of listening to music without knowing that much about the people who made it. It’s often startling to see these people in the flesh when you’re so used to your mental picture of them that you constructed from their music. It’s similar to when a movie comes out based on a book that you know really well. You’ve figured out all the characters and settings for yourself, and then you’re looking at another person’s interpretation of them in the movie, and it doesn’t necessarily match your original conception. Anyway, mc chris seems like he’s the man, and I am very excited to see him in person.

I started researching some resources today for building computers from scratch. I found a nice resource in Tom’s Hardware – there’s a lot of great information for beginner PC builders there. I learned exactly what components are necessary for a PC to work – motherboard, storage, memory, video and sound cards, power supply, etc. I’m definitely considering building my own the next time I need a new computer. The only thing is that it seems pretty tough to build one that Mac OS X will run on, since Macs use proprietary hardware that can’t be found anywhere else. Still, I’m investigating it, though it’s pretty likely that were I to build my own computer, it would run Ubuntu and/or Windows.

The Whiner’s Bio

Posted on 20th October 2010 in Something Daily

I would just like to make it known that Mates of State are a really good band. Especially their album “Team Boo”. I think I can count on one hand the number of people I’ve talked to who’ve known them since an ex-girlfriend showed me “Bring it Back”…and I think that’s very sad. They’re way too much fun to listen to for me to ignore them; I feel like it’s the kind of music that you can’t help but like, at least the first time you hear it. Opinions on Mates are formed after the fact.

I guess the Farfisa sound isn’t all that popular in modern indie pop, but I am crazy about it on all of Mates’ stuff, especially the aforementioned favorite album of theirs. I think it’s a wonderful combination of sounds that these two have discovered – the uncluttered arrangement of drums, organ, and two voices that’s (sort of) their signature at this point. I mean, I don’t want to write a music review here, but I do want to make sure that my opinion on the matter is clear: Mates of State are a great band, and I love them completely. Go see them in concert. Last time I saw them, you know who the opening acts were? A musical standup comic and a sword swallower. She swallowed two swords at once. It was crazy. Icing on the cake. Go see Mates of State.

Work on “The Game” is progressing much more quickly than at any other time in the past few weeks: I’m finishing up a framework (am I authorized to use such words?) that allows fairly intuitive control of the motion of enemies on the 2D plane. After that’s done, my last big non-design goal is to create a system that allows laser shapes to be shot by the group – like Ikaruga but more awesome (maybe). And a title. A title would be great. Hopefully this is all behind me by the end of the semester. And you, reader, will be playing a sweet dinosaur-based arcade shooter set in space on these very interwebs.

Oh, and check out Mac OS 10.7. App store? I don’t know, man. I’m incredulous over here. But we’ll see.

So having said these things, here is a reminder of the importance of radness.

This is going well. I like blogging.