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.

Netbeans IDE – Uncompilable Source Code exception

Posted on 12th March 2011 in Something Daily

So I’ve been working on a Java project recently, which, in terms of sheer lines of code, is pretty substantial. As such, I work on it a lot in different locations, and usually split the work between my two computers. Me being the efficiency freak that I am, I have found ways to ensure that the current version of the project is always accessible from anywhere on any system I’m using. That is, I keep the source files in the cloud (via Dropbox), so that every time I save a change in Netbeans it’s automatically uploaded, and I keep disk backups of the current files (done by a shell script every time I close a session). So basically the source directory that Netbeans looks at is just symlinked from Dropbox, while the class files are kept locally on each computer that I’m working on (apparently the Linux and Mac JVMs are different enough to require an annoying recompile if you don’t do this). But everything that I’m doing with this stuff is controlled by shell scripts.

The thing is, I started to notice that if I ever save anything in Netbeans when I’m not connected to Dropbox (that is, Dropbox fails to sync) I start getting errors about “uncompilable source code”. The identical code still runs just fine from the command line, but Netbeans can’t handle it. I finally found the answer to this issue today, though – it turns out that when Netbeans is set to compile every time the file is saved, a separate set of class files are created for debugging purposes. Certain things can cause these files to be corrupted and uncompilable, such as, I found out, a nonsyncing Dropbox containing the source files.

So to fix this, I first turned off the “compile on save” feature in Project Properties, then deleted closed Netbeans and deleted the directory “.netbeans/6.9/var/cache/index” (where the cache of extra class files is kept) and reopened. The directory is automatically recreated in a noncorrupted state when Netbeans reopens. The problem of uncompilable source code is gone now, with the one added annoyance of having to manually compile before running. Still, I’m glad my project runs.

The source of this new knowledge.

Unix/Vim Cheat Sheet

Posted on 21st February 2011 in Something Daily

Like I said I would yesterday, I have completed my conglomeration of two Unix/Vim command cheat sheets that I came across in my travels around the internet (or grape-net, if Justin is to be believed), along with some commands I know and use often that weren’t on the sheets. This hasn’t been spelling- or error-checked much at all, so I dunno….if you happen to take it and use it for yourself…you might, like, tell me if there are any errors that you find…probably? That would be nice of you, if you, the reader, were to use this in such a way. Anyway, here it is…(click the image for the fullsize 1440×900 version)

I tried to include as much as I could think of and fit into the frame – but surprisingly, I have space left over. I may add to it as I come across more useful stuff. But for now, enjoy if you care to do so.

I saw the Upright Citizens again last night. The line was huge because there were rumors that Amy Poehler was going to be involved, but unfortunately she was not. Still it was a sweet show. I also ate some pizza, skateboarded around a little bit in the snow – it was very good. I feel like I’ve been ending a lot of my posts recently by saying that I’m going to go play video games, but that’s actually kind of a rare thing for me these days. I’m being too productive – I gotta get my head in the game. Portal 2 is coming out soon, and I must prepare.

Command Line Tip – pushd & popd

Posted on 7th February 2011 in Something Daily

I learned a fun command line trick recently. I typically use cd to change the working directory, which is great, but I’ve found that a lot of time gets wasted if you need to frequently move between two or more directories – you have to type the path every time you want to switch, which adds up to a lot of typing. I discovered pushd and popd, which place your directory changes into a stack, allowing you to recall your directory history in a last in, first out configuration. For example, I’m in ~/Music/Gang Starr/Step In the Arena and I want to go to /usr/bin. I type $ pushd /usr/bin (the $ indicates the command prompt), and my working directory is changed to /usr/bin. From there, I want to work in /mnt/mac/Users/emmettbutler/Documents, so I again $ pushd /mnt/mac/Users/emmettbutler/Documents. Then, I want to go right back to the Gang Starr directory without having to type the whole thing – I just $ popd and I’m in /usr/bin again, then $ popd once more to get back to ~/Music/Gang Starr/Step In the Arena. The last item to be pushed onto the stack is the first one to be popped off. Neato!

