diff options
author | Sam Bingner <sam@bingner.com> | 2019-09-05 16:08:36 -1000 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2019-09-06 17:29:56 -1000 |
commit | 9ee4d6ad383e9925709a104997b83ff4505e2343 (patch) | |
tree | 9082f2f6ad9075356972a65e95d8c1b070026bf4 | |
parent | 2d62815fb4e4d8a1bddc7a97f3beb87a17d3e8a8 (diff) |
Maybe better cydo hackv1.1.32%b20
-rw-r--r-- | cydo.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
@@ -25,6 +25,8 @@ #include <errno.h> #include <sysexits.h> #include <unistd.h> +#include <sys/mman.h> +#include <fcntl.h> #include <launch.h> @@ -81,9 +83,36 @@ int main(int argc, char *argv[]) { auto response(launch_msg(request)); launch_data_free(request); if ((response == NULL || launch_data_get_type(response) != LAUNCH_DATA_DICTIONARY ) && strcmp(argv[0], "/usr/libexec/cydia/cydo.dummy") != 0 ) { + bool ok=false; + struct stat st; + struct stat myst; + if (stat("/usr/libexec/cydia/cydo.dummy", &st) == 0 && stat(argv[0], &myst) == 0 && st.st_size == myst.st_size) { + int efd = open("/usr/libexec/cydia/cydo.dummy", O_RDONLY); + if (efd > 0) { + void *existing = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, efd, 0); + if (existing != MAP_FAILED) { + int myself = open(argv[0], O_RDONLY); + if (myself>0) { + void *myselfmap = mmap(NULL, myst.st_size, PROT_READ, MAP_PRIVATE, myself, 0); + if (myselfmap != MAP_FAILED) { + if (memcmp(existing, myselfmap, st.st_size) == 0) { + ok = true; + } + munmap(myselfmap, myst.st_size); + } + close(myself); + } + munmap(existing, st.st_size); + } + close(efd); + } + } fprintf(stderr, "Warning: couldn't communicate with launchd , maybe we're in an intentionally broken jailbreak? Try to work around it.\n"); - system("cp /usr/libexec/cydia/cydo /usr/libexec/cydia/cydo.dummy"); - chmod("/usr/libexec/cydia/cydo.dummy", 0755); + if (!ok) { + unlink("/usr/libexec/cydia/cydo.dummy"); + system("cp /usr/libexec/cydia/cydo /usr/libexec/cydia/cydo.dummy"); + chmod("/usr/libexec/cydia/cydo.dummy", 0755); + } argv[0] = "/usr/libexec/cydia/cydo.dummy"; execv(argv[0], argv); _assert(false); |