1#include <memory.h> 2#include <string.h> 3#include <stdlib.h> 4#include <stdio.h> 5#include <ctype.h> 6#include <crack.h> 7 8void usage(char *command) { 9 char *c, *comm; 10 11 comm = command; 12 while ((c = strrchr(comm, '/')) != NULL) { 13 comm = c + 1; 14 } 15 16 fprintf(stderr, "Usage: %s -d dictionary\n\n", comm); 17 fprintf(stderr, " -d dictionary file for cracklib\n\n"); 18 fprintf(stderr, " The password is expected to be given via stdin.\n\n"); 19 exit(-1); 20} 21 22int main(int argc, char **argv) { 23 extern char *optarg; 24 int c; 25 26 char f[256]; 27 char *dictionary = NULL; 28 char *password; 29 char *reply; 30 31 while ( (c = getopt(argc, argv, "d:")) != EOF){ 32 switch(c) { 33 case 'd': 34 dictionary = strdup(optarg); 35 break; 36 default: 37 usage(argv[0]); 38 } 39 } 40 41 if (dictionary == NULL) { 42 fprintf(stderr, "ERR - Wrong Command Line\n\n"); 43 usage(argv[0]); 44 } 45 46 password = fgets(f, sizeof(f), stdin); 47 48 if (password == NULL) { 49 fprintf(stderr, "ERR - Failed to read password\n\n"); 50 exit(-2); 51 } 52 53 reply = FascistCheck(password, dictionary); 54 if (reply != NULL) { 55 fprintf(stderr, "ERR - %s\n\n", reply); 56 exit(-3); 57 } 58 59 exit(0); 60 61} 62 63