How hack the Android boot.img with no compilation

pirate

There are two very cool tools (unmkbooting and mkbootimg) that allows you to hack your boot.img and make changes in the ramdisk including the init.rc very quickly and faster than compilation. You actually do not need to compile anything, just using a Linux machine (I am using Ubuntu 12.04 64bits), install the two tools and run the procedure below:

  • Install install these two tools in your linux machine:

https://android.googlesource.com/platform/system/core/+/master/mkbootimg/

and

http://whiteboard.ping.se/Android/Unmkbootimg

and them,

  • Then run extract the ramdisk from your boot.img binary

unmkbootimg boot.img

mkdir ramdisk

mv initramfs.cpio.gz ramdisk/

 

  • decompress the ramdisk

gzip -dc initramfs.cpio.gz | cpio -i

  • edit the init.rc
  • compacting the ramdisk again

rm initramfs.cpio.gz

find . | cpio -o -H newc | gzip > ../initramfs.cpio.gz

cd ..

  • generating a new hacked boot (I named as new_boot). Note this commend line is displayed when you use the unmkbooting. In my case, I use the command line below.

  mkbootimg –kernel zImage –ramdisk initramfs.cpio.gz –base 0x10800000 –cmdline ‘console=ttymxc0,115200 init=/init video=mxcfb0:dev=lcd,Newhaven-LCD,if=RGB24,bpp=32 video=mxcfb1:off video=mxcfb2:off fbmem=12M fb0base=0x27b00000 vmalloc=400M androidboot.console=ttymxc0 androidboot.hardware=intrinsyc no_console_suspend=1’ -o new_boot.img

  • Reflashing the hacked boot

adb reboot fastboot

fastboot flash boot new_boot.img

Leave a Reply