Golang implementation of extract-vmlinux script.
This project was forked from https://github.com/Caesurus/extract-vmlinux-v2 and was completely reconstructed.
go install github.com/soxfmr/extract-vmlinux-v2@latest
extract-vmlinux-v2 -file /boot/vmlinuz -output /tmp/vmlinux
go get github.com/soxfmr/extract-vmlinux-v2@latest
decompress the kernel image and hold in memory:
file, err := os.Open("/boot/vmlinuz")
if err != nil {
log.Fatalf("couldn't open the input file: %s", err)
}
kernel, err := vmlinux.Extract(file)
if err != nil {
log.Fatalf("couldn't extract the kernel image: %s", err)
}
decompress the kernel image and save it to a file:
file, err := os.Open("/boot/vmlinuz")
if err != nil {
log.Fatalf("couldn't open the input file: %s", err)
}
tmpFile, err := os.CreateTemp("", "vmlinux")
if err := vmlinux.ExtractTo(kernelFile, tmpFile); err != nil {
log.Fatalf("couldn't extract the kernel image: %s", err)
}
At the moment I have only found good native support for gzip
/bzip
/lzma
/lz4
/xz
.
I haven't found good support for zstd
/lzop
.