1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* This program is copyright Alec Muffett 1993, portions copyright other authors.
* The authors disclaim all responsibility or liability with respect to it's usage
* or its effect upon hardware or computer systems.
*/
#include <stdio.h>
#include <string.h>
#define IN_CRACKLIB
#include "config.h"
#include "crack.h"
#include "packer.h"
int
main(argc, argv)
int argc;
char *argv[];
{
unsigned long readed;
unsigned long wrote;
PWDICT *pwp;
char buffer[STRINGSIZE], prev[STRINGSIZE];
char *file;
if (argc <= 1)
{
file = DEFAULT_CRACKLIB_DICT;
}
else
{
file = argv[1];
}
if ( argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) )
{
fprintf(stderr, "Usage:\t%s dbname\n", argv[0]);
fprintf(stderr, " if dbname is not specified, will use compiled in default of (%s).\n", DEFAULT_CRACKLIB_DICT);
return (-1);
}
if (!(pwp = PWOpen(file, "w")))
{
perror(file);
return (-1);
}
wrote = 0;
prev[0] = '\0';
for (readed = 0; fgets(buffer, STRINGSIZE, stdin); /* nothing */)
{
readed++;
buffer[MAXWORDLEN - 1] = '\0';
Chop(buffer);
if (!buffer[0])
{
fprintf(stderr, "skipping line: %lu\n", readed);
continue;
}
/*
* If this happens, strcmp() in FindPW() in packlib.c will be unhappy.
*/
if (strcmp(buffer, prev) < 0)
{
fprintf(stderr, "warning: input out of order: '%s' should not follow '%s' (line %lu)\n", buffer, prev, readed);
}
strcpy(prev, buffer);
if (PutPW(pwp, buffer))
{
fprintf(stderr, "error: PutPW '%s' line %luy\n", buffer, readed);
}
wrote++;
}
PWClose(pwp);
printf("%lu %lu\n", readed, wrote);
return (0);
}
|