Update license CLI command for Cdm changes

This commit is contained in:
rlaphoenix 2022-07-30 04:47:25 +01:00
parent 3536caf5f9
commit c7ec596031
1 changed files with 16 additions and 7 deletions

View File

@ -69,10 +69,14 @@ def license_(device: Path, pssh: str, server: str, type_: str, privacy: bool):
log.debug(device) log.debug(device)
# load cdm # load cdm
cdm = Cdm(device, pssh) cdm = Cdm(device)
log.info(f"[+] Loaded CDM with PSSH: {pssh}") log.info(f"[+] Loaded CDM")
log.debug(cdm) log.debug(cdm)
# open cdm session
session_id = cdm.open()
log.info(f"[+] Opened CDM Session: {session_id.hex()}")
if privacy: if privacy:
# get service cert for license server via cert challenge # get service cert for license server via cert challenge
service_cert = requests.post( service_cert = requests.post(
@ -83,13 +87,13 @@ def license_(device: Path, pssh: str, server: str, type_: str, privacy: bool):
log.error(f"[-] Failed to get Service Privacy Certificate: [{service_cert.status_code}] {service_cert.text}") log.error(f"[-] Failed to get Service Privacy Certificate: [{service_cert.status_code}] {service_cert.text}")
return return
service_cert = service_cert.content service_cert = service_cert.content
cdm.set_service_certificate(service_cert) provider_id = cdm.set_service_certificate(session_id, service_cert)
log.info("[+] Set Service Privacy Certificate") log.info(f"[+] Set Service Privacy Certificate: {provider_id}")
log.debug(service_cert) log.debug(service_cert)
# get license challenge # get license challenge
license_type = LicenseType.Value(type_) license_type = LicenseType.Value(type_)
challenge = cdm.get_license_challenge(license_type, privacy_mode=True) challenge = cdm.get_license_challenge(session_id, pssh, license_type, privacy_mode=True)
log.info("[+] Created License Request Message (Challenge)") log.info("[+] Created License Request Message (Challenge)")
log.debug(challenge) log.debug(challenge)
@ -106,13 +110,18 @@ def license_(device: Path, pssh: str, server: str, type_: str, privacy: bool):
log.debug(licence) log.debug(licence)
# parse license challenge # parse license challenge
keys = cdm.parse_license(licence) cdm.parse_license(session_id, licence)
log.info("[+] License Parsed Successfully") log.info("[+] License Parsed Successfully")
# print keys # print keys
for key in keys: # Note: This showcases how insecure a Python CDM implementation is
# The keys should not be given to the user, but we cannot prevent this
for key in cdm._sessions[session_id].keys:
log.info(f"[{key.type}] {key.kid.hex}:{key.key.hex()}") log.info(f"[{key.type}] {key.kid.hex}:{key.key.hex()}")
# close session, disposes of session data
cdm.close(session_id)
@main.command() @main.command()
@click.argument("device", type=Path) @click.argument("device", type=Path)