Extract Payload.Bin And Get Stock Boot Image File
In this tutorial, we will show you how to extract the payload.bin file so that you can get the stock boot image (boot.img) and other firmware files. A single zip file was used to contain all the stock firmware files provided by OEMs earlier. After you extract that stock firmware ZIP, all the necessary files will appear in front of you. While some OEMs still follow this rule, others like the OnePlus don’t. It might cause quite a bit of trouble for quite a few users here.
It turns out that all the important stock firmware files are now included in the payload.bin file. A file such as this cannot simply be extracted using WinZip, WinRAR, etc. It requires a specific set of applications, such as the Payload Dumper Tool and Python. Both of these tools will not be of any use if they are simply installed. When you want to extract payload.bin’s contents, there are a few steps involved. It will be helpful to have this guide on hand in this regard.
In this tutorial, we will show you how to extract the payload.bin and get the stock boot image and other important partition files. We must also understand why performing the aforementioned task might be necessary before we proceed. We will first discuss the need (importance) to () extract this payload.bin file in the following section. In the next part, we will discuss how to obtain the stock boot.img file using Payload Dumper and Python. Keep up with us.
The Need to Extract payload.bin File using PC
As a starting point, Payload.bin contains three of the most important partition files – system.img, boot.img, and vendor.img. It is possible that your system.img file needs to be flashed after returning from a GSI to stock ROM
There are many users out there who might be interested in the boot.img file. Seeing as Android is an open-source ecosystem, there are countless customizations to try out. It is possible to gain administrative-level privileges through root access at the top of the list. To root your device, there are two different methods: using TWRP or without TWRP.
The latter method is currently preferred by many users. There are a lot of Android devices that do not work with TWRP Recovery. The first prerequisite to rooting without TWRP is to get your hands on the device’s stock boot.img file. By patching it via Magisk and flashing it via fastboot commands, it can be easily done.
The OEM, however, combines all these files (including boot.img) inside the payload.bin file. As a result, in order to root your device, you will need to extract the payload.bin file. The best method to resolve this issue would be to install the Payload Dumper Tool on your PC along with Python. You can get the stock boot image file by extracting payload.bin. Here are the complete instructions.
Method 1: Using Payload Dumper to extract the payload.bin file
Ensure that all the necessary tools are downloaded by reading the requirements section. The rest of the steps can be completed once that has been completed. In order to simplify the instruction steps, we have divided them into separate sections.
In order to begin, you will need the payload.bin file. If you have stock firmware for your device, you might be able to find it there. On their official pages, many OEMs upload the same images, such as the OnePlus Download and Update page or the Google Factory Image page. Get the payload.bin file by downloading the firmware, extracting it with WinZip, WinRAR or 7ZIP, and then extracting it again.
Payload Dumper Tool is required for extracting the Payload.bin file. Gregory Montoir created this tool, and we would like to thank him. The payload_dumper.zip file can be downloaded from this link: payload_dumper.zip
The same applies to installing Python on your computer. You can download Python v3.8.5 (the latest version at the time of this writing).
STEP 1: Install Python on your PC
Run the Python installation file by clicking on the EXE file. Once the installation directory has been selected, it will ask for it. The default option would make following this guide easier, so click Install Now if you wish to use it. In case you want to change the installation directory, click Customize Installation.
No matter what installation directory you choose, keep it handy because you’ll need it later. Within a minute or two, the installation process will be complete. In order to exit the setup wizard, hit the Close button once that has been completed.
STEP 2: Install The Payload Dumper File
The Payload.bin file, which contains the stock boot image, can be extracted now that Python has been installed. Our tool of choice for doing so will be the Payload Dumper Tool. You can do that by following these steps:
- Make sure that the Payload Dumper Tool is extracted into the same folder as the Python file you have extracted.
- When installing Python, the default directory should be chosen, and the contents should be extracted there:
C:\Users\USER-NAME\AppData\Local\Programs\Python\Python <version number>
STEP 3: Extract Payload.Bin
After installing Python, copy the payload.bin file from the ROM to the folder where you have placed it.
Therefore, this directory now contains the Payload Dumper Tool, payload.bin, and Python.
- CMD can also be found in the same folder if you type it in the address bar and hit Enter. You will be prompted to launch the Command Prompt.
- To install the necessary dependencies, type the following command
python -m pip install -r requirements.txt
- Finally, run the below command to extract all the contents of the payload.bin file. It will take some time to download the package, depending on its size.
python payload_dumper.py payload.bin
- As a result of the payload.bin file, we received three files: boot, system, and vendor. Dtbo and a couple of other files may also be included in some cases. There is no problem with that. As well as that, we will show you how to handle it.
- As for the outcome of the process, once the extraction is complete, all the extracted files should be placed in a folder named Output. The output folder will be located in the following location if Python is installed in the default directory:
The following steps will guide you through the process of extracting the payload.bin file and obtaining the stock boot.img file. Now let’s see how this could be accomplished directly on an Android device, without a PC.
METHOD 2: Extract Payload.bin Directly on Android Without a PC
To make it easier for you to understand, we have divided the instructions into separate sections. The steps should be followed in the exact same order as described. By following these steps, AMS and its members won’t be held liable for thermonuclear war, your alarm not waking you up, or anything that may happen to your device and data.
STEP 1: Setup Payload Dumper Tool
The first step is to download the Payload Dumper Tool to your device.
Extraction should be performed at the root of the Internal Storage, not within any folder.
STEP 2: Get the Payload.Bin File
You can now download the ROM/firmware of your choice and extract the payload.bin file from it. There might be a filename.zip.jar extension attached to the OnePlus firmware you downloaded.
Ensure that the filename.zip is renamed and that the JAR is removed at the end. After extracting this ZIP firmware, you will gain access to the payload.bin file.
- Once you have downloaded the payload.bin file, place it in the same location where you extracted the Payload Dumper Tool.
STEP 3: Setup Python on Android
- Termux App can now be downloaded and installed on your device.
- Execute the following four commands after launching the app.
- Hit Enter after typing the first command, followed by the next command, and so forth.
- In this process, it might ask you to install additional dependencies, in which case type Y and press Enter.
pkg install python -y pip install --upgrade pip pip install protobuf apt update && apt upgrade -y
STEP 4: Grant Storage Permission
Termux now has access to your storage after you grant permission via the below command. You may receive a warning from termux stating that “the storage partition will be wiped but no storage contents will be affected”. You must type Y and then hit Enter. It won’t affect your data, so don’t worry. Also, I have personally tested it on my own device and no data loss occurred.
STEP 5: Change Termux Directory to Payload.Bin File
Now you will need to change Termux’s directory to the folder where the payload.bin file is located. In our case, it’s the payload_dumper folder within Internal Storage (where you’d get it after extracting the Payload Dumper Tool). In any case, you can change the directory with the following command:
STEP 6: Extract payload.bin on Android
You can also extract the payload.bin file directly from your Android device by executing the following command:
python payload_dumper.py payload.bin
In the payload_dumper folder, you will find all the partition files after the extraction has been completed.
METHOD 3: Extract Payload.bin via Payload Dumper Go
- Start by downloading payload-dumper-go 1.0.0 from GitHub [Credits: XDA Member ssssut].
- Once the file has been downloaded, you can extract it anywhere on your computer. Filenames will be something like payload-dumper-go_1.0.0_windows_amd64. Give it a new name: payload-dumper-go.
- The next step is to download the liblzma-5.dll file and copy it to the same folder as the payload-dumper-go.exe file.
- Once that has been done, transfer payload.bin to this folder as well.
- It should now be possible for you to find all the files, liblzma-5.dll, payload.bin, and payload-dumper-go.exe, in one folder.
- Then type CMD into the address bar of that folder, and hit Enter. Upon clicking this, you will be prompted to open the Command Prompt.
- You can extract the payload.bin file by typing the following command:
- Now, you can start the extraction process which will only take a few seconds.
As soon as the extraction process is complete, all the extracted files will be placed in a folder named extracted_date_time.
It’s all done. Using the Payload dumper tool and Python, you have successfully extracted the payload.bin file and obtained the stock boot image. In the same vein, we have also shared the steps to follow via the Payload Go Tool, which, at the moment, seems to be the best method.
The steps below are also for those who would like to do so directly on their devices without using a computer. Transfer the stock boot.img file over to your device and then follow our instructions to patch it via magisk and flash it via fastboot. We would be glad to answer any questions you might have regarding either of the two aforementioned steps.