8 void usage(char *command) {
12 while ((c = strrchr(comm, '/')) != NULL) {
16 fprintf(stderr, "Usage: %s [-c] [-s] [-d <dictionary>]\n\n", comm);
17 fprintf(stderr, " -c enables NT like complexity checks\n");
18 fprintf(stderr, " -d <dictionary file> for cracklib\n");
19 fprintf(stderr, " -s simple check use NT like checks ONLY\n\n");
20 fprintf(stderr, "The password is read via stdin.\n\n");
24 int complexity(char* passwd)
27 * check password for complexity like MS Windows NT
37 if (!passwd) goto fail;
40 for (i = 0; i < len; i++) {
42 if (c_tot >= 3) break;
44 if (isupper(passwd[i])) {
51 if (islower(passwd[i])) {
58 if (isdigit(passwd[i])) {
65 if (ispunct(passwd[i])) {
74 if ((c_tot) < 3) goto fail;
78 fprintf(stderr, "ERR Complexity check failed\n\n");
82 int main(int argc, char **argv) {
84 int c, ret, complex_check = 0, simplex_check = 0;
87 char *dictionary = NULL;
91 while ( (c = getopt(argc, argv, "d:cs")) != EOF){
94 dictionary = strdup(optarg);
108 if (!simplex_check && dictionary == NULL) {
109 fprintf(stderr, "ERR - Missing cracklib dictionary\n\n");
114 password = fgets(f, sizeof(f), stdin);
116 if (password == NULL) {
117 fprintf(stderr, "ERR - Failed to read password\n\n");
122 ret = complexity(password);
132 reply = FascistCheck(password, dictionary);
134 fprintf(stderr, "ERR - %s\n\n", reply);