-
Notifications
You must be signed in to change notification settings - Fork 135
/
ap1_test.py
58 lines (52 loc) · 5.16 KB
/
ap1_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from ap2.airplay1 import AP1Security
import socket
"""
This is a small test harness to verify the AP1Security returns correct
values vs what e.g. shairplay does.
"""
device_id = '48:5d:60:7c:ee:22'
request_host = '192.168.19.117'
apple_challenge = 'sGSTMmt+8AB8B+ee/KwdHw'
"""
Local: 192.168.19.117
Remote: 192.168.19.166
Local: 48:5d:60:7c:ee:22
Receiving on socket 6
in rsakey->use_crt
bigint: (size 64)
0001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00B06493326B7EF0007C07E79EFCAC1D1FC0A81375485D607CEE22000000000000
dP: (size 32)
D0EBAFBC4025BA818C75702334384E8F696F804D7AA0E7764E507BB7D3DFEFC7D678C6682D3FAD713441BEEAE724A09EC09BDC3BC0709C9133D489ECE2A51ADD053127490F9286D173C8A4054DC20A575C7E4C0C9834F4A1DE874917A3E400EAF885062DB5CB7E343689E711F75FE783D7E19192FD769CD542BEA4B90107ECD1
dQ: (size 32)
7F4018DC7DEA292DA53042386F3105A0778ADC6F3DE690DA2B74C5055983EDF574661A2FD7B7DE8053CCC0E208F0C8AC626F597D3D99D2CE51A37B39AE4B7E9EF2C075F0BF3D83CACD32DA969192C2899235825C07D1CD3259A1906CDCD499CB613E22C94CB1EA971906609DF1B0F48B063F17372034369499B5FDF970EF440D
qInv: (size 32)
904EE920F944EF5AAF7C9420A00F5E9B48082C0B84E0FBB5DDA2A22677DFB7B8488DB2BEE64C9BDD3CAC66FA320E76F71CE2AF2272BBBD76CAB94E084A0C41D9B0771DC63340C1ACCF5A89DA01B437986F269CF0C216E15EA14A038CDA692AF0EB6DB00E78802B9325204D2D20028A3F8CB13468E80F64188E1046BA1BE458A6
m1: (size 32)
0DB1B9225CD6094E389A744E40070531106EF7B22A1E9BF0EB03389AEE2D133DA53336838FD912B363E5414FCD23C65CDE33C29DA84FE4C1D5E890241547BB5C3659789B066DBBEC904A5BB2934C8A7D918C3746A9FF3DEB4633860AE68293F4B84A640F22E0F6E149AC8E5634CCF1C2B1E9F7C5B774792CD2905C795CAA8845
m2: (size 32)
DA58A5F955D8A295A053C449BC2498CB72265004C1A4D62DB21DA1336739B0F5EADA4B2E5FF351BCACB6A24708D26BBF1AA665CA53D6BDD317E22557FA0FCC48B3CE0249F4A3749E716AB51D45149985DDDAE0293C2BA94B1C9FC8ECF506D4B360FFA8CB1AF2FAB8608A6803A9C215714A43B32A7AEEC57254819E8617610D82
m1 add p: (size 33)
000000010592787C7B3D217FD325D658031E197514C8F125AF84AFA265E48926A21344AC10B27CB0BF5676F48F69F8BB8F62F169139607F02202286BCD19FFB9954F6EA89850E17DDABC91EBBB7183CA7F7F3E62251EC96FA4E6CC6292D47D69A3EC6986BAC3F32091170345825FBC720D86CDE0E41CE898C08D016996CF5556FED6BED6
m1 add p minus m2: (size 32)
2B39D28325647EEA32D2120E46F980A9A2A2A120EDDFD974B3C6E7F33AD993B625D831825F632537E2B35674869085A9F8EFA225CE2B6A98B537DA619B3FA25FE482DF33E6191D4D4A06CEAD3A6AA4DC4743E94668BB23177634B47CAEE594D359C44A557624088D21D5546E63C4B86F99D9356E459E3BF7424DB6D0E775B154
h multiply qInv: (size 64)
185DD9651AE87AF751B75BC51C76FD4C58A274A906AEDEC06DB773B41A292AE58D8491C6DB84628EE43435867A1FA98CE42D0628005DFAD5E230FD3A54F52F193BCF0CE0C2808B14D9DBF34EB3109B4D9734A4403328ECFB515D36D818432769DCF954F7032BB2D6F3CCF4393593154DC91D4C8809767AE939CAF32C17F72DE741C33D6423B121086DA9A2C068630FAD1DE4E74D2844DD37858F2EF21EA20F317EEEA5AE13B70B398E933B911FE2B9BD14169891EBEE70CADC93389EC66344AD092A77BDB2E274169438CE4394670A54557DD87905594C82319E7D3D22CFE5D1CC9D854C86D237F16718F7B49D4885DC79F8BD73EF8C434896F3B8945615DC78
h residue: (size 32)
CDAEC9E694E7D01247B7BD71830D601E2CB9BF03EEC18A18A54FE8B4F1D5BEC15852F4E1DBF1B861AC2F8DCB2B280C3F24BC81A3008E971D4FFB80E011551225D806BF599B3F64C02E450608CC4A788E0D05761D52D4853C746B4A1E92BDAD69F3A6EDFD6D22A0D35171AF38AFB3066DB366F95B27A7778FA0F00E04AC5F492D
m2 add (q*h): (size 64)
C0602AF171C971F14E69850BDECDE290D3E7E405259A003A2D270CA25A796A1FF57FA4FDFFC151C789454647D328C5E377AC8D2F7B0665BB7BEE5B5ADDE78C4F122929D3CA7C281E663FF69E3BAA42FA72DDE8E631345A453ABA79EE332A4D84130B76ED7F41C6416F27F83782E3DEF129ABAD0C344F4B33B8F841240B1F45D2C1B983CBBCA017C4A7000492A346755420AEE33A1C055D47D8E9E6E0FA0BC9FFA13050DAFBFE5C77267E712DCF106451ADBE5D0B9919A6AC5487A55C1050AFDBC11C6D17FB3552A1EC99B95DB7A7E96FC710B3293843832391271D694BDC0FC7DFB322F58A5A0D5EE973A0625EC4E8DE6B9BC3CECD356A43C1F7305D9F0DA5B1
Got challenge: sGSTMmt+8AB8B+ee/KwdHw
Got response: wGAq8XHJcfFOaYUL3s3ikNPn5AUlmgA6LScMolp5ah/1f6T9/8FRx4lFRkfTKMXjd6yNL3sGZbt77lta3eeMTxIpKdPKfCgeZj/2njuqQvpy3ejmMTRaRTq6ee4zKk2EEwt27X9BxkFvJ/g3guPe8SmrrQw0T0szuPhBJAsfRdLBuYPLvKAXxKcABJKjRnVUIK7jOhwFXUfY6ebg+gvJ/6EwUNr7/lx3Jn5xLc8QZFGtvl0LmRmmrFSHpVwQUK/bwRxtF/s1UqHsmbldt6fpb8cQsyk4Q4MjkScdaUvcD8ffsyL1iloNXulzoGJexOjea5vDzs01akPB9zBdnw2lsQ
"""
if len(request_host.split(".")) == 4: # ipv4
# data += socket.inet_pton(socket.AF_INET, request_host)
IPADDR_BIN = socket.inet_pton(socket.AF_INET, request_host)
print(IPADDR_BIN)
else:
# data += socket.inet_pton(socket.AF_INET6, request_host.split("%")[0])
IPADDR_BIN = socket.inet_pton(socket.AF_INET6, request_host)
DEVICE_ID_BIN = int((device_id).replace(":", ""), base=16).to_bytes(6, 'big')
# Use this for (request_host, device_id) as bin
# AP1Security.compute_apple_response(apple_challenge, IPADDR_BIN, DEVICE_ID_BIN)
# Use this for (request_host, device_id) as text
AP1Security.compute_apple_response(apple_challenge, request_host, device_id)