Symptoms of Mac OS X Hack?
goatbar asks: "Many of you have probably dealt with computer intrusion before, but this is the first time for me with Mac OS X. I've got a machine where the passwords have been altered. If this were Linux, I would drop in Knoppix, figure out which way I got hacked, backup the system, reinstall, secure it and be back up in a couple hours. However, with OSX what can I do? Does anyone have strategies for regaining access to the machine and doing a post-mortem? I'm going to bring up the system drive on a laptop, but then what? I can back it up, but other than the system logs, where to look beyond the usual '.BitchX' and '...' directories. How do I easily tell what other annoying little things have been installed?"
When did it happen, do you know? If so then you can search the drives for files that were created/modified on or after that date. That should allow you to restrict the number of things that you need to look anywhere from some to significantly.
Comment forecast: Bits of genius surrounded by a sea of mediocrity.
Boot off the install cd/dvd, and you can change your root password to anything you wish.
After that its just a matter of recreating accounts and adjusting permissions. You can do that pretty easily in the Finder by getting info on a folder and changing permissions for all the contents of that folder and it's sub-folders in one click.
Vonal Declosion
Until today I still have to figure out how to create accounts without using the GUI.
I've never dealt with a hacked Mac (cuddles powerbook and shivers in fear). However, some standard procedures would apply:
(1) Isolate it from the network. Unplug ethernet, turn off any wireless access points (if Airport was set up on it).
(2) Boot off a known good media. This means the OSX recovery CD (or DVD with newer models). I've never done it, but presumably you should be able to mount your Mac's hard drive, get to a terminal window and be able to poke around and repair the damage as with any other system.
(3) If you don't want to repair (which can be risky if you don't know what's infected), copy off all files & data that you want to keep (avoid copying anything that's executable because that could be infected / trojaned) - then manually erase as much of everything that you can, ideally wiping the hard drive and low-level formatting it. Then boot off the recovery media / OS X install disks - and do a full re-image of the machine.. disable remote access, turn on the firewall in system settings -> sharing -> firewall, patch the OS.. reinstall all applications then restore the data that you backed up. And this time use strong passwords.
Step 3 really is the only way to be sure that the system is no longer infected.
As others have mentioned, you can use the System install disk to change your root password (which may be what was done to you). At the first splash screen, look in the menu bar to select the pasword reset utility.
Also, if you'd like to look around, you can boot into single user mode using command-s when booting. once you see the command prompt, just go nuts.
Another option is to boot off of another drive with the OS on it. Target disk mode is very handy for this. you can do it with 2 desktops, or one laptop and one desktop. An external drive is possible. Also, you can find ways to make a bootable OS X CD to work from w/o working from the original drive if you can get to another Mac to build the CD on.
I am, and always will be, an idiot. Karma: Coma (mostly effected by
One place you can look to see what was installed on your computer...go to /Library/Receipts. This has a small .pkg file that is left behind every time something is installed through a package on the computer (which anything but a basic application will have). This should give you an idea of everything that has been installed on the computer since the OS was installed. Also, to reset your main password, put in the original OS install disc that came with the computer. Under File, you can select an option to reset passwords.
Gentoo offers a Linux live cd you can boot from, if there isn't a Knoppix live cd for PPC
after getting access as described here is how I deal with my machines
/Users/shared folder and move it into a your user folder.
/Users/Shared folder you renamed in step 1. (this is needed because the shared folder is not quite hndeled right by archiva and install)
/Library folder. There are very few apps that actually need anything stored in libraries folder and most of these are in application suport and prefs sub dirs. nearly all prefs can be wiped. as a pre-screen you can search for anything in this folder that is an executable or a .app using "find". these are highly suspect, but not neccessarily evil.
/sw for fink.
/bin /etc /usr. some non-apple freindly unix packages do, but you would probably know this. if you only used fink or only installed in the users's space then you are fine. if you installed in to places like /usr or /opt then you are on your own.
0) first rename the
1) do a full install of the system using the archive and install mode. this gives you a blank system with the default apps. But with all your old system stored in a folder.
2) re create all your users if any are missing and copy back their files. and move back the
3) drag and drop the contents of the old-applications folder on the new applications folder. When it asks you if you want to overwite check NO. this will give you clean copies of the apple apps and give you your old other appls back.
do the same with the Utilities folder.
4) now very selectively do the same with the
5) copy back any other root level folders that you personally created previously such as
6) go back and double check that all those applications and utilities that were not apple apps and utilites are okay. This is not simple but at least check some creation dates.
that should pretty much do it. what you will miss are any boot time services, host files, tcp permissions, cron jobs or firewall settings you hand tweaked, you installed as those config files are now wiped. It's possible your keychain will get corrupted but not neccessaility. and if you created any new users inthis process and their explict UID and GROUPID numbers are important you can edit these using the netinfo utility. Normal installations of packages and applications on apples do not tinker with
Some drink at the fountain of knowledge. Others just gargle.
that might help for general OS X security: http://www.securemac.com/
Other than that, starting off the install CD and resetting the password, as others mentioned before.
You can follow the same procedure you use for your linux recovery -- put in the install cd or darwin cd, boot to a shell, mount up the disk read only and perform your backup, analysis, and then recover by whatever means you want.
To boot to a shell using the install cd you have to go into open firmware and set OF to pass the -s option to the mach kernel. The darwin CD will give you the option to jump to a shell right off the bat.
You can reset the passwords if you boot off the OS install CD
- Zav - Imagine a Beowulf cluster of insensitive clods...
You can only modify /Applications if you're an admin user. Standard users don't have write privileges in /Applications. Though OSX doesn't do it by default it ought to make all new users Standard users. Panther will ask if to authenticate if you do try to drag something into /Applications.
I'm a loner Dottie, a Rebel.
This isn't necessarily a way to fix your system, but it's some points to check to see what's there.
/Sys/Lib/Extensions /Sys/Lib/StartupItems /Sys/Lib/Frameworks/ /Sys/Lib/PrivateFrameworks /Library
/etc/hostconfig, /etc/rc* . I poke with those files a lot so I have some familiarity with what they're supposed to be like.
/var/log/ can be useful stuff too, if you know the timeframe of when stuff happened (hackers aren't likely to clean up system logs that might have traced some actions unknowingly - by default, sudo commands are logged). Similarly, getting used to how dmesg is supposed to look and what ps -auxww is supposed to provide is important.
/Library's contents (anywhere in it) can affect your system a lot, but most (all?) of those items aren't essential, you should be able to freely remove whatever you want.
:P
/Users) and move things over that you think you need.
You'd want to check these directories for anything you don't recognize are doesn't seem like they belong,
- same goes for
Now keep in mind that existing items can be modified, not just added. It's good to familiarize yourself with a base install. For anything that you don't recognize, check your Receipts directories to see if they were installed with some credibility.
You'd also want to check
You'd also like to examine dot-files and stuff. To make it short, there's a lot of places that shit can go in, but script kiddies aren't that smart and actions may be obvious.
Keep in mind that
To check your system without using it, you can always boot off of a OS 9 volume if your system supports that (it can fit on a CompactFlash card... with my old PowerBook I can at least boot from the PCMCIA slot). I also have 10.1 on another volume that's good for prodding my Panther system with.
NetInfo is a bit of a pickle to familiarize yourself with. Or at least, I haven't familiarized myself with most of the stuff in there yet
Anyway, none of this is a guaranteed way to find or fix problems, but it can reveal what's happened. If your system's been comprimised, your only recourse is to wipe it out. Don't even use your old User accounts, as dotfiles and ~/Library may have comprimised stuff. Keep it around with unknown:unknown ownership (and not in
Moderators should have to take a reading comprehension test.
and REALLY, how do you _really_ figure out what binaries were compromised on a linux system you could rescue with knoppix?
You could compare md5sums of all the executables with the ones on the installation media. RPM has an option to do that.
and REALLY, how do you _really_ figure out what binaries were compromised on a linux system you could rescue with knoppix?
As I said above:
rpm -Va
put
If you think you were hacked than assume you were hacked. Boot up the machine in Firewire target mode, mount the drive on another mac, and copy over your Users folder.
Re-boot your machine and install from scratch and then re-install you applications. You can then copy the Users folder back over and create your users. OS X should set the permissions correctly on the folders in Users if you use the same usernames (IIRC). It's the only way to be sure...
What, me worry?
At this point, you should recover all of your user data to an outside volume, either on the known good Mac or on a CD-R or network volume. If you want to do forensics on the compromised Mac, create a disk image from the compromised Mac's hard drive (warning - this may take up a lot of space). This will preserve everything from that machine in a way that can easily be mounted and studied. Put the compromised Mac away as evidence and do your examination from the disk image.
Log files are your friends. However, a good rootkit will include ways of deleting telltale info from log files. Another problem is that the prebinding process will alter binaries in different ways depending on the machine and the amount of RAM. The right way to do a comparison between the compromised machine and a known good machine is to use an identical machine (same model, same amount of RAM) and bring the system up to the same set of updates. Then you can useto create CRC32 checksums of the
To get the compromised Mac up and running again, you can't count on fixing everything in place. It's too easy to miss something that's been trojaned. You need to do an erase and install on the compromised Mac, re-install all of your applications, re-create the user accounts, then copy back the data that you backed up earlier. Be careful if some users have installed apps inside their home dirs that you re-install those fresh, as they may have been attacked as well. Also be sure to run a virus scanner on user files before restoring them to catch things like Word macro viruses.
Be careful of the users' login keychains, as the data in those may not be recoverable if the passwords were changed by someone who logged in as the users themselves. If the passwords were changed via an outside reset mechanism, such as an admin user or an install CD, then the old keychain passwords should still work.
Joel Rennich has a good account of studying a compromised Mac OS X machine a while back on his website, afp548.com. It's based on a little bit older version of the OS, but still good advice.
--Paul
I realize you may only have one Mac to work with, but if you have two, you may want to try out Firewire target disk mode. It allows you to connect one Mac to another and use the first as an external disk. This is much more flexible than booting from the install CD.
Has anyone tried connecting a Mac in target disk mode to a PC with a Firewire card? Was the PC able to mount the Mac as an external disk? If you don't have another Mac, that may also work assuming the PC knows what to do with HFS filesystem.
...and not just on the receiving end, either. *malicious grin*
/System/Library/StartupItems is a favorite of mine, but /etc/rc* works too. But the question isn't about how to root a machine, but how to detect it. So here are a few of my suggestions:
.ssh, .*rc, .*history (don't assume they'll be in /Users) /var/log, especially wtmp, utmp, and lastlog. Lastlog, in particular, is often forgotten. /System and /Library against a known-good machine. Files in here don't usually change too much; it's the executables (/bin, /Applications) that get prebound, mostly.
OS X is relatively easy to "r00t", by various means. Until recently, nidump passwd was a SERIOUS problem - weak passwords could be broken within <48 hours with john on a fast machine. OS X also provides quite a few ways to patch your own code into a machine once you've rooted it, too -
* Mount the disk via Firewire Target mode, as suggested. Easiest way to get to a disk without running its code. (Yes, single-user mode will still execute some scripts on startup!)
* nidump passwd . - See if they've set passwords on any of the system accounts. Yes, they might be logging in as sshd or something equally silly.
* Files and directories to look for:
* Check
* Diff
1)
:)
Download BootCD which is an app to create a BootCD from a current working installation. This will give you at least a working Finder and BSD subsystem with which you can hack around with.
2)
If that isn't easy enough, the following will blow your boots off:
* The T key forces the PowerBook (FireWire) (and reportedly the Power Mac G4 (AGP Graphics), though I was unable to verify that on my machine) to start up in FireWire Target Disk Mode, which is essentially the modern equivalent of SCSI Disk Mode and enables a PowerBook (FireWire) to act as a FireWire-accessible hard disk for another Macintosh.
Too many options!
Here is at a very minimum the steps required to perform forensics work on your system, I should also mention at this juncture that it is imperative to take detailed notes on what is happening both observations and actions.
The first thing is to connect another system either to the same hub or switch that you can capture packets from the compromised system. This will enable us to run a packet analyzer such as Ethereal to determine what network traffic is leaving the system. We need to do this incase of a program that is "phoning home" and when you take it off the network and subsequently it can't phone home it deletes itself or performs some other nefarious task.
When you are confident that no unusual network traffic is leaving the system we want to run a few commands that will not compromise the integrity of the system. Ideally not modify any file access times as well. What we are looking for are active processes, open files and if possible the contents of memory and the swap file. The output of these commands should be sent to a trusted remote system and the binaries themselves should come from a trusted source IE not the system you are working from. Make a CD with all of the commands that you intend to use (mount, lsof, top, ps, ssh for example). Before you run any commands on the system it is important that you have a game plan in place. Due to the nature of operating systems anything that you do at this stage can damage evidence that you may later need. But the list of open files can be critical in determining the extent of disruption to the system
After you have all the information that you can gather from the booted system the next step is to image the drive. Either via a drive duplicator (which you probably don't have) or using Disk Utility and imaging the drive. Boot the system into target disk mode holding the 'T' key at boot. You will know the system is in target disk mode when there is a blue screen with yellow FireWire icon. After it is in target disk mode connect it to another trusted Mac launch Disk Utility and image the drive (IMPORTANT: not the logical volume, the drive will have numbers in front of it) you want to make a READ ONLY disk image of the drive. It is important that for the remainder of the investigation you only work from the image of the drive.
When the drive has been imaged open the image on a known good system and inspect the log files. Ideally you will have other logs than the one on your system to examine. For example firewall logs of network connections to the compromised system. Look for file modification times that don't appear to be accurate
I apologize for the lack of detail in this post, I had to generalize many concepts into one brief memo. If time avails itself I will follow up with a more detailed post later. Good luck. And if you have any questions just ask.
What you are looking for is the open firmware password. It is really easy to enable. Apple hase a Kbase article on it. http://docs.info.apple.com/article.html?artnum=106 482 They even have an app that takes all of the work out of enabling and disabling it. When it is enabled it disables all of the "snag" keys that you can hit on boot to say boot to a CD or single user mode. Cheers.
Every time the prebindings of a dynamically linked executable are updated, that file is changed. So, probably not a single one of the executables on the system will match those on the install media.
What is the robbing of a bank, compared to the founding of a bank? -- Bertolt Brecht
Try these Apple knowledgebase articles:
1 06 482u m=120 095
http://docs.info.apple.com/article.html?artnum=
http://docs.info.apple.com/article.html?artn
Implementing Open Firmware password protection as described in these articles will effectively prevent someone from booting your Mac from a CD and resetting the password, among other forms of security...and, by the way, this solution comes right from Apple!
The only way to clear this form of security is to gain physical access to your Mac and change the amount of RAM installed (which forces the Mac to perform a long RAM test at next boot, erasing the OF PW). And, seriously, if someone can gain this kind of physical access to your Mac then you have much worse things to worry about than just a compromised login password!