/* * This file is part of crack-o-matic * Copyright (c) 2001 Gianni Tedesco * * crack-o-matic is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * crack-o-matic is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with crack-o-matic; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #define CRACKLIB_DICT "/usr/lib/cracklib_dict" #define BUFFER_SIZE 2048 void evaluate(char *r) { if ( r ) { printf("-%s\n", r); }else{ printf("+Password is good\n"); } } int main (int argc, char **argv) { char buf[BUFFER_SIZE]; char *lf; char *raisin=NULL; int x, ignore=0; while (1) { /* Read in a line */ if ( (x=read(0, (char *)&buf, BUFFER_SIZE-1)) <=0 ) { if ( x<0 ) { perror("read()"); return 1; }else{ return 0; } } buf[x]='\0'; /* Do relevent defence mechanisms */ if ( (lf=strchr((char *)&buf, '\n')) ) { if ( ignore ) { ignore=0; evaluate(raisin); continue; } ignore=0; *lf='\0'; }else{ /* In the case of a long pass, just check * the first bit */ if ( !ignore ) raisin=FascistCheck((char *)&buf, CRACKLIB_DICT); ignore=1; continue; } /* Actually do the check */ raisin=FascistCheck((char *)&buf, CRACKLIB_DICT); evaluate(raisin); } /* Not reached */ return 0; }