Sky+, DNLA, UPnP, the iPad app and the IP control protocol

Sky launched an update to the iPad Sky+ app this week, which enables the ability to remotely control your Sky box over IP, if you’re updated to the new picasso interface. Obviously, I needed to figure out how it all works, and how I could write my own code to control it. Here are my inital findings.

The service is a DNLA/UPnP type thing, that runs on http://[sky-box-ip]:49153/

Authentication is provided simply by User-Agent. SKY_skyplus works.

More information is after the break.

It returns the following information:

[codebox 1]

The new Sky control protocol used in the iPad Sky+ app uses this webservice. I believe the description0 file is to do with the remote control service (hence references to RC2). The description0 file exposes the first 3 services provided by the Sky box’s server.

The example flow works like this with the iPad App:

iPad broadcasts to subnet request for Sky boxes. Sky box replies with its IP and a link to description0.xml via the SSDP service discovery protocol of UPnP. The iPad grabs this description0.xml file and then gets description2.xml. This file contains a very similar set of information, but for the SkyBrowse service – I suspect this is the planner editing bits, rather than a listings search.. I suspect the listings stuff still actually comes from sky’s webservices, rather than the local skybox. But I suppose it could contain information about the series link, and the “Watch on TV” command.

Then the iPad app sends a subscribe and a callback URL. This runs on port 51000 on your iPad and uses a SOAP urn of nds-com:serviceID:SkyPlay2. Not sure if this will ever be useful for us geeks, I doubt we’d ever want to send our own replies to the app?

The Sky Box then sends a SOAP wrapped HTTP packet with contains a SID which is a uuid – I think this is probably the session ID used for authentication on further requests, but i’m struggling to see where that is sent back in future requests at the moment.

A bunch of nonsense looking (from a ascii point of view) packets are sent throughout this, I don’t know that much about SOAP, so hopefully they might be standard things we don’t need to worry about. These seem to be basic syn/acks. I assume it’s proactive about keeping connections alive.

The fun stuff starts when you want to pause or so something like that. These are just simple SOAPACTIONs with urns like: “urn:schemas-nds-com:service:SkyPlay:2#Pause”. Once one of those has been ACK’d by the Sky Box, the iPad app sends another packet, but this time containing XML data with just seems to repeat the command, but in XML form.

The good news is, there doesn’t look like there is any encryption here. The next step is to try and make the Sky Box pause and play on demand using my own code, which I think means needing to reverse engineer the wsdl. I’ll write another post with more information once I get round to it.

Update 1:Just to clarify, there is 5 services exposed by this code: SkyPlay2, SkyCM2, SkyRC2, SkyBook2, SkyBrowse2.
Also, there is no description1.xml file (No idea why not…) 

Just a quick note to Sky or NDS, if they read this: I’m hoping this kind of playing isn’t a problem for you guys. If it is, just drop me an email (liam@gladdy.co.uk) and i’ll remove the blog posts and stop trying to figure out more. I’m not trying to do anything evil. If i discover anything that could be used for piracy (such as serving content over DNLA from the device) i’ll obviously not post about it. Just been a geek here.


Comments

