GRML Android

grml-android is a lightweight version of grml-live built with apktool, android-sdk, img2simg, sdat2img, img2sdat, and instructions.

The included tools allow on-the-fly development to extract the contents of system.dat from Android OS, edit the contents, then repackage them for installation. This guide will show you how to place tools in /root/ of the final operating system.

Download and run the standard version of GRML and run grml-network for internet access. Then install the live system tools with the command, apt-get install grml-live

Setup

Edit /etc/grml/fai/config/package_config/GRML_SMALL and add,

android-sdk apktool img2simg acpi bc

Create directory /etc/grml/fai/chroot_install/root/ and move custom files (download copies of sdat2img and img2sdat) to that folder.

Copy /etc/grml/grml-live.conf to /etc/grml/grml-live.local and then edit grml-live.local to include the following:

VERSION="2019.01" RELEASENAME="grml-live android" BOOT_METHOD='grub2' CHROOT_INSTALL="/etc/grml/fai/chroot_install/" HYBRID_METHOD='disable'
Build

grml-live -s stable -a amd64 -c GRMLBASE,GRML_SMALL,AMD64

dd if=grml.iso of=grml-android.img bs=4M status=progress

Using GRML Android

Extract your Android OS files, including system.transfer.list and system.new.dat then issue the following command:

./sdat2img.py system.transfer.list system.new.dat [OUTPUT FILE].img

Next mount the image file you created to /mnt by issuing the following command:

mount [OUTPUT FILE].img /mnt && cd /mnt
Apktool

To examine an apk, use apktool d [appname].apk and to repack an apk, use apktool b [appname] -o [new_appname].apk. To run a rebuilt application, you must re-sign the application. See Android Documentation (1, 2) for details.

Repacking

Use the umount /mnt command to unmount your image, then issue the following commands to convert your image back into a dat file. Use the zip command to compress your files.

img2simg [OUTPUT FILE].img [SPARSE IMG].img ./img2sdat.py [SPARSE IMG].img zip [ZIP FILE NAME].zip boot.img firmware-update, system.img, etc ...