Exemplo n.º 1
0
/**
 * Format URI
 *
 * @v uri		URI
 * @ret string		URI string, or NULL on failure
 *
 * The caller is responsible for eventually freeing the allocated
 * memory.
 */
char * format_uri_alloc ( const struct uri *uri ) {
	size_t len;
	char *string;

	len = ( format_uri ( uri, NULL, 0 ) + 1 /* NUL */ );
	string = malloc ( len );
	if ( string )
		format_uri ( uri, string, len );
	return string;
}
Exemplo n.º 2
0
/*
 * 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;
}
Exemplo n.º 3
0
/*
 * 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;
}