yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] CNexus:
I have not seen this posted anywhere, so I thought I would post it here. This is NOT purely my work, and I do not take credit for it as such.

Included in the attached ZIP are the following files:

boot_info - prints information about the boot.img passed to it, including the base address and ramdisk address. This tool prints out everything needed to repack the boot.img correctly.

split_boot - More commonly known as split_bootimg.pl, this rips apart the boot.img to extract the ramdisk and zImage. It has been modified by me to split the boot.img into a separate folder (specified by the file name of the boot.img passed to it) and to extract the ramdisk into a sub-folder as well (extracts the cpio from the gz and then extracts the actual files from the cpio archive)

unpack_ramdisk - unpacks the given ramdisk file.

Usage: unpack_ramdisk <ramdiskFile>

repack_ramdisk - repacks the ramdisk from the given directory (found online and modified slightly to take a directory)

Usage: repack_ramdisk <ramdiskDirectory> [outputFile]

mkbootimg - mkbootimg binary that creates a boot.img file from the given ramdisk and zImage. Updated to a version compiled by me to support the --ramdiskaddr option (ramdisk address) so that even nonstandard boot.img's can be repacked correctly (Use with boot_info for best results).

umkbootimg - included for convenience. Not made by me. Original thread here.

unpack - wrapper script made by me for the umkbootimg binary^ to unpack the boot.img into a separate directory and then unpack the ramdisk into a sub-directory.

Note: These tools were made for Linux. They may also work on Cygwin, but I have not personally tested them.

ANYONE is free to use / modify / kang these files as they see fit. No need to ever ask or do anything more than download.

Enjoy.
[Android Software/Hacking General [Developers Only]] CNexus:
UPDATE: If you downloaded, please redownload. There was an error with my repack_ramdisk script, but it's fixed now.
[Android Software/Hacking General [Developers Only]] CNexus:
Updated tools with a new boot_info script, also added my own mkbootimg binary compiled with the ramdisk address option.

Boot_info now displays the following information:

Commandline

Pagesize

Base address

Ramdisk address.

Which is everything you need to make a functional boot.img, even when the original boot.img is packed with a non-standard mkbootimg (ie, the ramdisk offset is different than the normal offset).
[Android Software/Hacking General [Developers Only]] slicingtaco:
How exactly do we use these files to unpack and repack?

I've tried running the scripts with chmod at 755 but it doesn't work.

I am i missing something?
[Android Software/Hacking General [Developers Only]] CNexus:
All the scripts must be in a folder in your path (~/bin for example)

Then it should work, because they call on each other. I keep all of them in my ~/bin folder, but they can be anywhere in your PATH

Sent from my buttered S3
[Android Software/Hacking General [Developers Only]] twins.7:
if Android Magic Word not found at offset 0, it fail.
[Android Software/Hacking General [Developers Only]] CNexus:
No, if you use unmkbootimg instead split_boot, it also finds embedded images.
[Android Software/Hacking General [Developers Only]] twins.7:
OK, it work. But .... :) sorry to much complain

My boot.img has magic word in offset 2048. so it mean, there is additional header in first 2048 byte.

umkbootimg succesfully extract embedded boot.img, but in repacking, I lost the first 2048 byte, because magic header placed in offset 0.

Actually, what is the additional header for? really asking...

I fail to fastboot flash if the image have no additional header.

And it will fail to verify, if the additional header is wrong. or is it called signed boot.img?

If I change the content of boot.img, I can't flash it to device. It always said verify fail. I though, the additional header has CRC or hash or anything.

If you have spare time and want to help me, I'll post my image :)
[Android Software/Hacking General [Developers Only]] KineichiNxt:
Thanks for this tools :)

Send from my AMOI N828 using Xda Premium
[Android Software/Hacking General [Developers Only]] CNexus:
I'm not sure. No tool will work for all devices, and since I've never had a device that has this special packing, it would be best if you asked one of your kernel devs for help unpacking/repacking
[Android Software/Hacking General [Developers Only]] twins.7:
ok thank's :)
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
is it possible to make these run on the device?

i have tried

adb root

adb remount

adb push * /sdcard/tmp/

adb push * /system/xbin/

adb push * /system/bin/

adb shell

cd /sdcard/tmp/

for f in $(ls)

do

chmod 755 /system/bin/$f

chmod 775 /system/xbin/$f

done

cd /

