mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-13 06:34:42 -04:00
Format detectors now accept input bytes or path
This commit is contained in:
parent
a2eca0aac6
commit
982e3f3fc9
4 changed files with 27 additions and 9 deletions
|
@ -7,7 +7,7 @@ AMI BIOS Guard Extractor
|
||||||
Copyright (C) 2018-2022 Plato Mavropoulos
|
Copyright (C) 2018-2022 Plato Mavropoulos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
title = 'AMI BIOS Guard Extractor v4.0_a7'
|
title = 'AMI BIOS Guard Extractor v4.0_a8'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -23,6 +23,7 @@ from common.path_ops import safe_name, make_dirs
|
||||||
from common.patterns import PAT_AMI_PFAT
|
from common.patterns import PAT_AMI_PFAT
|
||||||
from common.struct_ops import get_struct, char, uint8_t, uint16_t, uint32_t
|
from common.struct_ops import get_struct, char, uint8_t, uint16_t, uint32_t
|
||||||
from common.system import script_init, argparse_init, printer
|
from common.system import script_init, argparse_init, printer
|
||||||
|
from common.text_ops import file_to_bytes
|
||||||
|
|
||||||
class AmiBiosGuardHeader(ctypes.LittleEndianStructure):
|
class AmiBiosGuardHeader(ctypes.LittleEndianStructure):
|
||||||
_pack_ = 1
|
_pack_ = 1
|
||||||
|
@ -127,7 +128,9 @@ class IntelBiosGuardSignature2k(ctypes.LittleEndianStructure):
|
||||||
printer(['Exponent :', '0x%X' % self.Exponent], p, False)
|
printer(['Exponent :', '0x%X' % self.Exponent], p, False)
|
||||||
printer(['Signature:', '%s [...]' % Signature[:32]], p, False)
|
printer(['Signature:', '%s [...]' % Signature[:32]], p, False)
|
||||||
|
|
||||||
def is_ami_pfat(input_buffer):
|
def is_ami_pfat(in_file):
|
||||||
|
input_buffer = file_to_bytes(in_file)
|
||||||
|
|
||||||
return bool(get_ami_pfat(input_buffer)[0])
|
return bool(get_ami_pfat(input_buffer)[0])
|
||||||
|
|
||||||
def get_ami_pfat(input_buffer):
|
def get_ami_pfat(input_buffer):
|
||||||
|
|
|
@ -7,7 +7,7 @@ AMI UCP BIOS Extractor
|
||||||
Copyright (C) 2021-2022 Plato Mavropoulos
|
Copyright (C) 2021-2022 Plato Mavropoulos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
title = 'AMI UCP BIOS Extractor v2.0_a9'
|
title = 'AMI UCP BIOS Extractor v2.0_a10'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -26,7 +26,7 @@ from common.path_ops import agnostic_path, safe_name, safe_path, make_dirs
|
||||||
from common.patterns import PAT_AMI_UCP, PAT_INTEL_ENG
|
from common.patterns import PAT_AMI_UCP, PAT_INTEL_ENG
|
||||||
from common.struct_ops import get_struct, char, uint8_t, uint16_t, uint32_t
|
from common.struct_ops import get_struct, char, uint8_t, uint16_t, uint32_t
|
||||||
from common.system import script_init, argparse_init, printer
|
from common.system import script_init, argparse_init, printer
|
||||||
from common.text_ops import to_string
|
from common.text_ops import file_to_bytes, to_string
|
||||||
|
|
||||||
from AMI_PFAT_Extract import get_ami_pfat, parse_pfat_file
|
from AMI_PFAT_Extract import get_ami_pfat, parse_pfat_file
|
||||||
|
|
||||||
|
@ -159,8 +159,10 @@ def chk16_validate(data, tag, padd=0):
|
||||||
else:
|
else:
|
||||||
printer('Checksum of UCP Module %s is valid!' % tag, padd)
|
printer('Checksum of UCP Module %s is valid!' % tag, padd)
|
||||||
|
|
||||||
# Check if input file is AMI UCP image
|
# Check if input path or buffer is AMI UCP image
|
||||||
def is_ami_ucp(buffer):
|
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])
|
||||||
|
|
||||||
# Get all input file AMI UCP patterns
|
# Get all input file AMI UCP patterns
|
||||||
|
|
|
@ -7,7 +7,7 @@ Dell PFS Update Extractor
|
||||||
Copyright (C) 2018-2022 Plato Mavropoulos
|
Copyright (C) 2018-2022 Plato Mavropoulos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
title = 'Dell PFS Update Extractor v6.0_a6'
|
title = 'Dell PFS Update Extractor v6.0_a7'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
|
@ -25,6 +25,7 @@ from common.path_ops import safe_name, make_dirs
|
||||||
from common.patterns import PAT_DELL_HDR, PAT_DELL_FTR, PAT_DELL_PKG
|
from common.patterns import PAT_DELL_HDR, PAT_DELL_FTR, PAT_DELL_PKG
|
||||||
from common.struct_ops import get_struct, char, uint8_t, uint16_t, uint32_t, uint64_t
|
from common.struct_ops import get_struct, char, uint8_t, uint16_t, uint32_t, uint64_t
|
||||||
from common.system import script_init, argparse_init, printer
|
from common.system import script_init, argparse_init, printer
|
||||||
|
from common.text_ops import file_to_bytes
|
||||||
|
|
||||||
from AMI_PFAT_Extract import IntelBiosGuardHeader, IntelBiosGuardSignature2k, parse_bg_script
|
from AMI_PFAT_Extract import IntelBiosGuardHeader, IntelBiosGuardSignature2k, parse_bg_script
|
||||||
|
|
||||||
|
@ -205,8 +206,10 @@ def is_pfs_hdr(in_buffer):
|
||||||
def is_pfs_ftr(in_buffer):
|
def is_pfs_ftr(in_buffer):
|
||||||
return PAT_DELL_FTR.search(in_buffer)
|
return PAT_DELL_FTR.search(in_buffer)
|
||||||
|
|
||||||
# Check if input buffer is Dell PFS/PKG image
|
# Check if input path or buffer is Dell PFS/PKG image
|
||||||
def is_dell_pfs(in_buffer):
|
def is_dell_pfs(in_file):
|
||||||
|
in_buffer = file_to_bytes(in_file)
|
||||||
|
|
||||||
return bool(is_pfs_hdr(in_buffer) or is_pfs_pkg(in_buffer))
|
return bool(is_pfs_hdr(in_buffer) or is_pfs_pkg(in_buffer))
|
||||||
|
|
||||||
# Get PFS ZLIB Section Offsets
|
# Get PFS ZLIB Section Offsets
|
||||||
|
|
|
@ -17,3 +17,13 @@ def to_string(input_object, sep_char=''):
|
||||||
output_string = str(input_object)
|
output_string = str(input_object)
|
||||||
|
|
||||||
return output_string
|
return output_string
|
||||||
|
|
||||||
|
# Get Bytes from given buffer or file path
|
||||||
|
def file_to_bytes(in_object):
|
||||||
|
object_bytes = in_object
|
||||||
|
|
||||||
|
if type(in_object).__name__ not in ('bytes','bytearray'):
|
||||||
|
with open(to_string(in_object), 'rb') as object_data:
|
||||||
|
object_bytes = object_data.read()
|
||||||
|
|
||||||
|
return object_bytes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue