I was laying in bed this morning trying to remember where I put my laptop the day before and after I sorted that out it got me thinking. I should put something in place just in case some turkey managed to make off with my lappy. I don't think I need anything super elaborate since anyone with half a brain will just wipe the drive.


I poked around and I didn't see anything off the shelf that seemed worth the money so I took it as an opportunity to fiddle. It seemed simple enough but of course nothing ever is. So I figure I just want to periodically grab my wan ip and put it some place remotely accessible. The simplest way I could think to do this is by putting a bash script into the osx launchctl that outputs to a dropbox folder. This way I can let dropbox handle synchronizing to remote. Pretty simple, right?  Wrong.

As it turns out the "Start Dropbox on system startup" is somewhat misleading. What they mean to say is that Dropbox will start on login. Extensive research concluded that there is no straightforward way to sync to dropbox unless I'm logged in which defeats the purpose. If my laptop is stolen they most likely won't be able to login to my account anyway.  Hopefully I can update this later to use Dropbox but at this time it doesn't seem like a practical solution.










My alternative was to scp to my nas. :(


UPDATE: I got a little carried away and decided to add gps coordinates as well using core location. Many thanks to the coreLocationCli project for providing this handy tool for easily getting info from coreLocation.  If you want to use this you will need to download the file from their website and reference it in the script.


Here is the script I used to write the wan and lan info to the file in my dropbox.



Next I made a plist for the osx launchctl. This will execute the script on launch and every 3 hrs after that.



Once you have that ready put in your ~/Library/LaunchAgents/ folder and run the following command where com.dberringer.trackr.plist should be replaced with whatever you name your plist file.

launchctl load ~/Library/LaunchAgents/com.dberringer.trackr.plist


This is what your output should look like:


And you are up and running. I should also mention that dropbox will automatically keep a history of the file which is useful if you miss one of the script updates. I don't know how far back they keep file versions but you should have a nice little history of where your lappy has been hanging out.

That's pretty much all there is to it. Easy as pie. Now if your laptop happens to run off and the jerk is dumb enough not to reformat the drive you may have a couple options.

Thankfully I have not had the misfortune of having to go through this but I would think you would be able get that wan ip address from the file and run a Whois on it to get the ISP. Then I believe you would be able to work with local law enforcement and the ISP to track down the address of the Internet connection your laptop is being used on.

For good measure I included the lan info as well since this might tell me whether it's a wired or wireless connection (maybe someone on a neighbor's open wifi).

This only slightly increases your odds of getting your lappy back but I'll take it. I figure if someone is dumb enough to steal a laptop from such a charming and handsome fellow as myself he/she is probably not a real brainiac to begin with. I hope no one ever needs this but if you do let me know how it goes. Cheers!

5 Responses so far.

  1. Travis says:

    Another simple and flexible approach would be to have a script on your laptop that uses wget to fetch from a URL on start up. Then you could have a server-side script (e.g. Ruby on Rails) hosted on any free Cloud service. That server-side script could log the remote IP address and even send back a secondary shell script to augment the existing one on the laptop, allowing you to later make updates to the script's functionality even after your laptop was stolen. And by having the primary laptop script simply execute a secondary script (when provided by the server) allows you to push functionality updates from the server without worry of breaking subsequent runs (if you write a bad secondary laptop script it will simply be overwritten the next time the primary laptop script runs).

    This also has the advantage of performing all tasks over HTTP (i.e. port 80) which is much less likely to be blocked than SCP.

    You could continue with your GeoLocation setup by using curl instead of wget and simply POST any data you wanted to the server-side script.

  2. Doug says:

    SCP blocking can be a problem I agree. That's why I was so bummed I couldn't use dropbox.

    I was initially trying to keep the requirements low so anyone could use it however that went out the window give or take when I had to use scp since it requires a box to scp to.

    If I find time I may look into your server side idea or if you end up doing it let me know. Thanks for the feedback. :)

  3. Travis says:

    Application to call home on start up:

    http://goo.gl/rmw4g

  4. Anonymous says:

    You could install Prey.
    It can track IP adress, running programs, send a webcam snapshot and more

    http://preyproject.com/

  5. Doug says:

    Prey looks pretty snazzy. I'll have to look into it. Thanks!

Leave a Reply