rm -r /sdcard/tmp

cd /sdcard/working

split_bootimg.pl boot.img

returns "Permission denied"

hmmmmm???????? what could be the problem????????
[Android Software/Hacking General [Developers Only]] CNexus:
The Perl script should work if you have Perl (compiled for ARM x86) on your device.

The binaries will not work as they are not compiled for ARM. The scripts (at least some of them) should work if you change all instances of "#!/bin/bash" and "#!/usr/bin/env bash" to "#!/system/bin/sh".
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
will see if i can get it working tonight! this could be pretty good if i can get it to unpack on device!
[Android Software/Hacking General [Developers Only]] CNexus:
No need...download this zip and extract http://www12.zippyshare.com/v/37266634/file.html

It already contains an unmkbootimg binary compiled for ARM. Then you would just need to unpack the ramdisk to finish it off.
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
no way, ive been looking for something like this for ages, who is the author?
[Android Software/Hacking General [Developers Only]] CNexus:
I don't know who originally compiled that unmkbootimg binary for ARM.
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
hmm, gotta findout! i wanna use it in my tool!
[Android Software/Hacking General [Developers Only]] Slimegod:
Is this boot.img tool compatible with Microsoft windows as well?
[Android Software/Hacking General [Developers Only]] CNexus:
Read the OP.
[Android Software/Hacking General [Developers Only]] :
Beginner me

are these tools would be enough to edit/modify something in the boot.img? This will be my first attempt. My purpose is to change the boot splash image of a Kernel. With my intent to use this tool, would these suffice my needs? Thanks
[Android Software/Hacking General [Developers Only]] oldsoldier2003:
I suspect they were compiled on Ubuntu since Debian stable (wheezy as of this writing) uses an older version of glibc which causes mkbootimg to choke. Debian users will need to upgrade to testing/Jessie (swapping libc is not advisable, it is just better to go with Jessie)
[Android Software/Hacking General [Developers Only]] oldsoldier2003:
Update:

These tools work great on Debian Jessie/SID

I forgot to mention this for folks that are Debian users. Thanks for making these tools accessible to the masses :)
[Android Software/Hacking General [Developers Only]] Slimegod:
How do I use this with Ubuntu?
[Android Software/Hacking General [Developers Only]] oldsoldier2003:
These tools are command line tools you run them from a terminal. See the first part for usage
[Android Software/Hacking General [Developers Only]] Slimegod:
Do I have to rename the file after it's extracted to run it in Ubuntu?
[Android Software/Hacking General [Developers Only]] Mr_Ada:
Works with Cygwin

I was able to use scripts with cygwin.

Very cool.
[Android Software/Hacking General [Developers Only]] ShinySide:
God I need to start reading posts more often.... Thanks for the tip....
[Android Software/Hacking General [Developers Only]] nasr18:
bro I'm having ur file, but don't know how to run. please say it elaborately for me.

hope you will reply.
[Android Software/Hacking General [Developers Only]] kwisatz79:
How did u managed it? I allways get errors that he does not find all the commands.

Thx in advance.
[Android Software/Hacking General [Developers Only]] Mr_Ada:
if you can post those errors, maybe we can determine the cause of the error.

chris
[Android Software/Hacking General [Developers Only]] CNexus:
The scripts make use of gzip, gunzip, cpio, and others so make sure you download those when you go through the cygwin installer
[Android Software/Hacking General [Developers Only]] vlackhonor:
Some devices boot.img (G730-U00 boot.img) is can't unpack repack

how to ??
[Android Software/Hacking General [Developers Only]] spanish33:
[MENTION=4645794]CNexus[/MENTION] thank you, this tool helped me edit my ramdisk .
[Android Software/Hacking General [Developers Only]] m9j_cfALt:
better tool than urs..

no need of cygwin.. perl interpreter

with GUI.. for windows.. tiny and fast..

xdaforums.com/general/general/tool-abime-android-boot-image-editor-t2847426
[Android Software/Hacking General [Developers Only]] ShinySide:
That was just sad....
[Android Software/Hacking General [Developers Only]] bigwillyg:
And shameful. And rude
[Android Software/Hacking General [Developers Only]] m9j_cfALt:
i know i dont know how to write without being rude..

i just wrote the comment.. and thought over and over whole the night why did i wrote in such language..

im feeling guilty.. apologize..

btw.. ur tool is mother of mine.. and i learned lot from it..

