Skip to content

Commit 916af5d

Browse files
author
hackcatml
committed
support dopamine jb
1 parent f1630c3 commit 916af5d

6 files changed

Lines changed: 77 additions & 33 deletions

File tree

Sources/include/opainject/spawnpacchild.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void spawnPacChild(int argc, char *argv[])
1212
argsToPass[argc] = "pac";
1313
argsToPass[argc+1] = NULL;
1414

15-
pid_t targetPid = atoi(argv[1]);
15+
pid_t targetPid = atoi(argv[argc - 1]);
1616
mach_port_t task;
1717
kern_return_t kr = KERN_SUCCESS;
1818
kr = task_for_pid(mach_task_self(), targetPid, &task);

Sources/mldecrypt/Tool.swift

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ func setDecryptTarget(set: Bool, bundleId: String) -> Void {
185185
}
186186

187187
func backup(arguments: [String], bundleId: String) -> Void {
188+
if isRootless() {
189+
let decryptedFile = AppUtils.sharedInstance().searchAppExecutable(bundleId) + ".decrypted"
190+
let appDocumentsPath = AppUtils.sharedInstance().searchAppDataDir(bundleId) + "/Documents/"
191+
let decryptedFilePath = appDocumentsPath + decryptedFile
192+
let srcURL = URL(fileURLWithPath: decryptedFilePath)
193+
let dstURL = URL(fileURLWithPath: documentsPath + decryptedFile)
194+
do {
195+
try FileManager.default.copyItem(at: srcURL, to: dstURL)
196+
try FileManager.default.removeItem(at: srcURL)
197+
}
198+
catch {
199+
print("Error: \(error.localizedDescription)")
200+
}
201+
}
202+
188203
let documentsURL = URL(string: documentsPath)!
189204
let filelist = try! FileManager.default.contentsOfDirectory(atPath: documentsURL.path)
190205
let bundleExecutable = AppUtils.sharedInstance().searchAppExecutable(bundleId)!
@@ -221,36 +236,46 @@ func opainject(arguments: [String]) -> Void {
221236
exit(1)
222237
}
223238

224-
let bundleId = arguments[index]
225-
226-
let processList = Getpid()
227-
guard let processes = processList.processes else {
228-
print("Failed to retrieve process list.")
229-
exit(1)
230-
}
231239
var targetPid: Int32 = 0
232-
for process in processes {
233-
let pid = process.kp_proc.p_pid
234-
let name = withUnsafePointer(to: process.kp_proc.p_comm) {
235-
String(cString: UnsafeRawPointer($0).assumingMemoryBound(to: CChar.self))
240+
let bundleId = arguments[index]
241+
if isArm64eDevice(), CommandLine.argc >= 5 {
242+
let index = arguments.firstIndex(where: {
243+
$0.allSatisfy({ $0.isNumber })
244+
})
245+
targetPid = Int32(arguments[index!])!
246+
} else {
247+
let processList = Getpid()
248+
guard let processes = processList.processes else {
249+
print("Failed to retrieve process list.")
250+
exit(1)
236251
}
237-
if name.contains(AppUtils.sharedInstance().searchAppExecutable(bundleId)!) {
238-
targetPid = Int32(pid)
239-
break
252+
for process in processes {
253+
let pid = process.kp_proc.p_pid
254+
let name = withUnsafePointer(to: process.kp_proc.p_comm) {
255+
String(cString: UnsafeRawPointer($0).assumingMemoryBound(to: CChar.self))
256+
}
257+
if name.contains(AppUtils.sharedInstance().searchAppExecutable(bundleId)!) {
258+
targetPid = Int32(pid)
259+
break
260+
}
261+
}
262+
guard targetPid != 0 else {
263+
print("Cannot find pid for \(bundleId)")
264+
exit(1)
240265
}
241-
}
242-
guard targetPid != 0 else {
243-
print("Cannot find pid for \(bundleId)")
244-
exit(1)
245266
}
246267

247268
if isArm64eDevice() {
248269
var pacArg: UnsafeMutablePointer<Int8>? = nil
249-
if CommandLine.argc >= 4 {
250-
pacArg = CommandLine.unsafeArgv[3]
270+
if CommandLine.argc >= 5 {
271+
pacArg = CommandLine.unsafeArgv[Int(CommandLine.argc) - 1]
251272
}
252273
if pacArg == nil || String(cString: pacArg!) != "pac" {
253-
spawnPacChild(CommandLine.argc, CommandLine.unsafeArgv)
274+
let pidString = String(targetPid)
275+
let pidPtr = strdup(pidString)
276+
277+
CommandLine.unsafeArgv[Int(CommandLine.argc)] = pidPtr
278+
spawnPacChild(CommandLine.argc + 1, CommandLine.unsafeArgv)
254279
exit(0)
255280
}
256281
}
@@ -295,6 +320,9 @@ func opainject(arguments: [String]) -> Void {
295320
if arguments.contains("-b") {
296321
sleep(4)
297322
backup(arguments: arguments, bundleId: bundleId)
323+
} else {
324+
sleep(1)
325+
backup(arguments: arguments, bundleId: bundleId)
298326
}
299327

300328
exit(0)
@@ -346,6 +374,17 @@ public struct mldecrypt {
346374
print(helpString)
347375
exit(0)
348376
} else if arguments.contains("-r") {
377+
var index = arguments.firstIndex(of: "-r")
378+
if index != 1 {
379+
print("\nUsage: mldecrypt -r <bundleId> || mldecrypt -r -b <bundleId>")
380+
exit(1)
381+
} else if arguments.contains("-b") {
382+
index = arguments.firstIndex(of: "-b")
383+
if index != 2 {
384+
print("\nUsage: mldecrypt -r <bundleId> || mldecrypt -r -b <bundleId>")
385+
exit(1)
386+
}
387+
}
349388
opainject(arguments: arguments)
350389
} else if arguments.count == 2 || (arguments.count == 3 && arguments[1].contains("-b")) {
351390
let bundleId = arguments.count == 2 ? arguments[1] : arguments[2]

Sources/mldecryptor/Tweak.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ func isRootless() -> Bool {
2020
func dumpstart(_ targetImgName: UnsafeMutablePointer<Int8>?) {
2121
os_log("[hackcatml] binary dump started")
2222

23-
var documentsPath = "/var/mobile/Documents/"
24-
if isRootless() {
25-
documentsPath = "/var/jb" + documentsPath
26-
}
23+
let appDocumentsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.path + "/"
24+
var documentsPath = isRootless() ? appDocumentsPath : "/var/mobile/Documents/"
2725
let dumpPath: String = documentsPath + URL(fileURLWithPath: Bundle.main.executablePath ?? "").lastPathComponent + ".decrypted"
2826
if FileManager.default.fileExists(atPath: dumpPath) {
2927
unlink(dumpPath)

control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: com.hackcatml.mldecrypt
22
Name: mldecrypt
3-
Version: 0.1.1
3+
Version: 0.1.2
44
Architecture: iphoneos-arm
55
Description: An awesome tool of some sort!!
66
Maintainer: hackcatml

module/cdaswift/cda.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
- (NSString*)searchAppExecutable:(NSString*)bundleId;
4040
- (NSString*)searchAppResourceDir:(NSString*)bundleId;
4141
- (NSString*)searchAppBundleDir:(NSString*)bundleId;
42+
- (NSString*)searchAppDataDir:(NSString*)bundleId;
4243

4344
@end

module/cdaswift/cda.mm

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,17 @@ - (void) searchApp:(NSString *)searchTerm
4040

4141
- (NSString*)searchAppExecutable:(NSString*)bundleId
4242
{
43-
int i = 1;
4443
for(LSApplicationProxy* app in apps){
4544
NSString *identifier = app.bundleIdentifier;
4645
if([identifier isEqualToString:bundleId]){
4746
return app.bundleExecutable;
4847
}
49-
i++;
5048
}
5149
return @"Nope";
5250
}
5351

5452
- (NSString*)searchAppResourceDir:(NSString*)bundleId
5553
{
56-
int i = 1;
5754
for(LSApplicationProxy* app in apps){
5855
NSString *identifier = app.bundleIdentifier;
5956
if([identifier isEqualToString:bundleId]){
@@ -62,21 +59,30 @@ - (NSString*)searchAppResourceDir:(NSString*)bundleId
6259
// printf("appResourceDir: %s", [appResourceDir UTF8String]);
6360
return appResourceDir;
6461
}
65-
i++;
6662
}
6763
return @"Nope";
6864
}
6965

7066
- (NSString*)searchAppBundleDir:(NSString*)bundleId
7167
{
72-
int i = 1;
7368
for(LSApplicationProxy* app in apps){
7469
NSString* identifier = app.bundleIdentifier;
7570
if([identifier isEqualToString:bundleId]){
7671
NSString* appBundleDir = app.bundleContainerURL.path;
7772
return appBundleDir;
7873
}
79-
i++;
74+
}
75+
return @"Nope";
76+
}
77+
78+
- (NSString*)searchAppDataDir:(NSString*)bundleId
79+
{
80+
for(LSApplicationProxy* app in apps){
81+
NSString* identifier = app.bundleIdentifier;
82+
if([identifier isEqualToString:bundleId]){
83+
NSString* appDataDir = app.dataContainerURL.path;
84+
return appDataDir;
85+
}
8086
}
8187
return @"Nope";
8288
}

0 commit comments

Comments
 (0)