Skip to content

Commit

Permalink
Patched idevicebackup2 and ideviceinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanc123 committed Aug 16, 2020
1 parent d857a83 commit e3d3979
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
15 changes: 12 additions & 3 deletions tools/idevicebackup2.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ enum cmd_mode {
CMD_UNBACK,
CMD_CHANGEPW,
CMD_LEAVE,
CMD_CLOUD
CMD_CLOUD,
CMD_ERASE
};

enum cmd_flags {
Expand Down Expand Up @@ -1520,6 +1521,9 @@ int main(int argc, char *argv[])
else if (!strcmp(argv[i], "restore")) {
cmd = CMD_RESTORE;
}
else if (!strcmp(argv[i], "erase")) {
cmd = CMD_ERASE;
}
else if (!strcmp(argv[i], "--system")) {
cmd_flags |= CMD_FLAG_RESTORE_SYSTEM_FILES;
}
Expand Down Expand Up @@ -1658,7 +1662,7 @@ int main(int argc, char *argv[])
return -1;
}

if (cmd == CMD_CHANGEPW || cmd == CMD_CLOUD) {
if (cmd == CMD_CHANGEPW || cmd == CMD_CLOUD || cmd == CMD_ERASE) {
backup_directory = (char*)".this_folder_is_not_present_on_purpose";
} else {
if (backup_directory == NULL) {
Expand Down Expand Up @@ -1911,6 +1915,12 @@ int main(int argc, char *argv[])
checkpoint:

switch(cmd) {
case CMD_ERASE:
PRINT_VERBOSE(1, "Starting Erase device...\n");
err = mobilebackup2_send_message(mobilebackup2, "EraseDevice", NULL);
result_code = err;
cmd = CMD_LEAVE;
break;
case CMD_CLOUD:
opts = plist_new_dict();
plist_dict_set_item(opts, "CloudBackupState", plist_new_bool(cmd_flags & CMD_FLAG_CLOUD_ENABLE ? 1: 0));
Expand Down Expand Up @@ -2591,4 +2601,3 @@ int main(int argc, char *argv[])

return result_code;
}

41 changes: 39 additions & 2 deletions tools/ideviceinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ int main(int argc, char *argv[])
idevice_t device = NULL;
idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
int simple = 0;
int modifyFlag = 0;
int format = FORMAT_KEY_VALUE;
const char* udid = NULL;
int use_network = 0;
Expand All @@ -136,6 +137,7 @@ int main(int argc, char *argv[])
char *xml_doc = NULL;
uint32_t xml_length;
plist_t node = NULL;
char *setValue = NULL;

int c = 0;
const struct option longopts[] = {
Expand All @@ -148,14 +150,15 @@ int main(int argc, char *argv[])
{ "simple", no_argument, NULL, 's' },
{ "xml", no_argument, NULL, 'x' },
{ "version", no_argument, NULL, 'v' },
{ "modify", required_argument, NULL, 'm'},
{ NULL, 0, NULL, 0}
};

#ifndef WIN32
signal(SIGPIPE, SIG_IGN);
#endif

while ((c = getopt_long(argc, argv, "dhu:nq:k:sxv", longopts, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "dhu:nq:k:sxvm:", longopts, NULL)) != -1) {
switch (c) {
case 'd':
idevice_set_debug_level(1);
Expand Down Expand Up @@ -199,6 +202,22 @@ int main(int argc, char *argv[])
case 'v':
printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION);
return 0;
case 'm':
if (!*optarg) {
fprintf(stderr, "ERROR: 'm' must not be empty!\n");
return 2;
}
else if (!strcmp(optarg, "true")) {
modifyFlag = 3;
}
else if (!strcmp(optarg, "false")) {
modifyFlag = 2;
}
else {
modifyFlag = 1;
setValue = optarg;
}
break;
default:
print_usage(argc, argv, 1);
return 2;
Expand Down Expand Up @@ -231,7 +250,25 @@ int main(int argc, char *argv[])
}

/* run query and output information */
if(lockdownd_get_value(client, domain, key, &node) == LOCKDOWN_E_SUCCESS) {
if(modifyFlag == 1){
printf("Attempting Opperation\n");
if(lockdownd_set_value(client, domain, key, plist_new_string(setValue)) == LOCKDOWN_E_SUCCESS) {
printf("Success\n");
}
}
else if(modifyFlag == 2){
printf("Attempting Opperation\n");
if(lockdownd_set_value(client, domain, key, plist_new_bool(0)) == LOCKDOWN_E_SUCCESS) {
printf("Success\n");
}
}
else if(modifyFlag == 3){
printf("Attempting Opperation\n");
if(lockdownd_set_value(client, domain, key, plist_new_bool(1)) == LOCKDOWN_E_SUCCESS) {
printf("Success\n");
}
}
else if(lockdownd_get_value(client, domain, key, &node) == LOCKDOWN_E_SUCCESS) {
if (node) {
switch (format) {
case FORMAT_XML:
Expand Down

0 comments on commit e3d3979

Please sign in to comment.