honestly... Manoj Bhakar PCM(m9j_cfALt)
[Android Software/Hacking General [Developers Only]] mikeymopar:
a little stuck on mkbootimg

hi guys...i need a little help please.

unpack works perfectly and it displays (among other things):

*** WARNING ****
This image is built using NON-standard mkbootimg!
OFF_KERNEL_ADDR is 0xFE208100
OFF_RAMDISK_ADDR is 0x00200100
OFF_SECOND_ADDR is 0xFF100100
Please modify mkbootimg.c using the above values to build your image.

where do i enter those values. i'm guessing the mkbootimg command line but where and how is it worded.

repack_ramdisk works as advertised giving new-ramdisk.cpio.gz. but then using mkbootimg with what unpack displays as shown above (without trying to add the non-standard addr values yet just to see if it works)

To recompile this image, use:
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x1dfff00 --cmdline 'console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3' -o new_boot.img

i get this error all the time

mike@mike-VirtualBox:/usr/local/bin/kernels$ mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x1dfff00 --cmdline 'console=null androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3' -o new_boot.img
bash: /usr/local/bin/kernels/mkbootimg: cannot execute binary file: Exec format error

before using mkbootimg do zImage and new-ramdisk.clio.gz need to be moved into a separate folder or renamed or...or.......:confused:

(i'm using lubuntu. all the first steps of this kernel tool work perfect. i couldn't get mkbootimg to work for the life of me over the last two nights)

THANKS for any help/suggestions!!!:cool:
[Android Software/Hacking General [Developers Only]] I98:
Hello

can you please add support for unpacking and repacking the s2 boot.img please

thanks
[Android Software/Hacking General [Developers Only]] gee one:
You seem to have a bash error- what does 'mkbootimg --help' do? I suspect that it isn't even being called.

'which mkbootimg' might also shed some light.
[Android Software/Hacking General [Developers Only]] mikeymopar:
Big THANKS for the assistance!! :laugh:

I'm using the one from the op updated package (the second one in his dl list). I quickly just went thru and did the --help command on the seven files and while some throw a minor error or two at least they display something. using the --help option on the mkbootimg command throws the same error as when i try to use it - "cannot execute binary file" error. looks like it's an issue with the command itself??? i'll try getting one from elsewhere and seeing if it works i guess.

still need a bit more insight on the non-standard image addresses and how to incorporate them in the mkbootimg command line but...at least if i can get it to work without erroring from the start it'll help.

THANKS again.:cool:
[Android Software/Hacking General [Developers Only]] mikeymopar:
you nailed it man! i had 15 minutes to kill so i grabbed the mkbootimg from the op first dl option (not his modded tools one that i had), ran the "older" mkbootimg command and it didn't error and it correctly compiled the "new-boot.img".

i'll mess with the offset addresses later and see if it actually flashes correctly but it at least compiles now.

THANKS AGAIN gee!!!!!!! :D
[Android Software/Hacking General [Developers Only]] gee one:
As far as the offset addresses are concerned, I think you can modify the source code and build a new version that uses the correct address. The second option would be to use a hex editor and just adjust the address in the boot.img file after you build it, but before you flash it.

There used to be a few tutorials on how the boot.img files are put together that explain which bits to change.

Just remember, "nothing good comes from using a hex editor" ;)

sent while running with scissors
[Android Software/Hacking General [Developers Only]] shayind4:
It works for SM-T210 4.4.2 but not SM-T230 4.4.2. Please help.

Thanks
[Android Software/Hacking General [Developers Only]] ShinySide:
Look in tab 4 original dev
[Android Software/Hacking General [Developers Only]] shayind4:
Thanks. I will check it out.
[Android Software/Hacking General [Developers Only]] shayind4:
It works. Thanks.
[Android Software/Hacking General [Developers Only]] Da9L:
I might be missing something obvious here, but i cannot get any of this to work.. Extracted the zip file inside my home folder in Ubuntu. Navigate there throug the terminal, but entering "unpack boot.img" does nothing other than telling me that the command does not exist.. Boot.img is ofcourse also located within the same folder as unpack, and so is all the other files included in the zip ..
[Android Software/Hacking General [Developers Only]] ShinySide:
Make the scripts executable
[Android Software/Hacking General [Developers Only]] gee one:
You need to specify the path - either put the executable in someplace in your path or use "./unpack boot.img" There is a period and a slash (the right kind, not the backwards kind) in front of unpack.

the dot and the slash tell linux that you want to execute the binary file in the current directory. You can google $PATH environment variable for more information.
[Android Software/Hacking General [Developers Only]] nl3142:
Is there a 32 bit version of your mkbootimg anywhere?
[Android Software/Hacking General [Developers Only]] vboyz103:
Just FYI, if you are getting the WARNINGs about offset and non-standard bootimg. In the final mkbootimg command that provided to you by the umkbootimg tool, add the argument --base <offset> will get you a working boot.img to boot from.

Example:

If the offset provided to me by umkbootimg is

OFF_KERNEL_ADDR: 0x00000100 << this value needs to be plugged into the final mkbootimg command

Final command:

mkbootimg --base 0x00000100 .... < the rest of the command goes here

I tested this with 5.1.1 boot.img that I used to unpack to edit not forcing encryption.
[Android Software/Hacking General [Developers Only]] TiBiSMART:
unpack initramfs from zImage

please help me

somebody to know how can i unpack initramfs from zImage? (RK3188 4.4.4 kernel)

i tried with repack-zImage.sh but i got this error : Can't find a gzip header in file 'zImage'

thanks
[Android Software/Hacking General [Developers Only]] CNexus:
zImage is the kernel, it does not contain the initramfs.
[Android Software/Hacking General [Developers Only]] TiBiSMART:
2nd boot logo

Thanks. i' ve just realized.

My problem is that i installed huifei car dvd head unit and this android (Klyde Conquer Android 4.4.4 )contains a picture (this is the 2 nd boot logo before the boot animation script) full off chinese text.

