Allow optional spoofing on native Models

This commit is contained in:
Mykola Grymalyuk
2022-01-14 18:04:39 -07:00
parent 64b9e7ada6
commit 023fec03aa
6 changed files with 66 additions and 10 deletions

View File

@@ -19,6 +19,8 @@
- Add wxPython Based GUI
- Superceeds Obj-C Based GUI
- Both standard and offline builds provided
- Allow optional spoofing on native Models
- Recommended for systems that cannot update their firmware natively (ie. dead internal drive)
## 0.3.3
- Disable Asset Caching support with spoofless approach

View File

@@ -1915,10 +1915,22 @@ class wx_python_gui:
self.smbios_model_dropdown.Bind(wx.EVT_CHOICE, self.smbios_model_click)
self.smbios_model_dropdown.Center(wx.HORIZONTAL)
# Checkbox: Allow Native Spoofs
self.native_spoof_checkbox = wx.CheckBox(self.frame, label="Allow Native Spoofs")
self.native_spoof_checkbox.SetValue(self.constants.allow_native_spoofs)
self.native_spoof_checkbox.SetPosition(
wx.Point(self.smbios_model_dropdown.GetPosition().x, self.smbios_model_dropdown.GetPosition().y + self.smbios_model_dropdown.GetSize().height + 10)
)
self.native_spoof_checkbox.Bind(wx.EVT_CHECKBOX, self.native_spoof_click)
self.native_spoof_checkbox.Center(wx.HORIZONTAL)
self.native_spoof_checkbox.SetToolTip(wx.ToolTip("For native systems that cannot update their firmware, this option will allow OCLP to spoof the SMBIOS."))
if self.constants.allow_oc_everywhere is False:
self.native_spoof_checkbox.Disable()
# Button: Return to Main Menu
self.return_to_main_menu_button = wx.Button(self.frame, label="Return to Main Menu")
self.return_to_main_menu_button.SetPosition(
wx.Point(self.smbios_model_dropdown.GetPosition().x, self.smbios_model_dropdown.GetPosition().y + self.smbios_model_dropdown.GetSize().height + 10)
wx.Point(self.native_spoof_checkbox.GetPosition().x, self.native_spoof_checkbox.GetPosition().y + self.native_spoof_checkbox.GetSize().height + 10)
)
self.return_to_main_menu_button.Bind(wx.EVT_BUTTON, self.main_menu)
self.return_to_main_menu_button.Center(wx.HORIZONTAL)
@@ -1926,7 +1938,14 @@ class wx_python_gui:
self.frame.SetSize(wx.Size(-1, self.return_to_main_menu_button.GetPosition().y + self.return_to_main_menu_button.GetSize().height + 40))
def native_spoof_click(self, event):
if self.native_spoof_checkbox.GetValue():
print("Allow Native Spoofs Enabled")
self.constants.allow_native_spoofs = True
else:
print("Allow Native Spoofs Disabled")
self.constants.allow_native_spoofs = False
def smbios_spoof_level_click(self, event=None):
selection = self.smbios_dropdown.GetStringSelection()
print(f"SMBIOS Spoof Level: {selection}")

View File

