From 02a78c213fe61d453374956042911a268a1355d5 Mon Sep 17 00:00:00 2001 From: iAmInAction <83808704+iAmInActions@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:04:16 +0000 Subject: [PATCH] Added kver.c kver.c is a C script (use tcc for interpreted C) which i wrote for printing the version of a linux kernel image without having to boot said image. --- kver.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 kver.c diff --git a/kver.c b/kver.c new file mode 100644 index 0000000..5e63492 --- /dev/null +++ b/kver.c @@ -0,0 +1,25 @@ +#!/usr/bin/env -S tcc -run +#include + +int main(int argc, char** argv){ + if (argc > 1){ + FILE* f = fopen(argv[1], "r"); + short offset = 0; + char str[128]; + if(f){ + fseek(f, 0x20E, SEEK_SET); + fread(&offset, 2, 1, f); + fseek(f, offset + 0x200, SEEK_SET); + fread(str, 128, 1, f); + str[127] = '\0'; + printf("%s\n", str); + fclose(f); + return 0; + }else { + return 2; + } + } else { + printf("use: kver [kernel image file]\n"); + return 1; + } +}