--- aircrack.c.orig 2004-12-14 19:43:39.000000000 +0200 +++ aircrack.c 2004-12-14 23:53:24.000000000 +0200 @@ -49,6 +49,8 @@ char usage[] = " -m : MAC address to filter usable packets\n" " -n : WEP key length: 64 / 128 / 256 / 512\n" " -p : SMP support: # of processes to start\n" +" -q : quiet mode (less print, more speed)\n" +" -u : screen update only x seconds (default = each)\n" "\n"; /* command-line parameters */ @@ -61,6 +63,10 @@ unsigned char maddr[6]; /* MAC a int weplen = 13; /* WEP key length */ int ffact = 2; /* fudge threshold */ int nfork = 1; /* number of forks */ +int quietmode = 3; /* quiet mode, printf slowdown cracking */ +int seconds = 30; /* update x seconds */ +#define MAX_ENTROPY 5 +ushort entropy=1,quiet_show=1; /* runtime global data */ @@ -295,17 +301,27 @@ void show_stats( int B ) struct winsize ws; int i, et_h, et_m, et_s; - tm_prev = time( NULL ); + /* don't waste time, entropy help check + time only once in 5 calls, this save huge amount of ops + Entropy also avoids multiply fast printing + at matched seconds time. */ + + if( (entropy++) >= MAX_ENTROPY) { + tm_prev = time( NULL ); // get -1, delta = tm_prev - tm_start; + entropy = 0; + /* if( ! delta ) delta++; // Bogus checks, delays us */ + if( (delta % seconds) == 0) quiet_show = 1; + } + if(quietmode>=1 && quiet_show == 1 ) + { + quiet_show = 0; if( ioctl( 0, TIOCGWINSZ, &ws ) < 0 ) { ws.ws_row = 25; ws.ws_col = 80; } - - if( ! delta ) delta++; - et_h = delta / 3600; et_m = ( delta - et_h * 3600 ) / 60; et_s = delta - et_h * 3600 - et_m * 60; @@ -320,6 +336,8 @@ void show_stats( int B ) "%ld keys at %ld k/m\n", et_h, et_m, et_s, tried, ( 60 * tried ) / delta ); + if(quietmode>1 ) + { // quietmode = 2 printf( "\n KB depth votes\n" ); for( i = 0; i <= B; i++ ) @@ -334,19 +352,21 @@ void show_stats( int B ) if( j >= 256 ) break; if( wpoll[i][j].votes == INFINITY ) - printf( "%02X(+inf) ", wpoll[i][j].index ); + { if(quietmode>2) printf( "%02X(+inf) ", wpoll[i][j].index ); } else - printf( "%02X(%4d) ", wpoll[i][j].index, - wpoll[i][j].votes ); + { if(quietmode>2) printf( "%02X(%4d) ", wpoll[i][j].index, + wpoll[i][j].votes ); } } + /* if(quietmode>2) */ printf( "\n" ); } if( B < 11 ) printf( "\33[J" ); - + } // end of quietmode = 2 printf( "\n" ); + } // end of quietmode = 1 } /* safe I/O routines */ @@ -831,9 +851,13 @@ int do_wep_crack( int B ) keyfound: /* we have a valid key */ - + entropy=MAX_ENTROPY; // hack to show correct time + quiet_show = 1; // show lastest status show_stats( B ); + printf( "\t\t\33[1;32mWEP BSSID = %02X:%02X:%02X:%02X:%02X:%02X\33[0m\n", + maddr[0], maddr[1], maddr[2], + maddr[3], maddr[4], maddr[5] ); printf( " \33[31;1mKEY FOUND! [ " ); for( i = 0; i < weplen; i++ ) @@ -893,7 +917,7 @@ int main( int argc, char *argv[] ) while( 1 ) { - int option = getopt( argc, argv, "d:f:m:n:p:s:" ); + int option = getopt( argc, argv, "d:f:m:n:p:s:q:u:" ); if( option < 0 ) break; @@ -997,6 +1021,26 @@ int main( int argc, char *argv[] ) break; + case 'q': + + if( sscanf( optarg, "%d", &quietmode ) != 1 ) + goto usage; + + if( quietmode < 0 || quietmode > 3 ) + goto usage; + + break; + + case 'u': + + if( sscanf( optarg, "%d", &seconds ) != 1 ) + goto usage; + + if( seconds <= 1 || seconds >= 3600 ) + { printf(" seconds should be between 1...3600\n"); + seconds=30; } + break; + default : goto usage; } } @@ -1068,10 +1112,10 @@ int main( int argc, char *argv[] ) srand( time( NULL ) ); - tm_start = time( NULL ); + tm_start = time( NULL ) - 1 ; /* avoid check (perv-start) = 0 */ tm_prev = time( NULL ); - printf( "\33[2J" ); + if(quietmode>=1) printf( "\33[2J" ); fflush( stdout ); return( do_wep_crack( 0 ) );