I spent a really substantial amount of time today working once again on my long-term Java game project – it was the first day of real work on it since early November. I’ve made a bunch of decisions that should help to significantly decrease the amount of manual labor I’ll have to put into the project; namely, I was originally going to have several levels with giant, independently drawn maps, and part of the reason I stopped working that way was because I realized that I don’t have the necessary means or drive to do that much 8-bit drawing. So the new strategy for “level design” is that there will be no distinct levels in a setting sense, just a randomly ordered series of single-frame panels with stars, asteroids, planets, spaceships, and the like. The combat will now be wave-based, with increasingly diverse waves that get harder to kill over time. Those two decisions alone, along with the choice to randomize the settings and precise configurations of each wave, have both eliminated a lot of the work I’d been anticipating and added a lot of potential replay value. If my vision for the random waves is realized, it’ll never be the same exact game twice, but it’ll have the same general difficulty curve each time. It’ll be good. So the work I completed today was the drawing of about 20 background panels and the coding necessary to loop and randomize their scrolling motion downscreen. I also cleaned up some of the parent classes that I wrote back when I was just learning Java. That’s a funny thing about this project, it’s spanning a long enough amount of time that my knowledge base is changing significantly, and my code often has to update with it. But with this new plan laid out, I feel optimistic about the end-of-semester prediction.

I found out today that Jim James of My Morning Jacket and M. Ward of She and Him have a blog dedicated to creme brulee entitled the Cremebrulog. The mere fact that such a site exists is awesome. And it really makes me want some creme brulee.

I Made Myself a BASH Greeter the Right Way

Posted on 3rd February 2011 in Something Daily

I am in a state of exhausted delirium right now, or maybe it’s delirious exhaustion. As a result, I decided to make myself a Terminal greeter that tells me a true statement every time I log in to BASH. I coded it in about half an hour just a few minutes ago, with great results. Some I’ve gotten so far are “robots are sick”, “cyborgs are most bitchin’”, “dolphins are the bomb”, “SNES games are nifty”, and “pizzas are radical”. It just picks a random noun and a random adjective, with the occasional modifier and the ultra-rare super secret sentence extension (it’s “to the MAXX”). Also, for some reason, I was in the mood to come up with rhyming couplets based on the ends of my sentences; I’ll tweet them @EmmettButler when I come up with them. My favorite is

I’m a jerkface in the workplace
I keep all my shirts in a shirt case

A good evening.

If I were choosing a movie to watch as the world was ending, I’d have to go with “2001: A Space Odyssey”.

Glamour shot, activate!

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.

Ubuntu for the Win

Posted on 12th November 2010 in Something Daily

Last night I got it in my head that I wanted to use Ubuntu again. I installed it on my MacBook 2,1 over the summer and ended up getting kind of annoyed at the process of installing a lot of the hardware drivers manually, not to mention the installation of software that comes standard on Mac OS X. The time wasn’t really right for me and Ubuntu. But last night, for whatever reason, I decided that I wanted it back.

I discovered that the latest version of Ubuntu that works well with my MacBook generation is 9.10 Karmic Koala. I wanted to do a dual boot with OS X, which I actually tried to do over the summer and failed at it. Despite my earlier failure, burning the Live CD went fine, although partitioning my HD was a bit of a hassle. It turns out that my data was quite fragmented as it had been a while since I did a reinstall of the OS. As a result, the Disk Utility couldn’t find a large enough contiguous free space, and thus couldn’t make a big enough partition. To fix this, I ended up wiping the hard drive, partitioning from the OS X boot disk, then reinstalling OS X and Ubuntu.

I wanted to get deeper into the process of configuring Ubuntu correctly this time around, so I created an account on ubuntuforums.org and poked around for a lot of answers. Using the Linux terminal is fun, though. I feel like I’m finding all of these crazy terminal commands that didn’t exist in Unix. And apt-get is awesome – installing applications from the command line, that is. I’m actually typing this using Opera in Ubuntu right now. It’s fun.

I found a command that let you tweet from the shell…beforethe Twitter API was changed. Lame.

In honor of my operating system switch, here’s an amazing website I found that has all sorts of command line tips – commandlinefu.com.

comments: 0 » tags: , , ,