Created
March 30, 2021 22:38
-
-
Save patrickschur/ea11d1e22ac9bd83d026bc75db59d642 to your computer and use it in GitHub Desktop.
Reads the AGESA version from an UEFI image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Author
patrickschur
commented
Mar 30, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment