This commit is contained in:
f1shy-dev
2023-02-11 20:16:13 +00:00
parent 0dc0ff8151
commit 486b3d12bd
25 changed files with 671 additions and 378 deletions

View File

@@ -10,8 +10,7 @@ import Foundation
import Roxas
public extension UserDefaults
{
public extension UserDefaults {
static let shared: UserDefaults = {
guard let appGroup = Bundle.main.appGroups.first else { return .standard }
@@ -43,25 +42,27 @@ public extension UserDefaults
@NSManaged var trustedSourceIDs: [String]?
@nonobjc
var activeAppsLimit: Int? {
get {
return self._activeAppsLimit?.intValue
}
set {
if let value = newValue
{
if let value = newValue {
self._activeAppsLimit = NSNumber(value: value)
}
else
{
else {
self._activeAppsLimit = nil
}
}
}
@NSManaged @objc(activeAppsLimit) private var _activeAppsLimit: NSNumber?
class func registerDefaults()
{
@NSManaged var enableMacDirtyCowExploit: Bool
@NSManaged var isMacDirtyCowSupported: Bool
class func registerDefaults() {
let ios13_5 = OperatingSystemVersion(majorVersion: 13, minorVersion: 5, patchVersion: 0)
let isLegacyDeactivationSupported = !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios13_5)
let activeAppLimitIncludesExtensions = !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios13_5)
@@ -69,15 +70,31 @@ public extension UserDefaults
let ios14 = OperatingSystemVersion(majorVersion: 14, minorVersion: 0, patchVersion: 0)
let localServerSupportsRefreshing = !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios14)
let ios16 = OperatingSystemVersion(majorVersion: 16, minorVersion: 0, patchVersion: 0)
let ios16_2 = OperatingSystemVersion(majorVersion: 16, minorVersion: 2, patchVersion: 0)
let ios15_7_2 = OperatingSystemVersion(majorVersion: 15, minorVersion: 7, patchVersion: 2)
// MacDirtyCow supports iOS 14.0 - 15.7.1 OR 16.0 - 16.1.2
let isMacDirtyCowSupported =
(ProcessInfo.processInfo.isOperatingSystemAtLeast(ios14) && !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios15_7_2)) ||
(ProcessInfo.processInfo.isOperatingSystemAtLeast(ios16) && !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios16_2))
let defaults = [
#keyPath(UserDefaults.isBackgroundRefreshEnabled): true,
#keyPath(UserDefaults.isLegacyDeactivationSupported): isLegacyDeactivationSupported,
#keyPath(UserDefaults.activeAppLimitIncludesExtensions): activeAppLimitIncludesExtensions,
#keyPath(UserDefaults.localServerSupportsRefreshing): localServerSupportsRefreshing,
#keyPath(UserDefaults.requiresAppGroupMigration): true
#keyPath(UserDefaults.requiresAppGroupMigration): true,
#keyPath(UserDefaults.enableMacDirtyCowExploit): true,
#keyPath(UserDefaults.isMacDirtyCowSupported): isMacDirtyCowSupported,
]
UserDefaults.standard.register(defaults: defaults)
UserDefaults.shared.register(defaults: defaults)
if !isMacDirtyCowSupported {
// Disable enableMacDirtyCowExploit if running iOS version that doesn't support MacDirtyCow.
UserDefaults.standard.enableMacDirtyCowExploit = false
}
}
}

View File

@@ -13,7 +13,21 @@ import AltSign
import SemanticVersion
// Free developer accounts are limited to only 3 active sideloaded apps at a time as of iOS 13.3.1.
public let ALTActiveAppsLimit = 99999
public extension InstalledApp
{
static var freeAccountActiveAppsLimit: Int
{
if UserDefaults.standard.enableMacDirtyCowExploit && UserDefaults.standard.isMacDirtyCowSupported
{
return 99999
}
else
{
// Free developer accounts are limited to only 3 active sideloaded apps at a time as of iOS 13.3.1.
return 3
}
}
}
public protocol InstalledAppProtocol: Fetchable
{

View File

@@ -6,8 +6,8 @@
// Copyright © 2020 Riley Testut. All rights reserved.
//
import CoreData
import AltSign
import CoreData
@objc(InstalledAppToInstalledAppMigrationPolicy)
class InstalledAppToInstalledAppMigrationPolicy: NSEntityMigrationPolicy
@@ -50,7 +50,7 @@ class InstalledAppToInstalledAppMigrationPolicy: NSEntityMigrationPolicy
// We can assume there is an active app limit,
// but will confirm next time user authenticates.
UserDefaults.standard.activeAppsLimit = ALTActiveAppsLimit
UserDefaults.standard.activeAppsLimit = InstalledApp.freeAccountActiveAppsLimit
}
return NSNumber(value: isActive)