25 responses to “Sky+, DNLA, UPnP, the iPad app and the IP control protocol”

  1. There is a decription7.xml and description8.xml too !
    Also the Ssdp is broadcast repeatedly by the box, I don’t think the iPad requests it as such.

  2. Hey,
     
    I have also been looking into how the app works and via c# I was able to pause and play live TV.. maybe we could team up and have a little look? I want to create a Windows 8 / Windows Phone 8 app to control Sky+..
     
    I don’t want to post my email address but my twitter handle is mikeeaton. 
     
    Thanks,
     
    Michael

  3. @BruH5200 The box does repeatedly broadcast via SSDP, at in interval of around 30 seconds. The iPad does send a request also though, to prompt a SSDP broadcast sooner – ie advertising the fact that it is actively looking for a box. This is why the iPad app finds a box almost immediately, but all the code i’ve found online prompts you to wait for around 30 seconds to find something.

  4. “Then the iPad app sends a subscribe and a callback URL” – Do you have any more info on this please? I’m trying to figure out the request that is made, but having trouble pinning it down in wireshark.

  5. Hi, 
    @ mikeeaton and @Liam – can you share some code? That C# code you talked about? I don’t seem to be able to connect to my SKY box and I really need this. I am happy to contribute with everything else I add to the project.
    My email giorgio.macho@gmail.com
    Thanks,
    George

  6. Pretty sweet findings. I wonder whether one could make an XBMC plugin, that controls the SKY box such that the input would pass-through into the XBMC device and the device’s XBMC would overlay the SKY stream. That could mean that I’d need only one controller/remote in the end?

  7. Wesley Elder Avatar
    Wesley Elder

    Hi,

    first of all, great work!! And thank you.

    Has anyone been able to expose more than ( play/pause/stop/fwd/rewind – set and get channel, next and previous?

    i would like to replicate the remote as much as possible.

    I’d like send up/down/left/right/guide etc… , select and backup seem be in the iPhone App, however i can’t see this traffic in wireshark.. Has anyone had any luck with this?

    I’ve looked through alll the xml files i could find from the box, looked at the action commands however nothing is jumping out at me, i suspect it doesn’t exist.

    getxmlFile(“scm_cds.xml”)
    getxmlFile(“player_rui_http_cds.xml”)
    getxmlFile(“description0.xml”)
    getxmlFile(“description1.xml”)
    getxmlFile(“description2.xml”)
    getxmlFile(“description3.xml”)
    getxmlFile(“description4.xml”)
    getxmlFile(“description5.xml”)
    getxmlFile(“description7.xml”)
    getxmlFile(“description8.xml”)
    getxmlFile(“description9.xml”)
    getxmlFile(“player_avt.xml”)
    getxmlFile(“player_cm.xml”)
    getxmlFile(“player_rc.xml”)

    Cheers,

    Wes

    1. Hey – check out http://github.com/dalhundal/sky-remote. Allows you to send all commands that you can from the remote – it’s not using the DLNA endpoints, so you don’t get any feedback – but it does let you send buttons like power, up / down / left right etc.

      1. Chris Robertson Avatar
        Chris Robertson

        This is really good. How did you find this protocol?

  8. Mitchell Mann Avatar
    Mitchell Mann

    I know I’m late to the party here, but after using the Sky+ app recently to show off some photos on my iPhone to guests we had round I wondered if there was a Mac (or PC) app that allowed photos to be shared from a computer to the TV via the Sky+ box as I’ve many more on my Mac than I have on my iPhone. I used Wireshark to intercept the traffic to see how it worked and it *seemed* rather simple:-

    1. The app on the iPhone (or iPad/iPodTouch) opens a local port that acts as a web server, 51178 in my case although I’m sure this is randomly assigned.
    2. After initiating a TCP connection to the Sky+ box the app sends this: GET /photo-viewing/start?uri=http://192.168.0.5:51178/photo1763828098 HTTP/1.1 to port 49159 of the Sky+ box (192.168.0.5) being the IP of my iPhone and photo1763828098 being the jpg photo file on my iPhone.
    3. The photo is streamed from the iPhone to the Sky+ box and displayed.

    Quite simple. I thought I could initiate a TCP connection with netcat to port 49159 of the Sky+ box and substitute the IP of my iPhone for the IP of a local web server and specify port 80 and replace photo1763828098 with whatever photo file was stored in the home/root directory of the web server, but nothing happened. So I did some searching and came across this old blog and upon reviewing Liam’s excellent skyRemote.py I realise there are probably a few more steps required to make this work but my Python skills aren’t even noob level and as it already seems a pretty capable script I thought maybe adding this extra functionality would be quicker/easier than for me to code something from the ground up in a language I’m more familiar with.

    I hope this sparks some renewed interest and apologies for the spam as I notice there are a couple of related threads on this blog which I shall be copying and pasting this post to verbatim.

    1. Mitchell, I stumbled across your post

      I can happily post a single photo from a web browser using :
      http://:49159/photo-viewing/start?uri=http:///sky.jpg provided the image is in the order of 1280 x 720 (too far from this and it doesn’t work) and that the image isn’t too large (haven’t worked out the max size as yet) it also doesn’t like pngs and http://:49159/photo-viewing/stop to turn it off as well

  9. Thomas Luxton Avatar
    Thomas Luxton

    sorry, i’m late to the party also, i am trying to mimic the broadcast replies in hopes that i can access sky Q recordings over vpn any ideas how i might be able to accomplish this? I think the only problem is broadcasts are not sent over Vpn, so it will never receive a reply. thanks

    1. You should be able to configure your VPN to work just like a computer on the network. You just need to make sure you’re giving out IP addresses on the same subnet, and don’t block broadcasts. I’ve seen screenshots of people using VPNs to their home networks just fine with Sky Q, so it’s definitely possible!

      1. Thomas Luxton Avatar
        Thomas Luxton

        Hi, Thanks for the response, wasn’t anticipating one, however, the VPN i use on my Synology nas doesn’t allow putting IPs on the same subnet. If it did, I wouldn’t have thought this would be much help as I am doubtful that broadcasts would work over VPN due to the layers.

        I did contemplate trying to set up a new VPN in windows to put on the same subnet, but I dismissed the idea because generally broadcasts are not sent over VPN. I personally haven’t seen people using VPN’s with Sky Q, but I am hoping to overcome that.

        I have set the default gateway of the SkyQ box to the NAS – so the two endpoints will have no difficulties talking to each other. I have used wireshark to capture traffic between devices and SkyQ and that lead me to find this thread.

        I am hoping to replicate a broadcast manually on the local LAN with the source IP of the VPN client. Any knowledge how I can replicate the same traffic captured by the original broadcast?

        I suspect that when SkyQ receives the broadcast, it will communicate directly with the source IP.

        My other idea was to replicate the return traffic manually as the client would be expecting a response after it sent its broadcast.

        Tom

        1. Hey Tom,

          If you were on the same subnet, broadcast would definitely work (so long as it wasn’t configured to block) – though a quick google suggests that might depend on what type of VPN you’re using, as some block by default.

          You probably could just fake the Sky Q broadcasts as you said, because then it would communicate directly (see my more recent blog posts on how that works with Q) – but presumably you’d need another device on the VPN to do that? And maybe the VPN would just refuse to broadcast those too?

          1. Thomas Luxton Avatar
            Thomas Luxton

            I was imagining a device inside the LAN to broadcast on the client’s behalf. Maybe a linux shell running in a docker container on the NAS again.

            I will look at windows VPN software to see if there are any L2TP servers that allow IPs on the same subnet and see if broadcasts work.

            Thanks for the replies, really appreciate it.

          2. Thomas Luxton Avatar
            Thomas Luxton

            Right, so managed to get on the same subnet using a new vpn software. To my surprise it found the sky q box but failed to download or play recording. I have captured wireshark logs of the activity. Any initial thoughts? https://uploads.disquscdn.com/images/f987cd5d1d9703e5da8e8fa62b6bc468ae10236f65fa91a4720e956606b5433d.png

          3. I’ve seen some people say Sky do latency detection to try and prevent people using VPNs, so I guess this could be that? Whats your ping time to the sky box when on the VPN?

          4. Thomas Luxton Avatar
            Thomas Luxton

            Doesn’t seem that sky Q replies to ping packets, though I can scan the services. However I’ve tried pinging other local devices to compare their latency over the internet. It wouldn’t seem to me latency is the issue. Interestingly sharing photos service is not afftected. https://uploads.disquscdn.com/images/ae6ccca0e02cf6de61c9d0ee1305a8ac1c8f1034fdd5b2ad7f3dee63eebec92f.png https://uploads.disquscdn.com/images/5be9a78b2f9446123f47f030ee0d02a2d815dc5b1a5a3798ae5156e65fb723af.png https://uploads.disquscdn.com/images/d1f424487ba43f0b90f4031b86107960652d64f5ea9fefbd8bf0586f896c5051.png

          5. They use a custom ping system based around their HTTP interface.

  10. Rob Burrowes Avatar
    Rob Burrowes

    Just went through the same discovery process with a sky box in New Zealand, replicating your Python code in Ruby,
    before finding you had already done it 😉 (https://github.com/rbur004/mysky).

    Found the Sky box in a network scan, so had to play. It has ports 110 (pop), 143 (imap), 5901 (VNC?) and 49153 open. It is also broadcasting uPnP on 9000. Haven’t seen it call home to Sky yet, but it must, or the phone app wouldn’t be able to set up recordings (not that I can get that app to actually work).

    What might be useful to other kiwis, is the NZ sky channel codes in mysky_nz_channels.rb. Simple to generate, but time consuming, so I haven’t completed a full sweep of the channels.

    My sky box in NZ uses description3 and description4, though sometimes, these showed up on 0 and 2 instead. We have no equivalent of the Q version here, just the port 49153 Soap service. The controlURLs all have the UUID between the / and command.

    I did find that I needed to explicitly add a CR LF to the end of the soap body for it to work across my Mac, FreeBSD and Linux systems. I had to resort to tcpdump to see why one worked, and the others wouldn’t, using exactly the same code. I was getting an HTML 500 error on Linux and FreeBSD, before I added the line termination explicitly.

    I can play (FF/Rewind), pause, stop and change channel. I can’t play a recording, but can fetch the file:// url of a one that is playing, and can use ‘Stop’.

    I can’t get the skyBrowse or skyBook services to work. I just get an HTML 500 error for these.

  11. John Williamson Avatar
    John Williamson

    Loving your work Liam. I’m a Java guy and must admit the node.js and python code examples are a little confusing to me. In the process of converting some of what you have into Java but getting a bit stuck.

    I’ve got as far as discovering the sky box with a SSDP client which gives me all the info I think I will need but no idea what the next step would be to query the status of the box (i.e. is it playing or paused and what’s the current selected channel). Any tips from the below?

    HTTP/1.1 200 OK
    CACHE-CONTROL: max-age=115
    DATE: Wed, 05 Jan 2000 10:01:38 GMT
    EXT:
    LOCATION: http://192.168.0.12:49153/description0.xml
    OPT: “http://schemas.upnp.org/upnp/1/0/”; ns=01
    01-NLS: 7c6454de-1dd2-11b2-a146-96fef7129043
    SERVER: Linux/2.6.18.8 UPnP/1.0 SKY DLNADOC/1.50
    X-User-Agent: redsonic
    ST: urn:schemas-nds-com:service:SkyPlay
    USN: uuid:444D5276-3247-536B-7943-0019fbd780f1::urn:schemas-nds-com:service:SkyPlay

    1. John Williamson Avatar
      John Williamson

      Here’s where I have got to so far. This gives me a Response Code : 200 for SkyPlay (The subscription was successful) yet the content is empty. Maybe I am heading down the wrong path. There was no HttpSubscribe.class from apache so overriding the HttpGet and changing the method name to SUBSCRIBE

      HttpClient client = HttpClientBuilder.create().build();
      HttpSubscribe request = new HttpSubscribe(url.toString());
      request.addHeader(“User-Agent”, “SKY_skyplus”);
      request.addHeader(“nt”, “upnp:event”);
      request.addHeader(“callback”, callback.toString());

      HttpResponse response = client.execute(request);

      System.out.println(“Response Code : ” + response.getStatusLine().getStatusCode());

      BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

  12. Thomas Luxton Avatar
    Thomas Luxton

    I just wondered if anyone was close to being able to play recordings over a VPN?

  13. Thanks for sharing your work on this! I know it’s late from the original post but does anyone know what SOAP actions are needed to power the box on and off and what data is needed to detect its standby state? The Sky+ app does it on iOS but can’t see any obvious network traffic when I use the remote section of the app.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.