summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2019-10-14 08:57:14 -1000
committerSam Bingner <sam@bingner.com>2019-10-14 08:57:14 -1000
commit48f5e985307d082328da79c4b11610331ade2c03 (patch)
treeac81899af0656acc98ffb45d59c69d6f503278e7
parentb685d83e341d1a45bf76c3620b1b350e34d824be (diff)
Add blacklists etc
-rw-r--r--ldrestart.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/ldrestart.cpp b/ldrestart.cpp
index a6d6cb6..872ed68 100644
--- a/ldrestart.cpp
+++ b/ldrestart.cpp
@@ -34,6 +34,29 @@
#define FLAG_PLATFORMIZE (1 << 1)
#include <dlfcn.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",
+ "com.apple.securityd",
+ "com.apple.trustd",
+ "com.apple.diagnosticd",
+ NULL
+};
+
void platformizeme() {
void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
if (!handle) return;
@@ -51,6 +74,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 +128,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 +159,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 +172,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;
}