KeyDive/README.md

119 lines
6.3 KiB
Markdown
Raw Permalink Normal View History

2024-03-30 19:03:15 +00:00
# KeyDive: Widevine L3 Extractor for Android
2024-07-06 18:01:47 +00:00
KeyDive is a sophisticated Python script designed for precise extraction of Widevine L3 DRM (Digital Rights Management) keys from Android devices. This tool leverages the capabilities of the Widevine CDM (Content Decryption Module) to facilitate the recovery of DRM keys, enabling a deeper understanding and analysis of the Widevine L3 DRM implementation across various Android SDK versions.
2024-03-30 19:03:15 +00:00
2024-07-12 10:12:31 +00:00
> [!IMPORTANT]
> Support for OEM API 18+ (SDK > 33) requires the use of functions extracted from Ghidra.
2024-03-30 19:03:15 +00:00
## Features
2024-07-12 10:12:31 +00:00
- 🚀 Seamless Installation via [pip](#installation)
- 🔄 Automated extraction of Widevine L3 DRM keys.
- 📱 Compatibility with a wide range of Android versions (SDK > 22), ensuring broad applicability.
2024-07-12 10:13:02 +00:00
- 💾 Seamless extraction process, yielding essential DRM components.
2024-07-12 10:12:31 +00:00
- 🌐 Offline extraction mode for environments without internet access.
- 🖥️ Command-line options for flexible usage.
- 🛠️ Support for custom functions extracted from Widevine libraries using Ghidra.
- ❤️ Fully Open-Source! Pull Requests Welcome
2024-03-30 19:03:15 +00:00
## Prerequisites
Before you begin, ensure you have the following prerequisites in place:
2024-07-06 18:01:47 +00:00
1. **ADB (Android Debug Bridge):** Make sure to install [ADB](https://github.com/hyugogirubato/KeyDive/blob/main/docs/PACKAGE.md#adb-android-debug-bridge) and include it in your system's PATH environment variable for easy command-line access.
2024-03-30 19:03:15 +00:00
2. **Frida-Server:** Install `frida-server` on your target Android device. This requires root access on the device. For installation instructions and downloads, visit the [official Frida documentation](https://frida.re/docs/installation/).
## Installation
Follow these steps to set up KeyDive:
1. Ensure all prerequisites are met (see above).
2024-07-06 18:01:47 +00:00
2. Install KeyDive from PyPI using Poetry:
```shell
pip install keydive
```
2024-03-30 19:03:15 +00:00
## Usage
2024-04-01 11:10:21 +00:00
1. Play a DRM-protected video on the target device.
2. Launch the KeyDive script.
3. Reload the DRM-protected video on your device.
4. The script will automatically extract the Widevine L3 keys, saving them as follows:
2024-07-12 10:12:31 +00:00
- `client_id.bin` - This file contains device identification information.
- `private_key.pem` - This file contains the RSA private key for decryption.
2024-04-01 11:10:21 +00:00
This sequence ensures that the DRM-protected content is active and ready for key extraction by the time the KeyDive script is initiated, optimizing the extraction process.
2024-03-30 19:03:15 +00:00
### Command-Line Options
2024-03-31 13:27:10 +00:00
```shell
2024-07-07 08:06:46 +00:00
usage: keydive [-h] [-d <id>] [-v] [-l <dir>] [--delay <delay>] [--version] [-a] [-c <file>] [-w] [-o <dir>] [-f <file>]
2024-03-30 19:03:15 +00:00
Extract Widevine L3 keys from an Android device.
options:
-h, --help show this help message and exit
2024-07-06 18:01:47 +00:00
Global options:
-d <id>, --device <id>
Specify the target Android device ID to connect with via ADB.
-v, --verbose Enable verbose logging for detailed debug output.
-l <dir>, --log <dir>
Directory to store log files.
--delay <delay> Delay (in seconds) between process checks in the watcher.
--version Display KeyDive version information.
Cdm options:
-a, --auto Automatically open Bitmovin's demo.
-c <file>, --challenge <file>
Path to unencrypted challenge for extracting client ID.
2024-07-06 19:17:00 +00:00
-w, --wvd Generate a pywidevine WVD device file.
2024-07-06 18:01:47 +00:00
-o <dir>, --output <dir>
Output directory path for extracted data.
-f <file>, --functions <file>
Path to Ghidra XML functions file.
2024-03-30 19:03:15 +00:00
```
2024-07-12 10:12:31 +00:00
## Advanced Usage
2024-03-31 13:27:10 +00:00
2024-07-12 10:12:31 +00:00
### Extracting Functions
2024-03-31 13:27:10 +00:00
2024-07-12 10:12:31 +00:00
For advanced users looking to use custom functions with KeyDive, a comprehensive guide on extracting functions from Widevine libraries using Ghidra is available. Please refer to our [Functions Extraction Guide](https://github.com/hyugogirubato/KeyDive/blob/main/docs/FUNCTIONS.md) for detailed instructions.
2024-03-30 19:03:15 +00:00
2024-07-12 10:12:31 +00:00
### Offline Extraction
KeyDive supports offline extraction mode for situations without internet access. This mode allows you to extract DRM keys directly from your Android device. Ensure all necessary dependencies are installed and follow the detailed [Offline Mode Guide](https://github.com/hyugogirubato/KeyDive/blob/main/docs/Axinom/OFFLINE.md) for step-by-step instructions.
### Obtaining Unencrypted Challenge Data
2024-07-12 10:19:06 +00:00
> [!NOTE]
> Usage of unencrypted challenge is not required by default. It is only necessary when the script cannot extract the client id.
2024-07-12 10:12:31 +00:00
To extract the unencrypted challenge data required for KeyDive's advanced features, follow the steps outlined in our [Challenge Extraction Guide](https://github.com/hyugogirubato/KeyDive/blob/main/docs/CHALLENGE.md). This data is crucial for analyzing DRM-protected content and enhancing your DRM key extraction capabilities.
2024-03-30 19:03:15 +00:00
2024-07-12 10:12:31 +00:00
### Temporary Disabling L1 for L3 Extraction
2024-03-30 19:03:15 +00:00
2024-07-12 10:19:06 +00:00
> [!WARNING]
2024-07-12 10:12:31 +00:00
> Usage of the module is now deprecated because the deactivation of the library was natively added.
Some manufacturers (e.g., Xiaomi) allow the use of L1 keyboxes even after unlocking the bootloader. In such cases, it's necessary to install a Magisk module called [liboemcrypto-disabler](https://github.com/hyugogirubato/KeyDive/blob/main/docs/PACKAGE.md#liboemcrypto-disabler) to temporarily disable L1, thereby facilitating L3 key extraction.
2024-03-30 19:03:15 +00:00
## Disclaimer
KeyDive is intended for educational and research purposes only. The use of this tool in unauthorized testing of protected content is strictly prohibited. Please ensure you have permission before proceeding with DRM key extraction.
2024-07-12 10:12:31 +00:00
## Contributors
<a href="https://github.com/hyugogirubato"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/65763543?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="hyugogirubato"/></a>
<a href="https://github.com/FoxRefire"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/155989196?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="FoxRefire"/></a>
<a href="https://github.com/azimabid00"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/110490898?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="azimabid00"/></a>
## Licensing
This software is licensed under the terms of [MIT License](https://github.com/hyugogirubato/KeyDive/blob/main/LICENSE).
You can find a copy of the license in the LICENSE file in the root folder.
* * *
2024-07-12 10:22:14 +00:00
© hyugogirubato 2024