I update the old firmware (which doesn't contain this picture) the knew kernel (but only the kernel.img!!!) and the picture is appeared in the boot. So i tought this picture is in the initramfs ( or ramdisk) inside the kernel....

Anybody have got idea how can i remove the 2nd boot logo?

thanks
[Android Software/Hacking General [Developers Only]] CNexus:
It might be packaged in another partition or contained within the bootloader if you cannot find it inside the initramfs. It's hard to say without being familiar with the files that you are working with.
[Android Software/Hacking General [Developers Only]] Dvalin21:
When using repack_ramdisk, it seems to work, but the ramdisk comes out bigger than it originally was. To which at this point Im unable to install my recovery.img that I make because the file has to be no more than 7.6 mb, and after repacking everything its 9.1mb. any suggestions?
[Android Software/Hacking General [Developers Only]] shaowd:
Deleted
[Android Software/Hacking General [Developers Only]] realtebo:
just to start from zero.

After executing boot_info i got this

PAGE SIZE: 4096
BASE ADDRESS: 0x00000000
RAMDISK ADDRESS: 0x02000000
CMDLINE: 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 boot_cpus=0-5 ramoops_memreserve=2M'

And then, what the next step ?
[Android Software/Hacking General [Developers Only]] Ab.Shaheen:
repacking not working

unpacking is working well but when i unpack boot.img and then repack same folder without any change it new boot.img is 1 mb less then original boot.img as original boot.img is about 16 mb and new is 15 mb. also when i flash this image to device then device does not boot uo even it does not turn on. there may be some kind of problem with repacking. i am using lollypop on xperia z2 with unlocked bootloader.

any help..
[Android Software/Hacking General [Developers Only]] 4llerbuntu:
Hello. Please i need help.

I have a Mediatek device with a secured boot.img i have been trying to make it unsecured by changing ro.secure in default.prop

when i repack the boot.img and flash it with SP Flash tools the device does not boot at all. (reboots at first splash)

Can anyone help me do it properly? i'll really appreciate your help. this is a link to the boot.img and recovery.img: https://drive.google.com/open?id=0B39xYnt0Q7O0YktFaXE0NnVRSkk
[Android Software/Hacking General [Developers Only]] mom4ence:
Hi,

I have Acer Iconia Tab B1-830 , and I will installed him in my car.I want auto boot my tablet when i connect to charger.

To do this I must unpack boot.img , to make some changes in "charge" file and to repack it again.

I try several methods , but after that when I flash kernel , tablet boots in recovery menu.

Here is stock kernel and here is modified "charger" file ,can someone help me with unpack and repacking boot.img ?
[Android Software/Hacking General [Developers Only]] Crim Soukyuu:
The ramdiskaddr option doesn't seem to work here (got the 7.8.13 zip). No matter what I enter, the ramdisk offset is always stuck on the same value (little less than desired). Any idea what might be wrong?
[Android Software/Hacking General [Developers Only]] devilmaycry2020:
Hi all

why i can't extract boot.img in ubuntu 16.04 ? here is the error message
[Android Software/Hacking General [Developers Only]] Perseus:
Do

chmod +x

on all the executable that you are trying in that Screen. You can't find the files via Sudo since the path isn't set for these files.
[Android Software/Hacking General [Developers Only]] brainvision:
hi there, which attachment from OP is the last version? Can't find info about changelog, updates and so don't know that.. :(
[Android Software/Hacking General [Developers Only]] Matt07211:
Simple, 7.8. :)
[Android Software/Hacking General [Developers Only]] brainvision:
yes, simple, but it could have been that the last version was the other and the 7.8 was an old one to be used in some particular cases.. :D

thanks a lot!
[Android Software/Hacking General [Developers Only]] Matt07211:
Yea, should have mentioned in my above post that I had dowloaded both (a while back) to see which is which, which was the 7.8.

Good luck
[Android Software/Hacking General [Developers Only]] Jugehuge:
Little off-topic but it's easy if you have rooted the tablet. Just unpack boot.img and unzip ramdisk.

If you want to do it in windows http://dark-cyanide-devs.blogspot.fi/2015/01/port-bootimg.html

There simple unpack tool which also unpacks ramdisk automatically and then also pack it back.

Add following to end of the init.rc file.

#Check if chargermode and start rebootit service.
on property:ro.bootmode=charger
start rebootit

and after it added following:

#rebootit service which command reboot
service rebootit /su/bin/su /system/bin/reboot -c reboot now
user root
oneshot

You need to have SU installed to work.
[Android Software/Hacking General [Developers Only]] SRIHARI_GUY:
Does this tool works with other .img files such as lk.img etc.,
[Android Software/Hacking General [Developers Only]] alecxs:
not unpacking stock boot.img WIKO RAINBOW KITKAT_V16

ubuntu@ubuntu:~/src/bootimg_tools$ ./unpack_ramdisk boot/boot.img-ramdisk.cpio.gz
gzip: ../boot/boot.img-ramdisk.cpio.gz: not in gzip format
cpio: premature end of archive
ubuntu@ubuntu:~/src/bootimg_tools$ ./boot_info boot.img
PAGE SIZE: 2048
BASE ADDRESS: 0x10000000
RAMDISK ADDRESS: 0x11000000
CMDLINE: ' '
[Android Software/Hacking General [Developers Only]] 4r44444:
Thanks
[Android Software/Hacking General [Developers Only]] jalizi:
How can I use this tool for extract boot.img file for my GALAXY J1 (SM-J100H/DS) ?

Which version should I download?
[Android Software/Hacking General [Developers Only]] almoniplo:
I think I have a problem with my pack/unpack boot.img script..

If I unpack and pack an original boot.img (originally 33MB) I get a 31MB boot.img..

I use bootimg_tools mkbootimg/split_boot scripts:

split_boot boot.img
cd boot
mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz -o ../boot.img
[Android Software/Hacking General [Developers Only]] alecxs:
the size may vary, but the content is the same. if size is important, you can enlarge the file with zero bytes
[Android Software/Hacking General [Developers Only]] CollisionFactor:
love the tools!!!

Thank you!
[Android Software/Hacking General [Developers Only]] cobra1111new:
Данный инструмент не работает: Not Working this instrument
[Android Software/Hacking General [Developers Only]] pr0_JeR:
My problem

# boot_info original_boot.img

PAGE SIZE: 4096

BASE ADDRESS: 0x00000000

RAMDISK ADDRESS: 0x01000000

CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'

I create new boot and see boot_info

# boot_info new_boot.img

PAGE SIZE: 4096

BASE ADDRESS: 0x00000000

RAMDISK ADDRESS: 0x01300000

CMDLINE: 'console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 androidboot.configfs=true androidboot.usbcontroller=a800000.dwc3 loop.max_part=16 buildvariant=userdebug'

RAMDISK ADDRESS is bad
[Android Software/Hacking General [Developers Only]] gee one:
Are you setting the ramdisk address and it's coming out wrong, or are you not setting it at all?

What command did you use to repack the boot image?