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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
class tdfpdb
{
private:
char *db_file;
FILE *fd;
int integrity;
public:
int
compare_do_dont_line (char *line, unsigned char *d)
{
char *tmp = NULL;
if ((line == NULL) || (d == NULL))
return 0;
while ((line[0] != 0) && (d[0] != 0))
{
if (line[0] == '*')
{
integrity += 50;
return 1;
}
else if (line[0] == '?')
{
integrity++;
if (line[1] != 0)
line += 2;
return (compare_do_dont_line (line, d) || compare_do_dont_line (line, d + 1));
}
else if (atoi (line) != d[0])
return 0;
d += 1;
tmp = strstr (line, " ");
if (tmp)
line = tmp + 1;
}
if ((tmp != NULL) || (d[0] != 0))
return 0;
return 1;
}
void
find_in_db (unsigned char *dos, unsigned char *donts)
{
unsigned int x = 0;
char line[LINE_LENGTH + 1];
fseek (fd, 0, SEEK_SET);
while (!feof (fd))
{
bzero (line, LINE_LENGTH + 1);
fgets (line, LINE_LENGTH, fd);
if (strstr (line, "DO: ") != NULL)
{
if (compare_do_dont_line (line + 6, dos))
{
bzero (line, LINE_LENGTH + 1);
fgets (line, LINE_LENGTH, fd);
if (compare_do_dont_line (line + 6, donts))
{
printf ("Found matching finger print: ");
if (integrity > 0)
printf ("\nWarning: fingerprint contained wildcards! (integrity: %d)\n", integrity);
while (!feof (fd))
{
bzero (line, LINE_LENGTH + 1);
fgets (line, LINE_LENGTH, fd);
if ((strstr (line, "DO: ") == NULL) && (strlen (line) > 0))
printf ("%s", line);
else
return;
}
}
}
}
}
printf ("\nNOT FOUND!\n\nplease mail the following lines and OS/machine type to pa1mers@gmx.de:\nDO: ");
for (x = 0; x < strlen ((char *) dos); x++)
printf ("%d ", dos[x]);
printf ("\nDONT: ");
for (x = 0; x < strlen ((char *) donts); x++)
printf ("%d ", donts[x]);
printf ("\n\n");
}
int
open ()
{
if (db_file == NULL)
{
db_file = (char *) malloc (strlen (DEFAULT_DB) + 1);
memset (db_file, 0, strlen (DEFAULT_DB) + 1);
memcpy (db_file, DEFAULT_DB, strlen (DEFAULT_DB));
}
if ((fd = fopen (db_file, "r")) == NULL)
{
printf ("Error: can not open fingerprint file \"%s\"\n", db_file);
exit (2);
}
return 1;
}
void
close ()
{
fclose (fd);
}
void
set (char *file)
{
if (db_file != NULL)
{
free (db_file);
}
db_file = (char *) malloc (strlen (file) + 1);
memset (db_file, 0, strlen (file) + 1);
memcpy (db_file, file, strlen (file));
}
void
reset ()
{
integrity = 0;
fseek (fd, 0, SEEK_SET);
}
void
init ()
{
integrity = 0;
fd = NULL;
db_file = NULL;
}
};
|