且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否有人对Apple的iOS远程应用程序使用的协议进行反向工程,以通过IP控制Apple TV?

更新时间:2023-12-03 17:45:04

我确实设法通过python脚本控制了Apple TV(当前正在运行tvOS 9.2).事实证明,您不需要使用家庭共享"来让远程应用程序控制Apple TV.我不知道如果启用了家庭共享"功能,以下方法是否会起作用,但是在Apple TV上禁用了家庭共享"功能后,iOS远程应用程序可以选择手动添加设备. (这可能需要删除已经与之配对的所有设备,因为不幸的是,这对于我来说必须使它显示添加设备"按钮.)在将iPhone与Apple TV配对后,我记录了一些内容.它的请求,复制配对GUID,然后构造一些我自己的请求.

I did manage to control my Apple TV (currently running tvOS 9.2) from a python script. It turns out that you don't need to use Home Sharing to have a remote app control the Apple TV. I don't know if the following method will work if Home Sharing is enabled, but with it disabled on the Apple TV, the iOS Remote app has the option to manually add a device. (This may require removing all of the devices it is already paired with, since that was unfortunately necessary for me to get it to display the 'Add a device' button.) Once I had paired my iPhone to the Apple TV, I recorded some of its requests, copied the pairing GUID, and then constructed some of my own requests.

仅需执行三个请求:

/login?pairing-guid=< your pairing guid here >&hasFP=1

登录到Apple TV.响应的最后四个字节是会话ID,编码为大端4字节整数.

Logs into the Apple TV. The last four bytes of the response's is a session id, encoded as a big-endian four byte integer.

/logout?session-id=< your session id here >

注销.并非完全必要,因为我发现登录只是为您提供了一个新的会话ID,但按照预期的方式做事可能不是一个坏主意.

Logs out. Not strictly necessary, as I found that logging in simply gets you a new session id, but probably not a bad idea to do things the way it expects.

/ctrl-int/1/controlpromptentry?prompt-id=114&session-id=< your session id here >

将用户输入发送到Apple TV.数据是输入命令或可能的移动触摸的多个缓冲区之一.为了在基本方向上运动,有必要发送几个这样的请求来模拟运动触感.

Send user input to the Apple TV. The data is one of several buffers that input a command, or possible a moving touch. For movement in the cardinal directions, sending several of these requests to simulate a moving touch is necessary.

我有一个python脚本,在这里演示如何执行此操作: http://pastebin.com/mDHc353A

I have a python script demonstrating how to do this here: http://pastebin.com/mDHc353A

使用请求库: http://docs.python-requests.org/en/大师/

还要特别感谢Adam Miskiewicz/github用户skevy,因为我在他的atlas-后端存储库中使用了此文件,该文件方便地具有正确的缓冲区以供移动:

Also special thanks to Adam Miskiewicz / github user skevy, since I made use of this file in his atlas-backend repo that conveniently had the right buffers to send for movement: https://github.com/skevy/atlas-backend/blob/master/atlas/services/appletv.coffee