Fix main pattern detections, when found at offset 0x0

AMI UCP Update Extractor v2.0_a15

Phoenix TDK Packer Extractor v2.0_a7

Portwell EFI Update Extractor v2.0_a9

Fixes issue #13, thanks @PCRider for the report!
This commit is contained in:
platomav 2022-06-16 01:13:41 +03:00
parent fddd33aafd
commit f5905ec662
4 changed files with 14 additions and 19 deletions

View file

@ -7,7 +7,7 @@ AMI UCP Update Extractor
Copyright (C) 2021-2022 Plato Mavropoulos
"""
TITLE = 'AMI UCP Update Extractor v2.0_a14'
TITLE = 'AMI UCP Update Extractor v2.0_a15'
import os
import re
@ -163,13 +163,13 @@ def chk16_validate(data, tag, padd=0):
def is_ami_ucp(in_file):
buffer = file_to_bytes(in_file)
return bool(get_ami_ucp(buffer)[0])
return bool(get_ami_ucp(buffer)[0] != None)
# Get all input file AMI UCP patterns
def get_ami_ucp(buffer):
uaf_len_max = 0x0 # Length of largest detected @UAF|@HPU
uaf_hdr_off = 0x0 # Offset of largest detected @UAF|@HPU
uaf_buf_bin = b'' # Buffer of largest detected @UAF|@HPU
uaf_hdr_off = None # Offset of largest detected @UAF|@HPU
uaf_buf_bin = None # Buffer of largest detected @UAF|@HPU
uaf_buf_tag = '@UAF' # Tag of largest detected @UAF|@HPU
for uaf in PAT_AMI_UCP.finditer(buffer):
@ -419,7 +419,7 @@ def uaf_extract(buffer, extract_path, mod_info, padding=0, is_checksum=False, na
nested_uaf_off,nested_uaf_bin,nested_uaf_tag = get_ami_ucp(uaf_data_raw)
# Parse Nested AMI UCP Structure
if nested_uaf_off:
if nested_uaf_off != None:
uaf_dir = os.path.join(extract_path, safe_name(f'{uaf_tag}_nested-UCP')) # Generate extraction directory
ucp_extract(nested_uaf_bin, uaf_dir, nested_uaf_tag, padding + 4, is_checksum) # Call recursively
@ -512,7 +512,7 @@ if __name__ == '__main__':
# Get best AMI UCP Pattern match based on @UAF|@HPU Size
main_uaf_off,main_uaf_bin,main_uaf_tag = get_ami_ucp(input_buffer)
if not main_uaf_off:
if main_uaf_off == None:
printer('Error: This is not an AMI UCP Update executable!', padding)
continue # Next input file

View file

@ -7,7 +7,7 @@ Phoenix TDK Packer Extractor
Copyright (C) 2021-2022 Plato Mavropoulos
"""
TITLE = 'Phoenix TDK Packer Extractor v2.0_a6'
TITLE = 'Phoenix TDK Packer Extractor v2.0_a7'
import os
import sys
@ -149,7 +149,7 @@ def get_phoenix_tdk(in_buffer):
def is_phoenix_tdk(in_file):
buffer = file_to_bytes(in_file)
return bool(get_phoenix_tdk(buffer)[1])
return bool(get_phoenix_tdk(buffer)[1] != None)
# Parse & Extract Phoenix Tools Development Kit (TDK) Packer
def phoenix_tdk_extract(input_buffer, output_path, pack_off, base_off=0, padding=0):
@ -253,7 +253,7 @@ if __name__ == '__main__':
tdk_base_off,tdk_pack_off = get_phoenix_tdk(input_buffer)
# Check if Phoenix TDK Packer pattern was found on executable
if not tdk_pack_off:
if tdk_pack_off == None:
printer('Error: This is not a Phoenix TDK Packer executable!', padding)
continue # Next input file

View file

@ -7,7 +7,7 @@ Portwell EFI Update Extractor
Copyright (C) 2021-2022 Plato Mavropoulos
"""
TITLE = 'Portwell EFI Update Extractor v2.0_a8'
TITLE = 'Portwell EFI Update Extractor v2.0_a9'
import os
import sys
@ -40,7 +40,7 @@ def is_portwell_efi(in_file):
is_mz = PAT_MICROSOFT_MZ.search(in_buffer[:0x2]) # EFI images start with PE Header MZ
is_uu = PAT_PORTWELL_EFI.search(pe_buffer[:0x4]) # Portwell EFI files start with <UU>
return is_mz and is_uu
return bool(is_mz and is_uu)
# Get PE of Portwell EFI executable
def get_portwell_pe(in_buffer):

View file

@ -3,8 +3,6 @@
[BIOS Utilities News Feed](https://twitter.com/platomaniac)
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DJDZD3PRGCSCL"><img border="0" title="BIOS Utilities Donation via Paypal or Debit/Credit Card" alt="BIOS Utilities Donation via Paypal or Debit/Credit Card" src="https://user-images.githubusercontent.com/11527726/109392268-e0f68280-7923-11eb-83d8-0a63f0d20783.png"></a>
* [**AMI BIOS Guard Extractor**](#ami-bios-guard-extractor)
* [**AMI UCP Update Extractor**](#ami-ucp-update-extractor)
* [**Dell PFS Update Extractor**](#dell-pfs-update-extractor)
@ -100,7 +98,7 @@ Should work at all Windows, Linux or macOS operating systems which have Python 3
To run the utility, you must have the following 3rd party tools at the "external" project directory:
* [TianoCompress](https://github.com/tianocore/edk2/tree/master/BaseTools/Source/C/TianoCompress/) (e.g. [TianoCompress.exe for Windows](https://github.com/tianocore/edk2-BaseTools-win32/) or TianoCompress for Linux)
* [7-Zip Console](https://www.7-zip.org/) (i.e. 7z.exe for Windows or 7zz|7zzs for Linux)
* [7-Zip Console](https://www.7-zip.org/) (i.e. 7z.exe for Windows or 7zzs for Linux)
Optionally, to decompile the AMI UCP \> AMI PFAT \> Intel BIOS Guard Scripts (when applicable), you must have the following 3rd party utility at the "external" project directory:
@ -364,7 +362,7 @@ PyInstaller can build/freeze/compile the utility at all three supported platform
3. Build/Freeze/Compile:
> pyinstaller --noupx --onefile \<path-to-project\>\/Phoenix_TDK_Extract.py
> pyinstaller --noupx --onefile \<path-to-project\>\/VAIO_Package_Extract.py
At dist folder you should find the final utility executable
@ -375,6 +373,3 @@ Some Anti-Virus software may claim that the built/frozen/compiled executable con
#### **Pictures**
![]()
###### _Donate Button Card Image: [Credit and Loan Pack](https://flaticon.com/free-icon/credit-card_3898076) by **Freepik** under Flaticon license_
###### _Donate Button Paypal Image: [Credit Cards Pack](https://flaticon.com/free-icon/paypal_349278) by **Freepik** under Flaticon license_