How to extract payload.bin from OTA update or firmware

extract payload.bin

In a few rare cases, you may need to extract the payload.bin that is part of firmware and OTA update files from some OEMs to get the stock boot and system images. This helps when you are looking unbrick a device, or need base files for building a custom ROM. Well, here’s how you can extract the content of payload.bin easily using a script, after all, you can’t simply unzip its content.

You know, Google’s Android OS is, by far, the most widely used mobile operating system on the planet. The OS comes with its fair share of nifty features, but it is its open-source nature that has kept us hooked since Android’s first commercial rollout in 2008.

Even a couple of years back, extracting the stock firmware zip file would give you all the necessary .img files — system.img, boot.img, etc. But today, extracting the necessary files isn’t as straightforward anymore, thanks to the introduction of payload.bin. Google now packs all the sensitive files inside that Payload package, forcing you to perform a few additional tasks before getting on with your modding process.

How to extract payload.bin file

Here’s how you can get the boot.img, system.img, etc. files from a payload.bin file. Let’s see how to extract it:

Step 1: Install python for windows from here

Step 2: Run the installer and install Python. Make sure you also install PIP (installed by default under express installation, but if you opt for custom installation, make sure you tick the PIP checkbox).

Step 3: Installer will install Python in this location. Replace the your_windows_username_here part with your account’s username on the PC.

C:\Users\your_windows_username_here\AppData\Local\Programs\Python\Python37

Step 4: After you’ve successfully installed Python, you’ll need to install virtual environment on your Windows PC. Here’s how to install virtualenv:

4.1 Open Command Prompt.

4.2 Run the two commands given below to first change your directory in the CMD, and then set the path of the python scrips in the system PATH variable.

cd C:\Users\your_windows_username_here\AppData\Local\Programs\Python\Python37\Scripts

setx path C:\Users\your_windows_username_here\AppData\Local\Programs\Python\Python37\Scripts

Your command window will look like this.

Step 5: After it’s done successfully, run the command below

pip install virtualenv

A package will be downloaded and installed, and a success message will be generated containing the virtualenv version. Here’s how it will look:

Step 6: Now, you’ll need the PayLoad Dumper script/tool to do the remaining bit. Download PayLoad dumper from here.

Step 7: Extract Payload Dumper using free software like 7-zip. You will get payload_input and payload_output folders.

Step 8: Extract the ZIP file of the OTA update or firmware of your choice. You will get payload.bin file.

Step 9: Copy/move the payload.bin file to payload_input folder.

Step 10: Run payload_dumper.exe file by double-clicking on it.

Step 11: Let the script do its work. When done, it will extract all the content from payload.bin to payload_output folder. Pick your OTA file, recovery, boot, etc. from here.

Step 12:  As you can see, there’s no recovery image in this folder. It is because the boot image file doubles up also as a recovery image file here (in the case of Asus ZenFone 5Z). So, in order to flash stock recovery, you’ll need to flash the boot image file.

Tip: How to install the boot image extracted from payload.bin

The content you get from the payload.bin is stock partition files, meaning you have got the stock boot.img, stock system.img etc. stuff. If you need to remove the custom recovery like TWRP or Magisk, you can install the stock boot.img file. Here’s a simply fastboot command to do that. Make sure you have started the devices in fastboot/bootloader mode first, and have connected the device with the USB cable).

To flash stock boot/recovery, you’ll be required to run the command below

fastboot flash boot boot.img

You could also rename the boot image file, and in that case, replace “boot.img” with “new_boot_image_name.img”.

That’s all.

RELATED

Need any help in this regard? Contact us via the comments section below.

Posted by
Sushan

A mediocre engineer hoping to do something extraordinary with his pen (well, keyboard). Loves Pink Floyd, lives football, and is always up for a cup of Americano.