Skip to content

Commit

Permalink
v6 Beta 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lrdsnow committed Sep 14, 2024
1 parent 2a83275 commit 7f54948
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
30 changes: 26 additions & 4 deletions purekfd/Backend/Exploit/SparseRestore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ class SparseRestore: NSObject {
try? FileManager.default.removeItem(at: folder)
try? FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)

var backupFiles = [
ConcreteFile(path: "", domain: "SysContainerDomain-../../../../../../../../crash_on_purpose", contents: Data())
var backupFiles: [BackupFile] = [
Directory(path: "", domain: "RootDomain"),
Directory(path: "Library", domain: "RootDomain"),
Directory(path: "Library/Preferences", domain: "RootDomain")
]

let backupInfoURL = tempBackupDir.appendingPathComponent("backup_info.json")
Expand All @@ -92,12 +94,32 @@ class SparseRestore: NSObject {
let existingInfo = try? JSONSerialization.jsonObject(with: data, options: []) as? [String] {
backupInfo = existingInfo
}
for file in backupInfo {
for file in backupInfo.indices {
let filePath = backupInfo[file]
do {
backupFiles.append(ConcreteFile(path: "", domain: "SysContainerDomain-../../../../../../../..\(file)", contents: try Data(contentsOf: tempBackupDir.appendingPathComponent(file))))
let fileContents = try Data(contentsOf: tempBackupDir.appendingPathComponent(filePath))
//backupFiles.append(ConcreteFile(path: "", domain: "SysContainerDomain-../../../../../../../..\(file)", contents: ))
let to = URL(fileURLWithPath: filePath)
let folderPath = to.deletingLastPathComponent().path.replacingOccurrences(of: "//private/var", with: "/var")
let targetPath = to.path.replacingOccurrences(of: "//private/var", with: "/var")
var basePath = "var"
if #available(iOS 17.0, *) {
basePath = to.path.hasPrefix("/var/mobile/") ? "var/mobile" : "var"
}
backupFiles += [
ConcreteFile(path: "Library/Preferences/temp\(Int(file))", domain: "RootDomain", contents: fileContents, owner: 501, group: 501, inode: UInt64(file)),
Directory(path: "", domain: "SysContainerDomain-../../../../../../../../\(basePath)/backup\(folderPath)", owner: 501, group: 501),
ConcreteFile(path: "", domain: "SysContainerDomain-../../../../../../../../\(basePath)/backup\(targetPath)", contents: Data(), owner: 501, group: 501, inode: UInt64(file)),
ConcreteFile(path: "", domain: "SysContainerDomain-../../../../../../../../\(basePath)/.backup.i/var/root/Library/Preferences/temp\(Int(file))", contents: Data(), owner: 501, group: 501)
]

} catch {}
}

backupFiles += [
ConcreteFile(path: "", domain: "SysContainerDomain-../../../../../../../../crash_on_purpose", contents: Data())
]

try? fm.removeItem(at: tempBackupDir)
let mbdb = Backup(files: backupFiles)
try mbdb.writeTo(directory: folder)
Expand Down
13 changes: 12 additions & 1 deletion purekfd/Backend/TweakPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,25 @@ class TweakPath {

let pathComponents = url.pathComponents

var save: [String:Any] = [:]
if let save_data = try? Data(contentsOf: pkgpath.appendingPathComponent("save.json")),
let _save = try? JSONSerialization.jsonObject(with: save_data) as? [String:Any] {
save = _save
}

for component in pathComponents {
if component.contains("Segment"),
let components = parseSegment(component) {
from = pkgpath.appendingPathComponent("imported/\(components.name)")
if FileManager.default.fileExists(atPath: from!.path) {
path = path.replacingOccurrences(of: component, with: components.name)
} else {
return nil
if let variable = save[components.identifiers.first ?? ""],
variable as? String == components.values.first {
path = path.replacingOccurrences(of: component, with: components.name)
} else {
return nil
}
}
} else if component.contains("?pure_binary.") {
// eta s0n
Expand Down

0 comments on commit 7f54948

Please sign in to comment.