Added verbose option
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user