KernelTool is a versatile shell script that automates various tasks related to kernel debugging, filesystem extraction, file archiving, and core dump configuration. It is designed to assist developers and system administrators in managing kernel debugging sessions, extracting compressed filesystems, and setting up root filesystems for testing.
- Filesystem Extraction: Extracts compressed files (e.g., gzip) into a
rootfs
directory. - Root Filesystem Archiving: Creates
.cpio
or.cpio.gz
archives with custom binaries for testing. - Kernel Debugging Setup: Configures GDB for kernel debugging with pre-set breakpoints.
- Kernel Image Extraction: Extracts a compressed kernel image (
bzImage
) into avmlinux
file. - Core Dump Configuration: Configures core dump settings and prepares the environment for kernel crash analysis.
gcc
- for compilingexp.c
if you use the-mer
options.gdb
- for kernel debugging when using the-gdb
option.cpio
,gzip
,gunzip
- for filesystem extraction and archiving.wget
- for downloadingextract-vmlinux
if it is not already available.
curl https://raw.githubusercontent.com/kmm2003/KernelTool/refs/heads/main/KernelTool -o KernelTool && chmod +x KernelTool
./KernelTool <option> [file_name]
-ext <file_name>
: Extracts the specified compressed file (e.g., gzip) into therootfs
directory.-ext -vmlinux
: ExtractsbzImage
tovmlinux
using theextract-vmlinux
script.-mer -cpio <file_name>
: Compilesexp.c
, adds it torootfs
, and creates arootfs.cpio
archive.-mer -gz -cpio <file_name>
: Compilesexp.c
into a static binary, adds it torootfs
, and creates a compressed archiverootfs.cpio.gz
.-gdb <symbol_file> <address>
: Configures GDB for kernel debugging, sets up remote debugging onlocalhost:1234
, and adds asymbol file
with the specifiedload address
.
./KernelTool -ext rootfs.cpio.gz
./KernelTool -ext -vmlinux
./KernelTool -mer -cpio rootfs.cpio
./KernelTool -mer -cpio -gz rootfs.cpio.gz
./KernelTool -gdb vmlinux 0x1000000
-
Filesystem Extraction (
-ext <file_name>
)- Deletes and recreates
rootfs
directory. - Copies the specified file to
rootfs
and decompresses if it’s gzip-compressed. - Extracts the archive using
cpio
.
- Deletes and recreates
-
Kernel Image Extraction (
-ext -vmlinux
)- Downloads the
extract-vmlinux
script if not available. - Extracts
bzImage
to produce avmlinux
file for debugging.
- Downloads the
-
Root Filesystem Archiving (
-mer -cpio <file_name>
and-mer -cpio -gz <file_name>
)- Compiles
exp.c
into a static binary. - Moves the compiled binary to
rootfs
4ABC . - Creates a
.cpio
or.cpio.gz
archive for therootfs
directory.
- Compiles
-
Kernel Debugging Setup (
-gdb <symbol_file> <address>
)- Sets up GDB for kernel debugging.
- Configures the architecture and attaches to a remote session.
- Sets breakpoints and continues execution.