37 lines
1.1 KiB
Bash
37 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# Identify kernels by decompressing the bzImage payload and grepping "Linux version"
|
|
python3 - <<'EOF'
|
|
import glob, gzip, io, lzma, os, re, struct, zlib
|
|
|
|
def payload(d):
|
|
ss = d[0x1FE] or 4
|
|
return d[(ss + 1) * 512:]
|
|
|
|
def try_decompress(b):
|
|
for name, fn in (('gzip', lambda x: gzip.decompress(x)),
|
|
('xz', lambda x: lzma.decompress(x)),
|
|
('zlib', lambda x: zlib.decompress(x))):
|
|
try:
|
|
return fn(b), name
|
|
except Exception:
|
|
pass
|
|
return None, None
|
|
|
|
paths = []
|
|
for pat in ('ATI2025/dat10.dat', 'ATI2025/dat2.dat', 'ADDH12/dat14.dat', 'ADDH12/dat10.dat'):
|
|
paths.append('/path/to/pf/acronis/acr/ACR/' + pat)
|
|
|
|
for p in paths:
|
|
if not os.path.exists(p):
|
|
print(p, 'missing'); continue
|
|
d = open(p, 'rb').read()
|
|
body = payload(d)
|
|
out, kind = try_decompress(body)
|
|
ver = '?'
|
|
if out:
|
|
m = re.search(rb'Linux version ([0-9][^ \x00]{0,40})', out[:6_000_000])
|
|
if m:
|
|
ver = m.group(1).decode('latin1')
|
|
print('%-42s %-6s %s' % (p.split('ACR/')[-1], kind or 'raw', ver))
|
|
EOF
|