R0rt1z2 / lkpatcher

Streamline tool and module to patch bootloader (LK) images of MTK device(s).
https://lkpatcher.r0rt1z2.com
GNU General Public License v3.0
96 stars 17 forks source link
bootloader mediatek mtk oplus oppo realme unlock

lkpatcher

License GitHub Issues

lkpatcher serves as both a streamlined Python tool and module designed for the alteration and patching of LK (Little Kernel) images. The utility offers flexibility along with an intuitive API for ease of use. To use the library, Python 3.11 or higher is required. An alternative method of access is available via the new web version of the tool, which is not open-source but offers the same functionality and has a GUI.

Installation

sudo apt install python3-pip # If you don't have pip installed.
pip3 install --upgrade pip   # If pip hasn't been updated yet.
pip3 install --upgrade git+https://github.com/R0rt1z2/lkpatcher

[!NOTE] Windows users should omit the first two command(s) and install python manually from here.

Instructions

python3 -m lkpatcher [-h] [-o OUTPUT] [-j JSON] [-d DUMP_PARTITION] bootloader_image

[!NOTE] Arguments between <> are required, while arguments between [] are optional.

You can also use the module in your own projects:

# Import the patcher class from the module. This should be enough to
# get you started, as it provides an API to apply patches to images.
from lkpatcher.patcher import LkPatcher

# Create the patcher object. When initializing the object, you MUST
# specify the path to the image you want to patch, and, optionally,
# the path to the JSON file containing the patches. If you don't
# specify a JSON file, the default one will be used.
patcher = LkPatcher(image='lk.img', patches='patches.json')

# Use the patcher object to apply patches to the image. The output
# parameter is optional, and, if not specified, the patched image
# will be saved as 'lk-patched.img'.
image = patcher.patch(output='lk-patched.bin')

Important notes

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.