@@ -9,7 +9,7 @@ int parse_arguments(int argc, char **argv)
9
9
int index ;
10
10
int c ;
11
11
int opterr = 0 ;
12
- while ((c = getopt (argc , argv , "hqvw:d :n:t:X:K:u:U:W:" )) != -1 ) {
12
+ while ((c = getopt (argc , argv , "hqvVw:d:e :n:t:X:K:u:U:W:" )) != -1 ) {
13
13
switch (c ) {
14
14
case 'v' :
15
15
return ;
@@ -25,6 +25,12 @@ int parse_arguments(int argc, char **argv)
25
25
case 'd' :
26
26
conf0 .dict = optarg ;
27
27
break ;
28
+ case 'e' :
29
+ conf0 .ext = explode (optarg , ',' );
30
+ break ;
31
+ case 'V' :
32
+ conf0 .verbose = 1 ;
33
+ break ;
28
34
case 't' :
29
35
conf0 .timeout = atoi (optarg );
30
36
break ;
@@ -148,6 +154,7 @@ void* dbng_engine(void* queue_arg)
148
154
output ("FOUND %s (response code %d)\n" ,trim (url ),http_code );
149
155
outputToFile ("%s (HTTP code %d)\n" ,trim (url ),http_code );
150
156
}
157
+ if (conf0 .verbose ) output ("[%d] %s\n" , http_code , trim (url ));
151
158
free (url );
152
159
}
153
160
curl_easy_cleanup (curl );
@@ -165,12 +172,31 @@ int load_dict(struct queue* db_queue) {
165
172
exit (1 );
166
173
}
167
174
168
- while (!feof (dict_fh )) {
175
+ if (conf0 .ext .nb_strings ) {
176
+ int i ;
177
+ while (!feof (dict_fh )) {
178
+ if (!fgets (buffer ,4096 * sizeof (char ),dict_fh )) break ;
179
+ size_t entry_len = strlen (buffer );
180
+ //fgets would also store the trailing newline
181
+ if (buffer [entry_len - 1 ]== '\n' ) entry_len -= 1 ;
182
+ for (i = 0 ; i < conf0 .ext .nb_strings ; ++ i ) {
183
+ strncpy (buffer + entry_len , conf0 .ext .strlist [i ], 4096 - entry_len );
184
+ buffer [4096 - 1 ] = '\0' ;
185
+ queue_add (db_queue ,buffer );
186
+ }
187
+ }
188
+ }
189
+ else {
190
+ while (!feof (dict_fh )) {
169
191
fgets (buffer ,4096 * sizeof (char ),dict_fh );
170
192
//handling of recursion ??
171
193
//( dup the queue to keep an initial copy, save found dirs)
172
194
queue_add (db_queue ,buffer );
195
+ }
173
196
}
197
+
198
+ free (buffer );
199
+ strlfree (& (conf0 .ext ));
174
200
175
201
}
176
202
@@ -186,6 +212,8 @@ int init_config(dbng_config* conf0) {
186
212
conf0 -> proxy_auth = NULL ;
187
213
conf0 -> http_auth = NULL ;
188
214
conf0 -> output_file = NULL ;
215
+ conf0 -> ext = (stringlist ){NULL , 0 };
216
+ conf0 -> verbose = 0 ;
189
217
}
190
218
191
219
int init_workers (struct queue * db_queue ) {
@@ -197,7 +225,11 @@ int init_workers(struct queue* db_queue) {
197
225
for (i = 0 ;i < conf0 .nb_workers ;i ++ ) {
198
226
ret = pthread_create (& conf0 .workers [i ],NULL ,dbng_engine ,(void * ) db_queue );
199
227
}
200
-
228
+
229
+ void * res ;
230
+ for (i = 0 ;i < conf0 .nb_workers ;i ++ ) {
231
+ ret = pthread_join (conf0 .workers [i ], & res );
232
+ }
201
233
}
202
234
203
235
int init_workloads (struct queue * db_queue ) {
@@ -228,6 +260,7 @@ Options:\n -w <nb_threads>\tDefines the number of threads to use to make the att
228
260
-X <proxy_server:port>\tUse an HTTP proxy server to perform the queries\n\
229
261
-K <username:password>\tSets an username/password couple for proxy auth\n\
230
262
-d <dict>\tLoads an external textfile to use as a dictionary\n\
263
+ -e <ext>\tSpecify a list of extensions that would be appended to each word in the dict; seperated by comma\n\
231
264
-t <seconds>\tSets the timeout in seconds for each http query\n\
232
265
-W <file>\t Saves the program's result inside a file\n\
233
266
-u <ua>\tuse a predefined user-agent, corresponding to the most used browsers/crawlers:\n\
@@ -244,6 +277,7 @@ Options:\n -w <nb_threads>\tDefines the number of threads to use to make the att
244
277
\t\tbspid: Baidu Spider\n\
245
278
-q\t Enable quiet mode (relevent only with the -W flag)\n\
246
279
-h\t Prints this help then exits\n\
280
+ -V \t Verbose. Print each request url and response code\n\
247
281
-v\t Prints the program version then exits\n" );
248
282
249
283
exit (0 );
0 commit comments