diff options
author | Sam Bingner <sam@bingner.com> | 2019-10-14 08:57:14 -1000 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2019-10-14 08:59:05 -1000 |
commit | 931ece7fc1f36fb6f4964af513e8d397b56ef36a (patch) | |
tree | e2e031aada40925abdb5f18ff5fbf5e123519697 | |
parent | a56e7b5a3f292b7f222ba72043b77d59de34b923 (diff) |
Add blacklists etc
-rw-r--r-- | ldrestart.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ldrestart.cpp b/ldrestart.cpp index a6d6cb6..478840b 100644 --- a/ldrestart.cpp +++ b/ldrestart.cpp @@ -34,6 +34,28 @@ #define FLAG_PLATFORMIZE (1 << 1) #include <dlfcn.h> +#include <os/log.h> + +const char *first[] = { + NULL +}; + +const char *last[] = { + "com.apple.assertiond", + "com.apple.backboardd", + NULL +}; + +const char *skip[] = { + "jailbreakd", + "science.xnu.substituted", + "com.saurik.substrated", + "com.apple.MobileFileIntegrity", + "com.openssh.sshd.", + "com.apple.SpringBoard", + NULL +}; + void platformizeme() { void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY); if (!handle) return; @@ -51,6 +73,43 @@ void platformizeme() { ptr(getpid(), FLAG_PLATFORMIZE); } +bool launch_stop(const char * job) +{ + launch_data_t resp; + launch_data_t msg; + + msg = launch_data_alloc(LAUNCH_DATA_DICTIONARY); + if (msg == NULL) { + fprintf(stderr, "out of memory"); + exit(-1); + } + + launch_data_dict_insert(msg, launch_data_new_string(job), + LAUNCH_KEY_STOPJOB); + + resp = launch_msg(msg); + launch_data_free(msg); + + if (resp == NULL) { + return false; + } + + switch (launch_data_get_type(resp)) { + case LAUNCH_DATA_ERRNO: + errno = launch_data_get_errno(resp); + launch_data_free(resp); + if (errno != 0) { + return false; + } + + return true; + + default: + launch_data_free(resp); + return false; + } +} + void process(launch_data_t value, const char *name, void *baton) { if (launch_data_get_type(value) != LAUNCH_DATA_DICTIONARY) return; @@ -68,6 +127,19 @@ void process(launch_data_t value, const char *name, void *baton) { return; auto label(launch_data_get_string(string)); + for (const char **skipped = first; *skipped != NULL; skipped++) { + if (strcmp(label, *skipped) == 0) + return; + } + for (const char **skipped = skip; *skipped != NULL; skipped++) { + if (strncmp(label, *skipped, strlen(*skipped)) == 0) + return; + } + for (const char **skipped = last; *skipped != NULL; skipped++) { + if (strcmp(label, *skipped) == 0) + return; + } + auto stop(launch_data_alloc(LAUNCH_DATA_DICTIONARY)); launch_data_dict_insert(stop, string, LAUNCH_KEY_STOPJOB); @@ -86,6 +158,9 @@ void process(launch_data_t value, const char *name, void *baton) { int main(int argc, char *argv[]) { platformizeme(); + for (const char **service = first; *service != NULL; service++) { + launch_stop(*service); + } auto request(launch_data_new_string(LAUNCH_KEY_GETJOBS)); auto response(launch_msg(request)); launch_data_free(request); @@ -96,5 +171,8 @@ int main(int argc, char *argv[]) { return EX_SOFTWARE; launch_data_dict_iterate(response, &process, NULL); + for (const char **service = last; *service != NULL; service++) { + launch_stop(*service); + } return EX_OK; } |