jailbreakd_client.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6. #include "libjailbreak_mig.h"
  7. int main(int argc, char **argv, char **envp) {
  8. if (argc < 3){
  9. printf("Usage: \n");
  10. printf("jailbreakd_client <pid> <1 | 2 | 6>\n");
  11. printf("\t1 = entitle+platformize the target PID\n");
  12. printf("\t2 = entitle+platformize the target PID and subsequently sent SIGCONT\n");
  13. printf("\t6 = fixup setuid in the target PID\n");
  14. return 0;
  15. }
  16. if (atoi(argv[2]) != 1 && atoi(argv[2]) != 2 && atoi(argv[2]) != 6){
  17. printf("Usage: \n");
  18. printf("jailbreakd_client <pid> <1 | 2 | 6>\n");
  19. printf("\t1 = entitle the target PID\n");
  20. printf("\t2 = entitle+platformize the target PID and subsequently sent SIGCONT\n");
  21. printf("\t6 = fixup setuid in the target PID\n");
  22. return 0;
  23. }
  24. jb_connection_t jbc = jb_connect();
  25. pid_t pid = atoi(argv[1]);
  26. int arg = atoi(argv[2]);
  27. int ret = 0;
  28. if (arg == 1) {
  29. ret = jb_entitle_now(jbc, pid, 7 | FLAG_WAIT_EXEC);
  30. } else if (arg == 2) {
  31. ret = jb_entitle_now(jbc, pid, 15);
  32. } else if (arg == 6) {
  33. ret = jb_fix_setuid_now(jbc, pid);
  34. }
  35. jb_disconnect(jbc);
  36. return ret;
  37. }
  38. // vim:ft=objc