Ejemplo n.º 1
0
void doSim() {
	uint8_t key[KEYBYTES];
	int i,j;
	PTW_attackstate * state;
	state = PTW_newattackstate();
	printf("starting new sim\n");
	for (i = 0; i < HSBYTES; i++) {
		key[IVBYTES + i] = rand()%n;
	}
	
	for (i = 0; i < STARTSESS; i++) {
		addRound(key, state);
	}
	printStats(state, i, &key[3]);
	while (i < ENDSESS) {
		for (j = 0; j < INCSESS; j++) {
			addRound(key, state);
		}
		i += INCSESS;
		printStats(state, i, &key[3]);

	}
	printKey(&key[3], 13);
	PTW_freeattackstate(state);
}
Ejemplo n.º 2
0
void dumpacket( unsigned char *packet, int len )
{
	int dstoffset;
	uint8_t key[PTW_KEYHSBYTES];
	uint8_t buf[PTW_n];
	uint8_t iv[3];
	uint8_t keystream[16];
	uint8_t bssid[BSSIDLEN];
	int i,z;
	network *network_ptr;

	switch( packet[1] & 3 )
	{
	case  0: memcpy( bssid, packet + 16, 6 ); break;  //Adhoc
	case  1: memcpy( bssid, packet +  4, 6 ); break;  //ToDS
	case  2: memcpy( bssid, packet + 10, 6 ); break;  //FromDS
	case  3: memcpy( bssid, packet + 10, 6 ); break;  //WDS -> Transmitter taken as BSSID
	}

	network_ptr = networktable;
	while( network_ptr ) 
	{
		if ( memcmp(network_ptr->bssid, bssid, BSSIDLEN) == 0 ) 
		{
			break;
		}
		network_ptr = network_ptr->next;
	}

	if( network_ptr == NULL ) 
	{
		// Allocate a new table
		//printf("allocating a new table\n");
		//printf("bssid = %02X:%02X:%02X:%02X:%02X:%02X  keyindex=%01d\n", packet[bssoffset+0], packet[bssoffset+1], packet[bssoffset+2], packet[bssoffset+3], packet[bssoffset+4], packet[bssoffset+5], packet[27]);
		network *tmp = (network*) malloc(sizeof(network));
		tmp->state = PTW_newattackstate();
		if(tmp->state == NULL) 
		{
			// printf("could not allocate state\n");
			exit(-1);
		}
		memcpy( tmp->bssid, bssid, BSSIDLEN);
		tmp->keyindex = -1;
		tmp->bcn = 0;
		tmp->security = 0;
		tmp->channel = 0;
		tmp->sprofile = false;
		tmp->rcrack = false;
		memcpy( tmp->bssid, bssid, BSSIDLEN );

		tmp->next = networktable;
		networktable = network_ptr = tmp;
	}

	if( network_ptr->rcrack == true )
		return;

	if( packet[0] == 0x80 || packet[0] == 0x50 )
	{
		if( ( packet[34] & 0x10 ) >> 4 ) 
			network_ptr->security |= STD_WEP;
		else 
			network_ptr->security |= STD_OPN;

		unsigned char *p = packet + 36;

		while( p < packet + len )
		{
			if( p + 2 + p[1] > packet + len )
				break;

			switch( p[0] )
			{
			case 0x00:
				memcpy( network_ptr->essid, p + 2, p[1] );
				network_ptr->essid[p[1]] = 0;
				break;
			case 0x03:
				network_ptr->channel = p[2];
				break;
			case 0x30:
				if( p[2] == 1 )
				{

				}
				break;
			case 0xdd:
				break;
			}

			p += 2 + p[1];
		}
	}