Skip to content

Commit 3ef9453

Browse files
committed
fix bugs and hide more jailbreak traces
1 parent 0f2bc33 commit 3ef9453

File tree

14 files changed

+446
-220
lines changed

14 files changed

+446
-220
lines changed

Application/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ build/Build/Products/Debug-iphoneos/Dopamine.app: FORCE
2424
endif
2525
touch build/Build/Products/Debug-iphoneos/Dopamine.app/Dopamine.roothide
2626
cp -a Dopamine/Resources/*.deb build/Build/Products/Debug-iphoneos/Dopamine.app/
27-
ifeq ($(PALEHIDE), 1)
27+
# ifeq ($(PALEHIDE), 1)
2828
make -C Dopamine/Exploits/palera1n package
2929
cp -ar Dopamine/Exploits/palera1n/.framework build/Build/Products/Debug-iphoneos/Dopamine.app/Frameworks/palera1n.framework
30-
endif
30+
# endif
3131

3232

3333
clean:

BaseBin/_external/basebin/.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.5.19
1+
2.4.5.20

BaseBin/jailbreakd/src/main.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
int posix_spawnattr_setspecialport_np(posix_spawnattr_t *attr, mach_port_t new_port, int which);
1515
int posix_spawnattr_set_registered_ports_np(posix_spawnattr_t * __restrict attr, mach_port_t portarray[], uint32_t count);
1616

17-
void setJetsamEnabled(bool enabled)
17+
void setJetsamLimit(uint32_t sizeInMB, bool is_fatal_limit)
1818
{
19-
pid_t me = getpid();
20-
int priorityToSet = -1;
21-
if (enabled) {
22-
priorityToSet = 10;
23-
}
24-
int rc = memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_HIGH_WATER_MARK, me, priorityToSet, NULL, 0);
19+
uint32_t cmd = is_fatal_limit ? MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT : MEMORYSTATUS_CMD_SET_JETSAM_HIGH_WATER_MARK;
20+
int rc = memorystatus_control(cmd, getpid(), sizeInMB, NULL, 0);
2521
if (rc < 0) { perror ("memorystatus_control"); exit(rc);}
2622
}
2723

@@ -31,6 +27,8 @@ int main(int argc, char* argv[])
3127
{
3228
crashreporter_start();
3329

30+
setJetsamLimit(50, false);
31+
3432
#ifdef ENABLE_LOGS
3533
enableXPCLog(JBLogDebugFunction, JBLogErrorFunction);
3634
enableJBDLog(JBLogDebugFunction, JBLogErrorFunction);
@@ -39,7 +37,6 @@ int main(int argc, char* argv[])
3937
JBLogDebug("Hello from jailbrakd! uid=%d pid=%d ppid=%d", getuid(), getpid(), getppid());
4038

4139
@autoreleasepool {
42-
setJetsamEnabled(true);
4340

4441
mach_port_t *registeredPorts=NULL;
4542
mach_msg_type_number_t registeredPortsCount = 0;

BaseBin/jailbreakd/src/server.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ void jailbreakd_received_message(mach_port_t port)
126126

127127
case JBD_MSG_SYSTEMWIDE_LOG: {
128128
#ifdef ENABLE_LOGS
129+
static char logFilePath[PATH_MAX] = {0};
130+
static dispatch_once_t onceToken;
131+
dispatch_once(&onceToken, ^{
132+
JBLogGetLogFilePath("systemwide", NULL, logFilePath);
133+
});
134+
129135
const char* progname = NULL;
130136
const char* procpath = proc_get_path(clientPid,NULL);
131137
if(procpath) {
@@ -134,7 +140,7 @@ void jailbreakd_received_message(mach_port_t port)
134140
}
135141
uint64_t tid = xpc_dictionary_get_uint64(message, "tid");
136142
const char* log = xpc_dictionary_get_string(message, "log");
137-
JBLogFunction(JBLogGetLogFilePath("systemwide", NULL, NULL), clientPid, tid, progname ? progname : "(null)", "%s", log);
143+
JBLogFunction(logFilePath, clientPid, tid, progname ? progname : "(null)", "%s", log);
138144
xpc_dictionary_set_int64(reply, "result", 0);
139145
#else
140146
abort();

BaseBin/launchdhook/src/roothider.m

Lines changed: 6 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -37,92 +37,10 @@ int sysctlbyname_hook(const char *name, void *oldp, size_t *oldlenp, void *newp,
3737
return sysctlbyname_orig(name, oldp, oldlenp, newp, newlen);
3838
}
3939

40-
xpc_object_t (*orig_xpc_dictionary_create_reply)(xpc_object_t original);
41-
xpc_object_t new_xpc_dictionary_create_reply(xpc_object_t original)
42-
{
43-
xpc_object_t reply = orig_xpc_dictionary_create_reply(original);
44-
if(reply && xpc_get_type(reply)==XPC_TYPE_DICTIONARY)
45-
{
46-
audit_token_t clientToken={0};
47-
xpc_dictionary_get_audit_token(original, &clientToken);
48-
49-
if(isBlacklistedToken(&clientToken)) {
50-
xpc_dictionary_set_value(reply, "roothide-blacklisted-process-request", original);
51-
}
52-
}
53-
54-
return reply;
55-
}
56-
57-
int (*orig_xpc_pipe_routine_reply)(xpc_object_t reply);
58-
int new_xpc_pipe_routine_reply(xpc_object_t reply)
59-
{
60-
if (xpc_get_type(reply) == XPC_TYPE_DICTIONARY)
61-
{
62-
xpc_object_t original = xpc_dictionary_get_value(reply, "roothide-blacklisted-process-request");
63-
if (original)
64-
{
65-
xpc_dictionary_set_value(reply, "roothide-blacklisted-process-request", NULL);
66-
67-
audit_token_t clientToken={0};
68-
xpc_dictionary_get_audit_token(original, &clientToken);
69-
70-
const char* desc = NULL;
71-
JBLogDebug("xpc reply to blacklisted app (%d) %s :\n%s", audit_token_to_pid(clientToken), proc_get_path(audit_token_to_pid(clientToken),NULL), (desc=xpc_copy_description(reply)));
72-
if(desc) free((void*)desc);
73-
74-
uint64_t routine = xpc_dictionary_get_uint64(original, "routine");
75-
uint64_t subsystem = xpc_dictionary_get_uint64(original, "subsystem");
76-
77-
/*if(subsystem==2 && routine==708) {
78-
int error = xpc_dictionary_get_int64(reply, "error");
79-
if(error == 1) {
80-
const char* name = xpc_dictionary_get_string(original, "name");
81-
82-
xpc_dictionary_set_int64(reply, "error", 113);
83-
}
84-
}
85-
else if(subsystem==6 && routine==301) {
86-
87-
int pid = xpc_dictionary_get_int64(original, "pid");
88-
uint64_t outgsk = xpc_dictionary_get_uint64(original, "outgsk");
89-
90-
xpc_object_t out = xpc_dictionary_get_value(reply, "out");
91-
if(out && xpc_get_type(out)==XPC_TYPE_DICTIONARY) {
92-
93-
//fake WebContent Instance
94-
}
95-
}
96-
else*/ if(subsystem==3 && routine==829) {
97-
int error = xpc_dictionary_get_int64(reply, "error");
98-
if(error == 0) {
99-
const char* name = xpc_dictionary_get_string(reply, "name");
100-
const char* bundle_identifier = xpc_dictionary_get_string(reply, "bundle_identifier");
101-
102-
const char* bundle = bundle_identifier ? bundle_identifier : name;
103-
104-
if(bundle) {
105-
char client_identifier[255]={0};
106-
proc_get_identifier(audit_token_to_pid(clientToken), client_identifier);
107-
if(!string_has_prefix(bundle, client_identifier) && !string_has_prefix(bundle, "com.apple."))
108-
{
109-
JBLogDebug("hide coalition (%s) (%s) from blacklisted process(%d) %s", name, bundle_identifier, audit_token_to_pid(clientToken), proc_get_path(audit_token_to_pid(clientToken),NULL));
110-
111-
xpc_dictionary_set_value(reply, "cid", NULL);
112-
xpc_dictionary_set_value(reply, "name", NULL);
113-
xpc_dictionary_set_value(reply, "bundle_identifier", NULL);
114-
xpc_dictionary_set_value(reply, "resource-usage-blob", NULL);
115-
116-
xpc_dictionary_set_int64(reply, "error", 3);
117-
}
118-
}
119-
}
120-
}
121-
}
122-
}
123-
124-
return orig_xpc_pipe_routine_reply(reply);
125-
}
40+
extern xpc_object_t (*orig_xpc_dictionary_create_reply)(xpc_object_t original);
41+
extern xpc_object_t new_xpc_dictionary_create_reply(xpc_object_t original);
42+
extern int (*orig_xpc_pipe_routine_reply)(xpc_object_t reply);
43+
extern int new_xpc_pipe_routine_reply(xpc_object_t reply);
12644

12745
void roothide_launchd_preinit()
12846
{
@@ -202,6 +120,8 @@ void roothide_launchd_postinit(bool firstLoad)
202120
}
203121
}
204122

123+
loadAppStoredIdentifiers();
124+
205125
MSHookFunction(&xpc_dictionary_create_reply, (void*)new_xpc_dictionary_create_reply, &orig_xpc_dictionary_create_reply);
206126
MSHookFunction(&xpc_pipe_routine_reply, (void*)new_xpc_pipe_routine_reply, &orig_xpc_pipe_routine_reply);
207127

BaseBin/libjailbreak/src/jbserver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int jbserver_received_xpc_message(struct jbserver_impl *server, xpc_object_t xms
88
if (xpc_get_type(xmsg) != XPC_TYPE_DICTIONARY) return -1;
99

1010
/**********************************************/
11-
roothide_handler_jbserver_msg(xmsg);
11+
roothide_handle_xpc_msg(xmsg);
1212
/*********************************************/
1313

1414
if (!xpc_dictionary_get_value(xmsg, "jb-domain")) return -1;

BaseBin/libjailbreak/src/roothider/common.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int proc_patch_csflags(pid_t pid);
1919
pid_t proc_get_ppid(pid_t pid);
2020
int proc_get_pidversion(pid_t pid);
2121
int proc_paused(pid_t pid, bool* paused);
22-
char* proc_get_path(pid_t pid, char* buffer[PATH_MAX]);
22+
char* proc_get_path(pid_t pid, char buffer[PATH_MAX]);
2323
char* proc_get_identifier(pid_t pid, char buffer[255]);
2424

2525
uint64_t show_dyld_regions(mach_port_t task, bool more);
@@ -66,4 +66,26 @@ void hideDeveloperMode();
6666
void exec_set_patch(bool enabled);
6767
int exec_cmd_roothide_spawn(pid_t* pidp, const char* path, const posix_spawn_file_actions_t *fap, const posix_spawnattr_t *attrp, char *const argv[], char *const envp[]);
6868

69-
void roothide_handler_jbserver_msg(xpc_object_t xmsg);
69+
void roothide_handle_xpc_msg(xpc_object_t xmsg);
70+
71+
void loadAppStoredIdentifiers();
72+
73+
bool is_safe_bundle_identifier(const char* identifier);
74+
bool is_sensitive_app_identifier(const char* identifier);
75+
bool is_apple_internal_identifier(const char* identifier);
76+
77+
#define APPLE_INTERNAL_IDENTIFIERS @[\
78+
@"com.apple.atrun",\
79+
@"com.apple.kdumpd",\
80+
@"com.apple.Terminal",\
81+
]
82+
83+
//these apps may be signed with a (fake) certificate
84+
#define SENSITIVE_APP_IDENTIFIERS @[\
85+
@"com.icraze.gtatracker",\
86+
@"com.Alfie.TrollInstallerX",\
87+
@"com.opa334.Dopamine",\
88+
@"com.opa334.Dopamine.roothide",\
89+
@"com.opa334.Dopamine-roothide",\
90+
]
91+

0 commit comments

Comments
 (0)