Install, configure, and test Prey on your computer. Be sure it works.
$ wget https://raw.github.com/gist/3364706/be4ca25c49db67acaa8ce760b9f26fce3b1fa3b3/CreatePreyRecovery.sh
$ chmod u+x CreatePreyRecovery.sh
$ ./CreatePreyRecovery.sh
| #!/bin/bash | |
| # | |
| # source: https://groups.google.com/d/msg/prey-security/vBv3BGI8Qeg/5xIy0LZjzXAJ | |
| # | |
| # Mount the recovery partition | |
| /usr/bin/sudo /usr/sbin/diskutil mount Recovery\ HD | |
| # | |
| # Backup the recovery boot image | |
| /usr/bin/sudo /bin/cp /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg ~/Desktop/ | |
| # | |
| # Create a read/write version, and mount it | |
| /usr/bin/sudo /usr/bin/hdiutil convert ~/Desktop/BaseSystem.dmg -format UDRW -o ~/Desktop/BaseSystem-rw.dmg | |
| /usr/bin/sudo /usr/bin/hdiutil attach ~/Desktop/BaseSystem-rw.dmg | |
| # | |
| # Copy your working Prey installation to the read/write image | |
| /usr/bin/sudo /bin/cp -Rp /usr/share/prey /Volumes/Mac\ OS\ X\ Base\ System/usr/share/ | |
| # | |
| # Copy necessary utilities that are missing from the default recovery image | |
| for prog in dirname uname who whoami curl | |
| do | |
| /usr/bin/sudo /bin/cp -p /usr/bin/$prog /Volumes/Mac\ OS\ X\ Base\ System/usr/bin/ | |
| done | |
| # | |
| # Create the necessary files/folders | |
| /usr/bin/sudo /bin/mkdir /Volumes/Mac\ OS\ X\ Base\ System/Library/LaunchDaemons | |
| /usr/bin/sudo /usr/bin/touch /Volumes/Mac\ OS\ X\ Base\ System/Library/LaunchDaemons/org.preyproject.prey.plist | |
| /usr/bin/sudo /usr/bin/touch /Volumes/Mac\ OS\ X\ Base\ System/private/var/db/launchd.db/com.apple.launchd/overrides.plist | |
| # | |
| # Assign the correct ownership/permissions | |
| /usr/bin/sudo /usr/sbin/chown -R root:wheel /Volumes/Mac\ OS\ X\ Base\ System/Library/LaunchDaemons | |
| /usr/bin/sudo /usr/sbin/chown root:wheel /Volumes/Mac\ OS\ X\ Base\ System/private/var/db/launchd.db/com.apple.launchd/overrides.plist | |
| /usr/bin/sudo /bin/chmod 755 /Volumes/Mac\ OS\ X\ Base\ System/Library/LaunchDaemons | |
| /usr/bin/sudo /bin/chmod 644 /Volumes/Mac\ OS\ X\ Base\ System/Library/LaunchDaemons/org.preyproject.prey.plist | |
| /usr/bin/sudo /bin/chmod 600 /Volumes/Mac\ OS\ X\ Base\ System/private/var/db/launchd.db/com.apple.launchd/overrides.plist | |
| # | |
| # Create the plist file that tells launchctl to run prey every 10 minutes | |
| /usr/bin/sudo /bin/cat > /Volumes/Mac\ OS\ X\ Base\ System/Library/LaunchDaemons/org.preyproject.prey.plist << END1 | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>org.preyproject.prey</string> | |
| <key>LingonWhat</key> | |
| <string>/usr/share/prey/prey.sh</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/usr/share/prey/prey.sh</string> | |
| </array> | |
| <key>StartInterval</key> | |
| <integer>600</integer> | |
| </dict> | |
| </plist> | |
| END1 | |
| # | |
| # Tell launchctl to load the plist file automatically | |
| /usr/bin/sudo /bin/cat > /Volumes/Mac\ OS\ X\ Base\ System/private/var/db/launchd.db/com.apple.launchd/overrides.plist << END2 | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>org.preyproject.prey</key> | |
| <dict> | |
| <key>Disabled</key> | |
| <false/> | |
| </dict> | |
| </dict> | |
| </plist> | |
| END2 | |
| # | |
| # Be sure launchctl actually loads the plist file at boot | |
| /usr/bin/sudo echo "/bin/launchctl load -F /Library/LaunchDaemons/org.preyproject.prey.plist" >> /Volumes/Mac\ OS\ X\ Base\ System/etc/rc.common | |
| # | |
| # Unmount the modified image | |
| /usr/bin/sudo /usr/bin/hdiutil detach /Volumes/Mac\ OS\ X\ Base\ System | |
| # | |
| # Convert the modified image to compressed read-only, and verify the final image | |
| /usr/bin/sudo /usr/bin/hdiutil convert ~/Desktop/BaseSystem-rw.dmg -format UDZO -o ~/Desktop/BaseSystem+Prey.dmg | |
| /usr/bin/sudo /usr/bin/hdiutil verify ~/Desktop/BaseSystem+Prey.dmg | |
| # | |
| # Replace the old image with the new | |
| /usr/bin/sudo /bin/cp ~/Desktop/BaseSystem+Prey.dmg /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg | |
| # | |
| # Done! | |
| # |