Who's Listening To Your Shared iTunes Music?

itunes_20070328.jpg
With iTunes, it's really easy to make your music and video libraries available so that you can view them from another machine. For whatever reason, though, the good folks at Apple didn't add an option to track who is viewing your library or see what they are listening to.

Last month, I mentioned the *nix lsof command, which allows you to get a listing of all open file handles on a system, including open socket connections. You can use this command line utility to quickly figure out if anyone is connected to your iTunes library and see what mp3 files are being read. Here's how:

Who's connected:
Go to your command prompt and type:

lsof |grep iTunes |grep TCP

You'll see something like this:
iTunes 338 name 16u IPv4 0x37fc710 0t0 TCP *:daap (LISTEN)
iTunes 338 name 17u IPv4 0x2efb920 0t0 TCP 192.168.0.3:daap->192.168.0.8:50565 (ESTABLISHED)

The first line is just your iTunes application listening for incoming connections. The second is another machine with IP address 192.168.0.8 that is connected and browsing the music library. If nobody were connected, you'd just see that first line.


Who's listening?
When another machines iTunes client connects to your library, it first opens up a TCP connection for browsing your music library. When the client chooses to play a file, a second TCP connection is made to transmit that file's data. When you search for TCP connections and someone is actually downloading music, you'll see something like this:

iTunes 338 name 16u IPv4 0x37fc710 0t0 TCP *:daap (LISTEN)
iTunes 338 name 17u IPv4 0x2efb920 0t0 TCP 192.168.0.3:daap->192.168.0.8:50565 (ESTABLISHED)
iTunes 338 name 18u IPv4 0x2dae920 0t0 TCP 192.168.0.3:daap->192.168.0.8:50573 (ESTABLISHED)

Because there are two connections from 192.168.0.8 in this scenario, we know that the remote iTunes client is transferring file data, and not just browsing.


What's being listened to?
Back at the command prompt, run another lsof and look for files that are open in your music library. This assumes that your files are stored in the default iTunes Music directory.

lsof |grep "iTunes Music"

You should see something like this:
iTunes 338 name 17r REG 14,2 5657237 965155 /Users/name/Music/iTunes/iTunes Music/Compilations/Xen Cuts (Disc 3)/3-07 Drunk Trumpet 1.mp3

Now keep in mind, this will list every file that is opened by your iTunes application, whether it's being transmitted over the network or you are listening to it locally. Unfortunately, I don't know of a way to associate a particular file with a particular downloader, but it's not too difficult to figure out unless there are several people connected. If it's just a single user, just look for any files you aren't currently listening to yourself. If you know of an easy way to figure out exactly who is downloading what, please share it in the comments.


Recent Entries

Comments

Oldest comments listed first.

Posted by: Anonymous on December 6, 2007 at 8:02 AM

i know this is a bit old... but em.. Yeh the command line doesn't work for me! i have vista installed.. ah well!


Posted by: anonymous on January 5, 2008 at 11:07 PM

it's a linux command. not for windows. check out window's Process Explorer


Posted by: anon on February 6, 2008 at 7:16 PM

it's not a linux command - it's unix for the Mac OS X terminal.


Posted by: Anonymous on October 12, 2008 at 5:53 PM

Again, I'm late to the party. I keep getting a message that says, "A “|” can't go after this identifier."

What am I doing wrong?


Posted by: Jan on December 11, 2008 at 7:42 AM

"iTunes Music" in 'lsof |grep "iTunes Music"' is the default folder name for your iTunes Library folder. If you change the default location, use the new folder name instead.


Leave a comment


Subscribe to MAKE!Subscribe to MAKE Magazine!

Subscribe today, save 42% and get web access to MAKE free. MAKE Digital Edition is available only to subscribers.

$34.95 / 1 year
(4 Quarterly Issues)

Subscribe now


Void your warranty, violate a user agreement, fry a circuit, blow a fuse, poke an eye out. Make: The risk-takers, the doers, the makers of things... Welcome to Make: Online!


CRAFT Maker Shed Maker Faire MAKE television
Holiday Gift Guides from MAKE

Gifts for Dads
Science and Chemistry
More guides: Gifts Under $20, Santa Claus Machines, Geek Toys for Grown Up Girls & Boys


Check out all of the episodes of Make: television

Alex Rider Dream Gadget Contest
Make: Science Room

Connect with MAKE

Be a MAKE fan on Facebook MAKE on Facebook
Visit our Facebook page and become a fan of MAKE!
MAKE on Twitter MAKE on Twitter
Follow our MAKE tweets!
MAKE Flickr Pool MAKE on Flickr
Join our MAKE Flickr Pool!
    make_tips on Twitter




    Maker SHED

    Advertise here with FM.

    Why advertise on MAKE?
    Read what folks are saying about us!

    Click here to advertise on MAKE!



    Subscribe to MAKE Magazine!

    Make: Online authors!

    Gareth BranwynGareth Branwyn
    Senior Editor


    Phillip TorronePhillip Torrone
    Senior Editor
    | AIM | Twitter


    Becky SternBecky Stern
    Associate Editor
    | AIM | Twitter


    Marc de VinckMarc de Vinck
    Contributing Writer
    | AIM | Twitter


    John ParkJohn Park
    Contributing Writer
    | Twitter


    Sean RaganSean Ragan
    Contributing Writer
    | Twitter


    Matt MetsMatt Mets
    Contributing Writer
    | AIM | Twitter


    Dale DoughertyDale Dougherty
    Editor & Publisher
    | Twitter


    Shawn ConnallyShawn Connally
    Managing Editor
    | Twitter


    Goli MohammadiGoli Mohammadi
    Associate Managing Editor

    Kip KayKip Kay
    Weekend Projects
    | AIM | Twitter


    Collin CunninghamCollin Cunningham
    Contributing Writer
    | AIM | Twitter

    Adam FlahertyAdam Flaherty
    Contributing Writer
    | AIM | Twitter



    More contributors: Mark Frauenfelder (Editor-in-Chief, MAKE magazine), Kipp Bradford (Technical Consultant/Writer), Chris Connors (Education), Diana Eng (Guest Author), Peter Horvath (Intern), Brian Jepson (O'Reilly Media), Robert Bruce Thompson (Science Room)

    Suggest a Site!

    Current Podcast

    itunesdl.gif Weekend Project: Beetlebot Simple robot from your parts bin that avoids obstacles. Thanks go to Jerome Demers for the original article in MAKE, Volume 12. To download the Beetlebot video, click here or subscribe in iTunes. Check out the complete Beetlebot article... More...

    Get the Make: Online sent via email
    Enter your email to receive Make: Online each day:



    MAKE Fascination video series brought to you by Dow

    Make: Education
    MAKE: en Español MAKE: Japan
    Important please read


    Subscribe to MAKE Magazine!

    Recent Posts from the Craft: Blog