Add Serial Number Spoofing

This commit is contained in:
Mykola Grymalyuk
2022-05-06 23:07:45 -06:00
parent 7a859a8210
commit 8b4332e0c0
5 changed files with 135 additions and 11 deletions

View File

@@ -16,6 +16,8 @@
- Lists patch sets applied including files installed and removed
- Add `preinstall` script to AutoPatcher
- Removes old patcher files before installing new
- Add Serial Number Spoofing
- For recycled machines where MDM was mistakenly left on
## 0.4.4
- Lower SIP requirement for Root Patching

View File

@@ -2260,11 +2260,62 @@ class wx_python_gui:
self.smbios_model_dropdown.Bind(wx.EVT_CHOICE, self.smbios_model_click)
self.smbios_model_dropdown.Center(wx.HORIZONTAL)
# Label: Custom Serial Number
self.smbios_serial_label = wx.StaticText(self.frame, label="Custom Serial Number")
self.smbios_serial_label.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
self.smbios_serial_label.SetPosition(
wx.Point(self.smbios_model_dropdown.GetPosition().x, self.smbios_model_dropdown.GetPosition().y + self.smbios_model_dropdown.GetSize().height + 10)
)
self.smbios_serial_label.Center(wx.HORIZONTAL)
# Textbox: Custom Serial Number
self.smbios_serial_textbox = wx.TextCtrl(self.frame, style=wx.TE_CENTRE)
self.smbios_serial_textbox.SetPosition(
wx.Point(self.smbios_serial_label.GetPosition().x, self.smbios_serial_label.GetPosition().y + self.smbios_serial_label.GetSize().height + 5)
)
self.smbios_serial_textbox.SetValue(self.constants.custom_serial_number)
self.smbios_serial_textbox.SetSize(wx.Size(200, -1))
self.smbios_serial_textbox.Bind(wx.EVT_TEXT, self.smbios_serial_click)
self.smbios_serial_textbox.Center(wx.HORIZONTAL)
# Label: Custom Board Serial Number
self.smbios_board_serial_label = wx.StaticText(self.frame, label="Custom Board Serial Number")
self.smbios_board_serial_label.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
self.smbios_board_serial_label.SetPosition(
wx.Point(self.smbios_serial_textbox.GetPosition().x, self.smbios_serial_textbox.GetPosition().y + self.smbios_serial_textbox.GetSize().height + 10)
)
self.smbios_board_serial_label.Center(wx.HORIZONTAL)
# Textbox: Custom Board Serial Number
self.smbios_board_serial_textbox = wx.TextCtrl(self.frame, style=wx.TE_CENTRE)
self.smbios_board_serial_textbox.SetPosition(
wx.Point(self.smbios_board_serial_label.GetPosition().x, self.smbios_board_serial_label.GetPosition().y + self.smbios_board_serial_label.GetSize().height + 5)
)
self.smbios_board_serial_textbox.SetValue(self.constants.custom_board_serial_number)
self.smbios_board_serial_textbox.SetSize(wx.Size(200, -1))
self.smbios_board_serial_textbox.Bind(wx.EVT_TEXT, self.smbios_board_serial_click)
self.smbios_board_serial_textbox.Center(wx.HORIZONTAL)
# Button: Generate new serials
self.smbios_generate_button = wx.Button(self.frame, label=f"Generate S/N: {self.constants.custom_model or self.computer.real_model}")
self.smbios_generate_button.SetPosition(
wx.Point(self.smbios_board_serial_textbox.GetPosition().x, self.smbios_board_serial_textbox.GetPosition().y + self.smbios_board_serial_textbox.GetSize().height + 10)
)
self.smbios_generate_button.Center(wx.HORIZONTAL)
self.smbios_generate_button.Bind(wx.EVT_BUTTON, self.generate_new_serials_clicked)
if self.constants.allow_oc_everywhere is False and \
self.constants.custom_model is None and \
self.computer.real_model not in model_array.SupportedSMBIOS:
self.smbios_board_serial_textbox.Disable()
self.smbios_serial_textbox.Disable()
self.smbios_generate_button.Disable()
# 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)
wx.Point(self.smbios_generate_button.GetPosition().x, self.smbios_generate_button.GetPosition().y + self.smbios_generate_button.GetSize().height + 10)
)
self.native_spoof_checkbox.Bind(wx.EVT_CHECKBOX, self.native_spoof_click)
self.native_spoof_checkbox.Center(wx.HORIZONTAL)
@@ -2282,6 +2333,21 @@ 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 smbios_serial_click(self, event):
self.constants.custom_serial_number = self.smbios_serial_textbox.GetValue()
def smbios_board_serial_click(self, event):
self.constants.custom_board_serial_number = self.smbios_board_serial_textbox.GetValue()
def generate_new_serials_clicked(self, event):
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.constants.custom_model or self.computer.real_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
if len(macserial_output) == 2:
self.smbios_serial_textbox.SetValue(macserial_output[0])
self.smbios_board_serial_textbox.SetValue(macserial_output[1])
else:
self.smbios_serial_textbox.SetHint("Unable to generate serials")
self.smbios_board_serial_textbox.SetHint("Unable to generate serials")
def native_spoof_click(self, event):
if self.native_spoof_checkbox.GetValue():

View File

