mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
r12495: Crackcheck utility enhancement based on patch sent by Tom Geissler
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
2187502732
commit
aa34304f61
@ -19,20 +19,81 @@ void usage(char *command) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int complexity(char* passwd)
|
||||||
|
{
|
||||||
|
/* TG 26.10.2005
|
||||||
|
* check password for complexity like MS Windows NT
|
||||||
|
*/
|
||||||
|
|
||||||
|
int c_upper = 0;
|
||||||
|
int c_lower = 0;
|
||||||
|
int c_digit = 0;
|
||||||
|
int c_punct = 0;
|
||||||
|
int c_tot = 0;
|
||||||
|
int i, len;
|
||||||
|
|
||||||
|
if (!passwd) goto fail;
|
||||||
|
len = strlen(passwd);
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
|
||||||
|
if (c_tot >= 3) break;
|
||||||
|
|
||||||
|
if (isupper(passwd[i])) {
|
||||||
|
if (!c_upper) {
|
||||||
|
c_upper = 1;
|
||||||
|
c_tot += 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (islower(passwd[i])) {
|
||||||
|
if (!c_lower) {
|
||||||
|
c_lower = 1;
|
||||||
|
c_tot += 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isdigit(passwd[i])) {
|
||||||
|
if (!c_digit) {
|
||||||
|
c_digit = 1;
|
||||||
|
c_tot += 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ispunct(passwd[i])) {
|
||||||
|
if (!c_punct) {
|
||||||
|
c_punct = 1;
|
||||||
|
c_tot += 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c_tot) < 3) goto fail;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
fprintf(stderr, "ERR Complexity check failed\n\n");
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
int c;
|
int c, ret, complex_check = 0;
|
||||||
|
|
||||||
char f[256];
|
char f[256];
|
||||||
char *dictionary = NULL;
|
char *dictionary = NULL;
|
||||||
char *password;
|
char *password;
|
||||||
char *reply;
|
char *reply;
|
||||||
|
|
||||||
while ( (c = getopt(argc, argv, "d:")) != EOF){
|
while ( (c = getopt(argc, argv, "d:c")) != EOF){
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
dictionary = strdup(optarg);
|
dictionary = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
complex_check = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
@ -43,6 +104,7 @@ int main(int argc, char **argv) {
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fflush(stdin);
|
||||||
password = fgets(f, sizeof(f), stdin);
|
password = fgets(f, sizeof(f), stdin);
|
||||||
|
|
||||||
if (password == NULL) {
|
if (password == NULL) {
|
||||||
@ -50,6 +112,13 @@ int main(int argc, char **argv) {
|
|||||||
exit(-2);
|
exit(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (complex_check) {
|
||||||
|
ret = complexity(password);
|
||||||
|
if (ret) {
|
||||||
|
exit(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reply = FascistCheck(password, dictionary);
|
reply = FascistCheck(password, dictionary);
|
||||||
if (reply != NULL) {
|
if (reply != NULL) {
|
||||||
fprintf(stderr, "ERR - %s\n\n", reply);
|
fprintf(stderr, "ERR - %s\n\n", reply);
|
||||||
|
Reference in New Issue
Block a user