Who’s Listening To Your Shared iTunes Music?

Technology
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.

12 thoughts on “Who’s Listening To Your Shared iTunes Music?

  1. Anonymous says:

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

    1. Kevin Kwok says:

      I ran a batch file called “find_computer.bat” in Windows 7 to find out who (Computer Name) is listening to my iTunes shares.

      @echo off
      Echo Loading…
      netstat | find “:3689”
      pause

      (You can copy and paste the above code into a text file, then rename the extension to .bat and it will run when you doubleclick it)
      If the Computer Name is not easy to discern who it is, you’ll need to hunt it down by asking your network admin. If you are in a home network environment then you may get computer names like Tom-PC or Jerry-Desktop from a Vista or Windows 7 computer.

      In order to find out the actual song s/he is listening to, I ran an old program called Process Explorer (procexp.exe) from sysinternals (MS). I clicked on the iTunes.exe process, then I clicked the button to view all the associated files and voila, I see the file I’m listening to and I see the file they are listening to.

      Process Explorer by SysInternals is very similar to the Windows task manager, but gives you more detailed information. If you can find your hands on this small little program, I’d say this would be the easiest visual way to find the actual name of the song they are listening to.

  2. anonymous says:

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

  3. anon says:

    it’s not a linux command – it’s unix for the Mac OS X terminal.

  4. Anonymous says:

    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?

  5. Jan says:

    “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.

Comments are closed.

Discuss this article with the rest of the community on our Discord server!
Tagged

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK