From cf09af80251f5d34869b73cc3c278eb34cdf36f7 Mon Sep 17 00:00:00 2001 From: hyugogirubato <65763543+hyugogirubato@users.noreply.github.com> Date: Wed, 22 May 2024 18:33:04 +0200 Subject: [PATCH] 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 --- extractor/cdm.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extractor/cdm.py b/extractor/cdm.py index dd4a11d..4529659 100644 --- a/extractor/cdm.py +++ b/extractor/cdm.py @@ -9,11 +9,12 @@ import frida from frida.core import Device, Session, Script 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.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: @@ -86,7 +87,7 @@ class Cdm: """ 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 {} # Replace placeholders in script template @@ -246,7 +247,7 @@ class Cdm: private_key = self.keys.get(key_id) 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_client_id = path / 'client_id.bin' path_private_key = path / 'private_key.pem' @@ -262,7 +263,7 @@ class Cdm: Device( client_id=client_id.SerializeToString(), private_key=private_key.exportKey('PEM'), - type_=DeviceTypes['ANDROID'], + type_=DeviceTypes.ANDROID, security_level=3, flags=None ).dump(path_wvd)