aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremanuele-f <black.silver@hotmail.it>2019-09-27 10:15:20 +0200
committeremanuele-f <black.silver@hotmail.it>2019-09-27 10:15:20 +0200
commit277b4a060acda6f0f20b3df03c4c099df6c7b3a9 (patch)
tree1dea29c9bef99cead6ce9647c066f1f47224d86d
parent17f560a1cd5a539bf8940072bac05ccbf3b547f9 (diff)
Add categories test PCAP
-rw-r--r--example/categories.txt3
-rw-r--r--example/ndpiReader.c2
-rwxr-xr-xtests/do.sh2
-rw-r--r--tests/pcap/malware.pcapbin0 -> 468 bytes
-rw-r--r--tests/result/malware.pcap.out7
5 files changed, 12 insertions, 2 deletions
diff --git a/example/categories.txt b/example/categories.txt
new file mode 100644
index 000000000..6c5171c53
--- /dev/null
+++ b/example/categories.txt
@@ -0,0 +1,3 @@
+# Format: name\tcategory_id
+internetbadguys.com 100
+144.139.247.220 100
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 90e1b0d4f..f3e26b799 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -1897,7 +1897,7 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) {
int fields[4];
- if(verbose) printf("[Category] Loading %s\t%s\n", name, category);
+ if(verbose && !quiet_mode) printf("[Category] Loading %s\t%s\n", name, category);
if(sscanf(name, "%d.%d.%d.%d", &fields[0], &fields[1], &fields[2], &fields[3]) == 4)
ndpi_load_ip_category(ndpi_thread_info[thread_id].workflow->ndpi_struct,
diff --git a/tests/do.sh b/tests/do.sh
index 62b51288e..805437846 100755
--- a/tests/do.sh
+++ b/tests/do.sh
@@ -1,4 +1,4 @@
-READER="../example/ndpiReader -p ../example/protos.txt"
+READER="../example/ndpiReader -p ../example/protos.txt -c ../example/categories.txt"
RC=0
PCAPS=`cd pcap; /bin/ls *.pcap`
diff --git a/tests/pcap/malware.pcap b/tests/pcap/malware.pcap
new file mode 100644
index 000000000..c63389f04
--- /dev/null
+++ b/tests/pcap/malware.pcap
Binary files differ
diff --git a/tests/result/malware.pcap.out b/tests/result/malware.pcap.out
new file mode 100644
index 000000000..448633b3e
--- /dev/null
+++ b/tests/result/malware.pcap.out
@@ -0,0 +1,7 @@
+DNS 2 216 1
+HTTP 1 66 1
+ICMP 1 98 1
+
+ 1 UDP 192.168.7.7:42370 <-> 1.1.1.1:53 [proto: 5/DNS][cat: Malware/100][1 pkts/106 bytes <-> 1 pkts/110 bytes][Host: www.internetbadguys.com][PLAIN TEXT (internetbadguys)]
+ 2 ICMP 192.168.7.7:0 -> 144.139.247.220:0 [proto: 81/ICMP][cat: Malware/100][1 pkts/98 bytes -> 0 pkts/0 bytes]
+ 3 TCP 192.168.7.7:33706 -> 144.139.247.220:80 [proto: 7/HTTP][cat: Malware/100][1 pkts/66 bytes -> 0 pkts/0 bytes]