Skip to content

Commit 04bbcf2

Browse files
committed
New scripts, updated current scripts, new repo license
Added Dell PFS BIOS Extractor v3.0 (removed Dell HDR Module Extractor v2.0) Added Apple EFI Package Extractor v1.1 Apple EFI File Renamer v1.3 supports calling from Apple EFI Package Extractor utility Apple EFI IM4P Splitter v1.3 supports calling from Apple EFI Package Extractor utility Apple EFI Sucatalog Link Grabber v1.2 stores output text file with unique name for easier comparisons Repository is now licensed under BSD+Patent All scripts now require Python 3.7 or newer
1 parent 19a3a56 commit 04bbcf2

File tree

8 files changed

+841
-774
lines changed

8 files changed

+841
-774
lines changed

Apple EFI File Renamer/Apple_EFI_Rename.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"""
44
Apple EFI Rename
55
Apple EFI File Renamer
6-
Copyright (C) 2018 Plato Mavropoulos
6+
Copyright (C) 2018-2019 Plato Mavropoulos
77
https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Include/Library/BiosIdLib.h
88
"""
99

10-
print('Apple EFI File Renamer v1.2\n')
10+
print('Apple EFI File Renamer v1.3\n')
1111

1212
import os
1313
import re
@@ -18,12 +18,18 @@
1818

1919
pattern = re.compile(br'\x24\x49\x42\x49\x4F\x53\x49\x24') # Intel $IBIOSI$
2020

21-
if len(sys.argv) >= 2 :
21+
if len(sys.argv) >= 3 and sys.argv[1] == '-skip' :
22+
# Called via Apple_EFI_Package
23+
apple_efi = sys.argv[2:]
24+
skip_pause = True
25+
elif len(sys.argv) >= 2 :
2226
# Drag & Drop or CLI
2327
apple_efi = sys.argv[1:]
28+
skip_pause = False
2429
else :
2530
# Folder path
2631
apple_efi = []
32+
skip_pause = False
2733
in_path = input('\nEnter the full folder path: ')
2834
print('\nWorking...\n')
2935
for root, dirs, files in os.walk(in_path):
@@ -95,4 +101,4 @@
95101
print('\nError: Could not find $IBIOSI$ pattern at %s!' % file_name)
96102
print(' Make sure that "UEFIFind" and "UEFIExtract" executables exist!\n')
97103

98-
input('Done!')
104+
if not skip_pause : input('Done!')

Apple EFI IM4P Splitter/Apple_EFI_Split.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"""
44
Apple EFI Split
55
Apple EFI IM4P Splitter
6-
Copyright (C) 2018 Plato Mavropoulos
6+
Copyright (C) 2018-2019 Plato Mavropoulos
77
"""
88

9-
print('Apple EFI IM4P Splitter v1.2')
9+
print('Apple EFI IM4P Splitter v1.3')
1010

1111
import os
1212
import re
@@ -15,12 +15,19 @@
1515
im4p = re.compile(br'\x16\x04\x49\x4D\x34\x50\x16\x04') # Apple IM4P
1616
ifd = re.compile(br'\x5A\xA5\xF0\x0F.{172}\xFF{16}', re.DOTALL) # Intel Flash Descriptor
1717

18-
if len(sys.argv) >= 2 :
18+
# Get input catalog file paths
19+
if len(sys.argv) >= 3 and sys.argv[1] == '-skip' :
20+
# Called via Apple_EFI_Package
21+
apple_im4p = sys.argv[2:]
22+
skip_pause = True
23+
elif len(sys.argv) >= 2 :
1924
# Drag & Drop or CLI
2025
apple_im4p = sys.argv[1:]
26+
skip_pause = False
2127
else :
2228
# Folder path
2329
apple_im4p = []
30+
skip_pause = False
2431
in_path = input('\nEnter the full folder path: ')
2532
print('\nWorking...')
2633
for root, dirs, files in os.walk(in_path):
@@ -73,4 +80,6 @@
7380

7481
spi_start += spi_size
7582

76-
input('\nDone!')
83+
print('\n Split IM4P file into %d SPI/BIOS image(s)!' % len(ifd_count))
84+
85+
if not skip_pause : input('\nDone!')
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Apple EFI Package
5+
Apple EFI Package Extractor
6+
Copyright (C) 2019 Plato Mavropoulos
7+
"""
8+
9+
print('Apple EFI Package Extractor v1.1')
10+
11+
import os
12+
import sys
13+
import zlib
14+
import shutil
15+
import subprocess
16+
17+
if len(sys.argv) >= 2 :
18+
pkg = sys.argv[1:]
19+
else :
20+
pkg = []
21+
in_path = input('\nEnter the full folder path: ')
22+
print('\nWorking...')
23+
for root, dirs, files in os.walk(in_path):
24+
for name in files :
25+
pkg.append(os.path.join(root, name))
26+
27+
anytoiso_path = 'C:\\Program Files (x86)\\AnyToISO\\anytoiso.exe'
28+
29+
final_path = os.path.join(os.getcwd(), 'AppleEFI')
30+
if os.path.exists(final_path) : shutil.rmtree(final_path)
31+
32+
for input_file in pkg :
33+
file_path = os.path.abspath(input_file)
34+
file_name = os.path.basename(input_file)
35+
file_dir = os.path.dirname(file_path)
36+
file_ext = os.path.splitext(file_path)[1]
37+
38+
print('\nFile: %s\n' % file_name)
39+
40+
with open(input_file, 'rb') as in_buff : file_adler = zlib.adler32(in_buff.read()) & 0xFFFFFFFF
41+
42+
pkg_payload = os.path.join(final_path, '%s_%0.8X' % (file_name, file_adler))
43+
pkg_temp = os.path.join(final_path, '__TEMP_%s_%0.8X' % (file_name, file_adler))
44+
os.makedirs(pkg_temp)
45+
46+
subprocess.run([anytoiso_path, '/extract', file_path, pkg_temp], check = True, stdout=subprocess.DEVNULL)
47+
48+
if os.path.isfile(os.path.join(pkg_temp, 'Scripts')) :
49+
scripts_init = os.path.join(pkg_temp, 'Scripts')
50+
scripts_cpgz = os.path.join(pkg_temp, 'Scripts.cpgz')
51+
scripts_extr = os.path.join(pkg_temp, 'Scripts', '')
52+
efi_path = os.path.join(scripts_extr, 'Tools', 'EFIPayloads', '')
53+
54+
os.replace(scripts_init, scripts_cpgz)
55+
56+
subprocess.run([anytoiso_path, '/extract', scripts_cpgz, scripts_extr], check = True, stdout=subprocess.DEVNULL)
57+
58+
shutil.copytree(efi_path, pkg_payload)
59+
60+
elif os.path.isfile(os.path.join(pkg_temp, 'Payload')) :
61+
payload_init = os.path.join(pkg_temp, 'Payload')
62+
payload_pbzx = os.path.join(pkg_temp, 'Payload.pbzx')
63+
payload_extr = os.path.join(pkg_temp, 'Payload', '')
64+
zip_path = os.path.join(payload_extr, 'usr', 'standalone', 'firmware', 'bridgeOSCustomer.bundle', 'Contents', 'Resources', 'UpdateBundle')
65+
efi_path = os.path.join(zip_path, 'boot', 'Firmware', 'MacEFI', '')
66+
67+
os.replace(payload_init, payload_pbzx)
68+
69+
subprocess.run([anytoiso_path, '/extract', payload_pbzx, payload_extr], check = True, stdout=subprocess.DEVNULL)
70+
71+
subprocess.run([anytoiso_path, '/extract', zip_path + '.zip', zip_path], check = True, stdout=subprocess.DEVNULL)
72+
73+
if os.path.exists(efi_path) : shutil.copytree(efi_path, pkg_payload)
74+
75+
shutil.rmtree(pkg_temp)
76+
77+
im4p_files = []
78+
for root, dirs, files in os.walk(pkg_payload):
79+
for name in files :
80+
if name.endswith('.im4p') :
81+
im4p_files.append(os.path.join(root, name))
82+
83+
if im4p_files : subprocess.run(['python', 'Apple_EFI_Split.py', '-skip', *im4p_files], check = True, stdout=subprocess.DEVNULL)
84+
for im4p in im4p_files : os.remove(im4p)
85+
86+
final_files = []
87+
for root, dirs, files in os.walk(pkg_payload):
88+
for name in files :
89+
final_files.append(os.path.join(root, name))
90+
91+
if final_files : subprocess.run(['python', 'Apple_EFI_Rename.py', '-skip', *final_files], check = True, stdout=subprocess.DEVNULL)
92+
93+
for root, dirs, files in os.walk(pkg_payload):
94+
for name in files :
95+
if not os.path.isfile(os.path.join(final_path, name)) :
96+
shutil.copy2(os.path.join(root, name), os.path.join(final_path, name))
97+
98+
shutil.rmtree(pkg_payload)
99+
100+
else :
101+
input('\nDone!')

Apple EFI Sucatalog Link Grabber/Apple_EFI_Links.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
"""
44
Apple EFI Links
55
Apple EFI Sucatalog Link Grabber
6-
Copyright (C) 2018 Plato Mavropoulos
6+
Copyright (C) 2018-2019 Plato Mavropoulos
77
"""
88

9-
print('Apple EFI Sucatalog Link Grabber v1.1\n')
9+
print('Apple EFI Sucatalog Link Grabber v1.2\n')
1010

1111
import os
1212
import sys
13+
import datetime
1314

1415
# Remove previous output files
1516
if os.path.isfile('OUT.txt') : os.remove('OUT.txt')
16-
if os.path.isfile('EFI.txt') : os.remove('EFI.txt')
1717

1818
# Get input catalog file paths
1919
if len(sys.argv) >= 2 :
@@ -31,6 +31,10 @@
3131

3232
# Parse each input xml file
3333
for input_file in catalogs :
34+
input_name,input_extension = os.path.splitext(os.path.basename(input_file))
35+
36+
print('\n%s%s' % (input_name, input_extension))
37+
3438
with open(input_file, 'r') as in_file :
3539
for line in in_file :
3640
# Find EFI Firmware package links
@@ -54,7 +58,13 @@
5458

5559
final_lines = ''.join(map(str, sorted(final_lines)))
5660

57-
with open('EFI.txt', 'w') as efi_file : efi_file.write(final_lines) # Save final output file
61+
current_datetime = datetime.datetime.utcnow().isoformat(timespec='seconds').replace('-','').replace('T','').replace(':','')
62+
63+
output_file = 'EFI %s.txt' % current_datetime
64+
65+
with open(output_file, 'w') as efi_file : efi_file.write(final_lines) # Save final output file
66+
67+
print('\nStored %s!' % output_file)
5868

5969
os.remove('OUT.txt') # Remove temporary output file
6070

Dell HDR Module Extractor/Dell_HDR_Extract.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)