mirror of
https://github.com/iAmInActions/random-scripts.git
synced 2024-11-23 20:50:13 +00:00
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.
This commit is contained in:
parent
a1420d24e7
commit
02a78c213f
25
kver.c
Normal file
25
kver.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env -S tcc -run
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user