forked from WKS-uwu/WKS-KEY
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathl3.py
78 lines (66 loc) · 2.89 KB
/
l3.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
# -*- coding: utf-8 -*-
# Module: KEYS-L3
# Created on: 11-10-2021
# Authors: -∞WKS∞-
# Version: 1.1.0
import base64, requests, sys, xmltodict
import headers
import cookies
import json
from cdm import cdm, deviceconfig
from base64 import b64encode
from getPSSH import get_pssh
from wvdecryptcustom import WvDecrypt
from cdm.formats import wv_proto2_pb2 as wv_proto2
import logging
logging.basicConfig(level=logging.DEBUG)
MDP_URL = input('\nInput MPD URL: ')
# lic_url = input('License URL: ')
# hardcoded for kinopoisk.ru
lic_url = 'https://widevine-proxy.ott.yandex.ru/proxy'
pssh = get_pssh(MDP_URL)
# pssh = 'AAAAZXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAEUIARIQy8Z1jMAZRKm1xt0uRD4eRhoNd2lkZXZpbmVfdGVzdCIgNDMxNTA4MjQ4OWQ4NzY3N2IyMWY3YzgzNTkzZmNiNzM='
# pssh = 'AAAAZXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAEUIARIQy8Z1jMAZRKm1xt0uRD4eRhoNd2lkZXZpbmVfdGVzdCIgNDMxNTA4MjQ4OWQ4NzY3N2IyMWY3YzgzNTkzZmNiNzM='
# params from mdp_url:
# ottsession=5945048d6f844d1699054cc5d44548f1&
# puid=339572866&
# video_content_id=4315082489d87677b21f7c83593fcb73&
print(f'{chr(10)}PSSH obtained.\n{pssh}')
def WV_Function(pssh, lic_url, cert_b64=None):
"""main func, emulates license request and then decrypt obtained license
fileds that changes every new request is signature, expirationTimestamp, watchSessionId, puid, and rawLicenseRequestBase64 """
wvdecrypt = WvDecrypt(init_data_b64=pssh, cert_data_b64=cert_b64, device=deviceconfig.device_android_generic)
# widevine_license = requests.post(url=lic_url, data=wvdecrypt.get_challenge(), headers=headers.headers)
request = b64encode(wvdecrypt.get_challenge())
signature = cdm.hash_object
widevine_license = requests.post(url=lic_url, headers=headers.headers,
json={
"rawLicenseRequestBase64": str(request, "utf-8" ),
# "rawLicenseRequestBase64": "CAQ=",
"puid": '339572866',
# "watchSessionId": str(cdm.sessionIdTest),
"watchSessionId": '2f3b9d88f052449ab6dfa8be60f58e6d',
"contentId": '4315082489d87677b21f7c83593fcb73',
"contentTypeId": '21',
"serviceName": 'ott-kp',
"productId": '2',
"monetizationModel": 'SVOD',
"expirationTimestamp": '1638945824',
"verificationRequired": 'true',
"signature": str(signature),
# "signature":'b6ca3161c8bd38105e87770458aee16191214cfa', That is fucking amazon aws signing protocol!! V4!!
"version": 'V4'
}
)
print(f'{chr(10)}widevine_license: {str(signature)}{chr(10)}')
print(f'{chr(10)}widevine_license: {widevine_license.content}{chr(10)}')
license_b64 = b64encode(widevine_license.content)
# license_b64 = json.loads(widevine_license.content.decode())['license']
wvdecrypt.update_license(license_b64)
Correct, keyswvdecrypt = wvdecrypt.start_process()
if Correct:
return Correct, keyswvdecrypt
correct, keys = WV_Function(pssh, lic_url)
print()
for key in keys:
print('--key ' + key)