all of nugget's features

This commit is contained in:
leminlimez
2024-09-18 12:41:47 -04:00
parent 347a34e40f
commit df5dd5dc02
73 changed files with 20376 additions and 176 deletions

0
tweaks/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,92 @@
from .tweak_classes import Tweak, TweakModifyType
from exploit.restore import FileToRestore
from devicemanagement.constants import Version
import plistlib
import sys
from pathlib import Path
from os import path, getcwd
class InvalidRegionCodeException(Exception):
"Region code must be exactly 2 characters long!"
pass
def replace_region_code(plist_path: str, original_code: str = "US", new_code: str = "US"):
with open(plist_path, 'rb') as f:
plist_data = plistlib.load(f)
plist_str = str(plist_data)
updated_plist_str = plist_str.replace(original_code, new_code)
updated_plist_data = eval(updated_plist_str) # Convert string back to dictionary
return plistlib.dumps(updated_plist_data)
class EligibilityTweak(Tweak):
def __init__(
self, label: str,
min_version: Version = Version("1.0"),
divider_below: bool = False
):
super().__init__(label=label, key=None, value=["Method 1", "Method 2"], edit_type=TweakModifyType.PICKER, min_version=min_version, divider_below=divider_below)
self.code = "US"
self.method = 0 # between 0 and 1
def set_region_code(self, new_code: str):
if new_code == '':
self.code = "US"
else:
self.code = new_code
def set_selected_option(self, new_method: int):
self.method = new_method % 2 # force it to be either 0 or 1
self.set_enabled(True)
def get_selected_option(self) -> int:
return self.method
def apply_tweak(self) -> list[FileToRestore]:
# credit to lrdsnow for EU Enabler
# https://github.com/Lrdsnow/EUEnabler/blob/main/app.py
if not self.enabled:
return None
print(f"Applying EU Enabler for region \'{self.code}\'...")
# get the plists directory
try:
source_dir = path.join(sys._MEIPASS, "files/eligibility")
except:
source_dir = path.join(getcwd(), "files/eligibility")
# start with eligibility.plist
file_path = path.join(source_dir, 'eligibility.plist')
eligibility_data = replace_region_code(file_path, original_code="US", new_code=self.code)
files_to_restore = [
FileToRestore(
contents=eligibility_data,
restore_path="/var/db/os_eligibility/",
restore_name="eligibility.plist"
)
]
# next modify config.plist
file_path = path.join(source_dir, 'Config.plist')
config_data = replace_region_code(file_path, original_code="US", new_code=self.code)
if self.method == 0:
files_to_restore.append(
FileToRestore(
contents=config_data,
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/c55a421c053e10233e5bfc15c42fa6230e5639a9.asset/AssetData/",
restore_name="Config.plist"
)
)
elif self.method == 1:
files_to_restore.append(
FileToRestore(
contents=config_data,
restore_path="/var/MobileAsset/AssetsV2/com_apple_MobileAsset_OSEligibility/purpose_auto/247556c634fc4cc4fd742f1b33af9abf194a986e.asset/AssetData/",
restore_name="Config.plist"
)
)
# return the new files to restore
return files_to_restore

123
tweaks/tweak_classes.py Normal file
View File

@@ -0,0 +1,123 @@
from enum import Enum
from devicemanagement.constants import Version
class TweakModifyType(Enum):
TOGGLE = 1
TEXT = 2
PICKER = 3
class Tweak:
def __init__(
self, label: str,
key: str, subkey: str = None,
value: any = 1,
edit_type: TweakModifyType = TweakModifyType.TOGGLE,
min_version: Version = Version("1.0"),
divider_below: bool = False
):
self.label = label
self.key = key
self.subkey = subkey
self.value = value
self.min_version = min_version
self.edit_type = edit_type
self.divider_below = divider_below
self.enabled = False
def set_enabled(self, value: bool):
self.enabled = value
def toggle_enabled(self):
self.enabled = not self.enabled
def set_value(self, new_value: any, toggle_enabled: bool = True):
self.value = new_value
if toggle_enabled:
self.enabled = True
def is_compatible(self, device_ver: str):
return Version(device_ver) >= self.min_version
def apply_tweak(self):
raise NotImplementedError
class MobileGestaltTweak(Tweak):
def apply_tweak(self, plist: dict):
if not self.enabled:
return plist
new_value = self.value
if self.subkey == None:
plist["CacheExtra"][self.key] = new_value
else:
plist["CacheExtra"][self.key][self.subkey] = new_value
return plist
class MobileGestaltPickerTweak(Tweak):
def __init__(
self, label: str,
key: str, subkey: str = None,
values: list = [1],
min_version: Version = Version("1.0"),
divider_below: bool = False
):
super().__init__(label=label, key=key, subkey=subkey, value=values, edit_type=TweakModifyType.PICKER, min_version=min_version, divider_below=divider_below)
self.selected_option = 0 # index of the selected option
def apply_tweak(self, plist: dict):
if not self.enabled:
return plist
new_value = self.value[self.selected_option]
if self.subkey == None:
plist["CacheExtra"][self.key] = new_value
else:
plist["CacheExtra"][self.key][self.subkey] = new_value
return plist
def set_selected_option(self, new_option: int):
self.selected_option = new_option
self.enabled = True
def get_selected_option(self) -> int:
return self.selected_option
class MobileGestaltMultiTweak(Tweak):
def __init__(self, label: str, keyValues: dict, min_version: Version = Version("1.0"), divider_below: bool = False):
super().__init__(label=label, key=None, min_version=min_version, divider_below=divider_below)
self.keyValues = keyValues
# key values looks like ["key name" = value]
def apply_tweak(self, plist: dict):
if not self.enabled:
return plist
for key in self.keyValues:
plist["CacheExtra"][key] = self.keyValues[key]
return plist
class FeatureFlagTweak(Tweak):
def __init__(
self, label: str,
flag_category: str, flag_names: list,
is_list: bool=True, inverted: bool=False,
min_version: Version = Version("1.0"),
divider_below: bool = False
):
super().__init__(label=label, key=None, min_version=min_version, divider_below=divider_below)
self.flag_category = flag_category
self.flag_names = flag_names
self.is_list = is_list
self.inverted = inverted
def apply_tweak(self, plist: dict):
to_enable = self.enabled
if self.inverted:
to_enable = not self.enabled
# create the category list if it doesn't exist
if not self.flag_category in plist:
plist[self.flag_category] = {}
for flag in self.flag_names:
if self.is_list:
plist[self.flag_category][flag] = {
'Enabled': to_enable
}
else:
plist[self.flag_category][flag] = to_enable
return plist

