Skip to main content

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.

Metadata

Release files for pymonalisa 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymonalisa 0.1.2
File Size Uploaded
pymonalisa-0.1.2.tar.gz 18.5 kB Details

Release files / pymonalisa-0.1.2.tar.gz

Download URL pymonalisa-0.1.2.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ff76fe05adebfede07a3c242fe7fce1bd8d121d571def5cca898737eccf28f23
BLAKE2b-256 checksum
How to use checksums
86539b0c0a8100fdbd0a2e838cbe408c55817334f1a59e85e242f50a765f2bab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page