Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

Can I Spy on Another Mac User?

I have been an avid reader for some time but I have a question. The kids all have computers now (we all have macs) and I was wondering if there was a way to check up on them every once in a while. We all have macs running OS X. and I have read the oriely 'control' your mac from afar. but I was wondering if there was a cool way to login screenshot and logout through SSH, I am the only admin so I can get their passwords, I was just wondering about the process.


Dave's Answer:

A very interesting question, and I'm sure there's a solution, actually. The key is a simple command-line utility included with Mac OS X called screencapture.

Checking the man page for the command (in the Terminal application, type man screencapture) (you can find Terminal in Applications --> Utilities, in case you haven't used it before) (that's a lot of parens, too. I feel like I'm back programming LISP again) (eek!) there are two key flags you want to utilize:

-S: In window capture mode, capture screen, instead of window
-x: do not play sounds

Probably, you also want to point to the main monitor, in case there's more than one screen hooked up, in which case you'll also want to specify -m. The full command should look like this:

screencapture -Smx screenshot.png

This would take a single screenshot and save it in the file "screenshot.png". Now just open up your home directory through Apple's standard file sharing capability and you should be able to refresh the directory occasionally, reopen this file, and you can see what they're doing.

Of course, if you want to go a bit, um, overboard, you could turn this into a shell script that will run every "X" seconds, saving a new screenshot in a hidden directory. Like this:

#/bin/sh

# Every few minutes take a screenshot, keep the last X around

keeparound=10 # how many to keep around. Don't fill your disk!
counter=1
screendir="/tmp/.captures"
delay=300 # in seconds. 300 = five minutes

if [ ! -d $screendir ] ; then
  mkdir $screendir
  chmod a+rwx $screendir
fi

while [ /bin/true ]
do
  screencapture -Smx $screendir/capture-$current.png

  current=$(( $current + 1 ))

  if [ $current -gt $keeparound ] ; then
    current=1
  fi

  sleep $delay

done

exit 0

I've tested this on my own system and it works great. I saved it as "capture.sh" and simply got it started with sh capture.sh &. Thereafter, every "delay" seconds the script took a screenshot, neatly squirreling away in /tmp/.captures for later analysis. If you're so inclined, you can modify it even further, but this coupled with you accessing the system remotely via either command line, ftp or Apple file sharing, you can easily see as many snapshot of what they're doing as you'd like. Remember, though, if you find anything incriminating you'll need to save it on your local system as everything is routinely overwritten as this script continues to chug along.

I should mention that there's an ethical consideration here too. Should you tell your children you are actively monitoring their computer usage? Should you tell them what you're doing and inform them that if they want to use the computer they need to agree to this relatively benign surveillance? This is obviously an even greater issue if you launched this on the computer of a spouse or colleague: then you're moving into 'spyware' and there might well be legal implications. In any case, with your children it's more ethical than legal, but you should still think carefully about whether you want to tell them or not.

Anyway, whether you go for the complicated script demonstrated here or just occasionally log in to their system, type "screencapture" and then open it remotely, you can see that there is indeed a solution to your problem on the Mac.



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Hi Dave

how can I tell if someone is doing this to me ?
- or there is spyware loaded on my Mac

thanks
Scott

Posted by: Scott at April 23, 2007 9:44 AM

I use Apple Remote Desktop. A little on the pricey side. You can see what is going on at all times on multiple computers.
Thanks Dave for another great solution!

Posted by: Ana at May 14, 2007 10:41 AM

err i just watched a podcast called screencasts online and it had a pretty neat program on there for this that wasn't too pricey check it at: http://www.screencastsonline.com/sco/Shows/files/SCO0091-spyme2.html

(ps im not an advertiser for it i just thought that it would help)

MoJo JoJo

Posted by: Johnny at May 22, 2007 1:25 PM

Dave I manage to get the screenshot to work but when I tried typing in the more complicated scipt in the Terminal I get error messges.. cleary I am missing something. Do I need to prewrite the script somewhere and paste it? If so I am not sure what all in your posting is required and what is suggestions..

Posted by: memouse at February 27, 2008 2:17 PM

Why bother with this? Why not simply trust your kids? Chances are that if they are looking at pornography, they have questions...questions they clearly can't ask you because you wouldn't think they were hiding something from you, otherwise.

Posted by: Michael H at March 8, 2008 12:12 PM

You can try to use this invisible Mac Keylogger called "Perfect Key logger for Mac" - see www.blazingtools.com/mac_keylogger.html

It offers good value for the price.

Posted by: keylogger's fan at March 28, 2009 1:25 AM

can someone tell me is there some spy program for mac that can be installed remotely (i mean from distance via attachment)

need to check on my husband's mac.. usually he leaves is at work,
but i guess there is something in his life that he started to hide from me : (

thanks

regards

Posted by: irisa at September 16, 2009 9:32 PM

Hi, how can I get this script to automatically run every time a certain person logs in? It would have to silently run in the background with no way to detect it.

So far, it works great but every time the computer reboots, one must run "sh capture.sh &" in the terminal all over again.

Posted by: macspy001 at September 27, 2009 7:39 PM

Welll.... I'm a bit uncomfortable with this, but will go this far: you can run a script in a loop grepping the output of "who" to find when someone logs in, then trigger another script...

Posted by: Dave Taylor at September 27, 2009 10:18 PM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









snow leopard pre order advert amazon

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.