Skip to content

Commit e235b7f

Browse files
committed
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
1 parent fa1283e commit e235b7f

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

AMI BIOS Guard Extractor/AMI_PFAT_Extract.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"""
55
AMI PFAT Extract
66
AMI BIOS Guard Extractor
7-
Copyright (C) 2018-2020 Plato Mavropoulos
7+
Copyright (C) 2018-2021 Plato Mavropoulos
88
"""
99

10-
print('AMI BIOS Guard Extractor v3.0')
10+
print('AMI BIOS Guard Extractor v3.1')
1111

1212
import sys
1313

@@ -21,7 +21,6 @@
2121
import os
2222
import re
2323
import ctypes
24-
import struct
2524
import shutil
2625
import traceback
2726

@@ -205,7 +204,7 @@ def get_struct(buffer, start_offset, class_name, param_list = None) :
205204
input_dir = os.path.dirname(os.path.abspath(input_file))
206205

207206
file_data = b''
208-
final_image = b''
207+
final_data = b''
209208
block_name = ''
210209
block_count = 0
211210
file_index = 0
@@ -284,7 +283,7 @@ def get_struct(buffer, start_offset, class_name, param_list = None) :
284283
print(' Error: BIOS Guard Script Tool dependency missing!')
285284

286285
file_data += block_data
287-
final_image += block_data
286+
final_data += block_data
288287

289288
if i and is_file_start and file_data :
290289
file_index += 1
@@ -296,9 +295,10 @@ def get_struct(buffer, start_offset, class_name, param_list = None) :
296295

297296
with open('%s_%0.2d -- %s' % (file_path, file_index + 1, block_name), 'wb') as o : o.write(file_data) # Last File
298297

299-
with open('%s_00 -- AMI_PFAT_%d_DATA_ALL.bin' % (file_path, pfat_index), 'wb') as final : final.write(final_image)
300-
301298
eof_data = buffer[block_start:] # Store any data after the end of PFAT
299+
300+
with open('%s_00 -- AMI_PFAT_%d_DATA_ALL.bin' % (file_path, pfat_index), 'wb') as final : final.write(final_data + eof_data)
301+
302302
if eof_data[:-0x100] != b'\xFF' * (len(eof_data) - 0x100) :
303303
eof_path = '%s_%0.2d -- AMI_PFAT_%d_DATA_END.bin' % (file_path, file_index + 2, pfat_index)
304304
with open(eof_path, 'wb') as final : final.write(eof_data)
@@ -310,5 +310,4 @@ def get_struct(buffer, start_offset, class_name, param_list = None) :
310310
else :
311311
pfat_index = 1
312312

313-
else :
314-
input('\nDone!')
313+
input('\nDone!')

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019-2020 Plato Mavropoulos
1+
Copyright (c) 2019-2021 Plato Mavropoulos
22

33
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Some Anti-Virus software may claim that the built/frozen/compiled executable con
6666

6767
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.
6868

69-
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.
69+
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.
7070

7171
#### **Usage**
7272

0 commit comments

Comments
 (0)