-
Notifications
You must be signed in to change notification settings - Fork 36
/
ios-multiple-jailbreak-bypass2.js
189 lines (179 loc) · 6.83 KB
/
ios-multiple-jailbreak-bypass2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
Description: iOS Multiple Jailbreak Detection ByPass
Usage: frida -U -f XXX -l ios-multiple-jailbreak-bypass2.js
Credit: Incognito-Lab
*/
//Path list for fileExistsAtPath and fopen
const jailbreakPaths = [
"/Applications/Cydia.app",
"/Applications/FakeCarrier.app",
"/Applications/Icy.app",
"/Applications/IntelliScreen.app",
"/Applications/MxTube.app",
"/Applications/RockApp.app",
"/Applications/SBSetttings.app",
"/Applications/WinterBoard.app",
"/Applications/blackra1n.app",
"/Applications/Terminal.app",
"/Applications/Pirni.app",
"/Applications/iFile.app",
"/Applications/iProtect.app",
"/Applications/Backgrounder.app",
"/Applications/biteSMS.app",
"/Library/MobileSubstrate/DynamicLibraries/LiveClock.plist",
"/Library/MobileSubstrate/DynamicLibraries/Veency.plist",
"/Library/MobileSubstrate/DynamicLibraries/SBSettings.dylib",
"/Library/MobileSubstrate/DynamicLibraries/SBSettings.plist",
"/Library/MobileSubstrate/MobileSubstrate.dylib",
"/System/Library/LaunchDaemons/com.ikey.bbot.plist",
"/System/Library/LaunchDaemons/com.saurik.Cy@dia.Startup.plist",
"/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist",
"/System/Library/LaunchDaemons/com.bigboss.sbsettingsd.plist",
"/System/Library/PreferenceBundles/CydiaSettings.bundle",
"/bin/bash",
"/bin/sh",
"/etc/apt",
"/etc/ssh/sshd_config",
"/etc/profile.d/terminal.sh",
"/private/var/stash",
"/private/var/tmp/cydia.log",
"/private/var/lib/apt",
"/private/var/root/Media/Cydia",
"/private/var/lib/cydia",
"/private/var/mobile/Library/SBSettings/Themes",
"/private/var/lib/dpkg/info/cydia-sources.list",
"/private/var/lib/dpkg/info/cydia.list",
"/private/etc/profile.d/terminal.sh",
"/usr/lib/libsubstitute.dylib",
"/usr/lib/substrate",
"/usr/lib/libhooker.dylib",
"/usr/bin/cycript",
"/usr/bin/ssh",
"/usr/bin/sshd",
"/usr/sbin/sshd",
"/usr/libexec/sftp-server",
"/usr/libexec/ssh-keysign",
"/usr/libexec/cydia",
"/usr/sbin/sshd",
"/var/cache/apt",
"/var/lib/cydia",
"/var/log/syslog",
"/var/tmp/cydia.log",
"/var/lib/dpkg/info/cydia-sources.list",
"/var/lib/dpkg/info/cydia.list",
"/var/lib/dpkg/info/mobileterminal.list",
"/var/lib/dpkg/info/mobileterminal.postinst",
"/User/Library/SBSettings",
"/usr/bin/sbsettingsd",
"/var/mobile/Library/SBSettings"
];
//App URL list in lower case for canOpenURL
const canOpenURL = [
"cydia"
]
if (ObjC.available) {
try {
//Hooking fileExistsAtPath:
Interceptor.attach(ObjC.classes.NSFileManager["- fileExistsAtPath:"].implementation, {
onEnter(args) {
// Use a marker to check onExit if we need to manipulate
// the response.
this.is_common_path = false;
// Extract the path
this.path = new ObjC.Object(args[2]).toString();
// check if the looked up path is in the list of common_paths
if (jailbreakPaths.indexOf(this.path) >= 0) {
// Mark this path as one that should have its response
// modified if needed.
this.is_common_path = true;
}
},
onLeave(retval) {
// stop if we dont care about the path
if (!this.is_common_path) {
return;
}
// ignore failed lookups
if (retval.isNull()) {
console.log(`fileExistsAtPath: try to check for ` + this.path + ' was failed');
return;
}
console.log(`fileExistsAtPath: check for ` + this.path + ` was successful with: ` + retval.toString() + `, marking it as failed.`);
retval.replace(new NativePointer(0x00));
},
});
//Hooking fopen
Interceptor.attach(Module.findExportByName(null, "fopen"), {
onEnter(args) {
this.is_common_path = false;
// Extract the path
this.path = args[0].readCString();
// check if the looked up path is in the list of common_paths
if (jailbreakPaths.indexOf(this.path) >= 0) {
// Mark this path as one that should have its response
// modified if needed.
this.is_common_path = true;
}
},
onLeave(retval) {
// stop if we dont care about the path
if (!this.is_common_path) {
return;
}
// ignore failed lookups
if (retval.isNull()) {
console.log(`fopen: try to check for ` + this.path + ' was failed');
return;
}
console.log(`fopen: check for ` + this.path + ` was successful with: ` + retval.toString() + `, marking it as failed.`);
retval.replace(new NativePointer(0x00));
},
});
//Hooking canOpenURL for Cydia
Interceptor.attach(ObjC.classes.UIApplication["- canOpenURL:"].implementation, {
onEnter(args) {
this.is_flagged = false;
// Extract the path
this.path = new ObjC.Object(args[2]).toString();
let app = this.path.split(":")[0].toLowerCase();
if (canOpenURL.indexOf(app) >= 0) {
this.is_flagged = true;
}
},
onLeave(retval) {
if (!this.is_flagged) {
return;
}
// ignore failed
if (retval.isNull()) {
return;
}
console.log(`canOpenURL: check for ` +
this.path + ` was successful with: ` +
retval.toString() + `, marking it as failed.`);
retval.replace(new NativePointer(0x00));
}
});
//Hooking libSystemBFork
const libSystemBdylibFork = Module.findExportByName("libSystem.B.dylib", "fork");
if (libSystemBdylibFork) {
Interceptor.attach(libSystemBdylibFork, {
onLeave(retval) {
// already failed forks are ok
if (retval.isNull()) {
return;
}
console.log(`Call to libSystem.B.dylib::fork() was successful with ` +
retval.toString() + ` marking it as failed.`);
retval.replace(new NativePointer(0x0));
},
});
}
}
catch (err) {
console.log("Exception : " + err.message);
}
}
else {
console.log("Objective-C Runtime is not available!");
}