Unless you've been living under a rock or some other non-internet-connected object, you've probably been Rick Rolled at some point. I decided to take the concept a step further and whipped up a Python script that will let you Rick Roll the entire iPod of an unsuspecting victim when they leave it unattended.
iRolling an iPod
As opposed to an internet-based Rick Roll, iRolling your victim's iPod will provide a lot more hilarity as you can actually observe the confusion of your victim when they put in their headphones and hear nothing but Rick Astley's sweet melodies. Just ask to borrow your friend's iPod for a few seconds or grab it off their desk when they're not looking, plug it in to your machine via USB, and run the iRoll script.
Essentially, the iRoll script will replace every track on the victim's iPod with any song of your choosing. However, the metadata of the song including the artist, title, album, duration, etc will stay the same, hiding the fact that anything has been altered. The end result is that the victim's iPod appears normal and unmodified, but when they play any song, it will play the Rick Roll song instead.
The iRoll script works by loading up the iTunes DB on the iPod and copying over your desired track to the iPod. It then iterates through all of the existing tracks in the database and modifies their file paths to reference the newly added track. This allows the iRolling to happen in a matter of seconds since it's simply changing the reference to the MP3 rather than overwriting every MP3 with the Rick Roll one.
iRoll.py by Jon Oberheide <firstname.lastname@example.org> [+] Loading iTunes database [+] Adding Rick Roll track [+] Copying Rick Roll track to iPod [+] Linking all songs to Rick Roll track [+] Writing out backup file for unRoll'ing [+] Saving and closing iTunes database [+] iRoll complete!!
unRolling an iPod
Thankfully, support to undo the Rick Roll is implemented as well, so that your victim will not lose all their music and/or kill you. During the initial iRoll, an index of the current tracks and their associated paths is collected and saved on the iPod. Therefore, when unRolling the iPod, the script simply loads the backup index and iterates through the track list, restoring the correct path for each track.
unRoll.py by Jon Oberheide <email@example.com> [+] Loading iTunes database [+] Restoring original track paths in iTunes database [+] Saving and closing iTunes database [+] unRoll complete!!
The scripts require libgpod's Python bindings which should be available on most modern Linux distributions. There's no reason it shouldn't function on OS X or Windows as well assuming libgpod has been ported. Be sure that you have properly defined the MOUNT_POINT and RICK_ROLL paths before running the iRoll or unRoll scripts. MOUNT_POINT should be the path to the iPod's current mount point and RICK_ROLL is the path to the desired MP3.