diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/idevice.c | 16 | ||||
| -rw-r--r-- | src/idevice.h | 2 | ||||
| -rw-r--r-- | src/lockdown-cu.c | 4 | ||||
| -rw-r--r-- | src/lockdown.c | 4 | 
4 files changed, 19 insertions, 7 deletions
| diff --git a/src/idevice.c b/src/idevice.c index e9c909f..1cdfef2 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -946,6 +946,20 @@ idevice_error_t idevice_get_udid(idevice_t device, char **udid) | |||
| 946 | return IDEVICE_E_SUCCESS; | 946 | return IDEVICE_E_SUCCESS; | 
| 947 | } | 947 | } | 
| 948 | 948 | ||
| 949 | unsigned int idevice_get_device_version(idevice_t device) | ||
| 950 | { | ||
| 951 | if (!device) { | ||
| 952 | return 0; | ||
| 953 | } | ||
| 954 | if (!device->version) { | ||
| 955 | lockdownd_client_t lockdown = NULL; | ||
| 956 | lockdownd_client_new(device, &lockdown, NULL); | ||
| 957 | // we don't handle any errors here. We should have the product version cached now. | ||
| 958 | lockdownd_client_free(lockdown); | ||
| 959 | } | ||
| 960 | return device->version; | ||
| 961 | } | ||
| 962 | |||
| 949 | #if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS) | 963 | #if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS) | 
| 950 | typedef ssize_t ssl_cb_ret_type_t; | 964 | typedef ssize_t ssl_cb_ret_type_t; | 
| 951 | #elif defined(HAVE_MBEDTLS) | 965 | #elif defined(HAVE_MBEDTLS) | 
| @@ -1229,7 +1243,7 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) | |||
| 1229 | #if OPENSSL_VERSION_NUMBER < 0x10100002L || \ | 1243 | #if OPENSSL_VERSION_NUMBER < 0x10100002L || \ | 
| 1230 | (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2060000fL)) | 1244 | (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2060000fL)) | 
| 1231 | /* force use of TLSv1 for older devices */ | 1245 | /* force use of TLSv1 for older devices */ | 
| 1232 | if (connection->device->version < DEVICE_VERSION(10,0,0)) { | 1246 | if (connection->device->version < IDEVICE_DEVICE_VERSION(10,0,0)) { | 
| 1233 | #ifdef SSL_OP_NO_TLSv1_1 | 1247 | #ifdef SSL_OP_NO_TLSv1_1 | 
| 1234 | SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1_1); | 1248 | SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1_1); | 
| 1235 | #endif | 1249 | #endif | 
| diff --git a/src/idevice.h b/src/idevice.h index dd72f9d..e05338e 100644 --- a/src/idevice.h +++ b/src/idevice.h | |||
| @@ -52,8 +52,6 @@ | |||
| 52 | #include "common/userpref.h" | 52 | #include "common/userpref.h" | 
| 53 | #include "libimobiledevice/libimobiledevice.h" | 53 | #include "libimobiledevice/libimobiledevice.h" | 
| 54 | 54 | ||
| 55 | #define DEVICE_VERSION(maj, min, patch) (((maj & 0xFF) << 16) | ((min & 0xFF) << 8) | (patch & 0xFF)) | ||
| 56 | |||
| 57 | #define DEVICE_CLASS_IPHONE 1 | 55 | #define DEVICE_CLASS_IPHONE 1 | 
| 58 | #define DEVICE_CLASS_IPAD 2 | 56 | #define DEVICE_CLASS_IPAD 2 | 
| 59 | #define DEVICE_CLASS_IPOD 3 | 57 | #define DEVICE_CLASS_IPOD 3 | 
| diff --git a/src/lockdown-cu.c b/src/lockdown-cu.c index 9fbd2c8..30eec99 100644 --- a/src/lockdown-cu.c +++ b/src/lockdown-cu.c | |||
| @@ -509,7 +509,7 @@ lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdow | |||
| 509 | char *s_version = NULL; | 509 | char *s_version = NULL; | 
| 510 | plist_get_string_val(p_version, &s_version); | 510 | plist_get_string_val(p_version, &s_version); | 
| 511 | if (s_version && sscanf(s_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) { | 511 | if (s_version && sscanf(s_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) { | 
| 512 | client->device->version = DEVICE_VERSION(vers[0], vers[1], vers[2]); | 512 | client->device->version = IDEVICE_DEVICE_VERSION(vers[0], vers[1], vers[2]); | 
| 513 | } | 513 | } | 
| 514 | free(s_version); | 514 | free(s_version); | 
| 515 | } | 515 | } | 
| @@ -962,7 +962,7 @@ lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t cli | |||
| 962 | 962 | ||
| 963 | // Starting with iOS/tvOS 11.2 and WatchOS 4.2, this nonce is random and sent along with the request. Before, the request doesn't have a nonce and it uses hardcoded nonce "sendone01234". | 963 | // Starting with iOS/tvOS 11.2 and WatchOS 4.2, this nonce is random and sent along with the request. Before, the request doesn't have a nonce and it uses hardcoded nonce "sendone01234". | 
| 964 | unsigned char cu_nonce[12] = "sendone01234"; // guaranteed to be random by fair dice troll | 964 | unsigned char cu_nonce[12] = "sendone01234"; // guaranteed to be random by fair dice troll | 
| 965 | if (client->device->version >= DEVICE_VERSION(11,2,0)) { | 965 | if (client->device->version >= IDEVICE_DEVICE_VERSION(11,2,0)) { | 
| 966 | #if defined(HAVE_OPENSSL) | 966 | #if defined(HAVE_OPENSSL) | 
| 967 | RAND_bytes(cu_nonce, sizeof(cu_nonce)); | 967 | RAND_bytes(cu_nonce, sizeof(cu_nonce)); | 
| 968 | #elif defined(HAVE_GCRYPT) | 968 | #elif defined(HAVE_GCRYPT) | 
| diff --git a/src/lockdown.c b/src/lockdown.c index 411136c..a1ad67b 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -659,7 +659,7 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli | |||
| 659 | char *s_version = NULL; | 659 | char *s_version = NULL; | 
| 660 | plist_get_string_val(p_version, &s_version); | 660 | plist_get_string_val(p_version, &s_version); | 
| 661 | if (s_version && sscanf(s_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) { | 661 | if (s_version && sscanf(s_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) { | 
| 662 | device->version = DEVICE_VERSION(vers[0], vers[1], vers[2]); | 662 | device->version = IDEVICE_DEVICE_VERSION(vers[0], vers[1], vers[2]); | 
| 663 | } | 663 | } | 
| 664 | free(s_version); | 664 | free(s_version); | 
| 665 | } | 665 | } | 
| @@ -733,7 +733,7 @@ lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdown | |||
| 733 | plist_free(pair_record); | 733 | plist_free(pair_record); | 
| 734 | pair_record = NULL; | 734 | pair_record = NULL; | 
| 735 | 735 | ||
| 736 | if (device->version < DEVICE_VERSION(7,0,0) && device->device_class != DEVICE_CLASS_WATCH) { | 736 | if (device->version < IDEVICE_DEVICE_VERSION(7,0,0) && device->device_class != DEVICE_CLASS_WATCH) { | 
| 737 | /* for older devices, we need to validate pairing to receive trusted host status */ | 737 | /* for older devices, we need to validate pairing to receive trusted host status */ | 
| 738 | ret = lockdownd_validate_pair(client_loc, NULL); | 738 | ret = lockdownd_validate_pair(client_loc, NULL); | 
| 739 | 739 | ||
