From 49843509e54aa70dc69005dab5f02f32df7866e2 Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 3 Mar 2021 08:12:16 +0100 Subject: Added verbose option --- tests/dga/dga_evaluate.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'tests') 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 \n"); + printf("dga_evaluate []\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); -- cgit v1.2.3