⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aircrack-ng.c

📁 java softwar for you to send out the request
💻 C
📖 第 1 页 / 共 5 页
字号:
	if( is_cleared == 0 )	{		is_cleared++;		if( opt.l33t )			printf( "\33[40m" );		printf( "\33[2J" );	}	if( opt.l33t )		printf( "\33[34;1m" );	printf( "\33[2;%dH%s\n\n", (ws.ws_col - 12) / 2,		progname );	if( opt.l33t )		printf( "\33[33;1m" );	printf( "\33[5;%dH[%02d:%02d:%02d] Tested %lld keys (got %ld IVs)\33[K",		(ws.ws_col - 44) / 2, et_h, et_m, et_s, nb_tried, wep.nb_ivs_now );	if( opt.l33t )		printf( "\33[32;22m" );	printf( "\33[7;4HKB    depth   byte(vote)\n" );	for( i = 0; i <= B; i++ )	{		int j, k = ( ws.ws_col - 20 ) / 9;		if( opt.l33t )			printf( "   %2d  \33[1m%3d\33[22m/%3d   ",				i, wep.depth[i], wep.fudge[i] );		else			printf( "   %2d  %3d/%3d   ",				i, wep.depth[i], wep.fudge[i] );		for( j = wep.depth[i]; j < k + wep.depth[i]; j++ )		{			if( j >= 256 ) break;			if( wep.poll[i][j].val == 32767 )			{				if( opt.l33t )					printf( "\33[1m%02X\33[22m(+inf) ",						wep.poll[i][j].idx );				else					printf( "%02X(+inf) ", wep.poll[i][j].idx );			}			else			{				if( opt.l33t )					printf( "\33[1m%02X\33[22m(%4d) ",						wep.poll[i][j].idx,						wep.poll[i][j].val );				else					printf( "%02X(%4d) ",  wep.poll[i][j].idx,						wep.poll[i][j].val );			}		}		if (opt.showASCII)			if(wep.poll[i][wep.depth[i]].idx>=ASCII_LOW_T && wep.poll[i][wep.depth[i]].idx<=ASCII_HIGH_T)				if(wep.poll[i][wep.depth[i]].val>=ASCII_VOTE_STRENGTH_T || ASCII_DISREGARD_STRENGTH )					printf( "  %c",wep.poll[i][wep.depth[i]].idx );		printf( "\n" );	}	if( B < opt.keylen - 1 )		printf( "\33[J" );	printf( "\n" );}/* test if the current WEP key is valid */int check_wep_key( uchar *wepkey, int B, int keylen ){	uchar x1, x2;	unsigned long xv;	int i, j, n, bad;	int nb_ascii;	uchar K[64];	uchar S[256];	if (keylen<=0)		keylen = opt.keylen;	nb_tried++;	bad = 0;	memcpy( K + 3, wepkey, keylen );	for( n = 0; n < 32; n++ )	{		/* xv = 5 * ( rand() % wep.nb_ivs ); */		xv = 5 * n;		memcpy( K, &wep.ivbuf[xv], 3 );		memcpy( S, R, 256 );		for( i = j = 0; i < 256; i++ )		{			j = ( j + S[i] + K[i % (3 + keylen)]) & 0xFF;			SWAP( S[i], S[j] );		}		i = 1; j = ( 0 + S[i] ) & 0xFF; SWAP(S[i], S[j]);		x1 = wep.ivbuf[xv + 3] ^ S[(S[i] + S[j]) & 0xFF];		i = 2; j = ( j + S[i] ) & 0xFF; SWAP(S[i], S[j]);		x2 = wep.ivbuf[xv + 4] ^ S[(S[i] + S[j]) & 0xFF];		if( ( x1 != 0xAA || x2 != 0xAA ) &&			( x1 != 0xE0 || x2 != 0xE0 ) &&			( x1 != 0x42 || x2 != 0x42 ) )			bad++;		if( bad > 2 )			return( FAILURE );	}	nb_ascii = 0;	for( i = 0; i < keylen; i++ )		if( wepkey[i] == 0 ||		( wepkey[i] >= 32 && wepkey[i] < 127 ) )			nb_ascii++;	wepkey_crack_success = 1;	memcpy(bf_wepkey, wepkey, keylen);	if( opt.is_quiet )		printf( "KEY FOUND! [ " );	else	{		show_wep_stats( B - 1, 1 );		if( opt.l33t )			printf( "\33[31;1m" );		n = ( 80 - 14 - keylen * 3 ) / 2;		if( 100 * nb_ascii > 75 * keylen )			n -= ( keylen + 4 ) / 2;		if( n <= 0 ) n = 0;		printf( "\33[K\33[%dCKEY FOUND! [ ", n );	}	for( i = 0; i < keylen - 1; i++ )		printf( "%02X:", wepkey[i] );	printf( "%02X ] ",   wepkey[i] );	if( 100 * nb_ascii > 75 * opt.keylen )	{		printf( "(ASCII: " );		for( i = 0; i < opt.keylen; i++ )			printf( "%c", ( ( wepkey[i] >  31 && wepkey[i] < 127 ) ||				wepkey[i] > 160 ) ? wepkey[i] : '.' );		printf( " )" );	}	if( opt.l33t )		printf( "\33[32;22m" );	printf( "\n" );	return( SUCCESS );}/* routine used to sort the votes */int cmp_votes( const void *bs1, const void *bs2 ){	if( ((vote *) bs1)->val < ((vote *) bs2)->val )		return(  1 );	if( ((vote *) bs1)->val > ((vote *) bs2)->val )		return( -1 );	return( 0 );}/* sum up the votes and sort them */int calc_poll( int B ){	int i, n, cid, *vi;	int votes[N_ATTACKS][256];	/* send the current keybyte # to each thread */	for( cid = 0; cid < opt.nbcpu; cid++ )	{		n = sizeof( int );		if( safe_write( mc_pipe[cid][1], &B, n ) != n )		{			perror( "write failed" );			kill( 0, SIGTERM );			_exit( FAILURE );		}	}	/* collect the votes, multiply by the korek coeffs */	for( i = 0; i < 256; i++ )	{		wep.poll[B][i].idx = i;		wep.poll[B][i].val = 0;	}	for( cid = 0; cid < opt.nbcpu; cid++ )	{		n = sizeof( votes );		if( safe_read( cm_pipe[cid][0], votes, n ) != n )		{			perror( "read failed" );			kill( 0, SIGTERM );			_exit( FAILURE );		}		for( n = 0, vi = (int *) votes; n < N_ATTACKS; n++ )			for( i = 0; i < 256; i++, vi++ )				wep.poll[B][i].val += *vi * K_COEFF[n];	}	/* set votes to the max if the keybyte is user-defined */	if( opt.debug_row[B] )		wep.poll[B][opt.debug[B]].val = 32767;	/* if option is set, restrict keyspace to alpha-numeric */	if( opt.is_alnum )	{		for( i = 1; i < 32; i++ )			wep.poll[B][i].val = -1;		for( i = 127; i < 256; i++ )			wep.poll[B][i].val = -1;	}	if( opt.is_fritz )	{		for( i = 0; i < 48; i++ )			wep.poll[B][i].val = -1;		for( i = 58; i < 256; i++ )			wep.poll[B][i].val = -1;	}	/* if option is set, restrict keyspace to BCD hex digits */	if( opt.is_bcdonly )	{		for( i = 1; i < 256; i++ )			if( i > 0x99 || ( i & 0x0F ) > 0x09 )				wep.poll[B][i].val = -1;	}	/* sort the votes, highest ones first */	qsort( wep.poll[B], 256, sizeof( vote ), cmp_votes );	return( SUCCESS );}int update_ivbuf( void ){	int n;	struct AP_info *ap_cur;	/* 1st pass: compute the total number of available IVs */	wep.nb_ivs_now = 0;	wep.nb_aps = 0;	ap_cur = ap_1st;	while( ap_cur != NULL )	{		if( ap_cur->crypt == 2 && ap_cur->target )		{			wep.nb_ivs_now += ap_cur->nb_ivs;			wep.nb_aps++;		}		ap_cur = ap_cur->next;	}	/* 2nd pass: create the main IVs buffer if necessary */	if( wep.nb_ivs == 0 ||		( opt.keylen ==  5 && wep.nb_ivs_now - wep.nb_ivs > 20000 ) ||		( opt.keylen >= 13 && wep.nb_ivs_now - wep.nb_ivs > 40000 ) )	{		/* one buffer to rule them all */		if( wep.ivbuf != NULL )		{			free( wep.ivbuf );			wep.ivbuf = NULL;		}		wep.nb_ivs = 0;		ap_cur = ap_1st;		while( ap_cur != NULL )		{			if( ap_cur->crypt == 2 && ap_cur->target )			{				n = ap_cur->nb_ivs;				if( ( wep.ivbuf = realloc( wep.ivbuf,					( wep.nb_ivs + n ) * 5 ) ) == NULL )				{					perror( "realloc failed" );					kill( 0, SIGTERM );					_exit( FAILURE );				}				memcpy( wep.ivbuf + wep.nb_ivs * 5, ap_cur->ivbuf, 5 * n );				wep.nb_ivs += n;			}			ap_cur = ap_cur->next;		}		return( RESTART );	}	return( SUCCESS );}/* standard attack mode: *//* this routine gathers and sorts the votes, then recurses until it * * reaches B == keylen. It also stops when the current keybyte vote * * is lower than the highest vote divided by the fudge factor.      */int do_wep_crack1( int B ){	int i, j, tsel;	static int k = 0;	get_ivs:	switch( update_ivbuf() )	{		case FAILURE: return( FAILURE );		case RESTART: return( RESTART );		default: break;	}	if( ( wep.nb_ivs_now < 256 && opt.debug[0] == 0 ) ||		( wep.nb_ivs_now <  32 && opt.debug[0] != 0 ) )	{		if( ! opt.no_stdin )		{			printf(				"Not enough IVs available. You need about 250.000 IVs to crack\n"				"40-bit WEP, and more than 800.000 IVs to crack a 104-bit key.\n" );			kill( 0, SIGTERM );			_exit( FAILURE );		}		else		{			printf( "Read %ld packets, got %ld IVs...\r",				nb_pkt, wep.nb_ivs_now );			fflush( stdout );			sleep( 1 );			goto get_ivs;		}	}	/* if last keybyte reached, check if the key is valid */	if( B == opt.keylen )	{		if( ! opt.is_quiet )			show_wep_stats( B - 1, 0 );		return( check_wep_key( wep.key, B, 0 ) );	}	/* now compute the poll resultst for keybyte B */	if( calc_poll( B ) != SUCCESS )		return( FAILURE );	/* fudge threshold = higest vote divided by fudge factor */	for( wep.fudge[B] = 1; wep.fudge[B] < 256; wep.fudge[B]++ )		if( (float) wep.poll[B][wep.fudge[B]].val <		(float) wep.poll[B][0].val / opt.ffact )			break;	/* try the most likely n votes, where n is the fudge threshold */	for( wep.depth[B] = 0; wep.depth[B] < wep.fudge[B]; ( wep.depth[B] )++ )	{		switch( update_ivbuf() )		{			case FAILURE: return( FAILURE );			case RESTART: return( RESTART );			default: break;		}		wep.key[B] = wep.poll[B][wep.depth[B]].idx;		if( ! opt.is_quiet )			show_wep_stats( B, 0 );		if( B == 4 && opt.keylen == 13 )		{			/* even when cracking 104-bit WEP, *			 * check if the 40-bit key matches */			/* opt.keylen = 5; many functions use keylen. it is dangerous to do this in a multithreaded process */			if( check_wep_key( wep.key, B, 5 ) == SUCCESS )			{				opt.keylen = 5;				return( SUCCESS );			}			/* opt.keylen = 13; */		}		if( B + opt.do_brute + 1 == opt.keylen && opt.do_brute )		{			/* as noted by Simon Marechal, it's more efficient			 * to just bruteforce the last two keybytes. */			if (opt.nbcpu==1 || opt.do_mt_brute==0)			{				if (opt.do_brute==2)				{					for( i = 0; i < 256; i++ )					{						wep.key[B + 1] = i;						for( j = 0; j < 256; j++ )						{							wep.key[B + 2] = j;							if (check_wep_key( wep.key, B + 1, 0 ) == SUCCESS)								return SUCCESS;						}					}				}				else				{					for( i = 0; i < 256; i++ )					{						wep.key[B + 1] = i;						if (check_wep_key( wep.key, B + 1, 0 ) == SUCCESS)							return SUCCESS;					}				}			}			else			{				/* multithreaded bruteforcing of the last 2 keybytes */				k = (k+1) % opt.nbcpu;				do				{					for(tsel=0; tsel<opt.nbcpu && !wepkey_crack_success; ++tsel)					{						if (bf_nkeys[(tsel+k) % opt.nbcpu]>16)						{							usleep(1);							continue;						}						else						{							/* write our current key to the pipe so it'll have its last 2 bytes bruteforced */							bf_nkeys[(tsel+k) % opt.nbcpu]++;							if (safe_write(bf_pipe[(tsel+k) % opt.nbcpu][1], (void *) wep.key, 64) != 64)							{								perror( "write pmk failed" );								kill( 0, SIGTERM );								_exit( FAILURE );							}							break;						}					}				} while (tsel>=opt.nbcpu && !wepkey_crack_success);				if (wepkey_crack_success)				{					memcpy(wep.key, bf_wepkey, opt.keylen);					return(SUCCESS);				}			}		}		else		{			switch( do_wep_crack1( B + 1 ) )			{				case SUCCESS: return( SUCCESS );				case RESTART: return( RESTART );				default: break;			}		}	}	return( FAILURE );}/* experimental single bruteforce attack */int do_wep_crack2( int B ){	int i, j;	switch( update_ivbuf() )	{		case FAILURE: return( FAILURE );		case RESTART: return( RESTART );		default: break;	}	if( wep.nb_ivs_now / opt.keylen < 60000 )	{		printf(			"Not enough IVs available. This option is only meant to be used\n"			"if the standard attack method fails with more than %d IVs.\n",			opt.keylen * 60000 );		kill( 0, SIGTERM );		_exit( FAILURE );	}	for( i = 0; i <= B; i++ )	{		if( calc_poll( i ) != SUCCESS )			return( FAILURE );		wep.key[i] = wep.poll[i][0].idx;		wep.fudge[i] = 1;		wep.depth[i] = 0;		if( ! opt.is_quiet )			show_wep_stats( i, 0 );	}	for( wep.fudge[B] = 1; wep.fudge[B] < 256; wep.fudge[B]++ )		if( (float) wep.poll[B][wep.fudge[B]].val <		(float) wep.poll[B][0].val / opt.ffact )			break;	for( wep.depth[B] = 0; wep.depth[B] < wep.fudge[B]; wep.depth[B]++ )	{		switch( update_ivbuf() )		{			case FAILURE: return( FAILURE );			case RESTART: return( RESTART );			default: break;		}		wep.key[B] = wep.poll[B][wep.depth[B]].idx;		if( ! opt.is_quiet )			show_wep_stats( B, 0 );		for( i = B + 1; i < opt.keylen - 2; i++ )		{			if( calc_poll( i ) != SUCCESS )				return( FAILURE );			wep.key[i] = wep.poll[i][0].idx;			wep.fudge[i] = 1;			wep.depth[i] = 0;			if( ! opt.is_quiet )				show_wep_stats( i, 0 );		}		for( i = 0; i < 256; i++ )		{			wep.key[opt.keylen - 2] = i;			for( j = 0; j < 256; j++ )			{				wep.key[opt.keylen - 1] = j;				if( check_wep_key( wep.key, opt.keylen - 2, 0 ) == SUCCESS )					return( SUCCESS );			}		}	}	return( FAILURE );}int inner_bruteforcer_thread(void *arg){	int i, j;	size_t nthread = (size_t)arg;	uchar wepkey[64];	inner_bruteforcer_thread_start:	if (wepkey_crack_success)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -