openairplay / airplay2-receiver

AirPlay 2 Receiver - Python implementation
2.13k stars 133 forks source link

Unable to pair successfully #5

Closed hassbian-ABC closed 3 years ago

hassbian-ABC commented 3 years ago

%JHZD$T0 T`T4YO12OY`1_0 VNR(JPK}KFT@7 %6IXJEN08

Neustradamus commented 3 years ago

@PaulWieland, @systemcrash: What do you think?

systemcrash commented 3 years ago

Need more info. Need more logs from start to prooblem. But the 404 is a big hint. Maybe pair-add suggests a different crypto(?) - and things were done a bit differently on iOS 14.2

Font in screen-caps suggests the system is running a different language, which might hinder fs/directories?

SilasT commented 3 years ago

Here is my attempt, getting the same 404 error, running on macOS Big Sur.

Interface: en0
IPv4: 192.168.1.134
IPv6: fe80::462:e0e5:e3e8:779

mDNS service registered
Starting RSTP server, press Ctrl-C to exit...
serving at port 7000
Got connection with 192.168.1.133:51223
X-Apple-ProtocolVersion: 1
Content-Length: 70
Content-Type: application/x-apple-binary-plist
CSeq: 0
User-Agent: AirPlay/535.3

GET /info
{'qualifier': ['txtAirPlay']}
Sending:
{'audioLatencies': [{'inputLatencyMicros': 0,
                     'outputLatencyMicros': 400000,
                     'type': 100},
                    {'audioType': 'default',
                     'inputLatencyMicros': 0,
                     'outputLatencyMicros': 400000,
                     'type': 100},
                    {'audioType': 'media',
                     'inputLatencyMicros': 0,
                     'outputLatencyMicros': 400000,
                     'type': 100},
                    {'audioType': 'media',
                     'inputLatencyMicros': 0,
                     'outputLatencyMicros': 400000,
                     'type': 102}],
 'deviceID': '78:4f:43:80:5b:aa',
 'features': 496155702053376,
 'keepAliveLowPower': True,
 'keepAliveSendStatsAsBody': True,
 'manufacturer': 'Sonos',
 'model': 'One',
 'name': 'Camera da letto',
 'nameIsFactoryDefault': False,
 'pi': 'ba5cb8df-7f14-4249-901a-5e748ce57a93',
 'protocolVersion': '1.1',
 'sdk': 'AirPlay;2.0.2',
 'sourceVersion': '366.0',
 'statusFlags': 4}
X-Apple-AbsoluteTime: 639240584
X-Apple-HKP: 4
X-Apple-Client-Name: Silass iPhone
Content-Length: 9
Content-Type: application/x-apple-binary-plist
CSeq: 1
User-Agent: AirPlay/535.3

POST /pair-setup
00000000: 00 01 00 06 01 01 13 01  10                       .........
-----   Pair-Setup [1/2]
X-Apple-AbsoluteTime: 639240584
X-Apple-HKP: 4
X-Apple-Client-Name: Silass iPhone
Content-Length: 457
Content-Type: application/x-apple-binary-plist
CSeq: 2
User-Agent: AirPlay/535.3

POST /pair-setup
00000000: 06 01 03 03 FF 41 22 47  44 D1 86 BB 25 05 DB 25  .....A"GD...%..%
00000010: 22 56 F6 8F 1D DB 0F 23  58 81 F3 15 28 DE 48 FB  "V.....#X...(.H.
00000020: AB D2 26 40 DA F1 7E 4B  BD DE F0 82 2C 05 05 32  ..&@..~K....,..2
00000030: AA 89 0B 38 1A 1B 5D CF  B1 42 2B 44 6E CC A0 EA  ...8..]..B+Dn...
00000040: 58 D4 5E D7 2D BB 8E 9B  D6 A6 F2 09 3D B9 47 CF  X.^.-.......=.G.
00000050: 44 9A E0 2E 7F 16 AC FC  AE 61 39 8A 23 50 FC 2C  D........a9.#P.,
00000060: 91 49 04 4D 61 46 A4 57  ED DF 9D B1 D6 8B 56 EC  .I.MaF.W......V.
00000070: 0E 88 9B 6B 89 CC B9 28  4A A3 E2 10 23 FA 86 DB  ...k...(J...#...
00000080: 8D 28 08 2A 4B C9 FA 1F  E7 77 9F 74 91 9A CA 42  .(.*K....w.t...B
00000090: B4 F1 6F 87 91 DF 08 53  0A 2C B6 B6 64 11 12 27  ..o....S.,..d..'
000000A0: D1 FF A0 61 B8 B0 FA AB  25 0B 3E 38 78 40 E3 BE  ...a....%.>8x@..
000000B0: 3F 88 51 A4 EF 01 C4 14  9C 20 95 11 0D 1C 54 C6  ?.Q...... ....T.
000000C0: AB 3F 14 DA 14 F0 EF 84  61 33 4D 17 95 D8 BB F9  .?......a3M.....
000000D0: 81 BA 14 AC 2B 95 9A 51  B4 49 B3 E2 69 C6 DF C8  ....+..Q.I..i...
000000E0: A0 DC D7 F3 1E 46 2D B1  7E FD 10 9C A5 1A BA 9D  .....F-.~.......
000000F0: 9C 78 7D 8A 81 DB 13 06  17 8A 3E F4 6F 3A CB A2  .x}.......>.o:..
00000100: 04 00 B7 02 03 81 8E 61  10 2C CE 2A D5 C0 B3 08  .......a.,.*....
00000110: D1 21 28 50 8A F2 DC D7  0E DE F1 27 31 77 68 ED  .!(P.......'1wh.
00000120: 1D A4 0A BD DF F6 DB 45  39 53 7E A7 9F 26 2B EF  .......E9S~..&+.
00000130: 53 1C C3 4D DB BB 17 53  58 50 4E EE CC F6 80 4E  S..M...SXPN....N
00000140: D8 D0 59 78 8F D0 99 DA  51 34 6C 8B EC 24 6C E1  ..Yx....Q4l..$l.
00000150: FC CF C4 48 1C BC 7E 33  67 21 3C 79 DB D7 41 19  ...H..~3g!<y..A.
00000160: 9C 10 EC 8C 57 B3 30 5A  74 95 48 14 2E FD 91 EB  ....W.0Zt.H.....
00000170: 00 E4 CC 58 58 88 C6 7D  70 85 7F 63 FA C5 60 19  ...XX..}p..c..`.
00000180: 18 8F F3 80 48 C7 02 04  40 F3 19 0E 56 A1 7A 89  ....H...@...V.z.
00000190: D9 2F 0C 79 A5 DD 33 A2  E6 6B 28 5D 07 44 1C F1  ./.y..3..k(].D..
000001A0: 77 B2 EF 0E 21 56 D9 22  28 D9 72 72 1C 28 CE FE  w...!V."(.rr.(..
000001B0: 63 2D 53 BB 56 AD 1E 9B  89 F6 56 27 1C 17 90 EA  c-S.V.....V'....
000001C0: C6 B1 7D 7F 2B 26 B1 80  EC                       ..}.+&...
-----   Pair-Setup [2/2]
00000000: 67 2A 34 0E 58 A6 1C D2  B8 8A 07 1E B2 B5 36 BE  g*4.X.........6.
00000010: 50 6B 14 78 2B B1 57 57  D8 73 2C 5B CE 6A 9D 84  Pk.x+.WW.s,[.j..
00000020: 0F 11 C1 6E EE 5D 23 48  46 4F 91 2E EA B8 5B 71  ...n.]#HFO....[q
00000030: B3 23 29 16 92 19 8D DB  14 77 88 37 15 D1 EE CF  .#)......w.7....
----- ENCRYPTED CHANNEL -----
X-Apple-ET: 32
Content-Length: 16
Content-Type: application/octet-stream
CSeq: 3
User-Agent: AirPlay/535.3

POST /fp-setup
00000000: 46 50 4C 59 03 01 01 00  00 00 00 04 02 00 02 BB  FPLY............
X-Apple-ET: 32
Content-Length: 164
Content-Type: application/octet-stream
CSeq: 4
User-Agent: AirPlay/535.3

POST /fp-setup
00000000: 46 50 4C 59 03 01 03 00  00 00 00 98 02 8F 1A 9C  FPLY............
00000010: 65 74 06 EB 15 AD 9A 37  F9 BE E5 55 36 5F 2A FD  et.....7...U6_*.
00000020: 46 38 2A A5 77 50 5A 3B  9A 16 E4 58 29 0B 25 E4  F8*.wPZ;...X).%.
00000030: 03 4D 73 AA 2E A3 A8 B1  13 92 DB A9 A9 15 0B 79  .Ms............y
00000040: 89 74 42 6D F5 79 86 89  69 E0 68 F8 0F ED 1E 23  .tBm.y..i.h....#
00000050: 8C DB 15 E3 25 2A 07 23  41 E6 07 5B 6A 47 EE 10  ....%*.#A..[jG..
00000060: 7F D5 FD F5 69 54 5E E1  76 99 96 D2 60 8B F5 BE  ....iT^.v...`...
00000070: 82 70 65 7A 39 98 46 82  04 66 23 E2 B0 BF EB 70  .pez9.F..f#....p
00000080: B5 C2 B1 5D ED C4 D5 2B  03 7F BD 0A 40 F3 D5 5C  ...]...+....@..\
00000090: 81 B3 47 0D 58 5C 23 C7  78 D6 2F 72 04 FC 1D FD  ..G.X\#.x./r....
000000A0: 39 ED AB 5E                                       9..^
SETUP rtsp://192.168.1.134/90988885978794080
Content-Length: 373
Content-Type: application/x-apple-binary-plist
CSeq: 5
User-Agent: AirPlay/535.3

{'deviceID': '48:4B:AA:B4:25:9B',
 'isRemoteControlOnly': True,
 'macAddress': 'AE:21:2E:3B:96:70',
 'model': 'iPhone9,3',
 'name': 'Silass iPhone',
 'osBuildVersion': '18D61',
 'osName': 'iPhone OS',
 'osVersion': '14.4.1',
 'sessionUUID': '014341E8-E346-4860-B184-EBCEA83F5229',
 'sourceVersion': '535.3',
 'timingProtocol': 'None'}
Sending EVENT:
[+] eventPort=62451
{'eventPort': 62451,
 'timingPeerInfo': {'Addresses': ['192.168.1.134', 'fe80::462:e0e5:e3e8:779'],
                    'ID': '192.168.1.134'},
 'timingPort': 0}
X-Apple-ProtocolVersion: 1
CSeq: 6
User-Agent: AirPlay/535.3

GET /info
RECORD rtsp://192.168.1.134/90988885978794080
CSeq: 7
User-Agent: AirPlay/535.3

POST /pair-add Not implemented!
192.168.1.133 - - [04/Apr/2021 16:49:45] code 404, message Not Found
PaulWieland commented 3 years ago

Are you getting the same result with ckdo’s branch?

SilasT commented 3 years ago

Just gave it a try, same result yes.

Neustradamus commented 3 years ago

Note: ckdo master is same that this upstream.

TheSpookyCat commented 3 years ago

This has been fixed and tested with #41. Could someone please close unless the author can confirm that the latest commit of master doesn't work for their setup?

systemcrash commented 3 years ago

@SilasT @hassbian-ABC @PaulWieland

@LewdNeko and I did some stuff. Plz try current master 😉

hassbian-ABC commented 3 years ago

GET /info RECORD rtsp://10.0.0.85/4298854712228004544 CSeq: 7 User-Agent: AirPlay/545.22.21

X-Apple-AbsoluteTime: 648117321 Content-Length: 81 Content-Type: application/x-apple-binary-plist CSeq: 8 User-Agent: AirPlay/545.22.21