@@ -144,7 +144,7 @@ class BuildOpenCore:
]:
self.enable_kext(name, version, path, check)
if self.constants.allow_oc_everywhere is False:
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True:
if self.constants.serial_settings == "None":
# Credit to Parrotgeek1 for boot.efi and hv_vmm_present patch sets
# print("- Enabling Board ID exemption patch")
@@ -384,7 +384,7 @@ class BuildOpenCore:
usb_map_path = Path(self.constants.plist_folder_path) / Path("AppleUSBMaps/Info.plist")
if (
usb_map_path.exists()
and self.constants.allow_oc_everywhere is False
and (self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True)
and self.model not in ["Xserve2,1", "Dortania1,1"]
and (self.model in model_array.Missing_USB_Map or self.constants.serial_settings in ["Moderate", "Advanced"])
):
@@ -395,7 +395,7 @@ class BuildOpenCore:
self.get_kext_by_bundle_path("USB-Map.kext")["Enabled"] = True
if self.constants.allow_oc_everywhere is False:
if self.constants.serial_settings != "None":
if self.constants.serial_settings != "None":
if self.model == "MacBookPro9,1":
print("- Adding AppleMuxControl Override")
amc_map_path = Path(self.constants.plist_folder_path) / Path("AppleMuxControl/Info.plist")
@@ -907,7 +907,10 @@ class BuildOpenCore:
if self.constants.override_smbios == "Default":
if self.constants.serial_settings != "None":
print("- Setting macOS Monterey Supported SMBIOS")
spoofed_model = generate_smbios.set_smbios_model_spoof(self.model)
if self.constants.allow_native_spoofs is True:
spoofed_model = self.model
else:
spoofed_model = generate_smbios.set_smbios_model_spoof(self.model)
else:
spoofed_model = self.constants.override_smbios
print(f"- Using Model ID: {spoofed_model}")
@@ -918,7 +921,7 @@ class BuildOpenCore:
spoofed_board = ""
self.spoofed_model = spoofed_model
self.spoofed_board = spoofed_board
if self.constants.allow_oc_everywhere is False:
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True:
self.config["#Revision"]["Spoofed-Model"] = f"{self.spoofed_model} - {self.constants.serial_settings}"
# Setup menu
@@ -1175,7 +1178,7 @@ class BuildOpenCore:
def build_opencore(self):
self.build_efi()
if self.constants.allow_oc_everywhere is False:
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True:
self.set_smbios()
self.cleanup()
self.sign_files()

View File

@@ -891,6 +891,30 @@ Supported Options:
print("Invalid input, returning to previous menu")
self.set_fu_settings()
def set_allow_native_spoofs(self):
utilities.cls()
utilities.header(["Allow Native Spoofs"])
print(
"""
By default OCLP will not touch the SMBIOS of native models
to ensure a "stock-like" environment. However for systems that
cannot update their firmware, this option will allow OCLP to
spoof the SMBIOS.
By default VMM is used to spoof the SMBIOS. Minimal and higher are
available however not officially supported.
"""
)
change_menu = input("Allow Native Spoofs?(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.allow_native_spoofs = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.allow_native_spoofs = False
elif change_menu in {"q", "Q", "Quit", "quit"}:
print("Returning to previous menu")
else:
self.set_allow_native_spoofs()
def set_nvram_write(self):
utilities.cls()
utilities.header(["Set NVRAM Write"])
@@ -1088,6 +1112,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
options = [
[f"Set SMBIOS Spoof Level:\tCurrently {self.constants.serial_settings}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).change_serial],
[f"Set SMBIOS Spoof Model:\tCurrently {self.constants.override_smbios}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_smbios],
[f"Allow Native Spoofs:\tCurrently {self.constants.allow_native_spoofs}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).set_allow_native_spoofs],
[f"Set Custom name {self.constants.custom_cpu_model_value}", MenuOptions(self.constants.custom_model or self.constants.computer.real_model, self.constants).custom_cpu],
]

View File

@@ -122,6 +122,7 @@ class Constants:
self.custom_cpu_model_value = "" # New CPU name within About This Mac
self.serial_settings = "None" # Set SMBIOS level used
self.override_smbios = "Default" # Set SMBIOS model used
self.allow_native_spoofs = False # Allow native models to recieve spoofs
## FeatureUnlock Settings
self.fu_status = True # Enable FeatureUnlock

View File

@@ -71,9 +71,15 @@ def generate_fw_features(model, custom):
firmwarefeature = utilities.get_rom("firmware-features")
if not firmwarefeature:
print("- Failed to find FirmwareFeatures, falling back on defaults")
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
if smbios_data.smbios_dictionary[model]["FirmwareFeatures"] is None:
firmwarefeature = 0
else:
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
else:
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
if smbios_data.smbios_dictionary[model]["FirmwareFeatures"] is None:
firmwarefeature = 0
else:
firmwarefeature = int(smbios_data.smbios_dictionary[model]["FirmwareFeatures"], 16)
firmwarefeature = update_firmware_features(firmwarefeature)
return firmwarefeature