Fix device type for WVD and other improvements

- Corrected the device type for WVD
- Fixed device name to integer
- Use pywidevine only
- Renamed JS script
This commit is contained in:
hyugogirubato 2024-05-22 18:33:04 +02:00
parent 28a750cb6d
commit cf09af8025
1 changed files with 7 additions and 6 deletions

View File

@ -9,11 +9,12 @@ import frida
from frida.core import Device, Session, Script from frida.core import Device, Session, Script
from Cryptodome.PublicKey import RSA from Cryptodome.PublicKey import RSA
from extractor.license_protocol_pb2 import SignedMessage, LicenseRequest, ClientIdentification, DrmCertificate, SignedDrmCertificate
from extractor.vendor import Vendor
from pywidevine.device import Device, DeviceTypes from pywidevine.device import Device, DeviceTypes
from pywidevine.license_protocol_pb2 import SignedMessage, LicenseRequest, ClientIdentification, DrmCertificate, SignedDrmCertificate
SCRIPT_PATH = Path(__file__).parent / 'script.js' from extractor.vendor import Vendor
PARENT = Path(__file__).parent
class Cdm: class Cdm:
@ -86,7 +87,7 @@ class Cdm:
""" """
Prepares the Frida hook script, injecting dynamic content like SDK API and selected functions. Prepares the Frida hook script, injecting dynamic content like SDK API and selected functions.
""" """
content = SCRIPT_PATH.read_text(encoding='utf-8') content = (PARENT / 'keydive.js').read_text(encoding='utf-8')
selected = self._select_functions() if self.functions else {} selected = self._select_functions() if self.functions else {}
# Replace placeholders in script template # Replace placeholders in script template
@ -246,7 +247,7 @@ class Cdm:
private_key = self.keys.get(key_id) private_key = self.keys.get(key_id)
if private_key: if private_key:
path = Path() / 'device' / self.device.name / 'private_keys' / str(drm_certificate.system_id) / str(key_id)[:10] path = Path() / 'device' / str(self.device.name) / 'private_keys' / str(drm_certificate.system_id) / str(key_id)[:10]
path.mkdir(parents=True, exist_ok=True) path.mkdir(parents=True, exist_ok=True)
path_client_id = path / 'client_id.bin' path_client_id = path / 'client_id.bin'
path_private_key = path / 'private_key.pem' path_private_key = path / 'private_key.pem'
@ -262,7 +263,7 @@ class Cdm:
Device( Device(
client_id=client_id.SerializeToString(), client_id=client_id.SerializeToString(),
private_key=private_key.exportKey('PEM'), private_key=private_key.exportKey('PEM'),
type_=DeviceTypes['ANDROID'], type_=DeviceTypes.ANDROID,
security_level=3, security_level=3,
flags=None flags=None
).dump(path_wvd) ).dump(path_wvd)