diff options
author | Luca <deri@ntop.org> | 2021-03-03 08:12:16 +0100 |
---|---|---|
committer | Luca <deri@ntop.org> | 2021-03-03 08:12:16 +0100 |
commit | 49843509e54aa70dc69005dab5f02f32df7866e2 (patch) | |
tree | 3fc3a1a5e3078411e1dd4de55f58f910b0150662 /tests/dga | |
parent | 1a37595de02761497845503a390e24fc1cf11a4f (diff) |
Added verbose option
Diffstat (limited to 'tests/dga')
-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); |