Skip to content

Commit

Permalink
lego brick and art tape ahh fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lrdsnow committed Sep 29, 2024
1 parent e7cf534 commit 4acb28b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Binary file not shown.
30 changes: 28 additions & 2 deletions PureKFD/Backend/Exploit/SparseRestore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,12 @@ class SparseRestore: NSObject {
return "No files to write?"
}

var filteredBackupInfo = backupInfo.filter({ !$0.contains("/var/mobile") })
var varmobileBackupInfo = backupInfo.filter({ $0.contains("/var/mobile") })

var backupDirs: [String] = []
for file in backupInfo.indices {
let filePath = backupInfo[file]
for file in filteredBackupInfo.indices {
let filePath = filteredBackupInfo[file]
do {
let fileContents = try Data(contentsOf: tempBackupDir.appendingPathComponent(filePath))
let to = URL(fileURLWithPath: filePath)
Expand All @@ -255,6 +258,29 @@ class SparseRestore: NSObject {
} catch {}
}

// lego brick and art tape ahh fix (@spinnyspiwal reference)
for file in varmobileBackupInfo.indices {
var backupDirs2: [String] = []
let filePath = filteredBackupInfo[file]
let pathComponents = filePath.components(separatedBy: "/")
if filePath.contains("AppUUID{"),
let fileContents = try? Data(contentsOf: tempBackupDir.appendingPathComponent(filePath)),
let appuuidcomponentIndex = pathComponents.firstIndex(where: { $0.contains("AppUUID{") }),
let components = TweakPath.parseAppUUID(pathComponents[appuuidcomponentIndex]) {
let path = pathComponents[(appuuidcomponentIndex + 1)...].joined(separator: "/")
let pathURL = URL(fileURLWithPath: path)
backupFiles += [
ConcreteFile(path: path, domain: "AppDomain-\(components.appIdentifier)", contents: fileContents)
]
if !backupDirs2.contains(pathURL.deletingLastPathComponent().path) {
backupFiles += [
Directory(path: pathURL.deletingLastPathComponent().path, domain: "AppDomain-\(components.appIdentifier)")
]
backupDirs2.append(pathURL.deletingLastPathComponent().path)
}
}
}

let varMobile = backupInfo.contains(where: { $0.contains("/var/mobile/") })

if !varMobile {
Expand Down
5 changes: 5 additions & 0 deletions PureKFD/Backend/TweakPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ class TweakPath {
// eta s0n
return nil
} else if component.contains("AppUUID{") {
#if !NO_SPARSE
if path.contains("/var/mobile"), exploit == 2 {
return (nil, path)
}
#endif
if let components = parseAppUUID(component),
let _path = ExploitHandler.getAppPath(components.appIdentifier, components.data, exploit) {
return (nil, _path+(path.components(separatedBy: ".app").last ?? ""))
Expand Down

0 comments on commit 4acb28b

Please sign in to comment.