In this tutorial, we will show you how to extract the payload.bin file so that you may get the stock boot image (boot.img) and other firmware files. Earlier, the OEMs used to provide all the stock firmware files inside a single zip file. All you had to do is just extract that stock firmware ZIP and all the necessary files will be right in front of you. While some OEMs still follow this rule, others like the OnePlus don’t. And this is where it might issue trouble for quite a lot of users. Don’t Miss: How to Extract OZIP Realme Stock ROM (Firmware)
The thing is all the important stock firmware files are now bundled inside the payload.bin file. This file cannot be simply extracted using WinZip or WinRAR, etc. They require a specific set of applications in the form of the Payload Dumper Tool and Python. But simply installing both of these tools wouldn’t do any good. There are quite a few steps involved if you wish to extract the contents of the payload.bin file. And in this regard, this guide will come in handy.
Today, we will show you how to extract the payload.bin and get the stock boot image and other important partition files. But before we do so, it is also important to understand why you might need to carry out the aforementioned task. In the below section, we will first discuss the need (importance) to (of) extract this payload.bin file. After which the steps to get hold of the stock boot.img file via Payload Dumper and Python will be mentioned. Follow along.
NOTE: METHODS 1, 3, AND 4 HAVE VIDEO GUIDES AS WELL, SO DON’T FORGET TO CHECK OUT THE VIDEOS!
Table of Contents
The Need to Extract payload.bin File using PC
To begin with, Payload.bin holds three of the most important partition files- system.img, boot.img, and vendor.img. After coming back from a GSI to stock ROM, you might need to flash the system.img file (Read: How to Go Back to Stock ROM from GSI ROM). Vendor image, on the other hand, contains device-specific hardware drivers.
But it is the boot.img file that might be of interest to a lot of users out there. You see, with an open-source ecosystem like Android, there are a plethora of customizations to try out. Right at the top is the ability o gain administrative-level privileges in the form of the root. And to root your device, there exist two different methods: using TWRP and without TWRP.
As of now, many users prefer to go with the latter method. This is because there is no working TWRP Recovery for a lot of Android devices. Hence if you wish to root without TWRP, the first prerequisite is to get your hands on the device’s stock boot.img file. Once that is done, you could easily patch it via Magisk and then flash it via fastboot commands.
However, as mentioned before, OEM now compiles all these files (including boot.img) inside the payload.bin file. So to root your device, you will anyways have to extract the payload.bin file. In this regard, the best way out is to use the Payload Dumper Tool and Python installed on your PC. Here are the complete instructions set to extract payload.bin and get the stock boot image file.
METHOD 1: Via Fastboot Enhance Tool
Thsui is the easiest and most recommended method of extracting the boot.img. This is because you don’t need to execute any commands, the entire process will be carried out via an application with an easy-to-use GUI. Moroever, you don’t even need to extract the entire payload.bin, you could simply extract the boot.img from the payload and get the job done, thereby saving your valuable time and resource. So do check out our below-linked guide to carry out this task:
METHOD 2: Extract payload.bin File via Payload Dumper
Please go through the requirements section and make sure to download all the necessary tools. Once that is done, you may proceed with the steps. We have broken down the instruction steps into separate sections for ease of understanding.
- To begin with, you will need the payload.bin file. You could get it from the stock firmware for your device. Many OEMs upload the same on their official pages, such as the OnePlus Download and Update page or Google Factory Image page. So just download the firmware, extract it via WinZIP, WinRAR or 7ZIP and get hold of the payload.bin file.
- Now, for extracting the Payload.bin file, you need a Payload Dumper Tool. We would like to thank Gregory Montoir for creating this tool. You could download it from the following link: payload_dumper.zip
- Likewise, you should also have to install Python on your PC. Download Python v3.8.5 (latest version at the time of writing).
STEP 1: Install Python on your PC
- Launch the Python EXE setup file. It will then ask for the installation directory. Click on Install Now if you wish to proceed with the default one, which would make it easier for you to follow this guide. Or you could also click Customize Installation if you want to change the directory.
- Whatever installation directory you end up choosing, make sure to keep a note of it as it will be needed later on. The installation process will be completed within a minute or two. When that is done, hit the Close button to exit the setup wizard.
STEP 2: Install Payload Dumper file
Now that you have installed Python, you could proceed with the extraction of the Payload.bin file and then get the stock boot image file. For that, we will be making use of the Payload Dumper Tool. Follow the below steps for that:
- Extract all the contents of the Payload Dumper Tool inside the folder where you have extracted Python.
- If you have chosen the default directory while installing Python, then the contents should be extracted inside:
C:\Users\USER-NAME\AppData\Local\Programs\Python\Python <version number>
STEP 3: Extract Payload.Bin
- Now copy the payload.bin file from the ROM and move it to the folder where you have installed Python.
- Hence, this directory will now have the Payload Dumper Tool, the payload.bin file, and the Python software.
- Inside the same folder, type in CMD in the address bar and hit Enter. This will launch the Command Prompt.
- Type in the below command to install the necessary dependencies:
python -m pip install -r requirements.txt
- Finally, execute the below command to extract all the contents of the payload.bin file. It will take some time, depending on the size of the package.
python payload_dumper.py payload.bin
- In our case, the payload.bin file gave us three files: boot, system, and vendor. In some cases, you could also get dtbo, and a couple of other files as well. That is not an issue. We will show you how to deal with that as well.
- Anyways, moving on, once the process is complete, all the extracted files be placed in a folder named Output. If you have installed python in the default directory, then the location of the output folder will be:
So these were the steps to extract the payload.bin file and get the stock boot.img. Let’s now check out how this could be done directly on your Android device, without using a PC.
METHOD 3: Extract Payload.bin Directly on Android Without PC
The below instructions are listed under separate sections for ease of understanding. Make sure to follow in the exact same sequence as mentioned. Droidwin and its members wouldn’t be held responsible in case of a thermonuclear war, your alarm doesn’t wake you up, or if anything happens to your device and data by performing the below steps.
STEP 1: Setup Payload Dumper Tool
- To begin with, download the Payload Dumper Tool on your device.
- Then extract it to the root of the Internal Storage, i.e. not inside any folder.
STEP 2: Get the Payload.Bin File
- Now download the ROM/firmware of your choice and extract the payload.bin file from it. If you have downloaded the OnePlus firmware, then it might be in a filename.zip.jar extension.
- You need to rename it and remove the JAR at the end so that it becomes filename.zip. Now extract this ZIP firmware and you will get the payload.bin file.
- Once you have got the payload.bin file, transfer it to the same folder where you have extracted the Payload Dumper Tool.
STEP 3: Setup Python on Android
- Next up, download and install the Termux App on your device.
- Then launch the app and execute the below four commands. Type in the first command, hit Enter, type in the next command, and so on. While you do so, it might ask you to install additional dependencies, make sure to type in Y and hit Enter.
pkg install python -y pip install --upgrade pip pip install protobuf apt update && apt upgrade -y
STEP 4: Grant Storage Permission
After this, grant the storage permission to Termux via the below command. You might get a warning from termux that “storage partition is going to be wiped but no storage contents will be touched”. You need to type in Y and hit Enter. Don’t worry, you wouldn’t lose any data. I have personally tried it on my device as well and there was no data loss.
STEP 5: Change Termux Directory to Payload.Bin File
You will now have to change the Termux’s directory to the folder where you have placed the payload.bin file. In our case, that is the Internal Storage’s payload_dumper folder (this folder you would have got after extracting the Payload Dumper Tool). Anyways, the command to change the directory is:
STEP 6: Install Google APIs Dependencies
Next up, you’ll have to install a couple of Google API dependencies in Python. For that, just copy and paste the below two commands in the Termux window:
pip install google pip install google-api-core
STEP 7: Extract payload.bin on Android
- Finally, execute the below command to extract the payload.bin file directly on your Android device without using PC:
python payload_dumper.py payload.bin
- The extraction process will now being and once done, you shall get all the partition files inside the payload_dumper folder.
METHOD 4: Extract Payload.bin via Payload Dumper Go
- To begin with, download the payload-dumper-go 1.0.0 from Github [Credits: XDA Member ssssut].
- Then extract it to any convenient location on your PC. The name of the file will be something like payload-dumper-go_1.0.0_windows_amd64. Rename it to payload-dumper-go.
- Next up, download the liblzma-5.dll file and transfer it to the same folder where the payload-dumper-go.exe file is present.
- After that, transfer the payload.bin file to this folder as well.
- So as of now, you should have the payload-dumper-go.exe, payload.bin, and liblzma-5.dll files all under one folder.
- Now head over to that folder’s address bar, type in CMD, and hit Enter. This shall launch the Command Prompt window.
- Type in the below command to extract the payload.bin file:
- The extraction process will now begin and would only take a few seconds.
- Once done, all the extracted files will be placed under a folder named extracted_date_time that is created inside that directory.
That is it. With this, you have successfully extracted the payload.bin file and got the stock boot image file via the Payload dumper tool and Python. Along the same lines, we have also shared the steps to do via the Payload Go Tool which as of now, seems to be the best method for this job.
Apart from that, we have also listed out the steps to do so directly on your device without using a PC. You could transfer the stock boot.img file over to your device and then refer to our instructions to patch it via magisk and then flash it via fastboot. If you have any queries related to any of the two aforementioned steps, do let us know in the comments section below.