HOWTO: Track your mac
A couple years ago, after I purchased a mac laptop with a built-in camera, I set it up to take a picture every time it booted/woke up and upload it to one of my web servers if internet access was available. I called it my poor man’s laptop lojack. Of course with all good things, Apple came out with an operating system update that disabled access to the camera from any user (even root) except for the locally logged in user. I suppose that is a good thing except when you actually *want* to be able to do what I was doing. Once it broke, I hadn’t bothered to figure out a way around it until the other night when I was pissed off enough to find a way!
Luckily, a couple weeks ago, I learned about launchctl. It is now the primary way in OSX to launch system daemons instead of init scripts or xinetd. It turns out, using launchctl, as root, you can execute a program in another context using its bsexec subcommand! If you use the loginwindow process id’s context you’d like to run your program in, it will now run just as if you were physically sitting at the keyboard. The command:
isightcapture image.jpg
which would before fail if you ssh’d into a remote machine now becomes:
export PID=`ps auxww |grep loginwindow |grep -v grep |awk ‘{print $2}’`
launchctl bsexec $PID isightcapture image.jpg
Bamo! Now you’re breakin’ the law in style!
So, since I’ve got my crappy little image uploader working once again, I thought I’d share it with the rest of the world. I’m using sleepwatcher, isightcapture, and some other craziness that I hacked together to overlay some good information on a picture from your webcam and upload it to a website of your choice!
If you know what you’re doing, you should be able to follow my instructions just fine, if you don’t know what you’re doing, you might possibly blow up your mac and kill a kitten. You have been warned!
First, download the following file (I’m going to assume it will download into your Downloads folder):
http://tompohl.com/files/locateme.tgz
Create a directory on your web server to host the supporting scripts and uploaded images for example:
mkdir /var/www/html/locateme
mkdir /var/www/etc
htpasswd -c /var/www/etc/locateme.passwd myuser
htpasswd /var/www/etc/locateme.passwd anotheruser
<Directory “/var/www/html/locateme”>AuthType BasicAuthName PrivateAuthUserFile /var/www/etc/locateme.passwdAllowOverride NoneOrder allow,denyAllow from allrequire valid-user</Directory>
apachectl configtest
apachectl graceful
cd ~/Downloadstar -xzvf locateme.tgzcd locatememv .locateme /
chmod 777 /var/www/html/locateme/uploads
sudo vi /etc/rc.wakeup
su – $user -c “$home/.wakeup”
$home/.wakeup
ln -s /.locateme/.wakeup ~/.wakeup
vi /.locateme/locateme.conf
- If your computer doesn’t connect to the network, it will still save your pictures in /.locateme/images/taken and all images successfully sent to the webserver will be moved into /.locateme/images/sent
- On the webserver, all images will be saved in the directory locateme/username/ with locateme/username/latest.jpg always pointing to the last picture taken.
isightcapture:http://www.intergalactic.de/pages/iSight.html
sleepwatcher:http://www.bernhard-baehr.de/






