ShairPort – Airport Express hacked

A hacker managed to extract the public-key crypto scheme from the Airport Express. This means that you should be able to emulate an airport express function on your own machine. To install on your live machine use:

wget http://mafipulation.org/static/shairport-0.05.tar.gz
tar zxvf shairport-0.05.tar.gz
cd shairport-0.05/
sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao-common libao-dev libio-socket-inet6-perl libwww-perl avahi-utils
sudo perl -MCPAN -e 'install Crypt::OpenSSL::RSA'
sudo perl -MCPAN -e 'install HTTP::Message'
sudo perl -MCPAN -e 'install IO::Socket::INET6'
sudo service avahi-daemon start
perl shairport.pl

More info below. Please post your findings!

http://mafipulation.org/blagoblig/2011/04/08#shairport

https://github.com/albertz/shairport

Comments

  1. physio says:

    thank you so much!

  2. ubertracker says:

    zie er goed uit, de ipod maakt verbinding met xbmc, maar er is nog geen audio te horen

  3. Bart says:

    Voor de liefhebbers die hem in ubuntu (xbmc live) als daemon willen draaien:

    - Ik heb de bestanden “shairport.pl” en “hairtunes” in de map /opt/shairport gezet.
    - Verander line 20 van bestand “shairport.init.sample”
    - DAEMON=”/opt/shairport/shairport.pl”
    - Verander line 52 van /opt/shairport/shairport.pl
    - my $hairtunes_cli = “/opt/shairport/hairtunes”;
    - Kopieer het bestand shairport.init.sample naar “/etc/init.d/shairport”
    - Voer het volgende commando uit: “update-rc.d airplayer defaults”
    - Reboot je XBMC of start de service met “service airplayer start”

    Werkt voor mij, mocht het niet werken, kijk dan eerst of het wel werkt door handmatig te starten met “perl /opt/shairport/shairport.pl”

  4. Bart says:

    Niet dit commando:
    - Voer het volgende commando uit: “update-rc.d airplayer defaults”

    Maar:
    - Voer het volgende commando uit: “update-rc.d shairplayer defaults”

    Airplayer is ook cool :)

  5. Bart says:

    Zucht, het is nog vroeg…
    - Voer het volgende commando uit: “update-rc.d shairport defaults”

  6. BiTRiP says:

    Kan deze nu wel audio aan of niet? Anders heeft het voor mij geen zin om deze te installeren aangezien de eerdere airplayer van Pascal ook prima werkt.

  7. Marnix says:

    Great walktrough!

    May I add to that a ‘make’ command was still needed to compile hairtunes and that with a clean Maverick install ‘sudo apt-get install pkg-config’ was needed?

  8. Psylover says:

    I get this problem on the 10.1 live install:

    “E: Couldn’t find package libao-common”

    Any suggestions?

    On my normal ubuntu 10.10 machine i have it working, though, very cool!!!!!

  9. Psylover says:

    Never mind, solverd it, do

    sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao2 libao-dev libio-socket-inet6-perl libwww-perl avahi-utils”

    ( libao2 instead of libao-common)

    And don’t forget the “Make” command

    Listning to Vivaldi with Spotify for iPhone on my XBMC Asrocj ion 330-ht now….

    If a were mr. Sheen, I’d feel like “WINNING” right now, hahaha

  10. supersook says:

    Not an XBMC user, but interested in the Shairport solution nonetheless…

    Took a while to figure out that it was just not going to work on Fedora :| . Fired up an Ubuntu 10.10 as a virtual machine on my Win7 workstation. This Shairport thing actually works!

    Unfortunately I’m getting unpleasant ‘ticks’ during playback, which are clearly caused by something that makes Shairport mention the word ‘underrun’. Is this also the case with people running it on a native machine? Or is it because my crappy laptop just can’t keep up running this smoothly in a virtual machine, while playing in iTunes from the ‘host’ ?

  11. martijn says:

    Voor de domme blondjes onder ons wellicht de volgende vraag; wat heb ik aan AirPort (of SharePort) express op mijn XBMC machine? AirPort Express is toch een Wifi accesspoint? Of is dit puur om muziek en wellicht films naar de XBMC te streamen?

    thanks!

  12. apathy says:

    Could someone please retype what needs to be done, step by step. It’s a bit confusing.

    The following step crashes:
    sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao-common libao-dev libio-socket-inet6-perl libwww-perl avahi-utils
    Error: Package libwww-perl is not available, but is referred to by another package.

    Psylover’s advice doesn’t work for me. If I understand it correctly, Psylover meant:
    sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao2 libao-dev libio-socket-inet6-perl libwww-perl avahi-utils

    It still doesn’t work thought.
    I’m a bit confused with comments:
    - And don’t forget the “Make” command
    - May I add to that a ‘make’ command was still needed to compile hairtunes and that with a clean Maverick install ‘sudo apt-get install pkg-config’ was needed

  13. martijn says:

    nou toch maar geinstalleerd :) ziet er goed uit, echter ik snap de posting nog niet hoe ik hem als deamon moet draaien aangezien ik bv: shairport.init.sample niet heb…

    Maar mijn iPhone ziet de server, kan hem selecteren, echter er gebeurt niets, geen geluid.. any tips?

  14. Marnix says:

    apathy :
    Could someone please retype what needs to be done, step by step. It’s a bit confusing.
    The following step crashes:
    sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao-common libao-dev libio-socket-inet6-perl libwww-perl avahi-utils
    Error: Package libwww-perl is not available, but is referred to by another package.
    Psylover’s advice doesn’t work for me. If I understand it correctly, Psylover meant:
    sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao2 libao-dev libio-socket-inet6-perl libwww-perl avahi-utils
    It still doesn’t work thought.
    I’m a bit confused with comments:
    - And don’t forget the “Make” command
    - May I add to that a ‘make’ command was still needed to compile hairtunes and that with a clean Maverick install ‘sudo apt-get install pkg-config’ was needed

    The ‘make’ command is used to compile hairtunes.c, while in the directory of the extracted shairtunes zip. Concerning the not available package, you could try and install them manually. But… I tried installing with an existing setup and it didn’t work. Installing it on a fresh XBMC install worked right away.

  15. martijn says:

    Zo, ik heb het allemaal aan de praat, nu ook als service. Ik heb manueel het bestand. .sample.ini gebruikt van github. Nu echter ziet mijn iPod de service, maar zodra ik stream dan krijgt ik geen geluid. Hoe werkt dat precies? Waar kan ik gaan zoeken?

    Bedankt!

  16. martijn says:

    Dit is de output:

    listening…
    Established under name ’00BF9908A14A@ShairPort 2257 on XBMCLive’
    new connection from ::ffff:192.168.1.185
    REQ: OPTIONS
    REQ: ANNOUNCE
    REQ: SETUP
    launched decoder: 2261 on port: 6000
    REQ: RECORD
    REQ: SET_PARAMETER

  17. apathy says:

    My above problem was solved by doing an update (sudo apt-get update), although i did have the latest xbmcfreak version on my xbmc. after the update, proceding at step 4 worked fine.

    When i start shairport.pl it tells me:
    xbmc@XBMCLive:~/shairport-0.05$ perl shairport.pl
    listening…
    Established under name ’00930897BFB7@ShairPort 1637 on XBMCLive’

    Now i can see the remote button in the iphone. When i use it, shairport.pl exits with the following error:

    new connection from ::ffff:10.0.1.6
    REQ: OPTIONS
    REQ: ANNOUNCE
    REQ: SETUP
    sh: ./hairtunes: not found
    ***CHILD EXITED***
    Expected port number from decoder; got at shairport.pl line 298.

    Did anyone else encountered this problem?

  18. Mr.Jack says:

    Running 10.04 here..
    Shairport starts ok, but when I start playing I get the following errors:

    missing frame.

    underrun.
    ALSA: underrun, at least 0ms.

    overrun.

    overrun.
    etc etc..

    *********************************
    Anyone else experiencing the same problem?

  19. apathy says:

    From github i have gotten the following answer conserning the no-sound-problem:

    Try reinstalling libao. Or your sound is misconfigured somehow.
    In any case, this is not related to ShairPort in any way.

  20. apathy says:

    ok, so what worked for me is the following:
    - Turn the volume up for “master front” in the alsamixer
    (in a terminal type /usr/bin/alsamixer to enter the alsamixer).

    Now the sound is coming thrue the ‘headphone’ audio output of the asrock.
    Connecting that sound output to your hifi system will work.

    I don’t where to set the shairport output setting to the same as the audio output settings of the xbmc… but at least the above works

  21. Robert says:

    Cool, got it working on Ubuntu (full linux, not xbmc live). The clarify some things: this makes it possible to wireless stream music from your ipod/iphone to your Linux machine. Listening to a song on my Asrock 330-ht streaming from my iphone 3GS :-) .

    It is NOT integrated with xbmc though, it plays directly from Ubuntu.Only audio seems to work; when playing a movie the sound is streamed, the movie self is played on the iphone. And yes, I also get the buffer underrun statements.

    These are the commands I used (LINE 488 gave a missing liboa error, so that’s why I used line 489)

    485 wget http://mafipulation.org/static/shairport-0.05.tar.gz
    486 tar zxvf shairport-0.05.tar.gz
    487 cd shairport-0.05/
    488 sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao-common libao-dev
    489 sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao2 libao-dev libio-socket-inet6-perl libwww-perl avahi-utils
    490 make
    491 sudo perl -MCPAN -e ‘install Crypt::OpenSSL::RSA’
    492 sudo perl -MCPAN -e ‘install HTTP::Message’
    495 sudo perl -MCPAN -e ‘install IO::Socket::INET6′
    496 sudo service avahi-daemon start
    497 perl shairport.pl

  22. Edwin says:

    Vreselijk off topic sorry, maar kan iemand mij vertellen wat er aan de hand is met de registratie pagina voor het forum?

    Bedankt!

  23. Zoop1984 says:

    Net als Edwin ondervindt ik problemen met registreren op het forum. Ook kan ik nergens contact informatie vinden van een webmaster of iets dergelijks, dus dit is echt de enige plek waar ik dit kwijt kan!
    De registreer pagina is dus stuk en ik wil graag wat vragen stellen over XBMCFreak Live.

  24. ubertracker says:

    ondanks de warmte van vandaag toch even een update m.b.t. shairport.

    na het lezen van alle posts op xbmc freak en hier en daar wat zoeken op het internet heb ik geprobeerd om de stappen die nodig zijn voor shairport op een rijtje te zetten. credits naar de mensen waar de info vandaan komt (Bart, apathy)

    allereerst:

    wget https://github.com/albertz/shairport/tarball/master
    tar zxvf master

    nu het commande ls om te kijken wat de uitpak directory is geworden.
    kopieer dan die directory naar de directory shairport

    sudo cp -R albertz-shairport-38935bb/ shairport/

    vervolgens de volgende commandos uitvoeren

    cd shairport/
    sudo apt-get install libssl-dev libcrypt-openssl-rsa-perl libao-common libao-dev libio-socket-inet6-perl libwww-perl avahi-utils
    sudo perl -MCPAN -e ‘install Crypt::OpenSSL::RSA’
    sudo perl -MCPAN -e ‘install HTTP::Message’
    sudo perl -MCPAN -e ‘install IO::Socket::INET6′
    sudo service avahi-daemon start

    testen met :

    perl shairport.pl

    dit zal wellicht niet in 1 keer werken. gebruik dan het commando MAKE in de shairport directory

    make

    als er geen fouten ontstaan tijdens MAKE dan nog eens proberen met:

    perl shairport.pl

    ontstaan er toch fouten probeer dan eens pkg te installaren:

    sudo apt-get install pkg-config

    shairport als deamon

    De bestanden “shairport.pl” en “hairtunes” staan in de map /home/xbmc/shairport.
    op 2 plekken moet dit worden aangepast in 2 bestanden:

    Verander line 20 van bestand “shairport.init.sample”

    DAEMON=”/home/xbmc/shairport/shairport.pl”

    Verander line 52 van /home/xbmc/shairport/shairport.pl

    my $hairtunes_cli = “/home/xbmc/shairport/hairtunes”;

    Kopieer het bestand shairport.init.sample naar “/etc/init.d/shairport”

    sudo cp shairport.init.sample /etc/init.d/shairport

    pas vervolgens de rechten aan

    sudo chmod +x /etc/init.d/shairport

    Voer het volgende commando uit:

    update-rc.d shairport defaults

    Reboot je XBMC of start de service met “service shairport start”

    Werkt voor mij, mocht het niet werken, kijk dan eerst of het wel werkt door handmatig te starten met

    perl /home/xbmc/shairport/shairport.pl

    Volume regelen van shairport:

    /usr/bin/alsamixer

    het gaat hierbij om het front volume. Dit is het volume wat de headphone uitstuurd op een asrock ion 330. Uiteraard kan het volume ook op het iDevice worden geregeld.

    succes

  25. Joerek says:

    Werkt het geluid ook over hdmi, zoals mijn systeem is aangesloten?

  26. bladiebla says:

    @ubertracker,

    Thanks voor de manual. Ik krijg alleen dit bij apt-get:

    Couldn’t find package libao-common

  27. WaZo says:

    This is a great feature and I was waiting for it for a long time but I have 2 problems with it:
    1. I have to kill the xbmc process in order to work otherwise it tells me that the audio device ‘default’ is busy or in use.
    2. The audio drops every 5 sec or so. In the log it says that 2 packets need to be resent.

    Could anybody help me with this?

    Thanks for this tuto and thanks in advance for the help.

  28. apathy says:

    Ik ben weer even bezig geweest. Enkele opmerkingen.

    @ubertracker’s:
    Kleinigheidje.. er moeten wel doublequotes gebruikt worden, “, ipv de “.
    Anders krijg je: “Unrecognized character \xE2

    @bladiebla:
    Wat voor mij werkte: sudo apt-get update

    @Joerek:
    Did lukt mij ook niet. Op dit moment doe ik het maar via een extra kabel. De verklaring lijkt mij dat deze addon op unix is gebaseerd en niet is gekoppeld aan XBMC. Dus in deze shairport moet “ergens” gekeken worden wat de instellingen zijn van XBMC. Als iemand het geluid via de XBMC output kanaal weet te regelen, dan hoor ik het ook graag.

  29. apathy says:

    @Piethein,
    Is het mogelijk om deze foruminstelling zodanig aan te passen dat doublequote’s wel degelijk doublequote’s blijven en niet veranderin in dit: ” ?

  30. apathy says:

    Nog effe een update, dan houd ik op :)
    Volgens mij zit het probleem dat shairport de default sound output van alsamixer gebruikt. Ik heb gezocht in shairport (gezocht in alle bestanden op verschillende zoektermen) maar kon niet direct zien waar dit gezet wordt.
    Misschien dat iemand anders tijd/zin heeft om uit te zoeken hoe dit moet, of, de de “front” output van alsamixer om te buigen naar iec958 of hmdi. (type aplay -L om de defaults te zien). Ik kom er iig niet 1,2,3 uit.

    Zowieso zou dit wel mooi zijn om deze setup mee te nemen naar een volgende live versie.

  31. momoski says:

    Ik heb het werkend gekregen om geluid te krijgen. Ik heb nog twee problemen en een vraag:

    1. Ik kreeg port al bezet en heb het poortnummer gewijzigd in 5001. Hiermee werkte het weer, alleen zie ik nu 2 airports op mijn iPhone staan. Weet niet hoe ik de andere weer kan verwijderen. In TOP zie ik hem maar een keer staan.

    2. Ik krijg alleen geluid als ik de service xbmc-live stop. Oftewel als ik mijn asrock opstart heb ik geen geluid. Moet eerst via een console xbmc-live stoppen. Ik kan overigens daarna wel xbmclive weer starten. In het begin krijg ik de melding “audio device ‘default’ is busy or in use”.

    3. Kan ik ook videobeelden van youtube of fotos streamen naar hairtunes. Kan dat terwijl xbmclive draait of moet ik die eerst killen?

    In ieder geval bedankt voor het delen van deze topic. Mooi stukje software.

  32. momoski :

    Ik heb het werkend gekregen om geluid te krijgen. Ik heb nog twee problemen en een vraag:

    1. Ik kreeg port al bezet en heb het poortnummer gewijzigd in 5001. Hiermee werkte het weer, alleen zie ik nu 2 airports op mijn iPhone staan. Weet niet hoe ik de andere weer kan verwijderen. In TOP zie ik hem maar een keer staan.

    2. Ik krijg alleen geluid als ik de service xbmc-live stop. Oftewel als ik mijn asrock opstart heb ik geen geluid. Moet eerst via een console xbmc-live stoppen. Ik kan overigens daarna wel xbmclive weer starten. In het begin krijg ik de melding “audio device ‘default’ is busy or in use”.

    3. Kan ik ook videobeelden van youtube of fotos streamen naar hairtunes. Kan dat terwijl xbmclive draait of moet ik die eerst killen?

    In ieder geval bedankt voor het delen van deze topic. Mooi stukje software.

    1. Dit is een bekende bug doordat de service op zowel ipv4 als ipv6 actief. Optie is om ipv6 uit te zetten of te wachten op een bugfix.

    2. Dit heeft te maken met de configuratie van ALSA. In de issue lijst staan voorbeelden van configuraties om dit op te lossen.

    3. De shairport doet alleen audio. Voor video is een python script aanwezig van Pascal. Eerder heb ik hier een bericht over op de website gezet.

  33. momoski says:

    @Piethein Strengholt
    Piethein bedankt voor je snelle reply. Top!

    Bij punt 2 heb je het over de issue lijst. Welke issue lijst, op Github voor shairport kan ik niks erover vinden. Thanks

  34. Spencer says:

    @momoski
    I am also wondering where this issue list is located.

  35. werty1st says:

    i made a quick and dirty init.d script to start and stop the shairport server
    http://pastebin.com/ieMV0z4h

  36. michael says:

    I get the following error when trying to compile hairplay on Fedora 14. Any idea why?

    [root@smith shairport-0.05]# make
    gcc hairtunes.c alac.c -lm `pkg-config –cflags –libs ao openssl` -o hairtunes
    /usr/bin/ld: /tmp/ccYOsEPp.o: undefined reference to symbol ‘pthread_create@@GLIBC_2.2.5′
    /usr/bin/ld: note: ‘pthread_create@@GLIBC_2.2.5′ is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
    /lib64/libpthread.so.0: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make: *** [hairtunes] Error 1

Leave a Comment

*