/* * character-set based brute-forcing algorithm * (c) 2004 by mimayin@aciiid.ath.cx * * usage: ./crunch [charset] [-t [FIXED]@@@@] [-s startblock] * * e.g: ./crunch 3 7 abcdef * * This example will compute all passwords between 3 and 7 chars * using 'abcdef' as the character set and dump it to stdout. * * Options: * * -t [FIXED]@@@@ : allows you to specify a pattern, eg: @@god@@@@ * where the only the @'s will change * * -s : allows you to specify the starting string, eg: 03god22fs * * * This code can be easily adapted for use in brute-force attacks * against network services or cryptography. * * Compiles on: linux, ms visual c++, freebsd * */ #include #include #include #define TRUE 1 #define FALSE 0 char def_charset[] = "abcdefghijklmnopqrstuvwxyz"; unsigned int inc[128]; int finished(char *block, char *charset, char *templ) { unsigned int i; if(templ[0]==0) { for(i=0;i-1;i--) { if(templ[0]==0 || templ[i]=='@') { if(inc[i] < strlen(charset)-1) { inc[i]++; block[i] = charset[inc[i]]; i=-1; } else { block[i] = charset[0]; inc[i] = 0; } } else { } } } void chunk(int start, int end, char *charset, char *templ, char *startblock) { int i,j,k,t; char block[128]; if(end-start <0) return; if(templ[0]==0) t=0; else t=1; for(i=start;i<=end;i++) { memset(block,0,sizeof(block)); for(j=0;j [charset] [-t [FIXED]@@@@] [-s startblock]\n",argv[0]); return 0; } memset(charset,0,sizeof(charset)); memset(templ,0,sizeof(templ)); memset(startblock,0,sizeof(startblock)); /* remove duplicate characters from charset */ if(argc>3) { for(i=0;imin) { printf("Warning: starting length increased to %d.\n",strlen(argv[i+1])); min = strlen(argv[i+1]); } if(strlen(argv[i+1])