/* * Fill the list with the keys. BEWARE! At this point, Wireshark and Drivers * keys should be EQUALS! But is better to load keys from Wireshark, because * the driver is not always present, and maybe that cannot support some keys * (i.e. the WPA problem) */ void airpcap_fill_key_list(GtkListStore *key_list_store) { gchar* s = NULL; unsigned int i,n; airpcap_if_info_t* fake_if_info; GList* wireshark_key_list=NULL; decryption_key_t* curr_key = NULL; GtkTreeIter iter; fake_if_info = airpcap_driver_fake_if_info_new(); /* We can retrieve the driver's key list (i.e. we have the right .dll)*/ wireshark_key_list = get_wireshark_keys(); n = g_list_length(wireshark_key_list); for(i = 0; i < n; i++) { curr_key = (decryption_key_t*)g_list_nth_data(wireshark_key_list,i); if(curr_key->type == AIRPDCAP_KEY_TYPE_WEP) { gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT, KL_COL_TYPE, AIRPCAP_WEP_KEY_STRING, KL_COL_KEY, curr_key->key->str, KL_COL_SSID, "", -1); } else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PWD) { if(curr_key->ssid != NULL) s = format_uri(curr_key->ssid, ":"); else s = ""; gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT, KL_COL_TYPE, AIRPCAP_WPA_PWD_KEY_STRING, KL_COL_KEY, curr_key->key->str, KL_COL_SSID, s, -1); } else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PMK) { gtk_list_store_insert_with_values(key_list_store , &iter, G_MAXINT, KL_COL_TYPE, AIRPCAP_WPA_BIN_KEY_STRING, KL_COL_KEY, curr_key->key->str, KL_COL_SSID, "", -1); } } airpcap_if_info_free(fake_if_info); return; }
/* * This function will load from the preferences file ALL the * keys (WEP, WPA and WPA_BIN) and will set them as default for * each adapter. To do this, it will save the keys in the registry... * A check will be performed, to make sure that keys found in * registry and keys found in Wireshark preferences are the same. If not, * the user will be asked to choose if use all keys (merge them), * or use Wireshark preferences ones. In the last case, registry keys will * be overwritten for all the connected AirPcap adapters. * In the first case, adapters will use their own keys, but those * keys will not be accessible via Wireshark... */ gboolean airpcap_check_decryption_keys(GList* if_list) { gint if_n = 0; gint i = 0; gint n_adapters_keys = 0; gint n_driver_keys = 0; airpcap_if_info_t* curr_if = NULL; GList* wireshark_key_list; GList* driver_key_list; GList* curr_adapter_key_list; gboolean equals = TRUE; gboolean adapters_keys_equals=TRUE; /* * If no AirPcap interface is found, return TRUE, so Wireshark * will use HIS OWN keys. */ if(if_list == NULL) return TRUE; if_n = g_list_length(if_list); /* Get Wireshark preferences keys */ wireshark_key_list = get_wireshark_keys(); /* Retrieve AirPcap driver's keys */ driver_key_list = get_airpcap_driver_keys(); n_driver_keys = g_list_length(driver_key_list); equals &= key_lists_are_equal(wireshark_key_list,driver_key_list); for(i = 0; i < if_n; i++) { curr_if = (airpcap_if_info_t*)g_list_nth_data(if_list,i); curr_adapter_key_list = get_airpcap_device_keys(curr_if); n_adapters_keys += g_list_length(curr_adapter_key_list); adapters_keys_equals &= key_lists_are_equal(wireshark_key_list,curr_adapter_key_list); } if(n_adapters_keys != 0) /* If for some reason at least one specific key has been found */ equals &= adapters_keys_equals; /* */ if(n_driver_keys == 0) /* No keys set in any of the AirPcap adapters... */ return TRUE; /* Use Wireshark keys and set them ad default for airpcap devices */ return equals; }
/* * Fill the list with the keys. BEWARE! At this point, Wireshark and Drivers * keys should be EQUALS! But is better to load keys from Wireshark, because * the driver is not always present, and maybe that cannot support some keys * (i.e. the WPA problem) */ void airpcap_fill_key_list(GtkWidget *keylist) { gchar* s = NULL; gchar* s2 = NULL; unsigned int i,n; gchar* new_row[3]; airpcap_if_info_t* fake_if_info; GList* wireshark_key_list=NULL; decryption_key_t* curr_key = NULL; n = 0; fake_if_info = airpcap_driver_fake_if_info_new(); /* We can retrieve the driver's key list (i.e. we have the right .dll)*/ wireshark_key_list = get_wireshark_keys(); n = g_list_length(wireshark_key_list); for(i = 0; i < n; i++) { curr_key = (decryption_key_t*)g_list_nth_data(wireshark_key_list,i); if(curr_key->type == AIRPDCAP_KEY_TYPE_WEP) { s = g_strdup(curr_key->key->str); new_row[0] = g_strdup(AIRPCAP_WEP_KEY_STRING); new_row[1] = g_strdup(s); new_row[2] = g_strdup(""); gtk_clist_append(GTK_CLIST(keylist),new_row); g_free(new_row[0]); g_free(new_row[1]); g_free(new_row[2]); g_free(s); } else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PWD) { s = g_strdup(curr_key->key->str); if(curr_key->ssid != NULL) s2= g_strdup(format_uri(curr_key->ssid, ":")); else s2 = NULL; new_row[0] = g_strdup(AIRPCAP_WPA_PWD_KEY_STRING); new_row[1] = g_strdup(s); if(curr_key->ssid != NULL) new_row[2] = g_strdup(s2); else new_row[2] = g_strdup(""); gtk_clist_append(GTK_CLIST(keylist),new_row); g_free(new_row[0]); g_free(new_row[1]); g_free(new_row[2]); g_free(s); if(s2 != NULL) g_free(s2); } else if(curr_key->type == AIRPDCAP_KEY_TYPE_WPA_PMK) { s = g_strdup(curr_key->key->str); new_row[0] = g_strdup(AIRPCAP_WPA_BIN_KEY_STRING); new_row[1] = g_strdup(s); new_row[2] = g_strdup(""); gtk_clist_append(GTK_CLIST(keylist),new_row); g_free(new_row[0]); g_free(new_row[1]); g_free(new_row[2]); g_free(s); } } airpcap_if_info_free(fake_if_info); return; }