Skip to content

Instantly share code, notes, and snippets.

@patrickschur
Created March 30, 2021 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickschur/ea11d1e22ac9bd83d026bc75db59d642 to your computer and use it in GitHub Desktop.
Save patrickschur/ea11d1e22ac9bd83d026bc75db59d642 to your computer and use it in GitHub Desktop.
Reads the AGESA version from an UEFI image
#!/usr/bin/python3
import lzma
import sys
with open(sys.argv[1], "rb") as f:
image = f.read()
offset = image.find(b"\x93\xFD\x21\x9E\x72\x9C\x15\x4C\x8C\x4B\xE7\x7F\x1D\xB2\xD7\x92") + 0x30
CHUNK_SIZE = 2048
lz = lzma.LZMADecompressor()
while data := lz.decompress(image[offset:offset + CHUNK_SIZE]):
if (pos := data.find(b"AGESA!V9")) >= 0:
version = data[pos:data.find(b"\x00\x00\x00\x00", pos)].decode()
print(version)
sys.exit()
offset += CHUNK_SIZE
sys.exit(1)
@patrickschur
Copy link
Author

./agesa.py uefi.bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment