From e235b7fbc41ca124b51a385e83896ed91f7054ed Mon Sep 17 00:00:00 2001 From: Plato Mavropoulos Date: Sat, 2 Jan 2021 22:37:26 +0200 Subject: [PATCH] AMI BIOS Guard Extractor v3.1 File AMI_PFAT_X_DATA_ALL now includes AMI_PFAT_X_DATA_END Applied various static analysis code fixes --- AMI BIOS Guard Extractor/AMI_PFAT_Extract.py | 17 ++++++++--------- LICENSE | 2 +- README.md | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/AMI BIOS Guard Extractor/AMI_PFAT_Extract.py b/AMI BIOS Guard Extractor/AMI_PFAT_Extract.py index a3277a2..b1a6da4 100644 --- a/AMI BIOS Guard Extractor/AMI_PFAT_Extract.py +++ b/AMI BIOS Guard Extractor/AMI_PFAT_Extract.py @@ -4,10 +4,10 @@ """ AMI PFAT Extract AMI BIOS Guard Extractor -Copyright (C) 2018-2020 Plato Mavropoulos +Copyright (C) 2018-2021 Plato Mavropoulos """ -print('AMI BIOS Guard Extractor v3.0') +print('AMI BIOS Guard Extractor v3.1') import sys @@ -21,7 +21,6 @@ if sys_ver < (3,7) : import os import re import ctypes -import struct import shutil import traceback @@ -205,7 +204,7 @@ for input_file in ami_pfat : input_dir = os.path.dirname(os.path.abspath(input_file)) file_data = b'' - final_image = b'' + final_data = b'' block_name = '' block_count = 0 file_index = 0 @@ -284,7 +283,7 @@ for input_file in ami_pfat : print(' Error: BIOS Guard Script Tool dependency missing!') file_data += block_data - final_image += block_data + final_data += block_data if i and is_file_start and file_data : file_index += 1 @@ -296,9 +295,10 @@ for input_file in ami_pfat : with open('%s_%0.2d -- %s' % (file_path, file_index + 1, block_name), 'wb') as o : o.write(file_data) # Last File - with open('%s_00 -- AMI_PFAT_%d_DATA_ALL.bin' % (file_path, pfat_index), 'wb') as final : final.write(final_image) - eof_data = buffer[block_start:] # Store any data after the end of PFAT + + with open('%s_00 -- AMI_PFAT_%d_DATA_ALL.bin' % (file_path, pfat_index), 'wb') as final : final.write(final_data + eof_data) + if eof_data[:-0x100] != b'\xFF' * (len(eof_data) - 0x100) : eof_path = '%s_%0.2d -- AMI_PFAT_%d_DATA_END.bin' % (file_path, file_index + 2, pfat_index) with open(eof_path, 'wb') as final : final.write(eof_data) @@ -310,5 +310,4 @@ for input_file in ami_pfat : else : pfat_index = 1 -else : - input('\nDone!') \ No newline at end of file +input('\nDone!') \ No newline at end of file diff --git a/LICENSE b/LICENSE index 747d78f..47e82f4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2020 Plato Mavropoulos +Copyright (c) 2019-2021 Plato Mavropoulos Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index f184f2d..748f815 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Some Anti-Virus software may claim that the built/frozen/compiled executable con Parses AMI BIOS Guard (a.k.a. PFAT, Platform Firmware Armoring Technology) images, extracts their SPI/BIOS/UEFI firmware components and decompiles the Intel BIOS Guard Scripts. It supports all AMI PFAT revisions and formats, including those with nested AMI PFAT structures. The output comprises only final firmware components which are directly usable by end users. -Note that the AMI PFAT structure does not have an explicit component order. AMI's BIOS Guard Firmware Update Tool (AFUBGT) updates components based on the user/OEM provided Parameters and Options. That means that merging all the components together does not usually yield a proper SPI/BIOS/UEFI image. The utility does generate such a merged file with the name "X_00 -- AMI_PFAT_X_DATA_ALL.bin" but it is up to the end user to determine its usefulness. Moreover, any custom OEM data after the AMI PFAT structure are stored in a file with the name "X_YY -- AMI_PFAT_X_DATA_END.bin" and it is once again up to the end user to determine its usefulness. In cases where the trailing custom OEM data include a nested AMI PFAT structure, the utility will process and extract it automatically as well. +Note that the AMI PFAT structure does not have an explicit component order. AMI's BIOS Guard Firmware Update Tool (AFUBGT) updates components based on the user/OEM provided Parameters and Options. That means that merging all the components together does not usually yield a proper SPI/BIOS/UEFI image. The utility does generate such a merged file with the name "X_00 -- AMI_PFAT_X_DATA_ALL.bin" but it is up to the end user to determine its usefulness. Moreover, any custom OEM data after the AMI PFAT structure are additionally stored in a file with the name "X_YY -- AMI_PFAT_X_DATA_END.bin" and it is once again up to the end user to determine its usefulness. In cases where the trailing custom OEM data include a nested AMI PFAT structure, the utility will process and extract it automatically as well. #### **Usage**