https://github.com/knugihk/pypssh
A lightweight Python tool to extract and base64-encode Widevine and PlayReady PSSH boxes from MP4 init segments. Useful for DRM system diagnostics, media workflow automation, and security testing and research.
https://github.com/knugihk/pypssh
debugging debugging-tool diagnostics drm pentest pentesting playready playready-drm pssh research-tool widevine widevine-drm
Last synced: 17 days ago
JSON representation
A lightweight Python tool to extract and base64-encode Widevine and PlayReady PSSH boxes from MP4 init segments. Useful for DRM system diagnostics, media workflow automation, and security testing and research.
- Host: GitHub
- URL: https://github.com/knugihk/pypssh
- Owner: KnugiHK
- License: mit
- Created: 2025-04-06T11:02:45.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-12-23T07:13:03.000Z (21 days ago)
- Last Synced: 2025-12-24T21:55:55.884Z (19 days ago)
- Topics: debugging, debugging-tool, diagnostics, drm, pentest, pentesting, playready, playready-drm, pssh, research-tool, widevine, widevine-drm
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyPSSH
**PyPSSH** is a lightweight Python tool to extract and base64-encode Widevine and PlayReady PSSH boxes from MP4 init segments. Useful for DRM system diagnostics, media workflow automation, and security testing and research.
## ⚖️ Legal (Read Before Using!)
**PyPSSH** is provided under the [MIT License](LICENSE), which allows you to freely use, modify, and distribute the software. However, by using **PyPSSH**, you acknowledge the following:
### 🛡️ DRM and Copyright Compliance
**PyPSSH** may interact with DRM-protected content and is intended for diagnostic, research, and security testing purposes. It does _not_ provide tools to bypass DRM protections but helps in identifying and handling DRM information in media files. Users are responsible for ensuring their use complies with applicable laws, including DRM and copyright regulations, and should _not_ use **PyPSSH** for circumventing DRM protections or infringing on intellectual property rights.
### ⚠️ No Warranty and Liability
**PyPSSH** is provided "as-is," without warranty of any kind. The authors are not liable for any damages, misuse, or legal consequences arising from its use.
## 🚀 Features
- Extracts Widevine and PlayReady PSSH boxes from MP4 initialization segments.
- Outputs PSSH boxes in base64 encoding for easy use.
- Can be used for debugging DRM workflows or extracting information from encrypted media files.
- Simple and efficient with minimal dependencies.
## 🧰 Usages
### Command Line Usage
To extract Widevine and PlayReady PSSH boxes from an MP4 initialization segment, run the script as follows:
```bash
python3 pypssh.py init.mp4
```
The script will output the base64-encoded PSSH boxes for both Widevine and PlayReady (if present).
### Developer Usage
You can also import the script as a module and use the `extract_pssh()` function to get the PSSH boxes programmatically. Here's an example of how to use the function in your own Python code:
```python
from pypssh import PSSH
import logging
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger(__name__)
# Specify the path to the video initialization segment
video_file_path = '/path/to/video_init.mp4' # Replace with the actual path
# Parse the PSSH data from the file
pssh = PSSH.parse(video_file_path)
logger.info("Extracted PSSH Data:")
logger.info("--------------------")
# Extract and log Widevine & PlayReady PSSH base64 data if available
widevine_b64 = pssh.get_widevine_b64()
playready_b64 = pssh.get_playready_b64()
if widevine_b64:
logger.info(f"Widevine PSSH: {widevine_b64}")
else:
logger.info("No Widevine PSSH found")
if playready_b64:
logger.info(f"PlayReady PSSH: {playready_b64}")
else:
logger.info("No PlayReady PSSH found")
```