Skip to main content

pymonalisa - A Python library to decrypt IQIYI DRM License Ticket

Project description

pymonalisa

A Python library to decrypt IQIYI DRM License Ticket using the MonaLisa Content Decryption Module.

Installation

pip install pymonalisa

Run pymonalisa --help to view available CLI functions.

Devices

To use pymonalisa, you need a MonaLisa device file (.mld). These device files load the WASM module required to process IQIYI DRM License Tickets correctly.

License Processing

Process a MonaLisa encoded license and extract decryption keys:

pymonalisa license "AAAADgMwAADECisAAAdoS7HZAQEASDVEQ0lELVYzLVAxLTIwMjUwNTE5LTE0NDM1Mi1NRDc0N0RBNS0xNzQ0NjQ0OTk3LUExMTJERwEQcMHbn2aue/wLGYFpS2aNngMCADhAACCzbv21P1LuugXC34EhhYOfBQm1K7vNBcxClOM9nTS50AIQxPPew5UYQhKhOg3UrJqXLQQBAwMDADkBADCvjimPScsXNIyb9HxbzkHRB7Bhv3J8Pvpgm54TFhIKSwH32SedaLf7dJ6PRExsjyoBAQECASADBAA4QAAgIreHYYp2nI86fJDaAxR6CJyvM1h+OKXATIn9aj43O2ADEIDB259mrnv8CxmBaUtmjZ4EAQMEBQATARBwwdufZq57/AsZgWlLZo2eAP8GADQBEIDB259mrnv8CxmBaUtmjZ4AIM11WGlDSqV01Aw8PkaTUEgYPVduGGQpxMTnWbNx7qpP" device.mld

Options

  • -t, --key-type: Filter keys by type (CONTENT or FULL). Default: FULL
  • -v, --version: Print version information

Usage

An example code snippet:

from pymonalisa.cdm import Cdm
from pymonalisa.module import Module
from pymonalisa.license import License
from pymonalisa.types import KeyType

# Load the MonaLisa device module
module = Module.load("path/to/device.mld")

# Initialize CDM from module
cdm = Cdm.from_module(module)

# Open a new session
session_id = cdm.open()

# Create license object from base64 encoded license data
license_data = "AAAADgMwAADECisAAAdoS7HZAQEASDVEQ0lELVYzLVAxLTIwMjUwNTE5LTE0NDM1Mi1NRDc0N0RBNS0xNzQ0NjQ0OTk3LUExMTJERwEQcMHbn2aue/wLGYFpS2aNngMCADhAACCzbv21P1LuugXC34EhhYOfBQm1K7vNBcxClOM9nTS50AIQxPPew5UYQhKhOg3UrJqXLQQBAwMDADkBADCvjimPScsXNIyb9HxbzkHRB7Bhv3J8Pvpgm54TFhIKSwH32SedaLf7dJ6PRExsjyoBAQECASADBAA4QAAgIreHYYp2nI86fJDaAxR6CJyvM1h+OKXATIn9aj43O2ADEIDB259mrnv8CxmBaUtmjZ4EAQMEBQATARBwwdufZq57/AsZgWlLZo2eAP8GADQBEIDB259mrnv8CxmBaUtmjZ4AIM11WGlDSqV01Aw8PkaTUEgYPVduGGQpxMTnWbNx7qpP"
license_obj = License(license_data)

# Parse the license
cdm.parse_license(session_id, license_obj)

# Get content keys
keys = cdm.get_keys(session_id, KeyType.CONTENT)

# Print extracted keys
for key in keys:
    print(f"{key.key.hex()}")  # Content key only
    # or for full key info:
    # print(f"{key.kid.hex()}:{key.key.hex()}")

# Close the session
cdm.close(session_id)

Key Types

  • CONTENT: Returns only the content decryption KEY
  • FULL: Returns both Key ID and content key in KID:KEY format

Notes

  • This implementation is designed specifically for IQIYI DRM content
  • The library currently focuses on content key extraction for decrypting IQIYI BBTS streams
  • LicenseVersion 3 and below are supported
  • Keys are typically returned in hexadecimal format

TODO

  • Add support for LicenseVersion up to 3

Credits

Thanks to xhlove and duck.

License

This project is intended for educational and research purposes only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymonalisa-0.1.2.tar.gz (18.5 kB view details)

Uploaded Source

File details

Details for the file pymonalisa-0.1.2.tar.gz.

File metadata

  • Download URL: pymonalisa-0.1.2.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for pymonalisa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ff76fe05adebfede07a3c242fe7fce1bd8d121d571def5cca898737eccf28f23
MD5 63e57c578fdb5455c7d3426a148f0acc
BLAKE2b-256 86539b0c0a8100fdbd0a2e838cbe408c55817334f1a59e85e242f50a765f2bab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page