-
Notifications
You must be signed in to change notification settings - Fork 134
/
fp_decrypt.py
104 lines (98 loc) · 10.4 KB
/
fp_decrypt.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from ap2.fairplay3 import Fairplay3
import base64
fairplay3 = Fairplay3()
# The ordinal position in each array contains the corresponding components for key decryption.
# Don't change their order.
AESKeyB64Array = [
# mode 0 key
'RlBMWQECAQAAAAA8AAAAAG1EuhK5H0jgYesjD8U6v6IAAAAQihBgRl1RuAjfES0ItgRQH54+opzgkC88Q7gdUxnQV194UX4B',
# mode 1
'RlBMWQECAQAAAAA8AAAAANeaxph3yjgkpIJITHZVWPoAAAAQ4XcsQxoGY1RTSf35eMmoaU2Lt01gaTE63jPkQGxeWkvz7zdc',
# mode 2
'RlBMWQECAQAAAAA8AAAAAPKmjeIsM+mWHcEmRgyvv/8AAAAQPLQ8J5ikttb6JDKvhiMnKhy0KXTvqQC0D8/g7vTLKP6mgoLM',
# mode 3
'RlBMWQECAQAAAAA8AAAAAN3zvfbLYDrZPRe0ckYxlXcAAAAQgeYGpQr5o7TKIkKljM9O1rlsOKSiBGHwGDNx4BWE+h2Wp3eO',
# extra
'RlBMWQECAQAAAAA8AAAAAIk4saM9xX+1A/Q4om8jC6oAAAAQ7BswlbqPuZ2zeGpJqztrAHvNeOoP7XmIXDHMc0D28LpBPbIZ',
'RlBMWQECAQAAAAA8AAAAAHyfeIHo6BvZeu7CHSxiNl0AAAAQbwiI2NaVgwGhVp39QUnEGOSPbTQNaQnsmjA/qVQ26GMu95P9',
'RlBMWQECAQAAAAA8AAAAAHujE4EerWzeB3lqfXQfzwYAAAAQeNQ6tG/J4ic4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AQ4LMqlv4OLUKRLMcUgumcQKgg4W0vsngK/fGpsC1X3j1nH+ex',
'RlBMWQECAQAAAAA8AAAAAK6R9sgmEA6yPcW/bm5bX+0AAAAQGEOl8e8LETvJD8eNVVswwZEur+ffUs5YvhPgrKiN5qAOhpah',
'RlBMWQECAQAAAAA8AAAAAIjmTgsqA3VwKaeIUhu2e9AAAAAQ6cgKehFnMIsTuTGM1EER0X8aVol3EC8gEbIyfAeyUFdCBUMB',
]
keyMsgHexArray = [
# mode 0 -----------------∨
'46504c590301030000000098008f1a9ca548fdd57560a52926ff399f2eb154d0a7a0fffc997f58e27e00499eb9f310110d019e550e328047aea54308ab71b647041406878af96e06cf74127ae35941dceb58931b5543b39903f9f76a376248ee52e3656b561e1c1a0106ec6608df0ab4f2df528e65db6d622d3892d5b49c6c025606a574f19ebea7d93500bdd69db23333f22edcb3ccf7a6acde7389f2facabfa61b0b50',
# mode 1 -----------------∨
'46504c590301030000000098018f1a9c144a77fb15383f69cf6ba6ae3504582d489a121c644dac40bfb382388d758b294841cbe51bb4feea983f9157a1fb2e57765d1bfc7262053ca6f75c90c82794a43b8d844637aa018c28619a43da6727c7faf81b911a92f317d6ac7a3e1a7b923fe693cffb37317159be8904556862d81ed4f794957dc330b7e681e5a0067f596a0f3f936dd761f5afa2d69ab77938328bb1fcd92e',
# mode 2 -----------------∨
'46504c590301030000000098028f1a9c049ae04d1691802802c75b3ced9204acbeb5482b582f4faf3c008d7dd3675a37967e3bee3079bec95b8bfeea69aaec8233c7ab3b7df283e8f9a50b8ecdcc53e3ee2e5ee1d78421378fdf8cfa1e1c04995d3c6f14b47e9487f3458cc6e4727fe1e3ad2b1db60afdb590c14da5011404ab0972c15ab14ad6a71ebd8cab10098bc1b1822b14dd3e496fe13bfcca8fd399eee52581d4',
# mode 3 -----------------∨
'46504c590301030000000098038f1a9c63b126a2325158ff9ba6e5d9996b33cf4fda80c7bb3492ee15790fa57b5cdf0129fc3d29a2f6fb66ef4494aca148ddff2b726df69de41caf7292a3a960673699430df2eb5742ab52e61d5ef576ffbfb960686c14976dce6c66b07b491b94a41b445152a4449221fc704645fe1d5af60f446c3dbf1030580eb2c0002e387053fc9783d04dfba861da3f1444664737bcc2d82f4a5c',
# extra
'46504c590301030000000098018f1a9c29495ae9d6e3648a357409f2209a1c158c1f39ce8cc85e01071ac7cd9faab49c49c90d5d2eb9bab2848ac6712eaea5df12de1cda35bfa1b9a6d465f231e3588b0555d5bee46ba40f903988e6ac945d7718564de23eca6aa527edde0600568431349243c9569bf047c813675d0c19caca0ca68bd6a7e64e33616b204f2e67459f3494c462549f56d12391126a09b5b5a41486c9b0',
'46504c590301030000000098028f1a9cdf8b2485fcee11ff33f0ee5e2a5a4323641d631e4935f625312c5cf233455e075e5e469d7bc056c7ea127c0dcd14b9acbbf9d36b82f729df8b9436ddc06a617d1d1cb2fb1ed1d6b8a2f3e75a3e946cb96db3fc87397a7c456c60d2db150692e1a2f5aa22d032800cd71f45e0b40013f6d063f29d2ee244ab1a5b51123eee9bce5a6009add24a851ab7c16c8510e9afffef52649a',
'46504c590301030000000098018f1a9c6f35086eb11e63e57957b8668008e91a684f3c7fd21d7dabfbc11e463bba37fc25c0e9e003149894e4a2c31a42caa8bbc0ba0543fc72d195268402e441e0b2953118deaa0fc7361942d145e0359065fcf2f81e325295090b4c548b370c112f5f112e3854b36fdd2924ddf50e9d808b6b8d0dd6e424524de34f038db6559e5f3faeb8ffbf9e4806bfbab8b8015c576194429c7aec',
'46504c590301030000000098018f1a9c67ba6fab74a6e41137ec13540d661f85fbc50f8413dfdddec9af2e68c3136257165a822d3b28f24f7c51acd1b2edd38e7f6abdab966924f4104cfd138a52e4c860a7c5b72762dd386b77a6476acd6f3128c2e44b75900bffb67afeb9ba9401b83a56a1e7b2ad032bd854a054e38738bb8a163002f6670032b55a501c3027c21fc8d42b5b7951f1ea6456a7873a22fe2e184e381b',
'46504c590301030000000098018f1a9c18881cb5d47f6bd3171037556ad2e7e3d7c70d5cb1a3dca450f4358668417bf45429dc6c57ece1061b716715ae856736b4904f729827a68650e59f07cf43cc2c707d374a66fa4d1de635a4cd8d4ca87ea8fb672b4b493b4c5700a7df865d46a2ed3b0714d97b20088b6c605caa47bc8d45ec4a6f90eb1f731a0be9744a02777ecded8131e667db9bab7dc84c2a8879855638f64f',
'46504c590301030000000098008f1a9ca66352fcad37cf98cff8be95eb67fc07d78ea7cdec69285f30db7728254374b0b4875d37837eca8b9fc55663ddb55ccb2cb9800f5537d78f73a542d51017effd0470f32171cbf819680c7b2c695f087d20cb26c1e551b4449569ff09ffa89ff46e2db5cbe7d81df14ab91ada7cac520106a3569cd43a7985bbcc28c637066e6e4b942379f744eed1e661203e0e06a40edf4ffb45',
'46504c590301030000000098018f1a9c9dd7e68de23b32f3f169be4de7f2de6919ce0ae597e910c31bf03467137d7389026ca094af18bef5374380560136a511e67847b7afe2d6dedd3723832c5c6ff3dd90d7a06d06709cb1861c1129940a6bd37c2299eab023e64dc56b758a372d913d70aafe044a6525add22422eca069f68ec0bf53dc780541c65844b9843a24ec567aa3947831c6d0ea91989d39fb97e40f058a48',
'46504c590301030000000098028f1a9c384ed75e69fadd495b3751512e839c2b812e93fb59b18b2cf9ed02453e636c54035b4b75ac2852d284ebcdd74d7fdfdd94063bdf7a8fe3f3371c2057c5e2cd0ca288412bec984256356fdaa76c81fdbc7d48da7e234f4cd4a7008d48f274529e5aae6df5c36c93231b8cb3bcc9d0f7e1b1135b732c9c9a7b58b542193c831ee82a1cbaad029be1bafd052e71341891e3c9aaddea',
'46504c590301030000000098038f1a9c739127c444b13c7982c64ef5b5152d76d297a22816092cbb9f73c38284696e52c79222b83ed116035a5b052f9c0fe12f3666825305cd5392e95e5b45b06557b829dee8b4bbdd2b10092ddcf0bf010c03ad0cc6d2406b2e2253e106358fe0c8edcb8f040506bd3ba17e1be18efa3576d9ccdb759bf27114b031393d3f79d6961f2b43b6a9261d052b2c00bb79b8dac81a90bdb8b1',
'46504c590301030000000098008f1a9c8eea57769ca08100c4c4a42854fbd389b319597801bbee7954f64e2cccfe781733e65f73fa1a7a0cf0c1224160ff5c25e49969f3a81efe2d0f068407e242dc23ef4022a600f5db27b080300602735fb7cfad35c13f6f06d74aa432b359220483973ca8e4eb1fd00c1f4eca462a3ee83a2461ebb695eefd1c590e641055d65ebe4b2e31facb41543f209940a851a91a823799cd04',
'46504c590301030000000098018f1a9cfa235805d532ed9e3e0372715ebc0cb9764efe4d6f34cc1fa3f596e1469a59c9f5550d94a2b6e0740ce59d977f7dd48e29da74708370dc98362d2bd8e697521261f0c35d681265ceb23919faa5384c50b323a03e8a84ec289304972740e252449cdb06b5a0b727aa7eaa0a81c2510005cb2526c878829207b7d43d61947a5e54e6efbe4ac6b5fab3814a745e023eb48bb10ac77f',
'46504c590301030000000098028f1a9c6c0f5700e381dc018d364eba80117b639fb31317c0030575d53b854d4af4b279983058141fc67e82acd74ace7fc976dd8084609a9bb2ddb86e731c609dca2afba038b971be4282b7bf62a96a102560240a413d333dded20b14b723e7e8820bbc90ec630531da1c77ca12583587e43c5abc80faf0c379aee4d57c1e317eba6b4f4beaf85460e4bea20ae4c8e4c25cc7cac61ca3dd',
'46504c590301030000000098028f1a9c56f41aacc969a8b8deb34d81ec5d68649ab6678280ebed1e0240419761b9dee3b261d970065b68ace990fc44fab231783284351f0cc390e3297e575455cc093bd432e107bee3687807258710395bdc3f8db86103add6cb690a581f345b26607bc94710d62e0c3c66b31be2437b107fb54bf7b646276a7f6f456338a163a6d2eee6503e9943646363a3d6d91f1fff7001f240773b',
'46504c590301030000000098008f1a9c170c310e806087794119777cca4f91e26e6f13e88c1ddce46d371a5ab06d2c0acf8b7a2e2d26dde43a753c2af8ad5560ca56a9742be93ed5aee23c0c5c6a936e08ad6417e35b6798defcbf3fd86fb369f758ff17983d0d2732cda58ce7ed5cded4fb5c4decb3ce4c7aa112022ff8bc95af6f040848d514ae953f522635c533d7c02b823817f545039c0456249e70e2a95a48fd07',
'46504c590301030000000098018f1a9c0a1cb485933f9a1ece342077bfdb8224e1303b9ece9d83f8e289e03952be49eaf38ad9382983272f6e3bc261263d63e127a831482fe9ff1c1b35670a30c78f2ecfab1b8e9bd0da8c8eac626595858d8e9557a293fdf8b3ed0cd177656f2bf359847a8ac3f062dd682bbbbb864b9e4d572cb0eeed5321eb4c70d67824bc91f7797fa5722d951e85d8a1c7b8d7e94dfa85b0ec9cbf',
'46504c590301030000000098028f1a9c9322788842e7463d130a4326ee591b3b56240f39380f482853211950ea4a3c6e6284e19149cf66be49814ee3e9bc79dccda4f96b6c6e620a4aff35a0f6dc6d76b6ca3923da667b91409f7251010a8ab1de310d37242028ce711903bd777ecd2c7fe6dfb992623e842db6a61a2d63b432558fb68244e8a629c4a4e281623da7d8028c47f85565b23349e3af865ea192204d94deea',
]
expectedDecryptResults = [
# mode 0 key
'0496a612172f41e0fd71912acc33fc54',
# mode 1
'1512816fbdbe4856570931c3ec7d0e3d',
# mode 2
'bc3b888f894276c7dd43c3739a08947c',
# mode 3
'63082ff46b87d13d8211e048a696d914',
# extra
'2832d44e4dd9f7d3a806562ccd733aba',
'afb47b92476582fa19d5f2bacbb289b9',
'eb096a94a2bd2b2480d470c4a562d9bf',
'b7d8a066bcaed0448601472797a0feb0',
'97935000cfb79f384d996104362c2045',
'70e5d54a36a00f4878eba13604a5f3e5',
'f98a3079b81de696cecca09f18f7ed23',
'7777a0fc7c9b93d230c4f8795c3f3523',
'1b21477ed94e634da07769b696fc3e51',
'671a855130491be5a6c81b2a28a0c466',
'd6364d68cf353b9f74bb9488c7313b73',
'6031fc351232683d60b01cd2108e227e',
'7244f743459404794995317c848e91d9',
'dae8ac01942b80da0712e2873400acc4',
'546d85c2b476236e42f2b4906a438c95',
'7245a3cfeb08e958d4985a19255410ea',
]
print()
for k in range(0, len(keyMsgHexArray), 1):
#
keyMsg = bytes.fromhex(keyMsgHexArray[k])
AESKey = base64.b64decode(s=AESKeyB64Array[k])
decrypted = fairplay3.decryptAESKey(keyMsg, AESKey)
expected = expectedDecryptResults[k]
print(f'Length : {len(decrypted)} bytes')
print(f'Generated: {decrypted.hex()}')
print(f'Expected : {expected}')
print(f'Match : {decrypted.hex() == expected}')
print()