Let’s say your laptop is stolen. Wouldn’t that be awful?

Now, what if you had a way to track down the person that took it and get it back?

Using Linux or Mac, it’s easy. let’s take a look at a script that will do this for you. It will take you less than 5 minutes to set up.

Save the above in /tmp/phone.bash (change $yourserver to a place where you can have a file hosted), then set add a crontab entry to have it run every 5 minutes:

*/5 * * * * /tmp/phone.bash

What does it do? Every 5 minutes, this script will run, and it will execute whatever code you have placed in the phonehome file on $yourserver. By default, I have my phonehome file just set to run true, which does nothing. But if my laptop gets stolen, I modify the phonehome file to include bash commands. I have the full power of bash on my laptop as soon as the thief connects to the internet. Imagine the possibilities. Here are some ideas:

  1. traceroute - Let’s go ahead and get his IP address and where he is at. We should be able to give this to the police who can then contact his ISP and get his address. Save the output and copy it to $yourserver:

    traceroute > /tmp/traceroute.out
    scp /tmp/traceroute.out $yourserver:/tmp/theiftraceroute

    Tip: Set up ssh without a password to $yourserver so you can easily send information back and forth with rsync and/or scp.

  2. Keystroke logger - Now let’s record everything he types. Using bash, we can download, install, and run a keystroke logger. Here’s one that works for OSX
  3. Take a picture - If you have a Mac with a built in iSight camera, you can use isightcapture to take a pictures of the thief and send them to you!

    curl –silent "$urlforisightcapturescript" > /tmp/isightcapture
    chmod a+x /tmp/isightcapture
    /tmp/isightcapture –file /tmp/pictureoftheif$RANDOM
    scp /tmp/pictureoftheif* $yourserver:/tmp/

    Update:. See my post on automatically capturing pictures with isightcapture

Someone. Please. Steal my laptop. I can’t wait to use this.