if you are running a Raspbian Buster image it is easy to find the version in the image of the new 64 bit
/boot/kernel8.img. You can just use:
rpi ~$ strings /boot/kernel8.img | grep 'Linux version'
Linux version 4.19.93-v8+ (dom@buildbot) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9)) #1290 SMP PREEMPT Fri Jan 10 16:51:04 GMT 2020
But it only works because this is the only kernel image that isn't compressed by default. That's the reason why you don't find the version simply with strings in other kernel images. You have to decompress it but that cannot simply be done because the compressed part is anywhere contained in the kernel image and you have to know how it is compressed. I have checked that it is compressed in gzip format but you have to find the start of the compressed part. The header of the gzip part starts with a magic string
\x1f\x8b\x08 so you can search for it. Here in short how I have tested it. For details look at the references. To get
/proc/config.gz to look for the compressed format
CONFIG_KERNEL_* you have to load
sudo modprobe configs.
rpi ~$ pos=$(LC_ALL=C grep -P -a -b -m 1 --only-matching '\x1f\x8b\x08' /boot/kernel7l.img | cut -f 1 -d :)
rpi ~$ dd if=/boot/kernel7l.img of=kernel7l.gz bs=1 skip=$pos
rpi ~$ gzip --decompress --stdout kernel7l.gz | strings | grep 'Linux version'
Linux version 4.19.93-v7l+ (dom@buildbot) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1290 SMP Fri Jan 10 16:45:11 GMT 2020
gzip: kernel7l.gz: decompression OK, trailing garbage ignored
Please note that
LC_ALL=C preceeding grep is important because it is using UTF-8 by default and will not find the hex value
\x8b due to its most significant bit is set. Grep will not find the offset then.
Getting kernel version from the compressed kernel image
Find gzip start and end?
Bytewise grep fails for some byte values