Coder Social home page Coder Social logo

easykernel's Introduction

easykernel

This is an attempt to create a quick and easy kernel setup for Kernel Development and also for kernel exploitation challenges in CTFs. Kick back and have a cup of coffee while easy kernel builds you the setup you want!

Setup

You can build your kernel image using build_image wrapper.

  • To install buildroot run - ./build_image.sh -s
  • You can get a working 5.2 kernel image by ./build_image.sh -i
  • You can also get a custom version by running ./build_image.sh -p <version> (WIP)

Note that installing the kernel will take some time. At the end of the installation you will find in the files/ folder a bzImage

copy.sh allows you to copy your files into the initramfs (rootfs.cpio). This allows for an smooth file transfer from the host to the qemu guest.

start-qemu.sh starts the qemu guest. By default it starts in the nographic mode. But you can also start it in the serial mode.

Things to be noted

  • You can run ./build_image.sh -d to install the dependencies. However in start-qemu.sh we use the QEMU 5.0 version that buildroot compiles since it's better than the one available via the ppa install. However feel free to replace with your own version.
  • The kernel contains busybox - you can use the functions that busybox provides by using busybox <command>. To see the commands that busybox provides, run busybox and it will show you the options.
  • The kernel does not have libc or compilers installed. You can statically compile any binaries you want and copy them to the initramfs using copy.sh

Outline

We build kernel images with Buildroot - which is a commonly used tool for easily building kernel images for Embedded Linux kernel. We will also add some additional tools into the kernel image by adding busybox and also add some statically compiled tools taking inspiration from initramfs-wrap

Further Hacking

If you want to add more tools/features on to the kernel for your purposes. You can do so by compiling them statically and copying them onto the kernel. If your tool is supported by buildroot - then you can add it using buildroot.

Improving buildroot config

The repo currently uses a custom buildroot configuration that's based on the qemu_x86-64-defconfig provided by buildroot. However you can use your own buildroot configuration to build images.

You can use any of the existing ones that buildroot has by running make <config-name>. These or the existing one can be then modified using either of these commands.

$> make menuconfig
$> make config

TODO

  • Try to add conan to use statically generated files for improving speed of building images.
  • Add wrappers for GDB scripts for debugging kernels

Links

There are various links that I refered to while searching for good ways of creating a Linux kernel setup. I posted a few of them here.

AUTHOR

This repo is maintained by Siddharth Muralee (@R3x).

easykernel's People

Contributors

r3x avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.