37
tweaks/tweaks.py Normal file
View File

@@ -0,0 +1,37 @@
from devicemanagement.constants import Version
from .tweak_classes import MobileGestaltTweak, MobileGestaltMultiTweak, MobileGestaltPickerTweak, FeatureFlagTweak, TweakModifyType
from .eligibility_tweak import EligibilityTweak
tweaks = {
"DynamicIsland": MobileGestaltPickerTweak("Toggle Dynamic Island", "oPeik/9e8lQWMszEjbPzng", "ArtworkDeviceSubType", [2436, 2556, 2796, 2976, 2622, 2868]),
"ModelName": MobileGestaltTweak("Set Device Model Name", "oPeik/9e8lQWMszEjbPzng", "ArtworkDeviceProductDescription", "", TweakModifyType.TEXT),
# MobileGestaltTweak("Fix Dynamic Island", "YlEtTtHlNesRBMal1CqRaA"),
# MobileGestaltTweak("Set Dynamic Island Location", "Zg7DduDoSCy6vY6mhy3n2w", value="{ x: 390.000000, y: 205.848432, width: 50.000000, height: 105.651573 }"), # not sure what value this is supposed to be but it removes the island currently
"BootChime": MobileGestaltTweak("Toggle Boot Chime", "QHxt+hGLaBPbQJbXiUJX3w"),
"ChargeLimit": MobileGestaltTweak("Toggle Charge Limit", "37NVydb//GP/GrhuTN+exg"),
"CollisionSOS": MobileGestaltTweak("Toggle Collision SOS", "HCzWusHQwZDea6nNhaKndw"),
"TapToWake": MobileGestaltTweak("Toggle Tap To Wake (iPhone SE)", "yZf3GTRMGTuwSV/lD7Cagw"),
"CameraButton": MobileGestaltMultiTweak("Toggle iPhone 16 Settings", {"CwvKxM2cEogD3p+HYgaW0Q": 1, "oOV1jhJbdV3AddkcCg0AEA": 1}, min_version=Version("18.0")),
"Parallax": MobileGestaltTweak("Disable Wallpaper Parallax", "UIParallaxCapability", value=0),
"StageManager": MobileGestaltTweak("Toggle Stage Manager Supported (WARNING: risky on some devices, mainly phones)", "qeaj75wk3HF4DwQ8qbIi7g", value=1),
"iPadApps": MobileGestaltTweak("Allow iPad Apps on iPhone", "9MZ5AdH43csAUajl/dU+IQ", value=[1, 2]),
"Shutter": MobileGestaltMultiTweak("Disable Region Restrictions (ie. Shutter Sound)", {"h63QSdBCiT/z0WU6rdQv6Q": "US", "zHeENZu+wbg7PUprwNwBWg": "LL/A"}),
"Pencil": MobileGestaltTweak("Toggle Apple Pencil", "yhHcB0iH0d1XzPO/CFd3ow"),
"ActionButton": MobileGestaltTweak("Toggle Action Button", "cT44WE1EohiwRzhsZ8xEsw"),
"InternalStorage": MobileGestaltTweak("Toggle Internal Storage (WARNING: risky for some devices, mainly iPads)", "LBJfwOEzExRxzlAnSuI7eg"),
"InternalInstall": MobileGestaltTweak("Set as Apple Internal Install (ie Metal HUD in any app)", "EqrsVvjcYDdxHBiQmGhAWw", divider_below=True),
"EUEnabler": EligibilityTweak("EU Enabler", divider_below=True),
"AOD": MobileGestaltMultiTweak("Always On Display",
{"2OOJf1VhaM7NxfRok3HbWQ": 1, "j8/Omm6s1lsmTDFsXjsBfA": 1},
min_version=Version("18.0")),
"SleepApnea": MobileGestaltTweak("Toggle Sleep Apnea (real) [for apple watches]", "e0HV2blYUDBk/MsMEQACNA", min_version=Version("18.0"), divider_below=True),
"ClockAnim": FeatureFlagTweak("Toggle Lockscreen Clock Animation", flag_category='SpringBoard',
flag_names=['SwiftUITimeAnimation'],
min_version=Version("18.0")),
"Lockscreen": FeatureFlagTweak("Toggle Duplicate Lockscreen Button and Lockscreen Quickswitch", flag_category="SpringBoard",
flag_names=['AutobahnQuickSwitchTransition', 'SlipSwitch', 'PosterEditorKashida'],
min_version=Version("18.0")),
"PhotoUI": FeatureFlagTweak("Enable Old Photo UI", flag_category='Photos', flag_names=['Lemonade'], is_list=False, inverted=True, min_version=Version("18.0")),
"AI": FeatureFlagTweak("Enable Apple Intelligence", flag_category='SpringBoard', flag_names=['Domino', 'SuperDomino'], min_version=Version("18.1"))
}