iPhone and Linux

Tuesday, November 10, 2009

Iphone Panic Button

There was a thread at Macrumors where someone asked if there were any apps which could delete your sensitive files if someone took your phone. The poster's situation was that they were in school and if they were caught with a phone, they had to turn it over and the teacher would go through it looking for anything against school rules.

This can be done with a short shell script ran from SpringBoard using the method I posted about earlier.

There are several ways of doing it depending on your threat model. You could delete the files, but what will happen to the SMS app if you delete it's database? Will it crash or create a new one? If it crashes, you may not be able to use it until you get home and copy a new .db file to the phone. If you don't have one, you may even need to restore.

A smarter way is to simply hide the files from our SpringBoard script and unhide them with another script which is hidden on the phone and ran from MobileTerminal. This should be good enough for most people and these scripts accomplishes that.

Create a text file and list all the files and directories you want to hide. Don't worry about spaces or anything, just make a normal list with the full path to the files/directories, one per line. This example assumes you run the script from a fake app called Panic and the file list is in Panic.app.
#! /bin/sh 
while read line; do
dir=$(dirname "$line")
file=$(basename "$line")
mv "$line" "$dir"/."$file";
done < /Applications/Panic.app/filelist.txt
Files will be hidden in the same directory as their original location. If you want to move them all to a different directory, change "$dir"/."$file" to /path/to/another/directory/."$file"

Put this next script anywhere you want and run it from MobileTerminal to unhide the files. You may notice it's almost the same script, only one variable on the mv line has changed places.
#! /bin/sh 
while read line; do
dir=$(dirname "$line")
file=$(basename "$line")
mv "$dir"/."$file" "$line";
done < /Applications/Panic.app/filelist.txt
Now this is cool. You could (sorta) run this remotely if you have the Prowl app, you just need the person with the phone to cooperate a little. You can add this to panic's plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>panic URL</string>
<key>CFBundleURLSchemes</key>
<array>
<string>panic</string>
</array>
</dict>
</array>
Then go to Prowl's folder, find "Redirections.plist" and add this:
<key>Key</key>
<string>Panic</string>
<key>URL</key>
<string>panic:</string>
Then open Prowl and create a redirection based on the app name "Panic" and select panic from the list.

Send a Prowl notification from home using "panic" in the application field. When the notification pops up on the phone, a person can choose whether to view or close it like an SMS. If they select view, it will run the panic script and hide your files. However, if they select "close", it does nothing. You could just as easily rename the panic icon to "Bank Info" or "Nekkid Chicks" and trick them into running it. I just think it's cool.

Blog Archive