summaryrefslogtreecommitdiffstats
path: root/tools/irecovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/irecovery.c')
-rw-r--r--tools/irecovery.c90
1 files changed, 52 insertions, 38 deletions
diff --git a/tools/irecovery.c b/tools/irecovery.c
index 58b93f3..5e21921 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -51,7 +51,8 @@ enum {
51 kSendExploit, 51 kSendExploit,
52 kSendScript, 52 kSendScript,
53 kShowMode, 53 kShowMode,
54 kRebootToNormalMode 54 kRebootToNormalMode,
55 kQueryInfo
55}; 56};
56 57
57static unsigned int quit = 0; 58static unsigned int quit = 0;
@@ -127,6 +128,44 @@ static void print_hex(unsigned char *buf, size_t len)
127 } 128 }
128} 129}
129 130
131static void print_device_info(irecv_client_t client)
132{
133 int ret, mode;
134 const struct irecv_device_info *devinfo = irecv_get_device_info(client);
135 if (devinfo) {
136 printf("CPID: %04x\n", devinfo->cpid);
137 printf("CPRV: %02x\n", devinfo->cprv);
138 printf("BDID: %02x\n", devinfo->bdid);
139 printf("ECID: " _FMT_lld "\n", devinfo->ecid);
140 printf("CPFM: %02x\n", devinfo->cpfm);
141 printf("SCEP: %02x\n", devinfo->scep);
142 printf("IBFL: %02x\n", devinfo->ibfl);
143 printf("SRNM: %s\n", (devinfo->srnm) ? devinfo->srnm : "N/A");
144 printf("IMEI: %s\n", (devinfo->imei) ? devinfo->imei : "N/A");
145 printf("NONC: ");
146 if (devinfo->ap_nonce) {
147 print_hex(devinfo->ap_nonce, devinfo->ap_nonce_size);
148 } else {
149 printf("N/A");
150 }
151 printf("\n");
152 printf("SNON: ");
153 if (devinfo->sep_nonce) {
154 print_hex(devinfo->sep_nonce, devinfo->sep_nonce_size);
155 } else {
156 printf("N/A");
157 }
158 printf("\n");
159 } else {
160 printf("Could not get device info?!\n");
161 }
162
163 ret = irecv_get_mode(client, &mode);
164 if (ret == IRECV_E_SUCCESS) {
165 printf("MODE: %s\n", mode_to_str(mode));
166 }
167}
168
130static void parse_command(irecv_client_t client, unsigned char* command, unsigned int size) { 169static void parse_command(irecv_client_t client, unsigned char* command, unsigned int size) {
131 char* cmd = strdup((char*)command); 170 char* cmd = strdup((char*)command);
132 char* action = strtok(cmd, " "); 171 char* action = strtok(cmd, " ");
@@ -142,42 +181,7 @@ static void parse_command(irecv_client_t client, unsigned char* command, unsigne
142 irecv_send_file(client, filename, 0); 181 irecv_send_file(client, filename, 0);
143 } 182 }
144 } else if (!strcmp(cmd, "/deviceinfo")) { 183 } else if (!strcmp(cmd, "/deviceinfo")) {
145 int ret, mode; 184 print_device_info(client);
146 const struct irecv_device_info *devinfo = irecv_get_device_info(client);
147
148 if (devinfo) {
149 printf("CPID: %04x\n", devinfo->cpid);
150 printf("CPRV: %02x\n", devinfo->cprv);
151 printf("BDID: %02x\n", devinfo->bdid);
152 printf("ECID: " _FMT_lld "\n", devinfo->ecid);
153 printf("CPFM: %02x\n", devinfo->cpfm);
154 printf("SCEP: %02x\n", devinfo->scep);
155 printf("IBFL: %02x\n", devinfo->ibfl);
156 printf("SRNM: %s\n", (devinfo->srnm) ? devinfo->srnm : "N/A");
157 printf("IMEI: %s\n", (devinfo->imei) ? devinfo->imei : "N/A");
158 printf("NONC: ");
159 if (devinfo->ap_nonce) {
160 print_hex(devinfo->ap_nonce, devinfo->ap_nonce_size);
161 } else {
162 printf("N/A");
163 }
164 printf("\n");
165 printf("SNON: ");
166 if (devinfo->sep_nonce) {
167 print_hex(devinfo->sep_nonce, devinfo->sep_nonce_size);
168 } else {
169 printf("N/A");
170 }
171 printf("\n");
172 } else {
173 printf("Could not get device info?!\n");
174 }
175
176 ret = irecv_get_mode(client, &mode);
177 if (ret == IRECV_E_SUCCESS) {
178 printf("MODE: %s\n", mode_to_str(mode));
179 }
180
181 } else if (!strcmp(cmd, "/limera1n")) { 185 } else if (!strcmp(cmd, "/limera1n")) {
182 char* filename = strtok(NULL, " "); 186 char* filename = strtok(NULL, " ");
183 debug("Sending limera1n payload %s\n", filename); 187 debug("Sending limera1n payload %s\n", filename);
@@ -353,6 +357,7 @@ static void print_usage(int argc, char **argv) {
353 printf(" -n\t\treboot device into normal mode (exit recovery loop)\n"); 357 printf(" -n\t\treboot device into normal mode (exit recovery loop)\n");
354 printf(" -e FILE\texecutes recovery script from FILE\n"); 358 printf(" -e FILE\texecutes recovery script from FILE\n");
355 printf(" -s\t\tstart an interactive shell\n"); 359 printf(" -s\t\tstart an interactive shell\n");
360 printf(" -q\t\tquery device info\n");
356 printf(" -v\t\tenable verbose output, repeat for higher verbosity\n"); 361 printf(" -v\t\tenable verbose output, repeat for higher verbosity\n");
357 printf(" -h\t\tprints this usage information\n"); 362 printf(" -h\t\tprints this usage information\n");
358 printf("\n"); 363 printf("\n");
@@ -376,7 +381,7 @@ int main(int argc, char* argv[]) {
376 return 0; 381 return 0;
377 } 382 }
378 383
379 while ((opt = getopt(argc, argv, "i:vhrsmnc:f:e:k::")) > 0) { 384 while ((opt = getopt(argc, argv, "i:vhrsmnc:f:e:k::q")) > 0) {
380 switch (opt) { 385 switch (opt) {
381 case 'i': 386 case 'i':
382 if (optarg) { 387 if (optarg) {
@@ -436,6 +441,10 @@ int main(int argc, char* argv[]) {
436 argument = optarg; 441 argument = optarg;
437 break; 442 break;
438 443
444 case 'q':
445 action = kQueryInfo;
446 break;
447
439 default: 448 default:
440 fprintf(stderr, "Unknown argument\n"); 449 fprintf(stderr, "Unknown argument\n");
441 return -1; 450 return -1;
@@ -539,6 +548,11 @@ int main(int argc, char* argv[]) {
539 debug("%s\n", irecv_strerror(error)); 548 debug("%s\n", irecv_strerror(error));
540 } 549 }
541 break; 550 break;
551
552 case kQueryInfo:
553 print_device_info(client);
554 break;
555
542 default: 556 default:
543 fprintf(stderr, "Unknown action\n"); 557 fprintf(stderr, "Unknown action\n");
544 break; 558 break;