POST /pair-add pair-add /pair-add X-Apple-AbsoluteTime: 648117321 Content-Length: 81 Content-Type: application/x-apple-binary-plist CSeq: 8 User-Agent: AirPlay/545.22.21

----- Pair-Add [1/1] Controller does not have admin bit set in local pairings list TEARDOWN rtsp://10.0.0.85/4298854712228004544 Content-Length: 42 Content-Type: application/x-apple-binary-plist CSeq: 9 User-Agent: AirPlay/545.22.21

{}

@systemcrash

TheSpookyCat commented 3 years ago

@hassbian-ABC it seems you are trying to pair whilst there is already pairing data established in the ./pairings folder, and the stored permissions are not the admin bit. Unless systemcrash changed something, if you were to print(ltperm) just before this line it should be b'\x01' if you are an admin to your HomeKit Hone

hassbian-ABC commented 3 years ago

----- Pair-List [1/1] 00000000: 06 01 02 01 24 46 43 46 32 34 42 31 39 2D 32 34 ....$FCF24B19-24 00000010: 41 45 2D 34 35 35 44 2D 41 39 33 43 2D 38 34 45 AE-455D-A93C-84E 00000020: 42 46 46 37 44 37 39 35 36 03 20 11 39 15 A6 25 BFF7D7956. .9..% 00000030: 5B FA 64 78 BD 16 DD 33 92 7F 98 53 38 4C 47 D1 [.dx...3...S8LG. 00000040: 9E 7F E7 38 15 4C 9C 13 CE F3 78 0B 01 01 ...8.L....x... Content-Length: 154 Content-Type: application/x-apple-binary-plist CSeq: 10 User-Agent: AirPlay/545.22.21

POST /configure configure /configure Content-Length: 154 Content-Type: application/x-apple-binary-plist CSeq: 10 User-Agent: AirPlay/545.22.21

{'ConfigurationDictionary': {'Access_Control_Level': 0, 'Enable_HK_Access_Control': True, 'Password': '199012'}} {'Access_Control_Level': 0, 'Device_Name': 'NEWBORNE', 'Enable_HK_Access_Control': True, 'Identifier': 'aa5cb8df-7f14-4249-901a-5e748ce57a93', 'PublicKey': b'p\xb5\xdf\xa5\x9e\xf3\xa0\xf5S\xa8.\xb4w\xf8\x850\xf2\x1e\\xd2' b'9\xa8\xc1\x14\xa1/\xeb\x99\xf4\xa7\xacP'} 00000000: 2E CB 82 17 62 7F CA 70 98 B4 30 96 AE CF 15 95 ....b..p..0..... 00000010: 70 C0 29 3E FB 98 90 11 74 AF B3 F6 63 06 35 58 p.)>....t...c.5X 00000020: 8A 39 36 3F 06 4A CC C8 41 38 51 58 AD 9D C6 A8 .96?.J..A8QX.... 00000030: 6A A9 F5 A3 24 37 80 9A E3 33 9D 83 FC C1 48 AE j...$7...3....H. ----- ENCRYPTED CHANNEL -----

Exception happened during processing of request from ('10.0.0.96', 54279) Traceback (most recent call last): File "/usr/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python3.7/socketserver.py", line 347, in process_request self.finish_request(request, client_address) File "/usr/lib/python3.7/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python3.7/socketserver.py", line 720, in init self.handle() File "/usr/lib/python3.7/http/server.py", line 428, in handle self.handle_one_request() File "/usr/lib/python3.7/http/server.py", line 394, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/usr/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) File "/root/airplay2-receiver/ap2/pairing/hap.py", line 577, in recv_into data = self.recv(nbytes, flags) File "/root/airplay2-receiver/ap2/pairing/hap.py", line 596, in recv block_length_bytes = self.socket.recv(self.LENGTH_LENGTH) File "/root/airplay2-receiver/ap2/pairing/hap.py", line 586, in recv assert not flags and buflen > self.LENGTH_LENGTH AssertionError

@systemcrash @LewdNeko