From bfb1c0a946764372519156523211d171d2aabf1e Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Sat, 27 Dec 2025 20:09:06 +0700 Subject: [PATCH] Restructure.. again and add region spoof for appstorecomponentsd --- BypassMarketplace.x | 60 +++++++++++++++++++ BypassMarketplace/Makefile | 12 ---- BypassMarketplace/Tweak.x | 24 -------- FixDDI/Tweak.x => FixDDI.x | 9 +++ FixDDI/FixDDI.plist | 7 --- FixDDI/Makefile | 14 ----- Makefile | 12 +++- .../BypassMarketplace.plist => filter.plist | 2 + layout/DEBIAN/postinst | 2 +- layout/DEBIAN/postrm | 2 +- 10 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 BypassMarketplace.x delete mode 100644 BypassMarketplace/Makefile delete mode 100644 BypassMarketplace/Tweak.x rename FixDDI/Tweak.x => FixDDI.x (92%) delete mode 100644 FixDDI/FixDDI.plist delete mode 100644 FixDDI/Makefile rename BypassMarketplace/BypassMarketplace.plist => filter.plist (59%) diff --git a/BypassMarketplace.x b/BypassMarketplace.x new file mode 100644 index 0000000..a6237be --- /dev/null +++ b/BypassMarketplace.x @@ -0,0 +1,60 @@ +@import Foundation; + +%group Hook_managedappdistributiond +// "Not bypassing eligibility for com.apple.mobilesafari:personal (isProfileValidated: false isUPPValidated:false isBeta:false" +// Used in managedappdistributiond. Pseudocode of a validate function in OSEligbility.framework: +#if 0 +LSBundleRecord *bundleRecord = ...; +BOOL isProfileValidated = bundleRecord.isProfileValidated; +BOOL isUPPValidated = bundleRecord.isUPPValidated; +BOOL isBeta = bundleRecord.isBeta; +if ( (isProfileValidated == NO) || (isUPPValidated == YES) || (isBeta == YES) ) { + log("Not bypassing eligibility for %s:%s (isProfileValidated: %{bool}d isUPPValidated:%{bool}d isBeta:%{bool}d", bundleRecord.bundleIdentifier.UTF8String, somethingThatSaysPersonal, isProfileValidated, isUPPValidated, isBeta); + return 0; +} +#endif + +// So we just hook these to return values that will bypass eligibility +// for managedappdistributiond +%hook LSBundleRecord +- (BOOL)isProfileValidated { + return YES; +} +- (BOOL)isUPPValidated { + return NO; +} +- (BOOL)isBeta { + return NO; +} +%end +%end + +// for appstorecomponentsd, we hook URL method to replace region code +%group Hook_appstorecomponentsd +%hook NSURLRequest +- (instancetype)initWithURL:(NSURL *)url { + NSString *prefix = @"https://amp-api.apps-marketplace.apple.com/v1/catalog/"; + NSString *urlString = url.absoluteString; + if ([url.absoluteString hasPrefix:prefix]) { + // replace region code + NSArray *components = [urlString componentsSeparatedByString:@"/"]; + if (components.count > 6) { + NSMutableArray *newComponents = [components mutableCopy]; + newComponents[5] = @"fr"; // spoof to France region + NSURL *newURL = [NSURL URLWithString:[newComponents componentsJoinedByString:@"/"]]; + return %orig(newURL); + } + } + return %orig; +} +%end +%end + +%ctor { + NSString *processName = NSProcessInfo.processInfo.processName; + if ([processName isEqualToString:@"managedappdistributiond"]) { + %init(Hook_managedappdistributiond); + } else if ([processName isEqualToString:@"appstorecomponentsd"]) { + %init(Hook_appstorecomponentsd); + } +} diff --git a/BypassMarketplace/Makefile b/BypassMarketplace/Makefile deleted file mode 100644 index 0f0301a..0000000 --- a/BypassMarketplace/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -TARGET := iphone:clang:latest:15.0 -INSTALL_TARGET_PROCESSES = managedappdistributiond - -include $(THEOS)/makefiles/common.mk - -TWEAK_NAME = BypassMarketplace - -BypassMarketplace_FILES = Tweak.x -BypassMarketplace_CFLAGS = -fobjc-arc -BypassMarketplace_CODESIGN_FLAGS = -Cadhoc -S - -include $(THEOS_MAKE_PATH)/tweak.mk diff --git a/BypassMarketplace/Tweak.x b/BypassMarketplace/Tweak.x deleted file mode 100644 index f089131..0000000 --- a/BypassMarketplace/Tweak.x +++ /dev/null @@ -1,24 +0,0 @@ -// "Not bypassing eligibility for com.apple.mobilesafari:personal (isProfileValidated: false isUPPValidated:false isBeta:false" -// Used in managedappdistributiond. Pseudocode of a validate function in OSEligbility.framework: -#if 0 -LSBundleRecord *bundleRecord = ...; -BOOL isProfileValidated = bundleRecord.isProfileValidated; -BOOL isUPPValidated = bundleRecord.isUPPValidated; -BOOL isBeta = bundleRecord.isBeta; -if ( (isProfileValidated == NO) || (isUPPValidated == YES) || (isBeta == YES) ) { - log("Not bypassing eligibility for %s:%s (isProfileValidated: %{bool}d isUPPValidated:%{bool}d isBeta:%{bool}d", bundleRecord.bundleIdentifier.UTF8String, somethingThatSaysPersonal, isProfileValidated, isUPPValidated, isBeta); -} -#endif - -// So we just force the three functions to return values that will bypass eligibility -%hook LSBundleRecord -- (BOOL)isProfileValidated { - return YES; -} -- (BOOL)isUPPValidated { - return NO; -} -- (BOOL)isBeta { - return NO; -} -%end diff --git a/FixDDI/Tweak.x b/FixDDI.x similarity index 92% rename from FixDDI/Tweak.x rename to FixDDI.x index a9040a8..442e219 100644 --- a/FixDDI/Tweak.x +++ b/FixDDI.x @@ -24,6 +24,7 @@ const char *container_system_group_path_for_identifier(int, const char *group, v errno_t img4_nonce_domain_copy_nonce(const img4_nonce_domain_t *nd, img4_nonce_t *n); int img4_firmware_execute(void* fw, const void *chip, const void *nonce); +%group Hook_MobileStorageMounter %hookf(errno_t, img4_nonce_domain_copy_nonce, const img4_nonce_domain_t *nd, img4_nonce_t *n) { if (nd != IMG4_NONCE_DOMAIN_DDI) { return %orig(nd, n); @@ -66,3 +67,11 @@ BOOL gCalledImg4Execute = NO; } return ret; } +%end + +%ctor { + NSString *processName = NSProcessInfo.processInfo.processName; + if ([processName isEqualToString:@"MobileStorageMounter"]) { + %init(Hook_MobileStorageMounter); + } +} diff --git a/FixDDI/FixDDI.plist b/FixDDI/FixDDI.plist deleted file mode 100644 index b4e55d3..0000000 --- a/FixDDI/FixDDI.plist +++ /dev/null @@ -1,7 +0,0 @@ -{ - Filter = { - Executables = ( - MobileStorageMounter, - ); - }; -} \ No newline at end of file diff --git a/FixDDI/Makefile b/FixDDI/Makefile deleted file mode 100644 index af9ab7f..0000000 --- a/FixDDI/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TARGET := iphone:clang:latest:15.0 -INSTALL_TARGET_PROCESSES = MobileStorageMounter - -include $(THEOS)/makefiles/common.mk - -TWEAK_NAME = FixDDI - -FixDDI_FILES = Tweak.x -FixDDI_CFLAGS = -fobjc-arc -FixDDI_FRAMEWORKS = IOKit -FixDDI_LIBRARIES = image4 -FixDDI_CODESIGN_FLAGS = -Cadhoc -S - -include $(THEOS_MAKE_PATH)/tweak.mk diff --git a/Makefile b/Makefile index b736061..6d8a736 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,15 @@ TARGET := iphone:clang:latest:15.0 +INSTALL_TARGET_PROCESSES = appstorecomponentsd managedappdistributiond MobileStorageMounter THEOS_PACKAGE_SCHEME := rootless include $(THEOS)/makefiles/common.mk +TWEAK_NAME = aintuitweaks + +aintuitweaks_FILES = BypassMarketplace.x FixDDI.x +aintuitweaks_CFLAGS = -fobjc-arc +aintuitweaks_FRAMEWORKS = IOKit +aintuitweaks_LIBRARIES = image4 +aintuitweaks_CODESIGN_FLAGS = -Cadhoc -S + include $(THEOS_MAKE_PATH)/tweak.mk -SUBPROJECTS += BypassMarketplace -SUBPROJECTS += FixDDI -include $(THEOS_MAKE_PATH)/aggregate.mk diff --git a/BypassMarketplace/BypassMarketplace.plist b/filter.plist similarity index 59% rename from BypassMarketplace/BypassMarketplace.plist rename to filter.plist index e421078..ebc1839 100644 --- a/BypassMarketplace/BypassMarketplace.plist +++ b/filter.plist @@ -1,7 +1,9 @@ { Filter = { Executables = ( + appstorecomponentsd, "managedappdistributiond", + MobileStorageMounter, ); }; } \ No newline at end of file diff --git a/layout/DEBIAN/postinst b/layout/DEBIAN/postinst index 6393be7..e38a721 100755 --- a/layout/DEBIAN/postinst +++ b/layout/DEBIAN/postinst @@ -1,3 +1,3 @@ #!/bin/sh # managedappdistributiond does not honor SIGTERM -killall -KILL managedappdistributiond +killall -KILL managedappdistributiond || true diff --git a/layout/DEBIAN/postrm b/layout/DEBIAN/postrm index 6393be7..e38a721 100755 --- a/layout/DEBIAN/postrm +++ b/layout/DEBIAN/postrm @@ -1,3 +1,3 @@ #!/bin/sh # managedappdistributiond does not honor SIGTERM -killall -KILL managedappdistributiond +killall -KILL managedappdistributiond || true