@@ -1023,9 +1023,34 @@ class BuildOpenCore:
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
self.config["PlatformInfo"]["UpdateDataHub"] = True
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
print("- Adding custom serial numbers")
sn = self.constants.custom_serial_number
mlb = self.constants.custom_board_serial_number
# Serial Number
self.config["PlatformInfo"]["SMBIOS"]["ChassisSerialNumber"] = sn
self.config["PlatformInfo"]["SMBIOS"]["SystemSerialNumber"] = sn
self.config["PlatformInfo"]["DataHub"]["SystemSerialNumber"] = sn
self.config["PlatformInfo"]["PlatformNVRAM"]["SystemSerialNumber"] = sn
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-SN"] = sn
# Board Serial Number
self.config["PlatformInfo"]["SMBIOS"]["BoardSerialNumber"] = mlb
self.config["PlatformInfo"]["PlatformNVRAM"]["BoardSerialNumber"] = mlb
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-MLB"] = mlb
def moderate_serial_patch(self):
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
print("- Adding custom serial numbers")
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = self.constants.custom_serial_number
self.config["PlatformInfo"]["Generic"]["MLB"] = self.constants.custom_board_serial_number
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-SN"] = self.constants.custom_serial_number
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-MLB"] = self.constants.custom_board_serial_number
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
self.config["PlatformInfo"]["Automatic"] = True
self.config["PlatformInfo"]["UpdateDataHub"] = True
@@ -1037,8 +1062,14 @@ class BuildOpenCore:
def advanced_serial_patch(self):
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "":
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
sn = macserial_output[0]
mlb = macserial_output[1]
else:
sn = self.constants.custom_serial_number
mlb = self.constants.custom_board_serial_number
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["run-efi-updater"] = "No"
self.config["PlatformInfo"]["Automatic"] = True
self.config["PlatformInfo"]["UpdateDataHub"] = True
@@ -1047,9 +1078,11 @@ class BuildOpenCore:
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
self.config["PlatformInfo"]["Generic"]["ROM"] = binascii.unhexlify("0016CB445566")
self.config["PlatformInfo"]["Generic"]["SystemProductName"] = self.spoofed_model
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = macserial_output[0]
self.config["PlatformInfo"]["Generic"]["MLB"] = macserial_output[1]
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = sn
self.config["PlatformInfo"]["Generic"]["MLB"] = mlb
self.config["PlatformInfo"]["Generic"]["SystemUUID"] = str(uuid.uuid4()).upper()
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-SN"] = sn
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-MLB"] = mlb
if self.constants.serial_settings == "Moderate":
@@ -1074,6 +1107,18 @@ class BuildOpenCore:
print("- Detected UEFI 1.2 or older Mac, updating BoardProduct")
self.config["PlatformInfo"]["DataHub"]["BoardProduct"] = self.spoofed_board
self.config["PlatformInfo"]["UpdateDataHub"] = True
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
print("- Adding custom serial numbers")
self.config["PlatformInfo"]["Automatic"] = True
self.config["PlatformInfo"]["UpdateDataHub"] = True
self.config["PlatformInfo"]["UpdateNVRAM"] = True
self.config["PlatformInfo"]["UpdateSMBIOS"] = True
self.config["UEFI"]["ProtocolOverrides"]["DataHub"] = True
self.config["PlatformInfo"]["Generic"]["SystemSerialNumber"] = self.constants.custom_serial_number
self.config["PlatformInfo"]["Generic"]["MLB"] = self.constants.custom_board_serial_number
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-SN"] = self.constants.custom_serial_number
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["OCLP-Spoofed-MLB"] = self.constants.custom_board_serial_number
# USB Map and CPUFriend Patching
if (
@@ -1239,7 +1284,7 @@ class BuildOpenCore:
def build_opencore(self):
self.build_efi()
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True:
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True or (self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != ""):
self.set_smbios()
self.cleanup()
self.sign_files()

View File

@@ -129,11 +129,13 @@ class Constants:
self.verbose_debug = False # -v
## SMBIOS Settings
self.custom_cpu_model = 2 # Patch type value
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
self.custom_cpu_model = 2 # Patch type value
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
self.custom_serial_number = "" # Set SMBIOS serial number
self.custom_board_serial_number = "" # Set SMBIOS board serial number
## FeatureUnlock Settings
self.fu_status = True # Enable FeatureUnlock

View File

@@ -11,8 +11,17 @@ class generate_defaults:
settings.sip_status = True
settings.secure_status = False # Default false for Monterey
settings.amfi_status = True
settings.custom_serial_number = ""
settings.custom_board_serial_number = ""
if host_is_target:
settings.custom_serial_number = utilities.get_nvram("OCLP-Spoofed-SN", "7C436110-AB2A-4BBB-A880-FE41995C9F82", decode=True)
settings.custom_board_serial_number = utilities.get_nvram("OCLP-Spoofed-MLB", "7C436110-AB2A-4BBB-A880-FE41995C9F82", decode=True)
if settings.custom_serial_number is None or settings.custom_board_serial_number is None:
# If either variables are missing, we assume something is wrong with the spoofed variables and reset
settings.custom_serial_number = ""
settings.custom_board_serial_number = ""
if settings.computer.usb_controllers:
try:
if smbios_data.smbios_dictionary[model]["CPU Generation"] < cpu_data.cpu_data.ivy_bridge.value: