diff options
-rw-r--r-- | tests/dga/dga_evaluate.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/dga/dga_evaluate.c b/tests/dga/dga_evaluate.c index a2f792dae..4dfda8df5 100644 --- a/tests/dga/dga_evaluate.c +++ b/tests/dga/dga_evaluate.c @@ -32,7 +32,7 @@ void help() { - printf("dga_evaluate <file name>\n"); + printf("dga_evaluate <file name> [<verbose>]\n"); exit(0); } @@ -42,15 +42,18 @@ void help() { int main(int argc, char **argv) { FILE *fd; char buffer[512]; - + int verbose = 0; + if(argc != 2) help(); fd = fopen(argv[1], "r"); - + if(fd == NULL) { printf("Unable to open file %s\n", argv[1]); exit(0); } + if(argv[1] != NULL) verbose = 1; + if (ndpi_get_api_version() != NDPI_API_VERSION) { printf("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n"); return -1; @@ -68,9 +71,17 @@ int main(int argc, char **argv) { while(fgets(buffer, sizeof(buffer), fd) != NULL) { - char *hostname; - hostname = strtok(buffer, "\n"); - if (ndpi_check_dga_name(ndpi_str, NULL, hostname, 1)) num_detections++; + char *hostname = strtok(buffer, "\n"); + + if(ndpi_check_dga_name(ndpi_str, NULL, hostname, 1)) { + if(verbose) + printf("%10s\t%s\n", "[DGA]", hostname); + + num_detections++; + } else { + if(verbose) + printf("%10s\t%s\n", "[NON DGA]", hostname); + } } fclose(fd); |