@@ -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
12745void 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
0 commit comments