summaryrefslogtreecommitdiff
path: root/other/telnetfp-0.1.2/fingerdb.cpp
diff options
context:
space:
mode:
authorSkyperTHC2026-03-03 06:28:55 +0000
committerSkyperTHC2026-03-03 06:28:55 +0000
commit5d3573ef7a109ee70416fe94db098fe6a769a798 (patch)
treedc2d5b294c9db8ab2db7433511f94e1c4bb8b698 /other/telnetfp-0.1.2/fingerdb.cpp
parentc6c59dc73cc4586357f93ab38ecf459e98675cc5 (diff)
packetstorm sync
Diffstat (limited to 'other/telnetfp-0.1.2/fingerdb.cpp')
-rw-r--r--other/telnetfp-0.1.2/fingerdb.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/other/telnetfp-0.1.2/fingerdb.cpp b/other/telnetfp-0.1.2/fingerdb.cpp
new file mode 100644
index 0000000..f3007d5
--- /dev/null
+++ b/other/telnetfp-0.1.2/fingerdb.cpp
@@ -0,0 +1,144 @@
1class tdfpdb
2{
3 private:
4 char *db_file;
5 FILE *fd;
6 int integrity;
7
8 public:
9
10 int
11 compare_do_dont_line (char *line, unsigned char *d)
12 {
13 char *tmp = NULL;
14
15 if ((line == NULL) || (d == NULL))
16 return 0;
17
18 while ((line[0] != 0) && (d[0] != 0))
19 {
20 if (line[0] == '*')
21 {
22 integrity += 50;
23 return 1;
24 }
25 else if (line[0] == '?')
26 {
27 integrity++;
28 if (line[1] != 0)
29 line += 2;
30 return (compare_do_dont_line (line, d) || compare_do_dont_line (line, d + 1));
31 }
32 else if (atoi (line) != d[0])
33 return 0;
34
35 d += 1;
36 tmp = strstr (line, " ");
37 if (tmp)
38 line = tmp + 1;
39 }
40 if ((tmp != NULL) || (d[0] != 0))
41 return 0;
42 return 1;
43 }
44
45
46 void
47 find_in_db (unsigned char *dos, unsigned char *donts)
48 {
49 unsigned int x = 0;
50 char line[LINE_LENGTH + 1];
51
52 fseek (fd, 0, SEEK_SET);
53 while (!feof (fd))
54 {
55 bzero (line, LINE_LENGTH + 1);
56 fgets (line, LINE_LENGTH, fd);
57 if (strstr (line, "DO: ") != NULL)
58 {
59 if (compare_do_dont_line (line + 6, dos))
60 {
61 bzero (line, LINE_LENGTH + 1);
62 fgets (line, LINE_LENGTH, fd);
63 if (compare_do_dont_line (line + 6, donts))
64 {
65 printf ("Found matching finger print: ");
66 if (integrity > 0)
67 printf ("\nWarning: fingerprint contained wildcards! (integrity: %d)\n", integrity);
68 while (!feof (fd))
69 {
70 bzero (line, LINE_LENGTH + 1);
71 fgets (line, LINE_LENGTH, fd);
72 if ((strstr (line, "DO: ") == NULL) && (strlen (line) > 0))
73 printf ("%s", line);
74 else
75 return;
76 }
77 }
78 }
79 }
80 }
81 printf ("\nNOT FOUND!\n\nplease mail the following lines and OS/machine type to pa1mers@gmx.de:\nDO: ");
82 for (x = 0; x < strlen ((char *) dos); x++)
83 printf ("%d ", dos[x]);
84 printf ("\nDONT: ");
85 for (x = 0; x < strlen ((char *) donts); x++)
86 printf ("%d ", donts[x]);
87 printf ("\n\n");
88 }
89
90
91 int
92 open ()
93 {
94 if (db_file == NULL)
95 {
96 db_file = (char *) malloc (strlen (DEFAULT_DB) + 1);
97 memset (db_file, 0, strlen (DEFAULT_DB) + 1);
98 memcpy (db_file, DEFAULT_DB, strlen (DEFAULT_DB));
99 }
100 if ((fd = fopen (db_file, "r")) == NULL)
101 {
102 printf ("Error: can not open fingerprint file \"%s\"\n", db_file);
103 exit (2);
104 }
105 return 1;
106 }
107
108
109 void
110 close ()
111 {
112 fclose (fd);
113 }
114
115
116 void
117 set (char *file)
118 {
119 if (db_file != NULL)
120 {
121 free (db_file);
122 }
123 db_file = (char *) malloc (strlen (file) + 1);
124 memset (db_file, 0, strlen (file) + 1);
125 memcpy (db_file, file, strlen (file));
126 }
127
128
129 void
130 reset ()
131 {
132 integrity = 0;
133 fseek (fd, 0, SEEK_SET);
134 }
135
136
137 void
138 init ()
139 {
140 integrity = 0;
141 fd = NULL;
142 db_file = NULL;
143 }
144};