Skip to content

locus-x64/android-kernel-exploitation-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Android Kernel using Docker

With the help of @cloudfuzz, I have crafted a Dockerfile to build Android kernel images. This Dockerfile is based on the official Android build environment and includes all necessary dependencies for building the kernel.

In this repo, I am building the kernel for the Pixel 2 (Android 10:goldfish) and patching it for reach commit: 182a76ba7053af521e4c0d5fd62134f1e323191d to recreate CVE-2019-2215.

Build Android Kernel

After making chnages for building relevent kernel, you can build the kernel using the following command:

docker build -t android-kern-build-env .

Build Android Kernel with Patches

After building the image, we can run the container with volume mapping to the current directory. This allows us to access the kernel source code and build it inside the container. The --cpus flag is used to limit the number of CPU cores available to the container.

docker run -it --cpus 12 -v .:/android-lab android-kern-build-env --name android-kern-build-env

Once done building kernel, we can find files of our interest in the out directory.

tree out/kasan/dist/
dist/
├── bzImage
├── kernel-headers.tar.gz
├── kernel-uapi-headers.tar.gz
├── System.map
└── vmlinux

1 directory, 5 files

Booting the Kernel with emulator

To boot the kernel with the emulator, we can use the following command:

~/Android/Sdk/emulator/emulator -show-kernel -no-snapshot -wipe-data -avd CVE-2019-2215 -kernel ./out/kasan/dist/bzImage

Where: -show-kernel is used to show the kernel log (dmesg) on the console. -no-snapshot is used to disable snapshot support. -wipe-data is used to wipe the data partition before booting. -avd is used to specify the name of the AVD (Android Virtual Device) to use. -kernel is used to specify the path to the kernel image to boot.

About

A lab environment for Android kernel exploitation

Resources

Stars

Watchers

Forks