Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added irecv_get_srnm (serial number) and irecv_get_imei (imei) to lib…

…irecovery and /deviceinfo to the irecovery shell which displays basic device information.
  • Loading branch information...
commit ee84c231a361ccb85f9eebc40a4c2e1551bcf010 1 parent 95fb480
Nicolas Haunold westbaer authored
Showing with 75 additions and 2 deletions.
  1. +34 −0 irecovery.c
  2. +41 −2 libirecovery.c
34 irecovery.c
View
@@ -46,6 +46,7 @@ void shell_usage() {
printf("Usage:\n");
printf("\t/upload <file>\tSend file to client.\n");
printf("\t/exploit [file]\tSend usb exploit with optional payload\n");
+ printf("\t/deviceinfo\tShow device information (ECID, IMEI, etc.)\n");
printf("\t/help\t\tShow this help.\n");
printf("\t/exit\t\tExit interactive shell.\n");
}
@@ -70,6 +71,38 @@ void parse_command(irecv_client_t client, unsigned char* command, unsigned int s
}
} else
+ if (!strcmp(cmd, "/deviceinfo")) {
+ int ret;
+ unsigned int cpid, bdid;
+ unsigned long long ecid;
+ unsigned char srnm[12], imei[15], bt[15];
+
+ ret = irecv_get_cpid(client, &cpid);
+ if(ret == IRECV_E_SUCCESS) {
+ printf("CPID: %d\n", cpid);
+ }
+
+ ret = irecv_get_bdid(client, &bdid);
+ if(ret == IRECV_E_SUCCESS) {
+ printf("BDID: %d\n", bdid);
+ }
+
+ ret = irecv_get_ecid(client, &ecid);
+ if(ret == IRECV_E_SUCCESS) {
+ printf("ECID: %lld\n", ecid);
+ }
+
+ ret = irecv_get_srnm(client, srnm);
+ if(ret == IRECV_E_SUCCESS) {
+ printf("SRNM: %s\n", srnm);
+ }
+
+ ret = irecv_get_imei(client, imei);
+ if(ret == IRECV_E_SUCCESS) {
+ printf("IMEI: %s\n", imei);
+ }
+ } else
+
if (!strcmp(cmd, "/exploit")) {
char* filename = strtok(NULL, " ");
debug("Sending exploit %s\n", filename);
@@ -109,6 +142,7 @@ void init_shell(irecv_client_t client) {
irecv_event_subscribe(client, IRECV_POSTCOMMAND, &postcommand_cb, NULL);
while (!quit) {
error = irecv_receive(client);
+
if (error != IRECV_E_SUCCESS) {
debug("%s\n", irecv_strerror(error));
break;
43 libirecovery.c
View
@@ -844,7 +844,7 @@ irecv_error_t irecv_get_cpid(irecv_client_t client, unsigned int* cpid) {
irecv_error_t irecv_get_bdid(irecv_client_t client, unsigned int* bdid) {
if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
-
+
char* bdid_string = strstr(client->serial, "BDID:");
if (bdid_string == NULL) {
*bdid = 0;
@@ -868,6 +868,45 @@ irecv_error_t irecv_get_ecid(irecv_client_t client, unsigned long long* ecid) {
return IRECV_E_SUCCESS;
}
+irecv_error_t irecv_get_srnm(irecv_client_t client, unsigned char* srnm) {
+ if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
+
+ char* srnmp;
+ char* srnm_string = strstr(client->serial, "SRNM:[");
+ if(srnm_string == NULL) {
+ srnm = NULL;
+ return IRECV_E_UNKNOWN_ERROR;
+ }
+
+ sscanf(srnm_string, "SRNM:[%s]", srnm);
+ srnmp = strrchr(srnm, ']');
+ if(srnmp != NULL) {
+ *srnmp = '\0';
+ }
+
+ return IRECV_E_SUCCESS;
+}
+
+irecv_error_t irecv_get_imei(irecv_client_t client, unsigned char* imei) {
+ if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
+
+ char* imeip;
+ char* imei_string = strstr(client->serial, "IMEI:[");
+ if (imei_string == NULL) {
+ *imei = 0;
+ return IRECV_E_UNKNOWN_ERROR;
+ }
+
+
+ sscanf(imei_string, "IMEI:[%s]", imei);
+ imeip = strrchr(imei, ']');
+ if(imeip != NULL) {
+ *imeip = '\0';
+ }
+
+ return IRECV_E_SUCCESS;
+}
+
irecv_error_t irecv_send_exploit(irecv_client_t client) {
if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
irecv_control_transfer(client, 0x21, 2, 0, 0, NULL, 0, 1000);
@@ -877,7 +916,7 @@ irecv_error_t irecv_send_exploit(irecv_client_t client) {
irecv_error_t irecv_execute_script(irecv_client_t client, const char* filename) {
irecv_error_t error = IRECV_E_SUCCESS;
if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
-
+
char* file_data = NULL;
unsigned int file_size = 0;
if(irecv_read_file(filename, &file_data, &file_size) < 0) {
Please sign in to comment.
Something went wrong with that request. Please try again.