Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64929a75e0 | ||
|
|
02de8e10ca | ||
|
|
c2d8955c18 | ||
|
|
e9721eb4ce | ||
|
|
88f3519ab3 | ||
|
|
031cd04b7c | ||
|
|
d5d2a7e3f3 | ||
|
|
2051e51380 | ||
|
|
c92e0d13fd | ||
|
|
05d93790e4 | ||
|
|
32e4922c5a | ||
|
|
d4d82c27a5 | ||
|
|
addc775811 | ||
|
|
b68a3707f6 | ||
|
|
b0c4d01734 | ||
|
|
2c1b7cf1bd | ||
|
|
656323c334 | ||
|
|
8e1a3f5cdc | ||
|
|
58538b7d19 | ||
|
|
d0dbcf6dd6 | ||
|
|
8413faf2ef | ||
|
|
204f3ddff5 | ||
|
|
044ed14b4f | ||
|
|
51e86346d3 | ||
|
|
8e7a707be1 | ||
|
|
837ce7306b | ||
|
|
05dfae6430 | ||
|
|
d29a0241ee | ||
|
|
cbf1be5789 | ||
|
|
5f99433ee7 | ||
|
|
27bad14738 | ||
|
|
362baa6321 | ||
|
|
60a9f6610d | ||
|
|
0259ff58e1 | ||
|
|
d700ab3994 | ||
|
|
e6d206fd15 | ||
|
|
a263ac9024 | ||
|
|
87c43450f3 | ||
|
|
8ba1baace1 | ||
|
|
ff1cc1fa41 | ||
|
|
ea9177cc93 | ||
|
|
1385f05713 | ||
|
|
dcac633878 | ||
|
|
fdef6f3545 | ||
|
|
d0052fd5b2 | ||
|
|
bcce122665 | ||
|
|
6a7139bb24 | ||
|
|
b5b4512022 | ||
|
|
d81bc1add6 | ||
|
|
753b5dde16 | ||
|
|
9189aee83b | ||
|
|
4cc4efa228 | ||
|
|
ad8318e247 | ||
|
|
91e3292e6b | ||
|
|
98a81cb163 | ||
|
|
3a6ba7fa12 | ||
|
|
37abe0daea | ||
|
|
1c0e617d80 | ||
|
|
8db084ab06 | ||
|
|
ea4240055d | ||
|
|
5ac870074b | ||
|
|
7086197047 | ||
|
|
8ca13bc46a | ||
|
|
842c00e681 | ||
|
|
4c776501a6 | ||
|
|
7d5a0e1f04 | ||
|
|
a1014e8895 | ||
|
|
601928cc8e | ||
|
|
5a3956fe27 | ||
|
|
df14d225f6 | ||
|
|
fe5aa7ebca | ||
|
|
41d35fc7d0 | ||
|
|
799a6abfe6 | ||
|
|
8ed6409b35 | ||
|
|
3f49062db9 | ||
|
|
3cca5af8c3 | ||
|
|
7051acc0b5 | ||
|
|
580859a47d | ||
|
|
5d2551ff3e | ||
|
|
cefb667d8b | ||
|
|
8575a07113 | ||
|
|
460ff3c7ab | ||
|
|
029448759b | ||
|
|
448265a151 | ||
|
|
7da4abe6ad | ||
|
|
638624869a | ||
|
|
647c7d59bb | ||
|
|
f597086386 | ||
|
|
dd75060932 | ||
|
|
8bf95b6198 | ||
|
|
adab0139c2 | ||
|
|
bf9dbd6ccf | ||
|
|
e998fc28d1 | ||
|
|
1810281d7f | ||
|
|
f0325f713a | ||
|
|
5b27dfdd0c | ||
|
|
c17463539f | ||
|
|
2e8aa9f08e | ||
|
|
487d915262 | ||
|
|
5e1bb0dbc1 | ||
|
|
363ab2259c | ||
|
|
b94e13da43 | ||
|
|
97b80a8838 | ||
|
|
b8307eb855 | ||
|
|
46ba657562 | ||
|
|
4570dbfece | ||
|
|
35fd4ddb27 | ||
|
|
fe1e2c241f | ||
|
|
af3ce74e02 | ||
|
|
93003d0523 | ||
|
|
519ba7a9d5 | ||
|
|
b23cfd6b84 | ||
|
|
7a1147d733 | ||
|
|
d62ae567d1 | ||
|
|
23ec82b59d | ||
|
|
fef199ad45 | ||
|
|
b23781e807 | ||
|
|
da2684dbe1 | ||
|
|
7e9354ef23 | ||
|
|
f4421314b0 | ||
|
|
59ac73b37f | ||
|
|
115888ef7a | ||
|
|
248d756e99 | ||
|
|
9f431f9218 | ||
|
|
d87bdf9302 | ||
|
|
3a76786121 | ||
|
|
8e93f48c43 | ||
|
|
673d8b7fac | ||
|
|
1f921562d1 | ||
|
|
34a98abcc0 | ||
|
|
b501239d3f | ||
|
|
ebf89f46e3 | ||
|
|
019a64630b | ||
|
|
98a9afc40c | ||
|
|
13cbd1e4ae | ||
|
|
b31fde4bbb | ||
|
|
46ec91ca4b | ||
|
|
8090765a64 | ||
|
|
aa856735c0 | ||
|
|
9edddee0b7 | ||
|
|
d5cac570d6 | ||
|
|
0e363d0ca6 | ||
|
|
8c2c388d54 | ||
|
|
8fcb49af25 | ||
|
|
dfa9dd66c0 | ||
|
|
56a3a33bc0 | ||
|
|
8f74d5733d | ||
|
|
4ead6d6594 | ||
|
|
8da5f42fa0 | ||
|
|
2722861d6e | ||
|
|
95dfbdc64a | ||
|
|
c2156a5161 | ||
|
|
5b6ffad278 | ||
|
|
d3fb1fb25a | ||
|
|
79b89d2866 | ||
|
|
07d9fa7f96 | ||
|
|
00b2763399 | ||
|
|
e16675b700 | ||
|
|
ea10b8e757 | ||
|
|
57e28e03ee | ||
|
|
2ae4c6675d | ||
|
|
e71df49b3e | ||
|
|
6904935934 | ||
|
|
a828ac0191 | ||
|
|
c4b19fd6c5 | ||
|
|
02dc8d5feb | ||
|
|
32bd3d7a59 | ||
|
|
da87cc3157 | ||
|
|
69f140878c | ||
|
|
4b1cae2c2b | ||
|
|
7d843f4d17 | ||
|
|
95263fc32e | ||
|
|
1c405e382a | ||
|
|
b26539d65a | ||
|
|
6719fa30f9 | ||
|
|
21e2e57614 | ||
|
|
439558f6a3 | ||
|
|
0956badd11 | ||
|
|
a9ca47fcdb | ||
|
|
1c1be5a0d1 | ||
|
|
2723ac70ce | ||
|
|
3cd1ec5c9a | ||
|
|
a279423bff | ||
|
|
a3ba9253ef | ||
|
|
c450caae94 | ||
|
|
36af97a14c | ||
|
|
af5d792c08 | ||
|
|
8e2cd9ff43 | ||
|
|
88dd3ebd62 | ||
|
|
d9fc4d52e9 | ||
|
|
a688e36b51 | ||
|
|
f83d0b18c6 | ||
|
|
66178e37cc | ||
|
|
1740042cbb | ||
|
|
f6242f0e46 | ||
|
|
0a182c6d18 | ||
|
|
53b2b08aeb | ||
|
|
9c521c5ddd | ||
|
|
847eb7b180 | ||
|
|
d90b333363 | ||
|
|
f66cd5aabc | ||
|
|
4b4dcabeda | ||
|
|
879cec94b2 | ||
|
|
9f4f228832 | ||
|
|
b568c26989 | ||
|
|
29315cee6d | ||
|
|
f452dabd92 | ||
|
|
64fb40d21e | ||
|
|
6e1dcba9dd | ||
|
|
ebf18a0c61 | ||
|
|
a268952068 | ||
|
|
acd05b171e | ||
|
|
69ca98ca35 | ||
|
|
46e97d5da3 | ||
|
|
9f3e3e8456 | ||
|
|
91d132ea3d | ||
|
|
3fd3153089 | ||
|
|
a8ad99aca5 | ||
|
|
7744c225f9 | ||
|
|
e2e0303099 | ||
|
|
802254327a | ||
|
|
9d8717a0c7 | ||
|
|
9d35364ef1 | ||
|
|
051bdb1957 | ||
|
|
96c193cf79 | ||
|
|
23c0721538 | ||
|
|
35f1c362b9 | ||
|
|
12abcd516b | ||
|
|
014fdd9a02 | ||
|
|
9d8967236e | ||
|
|
6511db8941 | ||
|
|
b8d406b1f8 | ||
|
|
ce02359953 | ||
|
|
24fea66a26 | ||
|
|
d658ac9e61 | ||
|
|
f75984633b | ||
|
|
20fed83e0f | ||
|
|
f72b402aa2 | ||
|
|
4f794aec22 | ||
|
|
fd6a5bc1cd | ||
|
|
5be9370cd2 | ||
|
|
ccb30a04ad | ||
|
|
fb04dbbc47 | ||
|
|
f1dd8bc8c5 | ||
|
|
0c80e6ee3b | ||
|
|
e308e59002 | ||
|
|
1c60c22893 | ||
|
|
db707e0829 | ||
|
|
540326f3ff | ||
|
|
94bf7b0130 | ||
|
|
030f3f3d48 | ||
|
|
de25ba7d0b | ||
|
|
9bbcc2548e | ||
|
|
055422503c | ||
|
|
c0b34555c2 | ||
|
|
b4edb75824 | ||
|
|
dfb9e8ec1f | ||
|
|
c17a21359b | ||
|
|
6e8f268873 | ||
|
|
4b8c8608d1 | ||
|
|
503e3bb495 | ||
|
|
513c857631 | ||
|
|
f7b91b46fa | ||
|
|
143fcf0b0e | ||
|
|
ae89831055 | ||
|
|
8f53c231df | ||
|
|
974c1cc681 | ||
|
|
c08693fda5 | ||
|
|
08698c65e5 | ||
|
|
2d68f8f635 | ||
|
|
2860e3af15 | ||
|
|
be35d423b4 | ||
|
|
cf9c0b96b8 | ||
|
|
ea6332e004 | ||
|
|
392ce44573 | ||
|
|
05d7400563 | ||
|
|
ea30fcb5de | ||
|
|
3068306b60 | ||
|
|
0d2d44f1b6 | ||
|
|
07615903e2 | ||
|
|
2c263bc726 | ||
|
|
4a6c525db8 | ||
|
|
93a4a4387a | ||
|
|
f39e3c98f0 | ||
|
|
317d3ffd3e | ||
|
|
b24f5c4c0a | ||
|
|
d6a97219ea | ||
|
|
3669c14afd | ||
|
|
ece5d3e199 | ||
|
|
2cdf7ce806 | ||
|
|
2effa57d8a | ||
|
|
b68b45f3bb | ||
|
|
b2e89e6736 | ||
|
|
1010520cc4 | ||
|
|
f028cce209 | ||
|
|
fbfa54eee6 | ||
|
|
ff67e09101 | ||
|
|
76e6c38459 | ||
|
|
243104a8c2 | ||
|
|
1f4523e331 | ||
|
|
b5f3facf7c | ||
|
|
8566288e43 | ||
|
|
8de62c6d34 | ||
|
|
0cd0905400 | ||
|
|
56d87186f7 | ||
|
|
ebfb5e7f01 | ||
|
|
d805611fcb | ||
|
|
9742dcc45c | ||
|
|
f38a8bd7a5 | ||
|
|
3c66ca236b | ||
|
|
70a926088f | ||
|
|
6b69e7ebbc | ||
|
|
0b53bc2aab | ||
|
|
ecdf7df454 | ||
|
|
3034e53d00 | ||
|
|
2350daa2dc | ||
|
|
d710b8291d | ||
|
|
485e56d855 | ||
|
|
38c0d927a9 | ||
|
|
94a68451df | ||
|
|
17c26911fb | ||
|
|
ca68beda85 | ||
|
|
2f5766d2f5 | ||
|
|
39800c88fa | ||
|
|
678fbcdfd6 | ||
|
|
d9af1562f0 | ||
|
|
e29e14b7aa | ||
|
|
c9d8efc2a4 | ||
|
|
1a62f4c799 | ||
|
|
2a137100da | ||
|
|
6a9f5e4f7c | ||
|
|
fd0591b4fc | ||
|
|
48758d28ea | ||
|
|
14f514134d | ||
|
|
63670927e7 | ||
|
|
23594f0365 | ||
|
|
b2c24558c5 | ||
|
|
46d96e7f32 | ||
|
|
ffd20ebdf9 | ||
|
|
da37f2444f | ||
|
|
073e3a027b | ||
|
|
0ddc3a0052 | ||
|
|
38e4910636 | ||
|
|
4247dd8322 | ||
|
|
55364ef0b4 | ||
|
|
60aaa80570 | ||
|
|
0b9e46e65a | ||
|
|
64fab4a478 | ||
|
|
3506a07864 | ||
|
|
d318285cae | ||
|
|
1479c0a278 | ||
|
|
43ddbfdfba | ||
|
|
801c9481cb | ||
|
|
2beecdc8af | ||
|
|
605d548d4a | ||
|
|
0da76fdac6 | ||
|
|
597d6e5d60 | ||
|
|
67c72a8cb5 | ||
|
|
07c54f9992 | ||
|
|
16ca69733a | ||
|
|
40550073ef | ||
|
|
52893d99f6 | ||
|
|
86a3dc5bea | ||
|
|
5afa3ad818 | ||
|
|
af2a44ae5f | ||
|
|
241af016e9 | ||
|
|
16dc0ec29e | ||
|
|
29d9c2d2c8 | ||
|
|
669b7579ff | ||
|
|
a4f8d913ea | ||
|
|
dc5b4cbde0 | ||
|
|
b0bf66c436 | ||
|
|
c793e16050 | ||
|
|
b6eef17e54 | ||
|
|
374a24a1fb | ||
|
|
cbb0b864a2 | ||
|
|
61066fb106 | ||
|
|
4ceff1dc77 | ||
|
|
0271e29097 | ||
|
|
fcb50dec70 | ||
|
|
db5cd92fe1 | ||
|
|
3085d8e4ff | ||
|
|
9c3bfeca80 | ||
|
|
f6038c358a | ||
|
|
3108c75059 | ||
|
|
811d7a39b5 | ||
|
|
030e9dddb7 | ||
|
|
2dce6cd525 | ||
|
|
8fa5c31996 | ||
|
|
ee35834be6 | ||
|
|
e5c2c400ef | ||
|
|
bbbc5fdbae | ||
|
|
3874f0e0e0 | ||
|
|
83ae5b7256 | ||
|
|
c02b00e0ce | ||
|
|
07d9e4f9ba | ||
|
|
e9519c9aca | ||
|
|
329eff069e | ||
|
|
246ec53bcf | ||
|
|
cd65da69d3 | ||
|
|
068c1b1f22 | ||
|
|
b7e666e465 | ||
|
|
c5e16b4ff7 | ||
|
|
3d9285f1be | ||
|
|
c375782b96 | ||
|
|
8e7b1ea7a1 | ||
|
|
e90c5c7c32 | ||
|
|
7dfbfff743 | ||
|
|
da22aa5fc7 | ||
|
|
a183b2ab9b | ||
|
|
adfe6b763c | ||
|
|
9ed94a722c | ||
|
|
7037e79604 | ||
|
|
1edf5c49d6 | ||
|
|
baddfbb6c3 | ||
|
|
fb64346e28 | ||
|
|
50be0b0049 | ||
|
|
08f32f2e0e | ||
|
|
0a4fbb8cfb | ||
|
|
9dfd0d0071 | ||
|
|
17235d234e | ||
|
|
db16a987c5 | ||
|
|
f7f705406f | ||
|
|
cd765c08d6 | ||
|
|
ee15c6149d | ||
|
|
ae803c8b51 | ||
|
|
e5e69d0f7a | ||
|
|
b69177be2f | ||
|
|
f8503da9e9 | ||
|
|
39ae57e6a3 | ||
|
|
c9b37b92f5 | ||
|
|
4a09b4efa0 | ||
|
|
fd646bd05f | ||
|
|
6a1b8baa00 | ||
|
|
2ccd2c204b | ||
|
|
263547e77d | ||
|
|
86e34fbf6d | ||
|
|
84f66b4d6b | ||
|
|
7855e0318d | ||
|
|
48282369e2 | ||
|
|
7d63149ced | ||
|
|
427002d14f | ||
|
|
4148c5e065 | ||
|
|
c120cca662 | ||
|
|
7344bf65bc | ||
|
|
6f79b78f71 | ||
|
|
a70fd6ed3b | ||
|
|
bd0fd6cf8d | ||
|
|
0bf809f8e5 | ||
|
|
44259ab2b9 | ||
|
|
328016895f | ||
|
|
780dc8d1e7 | ||
|
|
4d746dabe9 | ||
|
|
097127c31d | ||
|
|
c2ebbb15ad | ||
|
|
f965983c23 | ||
|
|
8d8e61b256 | ||
|
|
0b702c20d3 | ||
|
|
473a5d1d0b | ||
|
|
65b428899d | ||
|
|
6769168d89 | ||
|
|
4d5ca2c473 | ||
|
|
e8cae3cff9 | ||
|
|
019b51bb17 | ||
|
|
e2be7daed6 | ||
|
|
1b73f7372e | ||
|
|
b1a6c6b895 | ||
|
|
e603549967 | ||
|
|
3bdec5ae5f | ||
|
|
25cd2a23a6 | ||
|
|
97badc574b | ||
|
|
493bffb3e0 | ||
|
|
c2b2692e65 | ||
|
|
db5f3b38b7 | ||
|
|
da0889d3ba | ||
|
|
94eee66a7b | ||
|
|
748df7972a | ||
|
|
a766de7b94 | ||
|
|
711ba99eaa | ||
|
|
32d25bfdaf | ||
|
|
287015ffdc | ||
|
|
f4c24663fc | ||
|
|
9f2dabbda4 | ||
|
|
4f370fe7c4 | ||
|
|
9483c842b5 | ||
|
|
c1f9f05d33 | ||
|
|
cf47ba234a | ||
|
|
98f2d3a73c | ||
|
|
c1baf1516d | ||
|
|
369dc65c1a | ||
|
|
4ec3e6c064 | ||
|
|
81e97d7515 | ||
|
|
32ab88a26e | ||
|
|
afdae85b30 | ||
|
|
63c4eaae9b | ||
|
|
4e876a4543 | ||
|
|
7b54d028a3 | ||
|
|
9cba06a080 | ||
|
|
794f7fa124 | ||
|
|
d3b4b81d6f | ||
|
|
1bee9d85a4 | ||
|
|
fa15e170b4 | ||
|
|
b75838b771 | ||
|
|
d665df64e2 | ||
|
|
e84563f971 | ||
|
|
a60854bae6 | ||
|
|
7b690d8b2d | ||
|
|
0c1322a718 | ||
|
|
b40732d8a5 | ||
|
|
db8497778d | ||
|
|
dea883a25d | ||
|
|
81a2f54dd7 | ||
|
|
c2c01b618b | ||
|
|
fb863c6bfb | ||
|
|
7ce478a58b | ||
|
|
3bbb0cd329 | ||
|
|
56ca71bda9 | ||
|
|
498571354d | ||
|
|
3924257f32 | ||
|
|
817aa54214 | ||
|
|
97fc94c7e8 | ||
|
|
9ec711aa90 | ||
|
|
9c2c04d8ce | ||
|
|
4f399356a6 | ||
|
|
45ff2a3f5a | ||
|
|
58f0f29113 | ||
|
|
da5e5a3e2a | ||
|
|
17d531e3db | ||
|
|
0d223ada3f | ||
|
|
890e8644ac | ||
|
|
1bab8a1c22 | ||
|
|
24bb0b7f53 | ||
|
|
803b13a7a8 | ||
|
|
7841145d9c | ||
|
|
efdac78ddc | ||
|
|
74825ffc6e | ||
|
|
1b8f7ed101 | ||
|
|
9cf016c5f1 | ||
|
|
47a4507d9e | ||
|
|
779d9a6e51 | ||
|
|
ac17e0bea7 | ||
|
|
4d95dae2ae | ||
|
|
6c3cbe50e2 | ||
|
|
a2b163beca | ||
|
|
c8a1767465 | ||
|
|
40be74c629 | ||
|
|
df5cf59787 | ||
|
|
d26349e082 | ||
|
|
7add3acc53 | ||
|
|
1c1a18d12f | ||
|
|
92bd223c34 | ||
|
|
9d53c3c3b8 | ||
|
|
906d7fe0c1 | ||
|
|
cd78740caf | ||
|
|
626ee52049 | ||
|
|
7a93994802 | ||
|
|
1bb10863e4 | ||
|
|
924bc9698b | ||
|
|
9aba94713c | ||
|
|
00beac6b1a | ||
|
|
8c2ffc5b37 | ||
|
|
a845e99720 | ||
|
|
8cda02bb14 | ||
|
|
3e259aac98 | ||
|
|
2aec630202 | ||
|
|
c6acf97bfb | ||
|
|
e9195589d2 | ||
|
|
b2cbe76e71 | ||
|
|
4227be7989 | ||
|
|
e282e43279 | ||
|
|
2f15ce706f | ||
|
|
70ee793ff3 | ||
|
|
7806eb5f5b | ||
|
|
9d1340a8e7 | ||
|
|
7a2bcd9c39 | ||
|
|
fe513014a8 | ||
|
|
3c05d4551d | ||
|
|
4976d93d4e | ||
|
|
1e933e8b02 | ||
|
|
942a71c7eb | ||
|
|
7fd135a8c9 | ||
|
|
34ad06fef5 | ||
|
|
8f45f51e6c | ||
|
|
9f72b15fff | ||
|
|
6fe9535881 | ||
|
|
5fc9d41eb0 | ||
|
|
933351840d | ||
|
|
83fdfe24d0 | ||
|
|
d4c093e828 | ||
|
|
c0ec78885d | ||
|
|
a55c410202 | ||
|
|
e675be1a83 | ||
|
|
f07a329447 | ||
|
|
2ceff3e214 | ||
|
|
dcb6fde0c9 | ||
|
|
e67604a583 | ||
|
|
40896d3d44 | ||
|
|
5a0f609086 | ||
|
|
2972e29097 | ||
|
|
dd80ec869a | ||
|
|
1714d7aa52 | ||
|
|
90e08b3568 | ||
|
|
080e23e30e | ||
|
|
edce5a8c1f | ||
|
|
c8ccf33f07 | ||
|
|
ee979ac14a | ||
|
|
3eb9907dd7 | ||
|
|
fdf8dd724f | ||
|
|
37121a9b58 | ||
|
|
bbaf9147b6 | ||
|
|
9796fdc0e9 | ||
|
|
e0a058af67 | ||
|
|
80e9826040 | ||
|
|
bf7dcd63c3 | ||
|
|
b287dccecf | ||
|
|
cb34c6b233 | ||
|
|
fd94270507 | ||
|
|
03cf975c07 | ||
|
|
428661c00b | ||
|
|
5c52c00ea4 | ||
|
|
f89f25c118 | ||
|
|
d4ae8a5f16 | ||
|
|
7234f36949 | ||
|
|
2efc09a20e | ||
|
|
3fa61a394b | ||
|
|
582a01303f | ||
|
|
97fb50e837 | ||
|
|
a3da5604a3 | ||
|
|
af6c86de28 | ||
|
|
34984f1aec | ||
|
|
83bbb4cb69 | ||
|
|
ff4f32ff48 | ||
|
|
33d761a55a | ||
|
|
2bd89be3e2 | ||
|
|
5cad39f0e8 | ||
|
|
3be263aafc | ||
|
|
452ba1f339 | ||
|
|
ec15089208 | ||
|
|
af661bd652 | ||
|
|
4613515635 | ||
|
|
2009361b89 | ||
|
|
f027ab1ae7 | ||
|
|
fa26c62b0c | ||
|
|
0faba29351 | ||
|
|
2701cc9491 | ||
|
|
88fc9232ff | ||
|
|
0703ab5ac5 | ||
|
|
418ea234ae | ||
|
|
3e99b73635 | ||
|
|
6dbe81588f | ||
|
|
2b6a639192 | ||
|
|
9e87645022 | ||
|
|
626fcf1418 | ||
|
|
5b11c2ffc5 | ||
|
|
8486eb08ea | ||
|
|
ce4f4fbe2f | ||
|
|
3422574c17 | ||
|
|
b3138d5e3e | ||
|
|
0bf2ca56a8 | ||
|
|
b97360d931 | ||
|
|
579dd7dff9 | ||
|
|
ff89a14b49 | ||
|
|
b5b2260f2e | ||
|
|
39b1ad3087 | ||
|
|
c68ea3067b | ||
|
|
4e538b1e4d | ||
|
|
5c8c2d843a | ||
|
|
ea957687e1 | ||
|
|
c84ed5a712 | ||
|
|
ab2a011cf9 | ||
|
|
d86d632fe6 | ||
|
|
87d228f78e | ||
|
|
a7a4bf32d3 | ||
|
|
e20c4acbde | ||
|
|
daf15e70bf | ||
|
|
daa1171593 | ||
|
|
dc5fecfc92 | ||
|
|
79e1ec9f50 | ||
|
|
902a1c7b4c | ||
|
|
5b88867084 | ||
|
|
4749e61bdb | ||
|
|
4f230943cf | ||
|
|
6186e1ab01 | ||
|
|
9fe8bf018a | ||
|
|
e082134a0d | ||
|
|
cedbf3b636 | ||
|
|
5f6fd8d2a5 | ||
|
|
cbb755666e | ||
|
|
1d024ece7a | ||
|
|
77db14fd7a | ||
|
|
5a40f9b7fd | ||
|
|
931f51bd77 | ||
|
|
283588a37b | ||
|
|
812505b56b | ||
|
|
98d9f524f9 | ||
|
|
0023a96f80 | ||
|
|
9f7b1c84f2 | ||
|
|
e1047b324b | ||
|
|
10738a0ca3 | ||
|
|
fe312ffbe1 | ||
|
|
24f2cd6fc1 | ||
|
|
cbabbd5865 | ||
|
|
da5208ee68 | ||
|
|
bccf1c433a | ||
|
|
cc7593fe5a | ||
|
|
5571ce114d | ||
|
|
4dd887e516 | ||
|
|
a3e06da2a8 | ||
|
|
dc21079851 | ||
|
|
5987ec6014 | ||
|
|
757b0c602f | ||
|
|
498b346219 | ||
|
|
3e66bbc5bc | ||
|
|
3ba7667887 | ||
|
|
fd943d6000 | ||
|
|
691778df33 | ||
|
|
81c3f5813c | ||
|
|
fdf402d027 | ||
|
|
f0014a5a24 | ||
|
|
53a5be3399 | ||
|
|
f389969c0b | ||
|
|
dc02afa3ea | ||
|
|
d1fb41a161 | ||
|
|
ef16591f3f | ||
|
|
29dd45838d | ||
|
|
798bb6e2e1 | ||
|
|
2332cbfefe | ||
|
|
a58a135758 | ||
|
|
634457615c | ||
|
|
cb825766ea | ||
|
|
8b01056b21 | ||
|
|
f6c7a33177 | ||
|
|
daae1cc9b1 | ||
|
|
499c80535b | ||
|
|
9fb3a57a71 | ||
|
|
257ec7cc5f | ||
|
|
73c7ccdb65 | ||
|
|
cffb11fbc9 | ||
|
|
23421b47d9 | ||
|
|
1cab9fe838 | ||
|
|
27ea04c08e | ||
|
|
5c225b8a2e | ||
|
|
4961241c62 | ||
|
|
843204299c | ||
|
|
09cd95d54a | ||
|
|
1d3bef41a4 | ||
|
|
e21fe5d594 | ||
|
|
9133955219 | ||
|
|
acb74905a5 | ||
|
|
ed3fff554a | ||
|
|
7ebe6a0c82 | ||
|
|
87333aa68c | ||
|
|
e593319ba0 | ||
|
|
812a3e7099 | ||
|
|
1097f5488d | ||
|
|
b90410e335 | ||
|
|
deed27cbef | ||
|
|
ea001b439a | ||
|
|
14e5adc7c2 | ||
|
|
81012b3201 | ||
|
|
406aa12468 | ||
|
|
2c2bb11c9b | ||
|
|
1bd63d68a5 | ||
|
|
bf5e9b7b0b | ||
|
|
7fe9dddf65 | ||
|
|
6d7f3976f3 | ||
|
|
65d526d8f6 | ||
|
|
56eeb965bf | ||
|
|
c4d476cc58 | ||
|
|
23b0b8625d | ||
|
|
558983c99c | ||
|
|
c8d6f2845f | ||
|
|
1a115cac5a | ||
|
|
11401edfe7 | ||
|
|
239842b821 | ||
|
|
606ff10ecf | ||
|
|
d37b69ce9c | ||
|
|
226a9abf22 | ||
|
|
f26096ee4c | ||
|
|
2b3ef7e762 | ||
|
|
d62526f9ed | ||
|
|
e66d7216b8 | ||
|
|
fbc59c5f81 | ||
|
|
32dc9e3225 | ||
|
|
b4468239b9 | ||
|
|
95c1282ef4 | ||
|
|
a7b0457753 | ||
|
|
7da7ae622b | ||
|
|
a95cfcc989 | ||
|
|
a65c959940 | ||
|
|
d328c3bccc | ||
|
|
8368568443 | ||
|
|
c223bb1f10 | ||
|
|
c7efd0892f | ||
|
|
ae9429408b | ||
|
|
0ce56d5714 | ||
|
|
509cfcb556 | ||
|
|
3b203d57e9 | ||
|
|
68d66b780c | ||
|
|
f94d6cca7d | ||
|
|
382217887b | ||
|
|
537c11a985 | ||
|
|
bdc0719e76 | ||
|
|
fc82cdfa4a | ||
|
|
e98b994a39 | ||
|
|
a58c838c4c | ||
|
|
f91f2c57ef | ||
|
|
68b7986d9b | ||
|
|
ead0325deb | ||
|
|
0b819badd2 | ||
|
|
3754e6dd12 | ||
|
|
da029607a0 | ||
|
|
803dc6ff77 | ||
|
|
65a629304c | ||
|
|
51cfdfb0d8 | ||
|
|
53108c9ff1 | ||
|
|
82a186e096 | ||
|
|
e467fe9aa6 | ||
|
|
7a1940e1f7 | ||
|
|
6b7c56c909 | ||
|
|
470d30ac23 | ||
|
|
7e87bfd039 | ||
|
|
ab9ccf9eb9 | ||
|
|
15ec013af8 | ||
|
|
748f10c0d6 | ||
|
|
8181d63a95 | ||
|
|
d0e7e69552 | ||
|
|
0558d641f2 | ||
|
|
ac46a4dd58 | ||
|
|
fb56b042c0 | ||
|
|
6298ecc271 | ||
|
|
a26fe08aa6 | ||
|
|
5b2c0f68fe | ||
|
|
e695dd6ead | ||
|
|
953571e3d8 | ||
|
|
01455c3188 | ||
|
|
a5210af823 | ||
|
|
9e42b525ec | ||
|
|
02d69b72f5 | ||
|
|
c998e2e9ef | ||
|
|
a3a85106a1 | ||
|
|
75302a10bd | ||
|
|
2ab0433aca | ||
|
|
e272db0f7f | ||
|
|
3580765ba3 | ||
|
|
cb79d89f83 | ||
|
|
2e178d0f05 | ||
|
|
edf0b171e2 | ||
|
|
148506ede8 | ||
|
|
c0a08d9ca2 | ||
|
|
4802987178 | ||
|
|
1cd7cf9990 | ||
|
|
4830755fac | ||
|
|
124545e1ed | ||
|
|
af01e61c89 | ||
|
|
9400a3b9ef | ||
|
|
6e314ea6d7 | ||
|
|
dfd962a8bc | ||
|
|
cfcbfe1e8f | ||
|
|
0e54f87b18 | ||
|
|
9f5e5b90e5 | ||
|
|
d619ba0857 | ||
|
|
fbea243e56 | ||
|
|
d062386656 | ||
|
|
d2f04f5bdf | ||
|
|
42c8d3ac27 | ||
|
|
d53563ab46 | ||
|
|
3d5f0ee315 | ||
|
|
ecdb7cdc55 | ||
|
|
fd38b752c4 | ||
|
|
64804a2a24 | ||
|
|
b603cb4530 | ||
|
|
8f2c7c0638 | ||
|
|
044ba7697a | ||
|
|
e6bd64b3ea | ||
|
|
56db916833 | ||
|
|
12cf0c4763 | ||
|
|
0a92e0f532 | ||
|
|
e6f9177fdb | ||
|
|
c3f6a4a57a | ||
|
|
653c209253 | ||
|
|
0974075fa0 | ||
|
|
53e1ee3475 | ||
|
|
46affea055 | ||
|
|
0ffe5cf1ff | ||
|
|
d023f9bf2d | ||
|
|
b2832cee8e | ||
|
|
960aa77b6d | ||
|
|
58daa5ed7d | ||
|
|
437e8bd706 | ||
|
|
1a5c7daaf6 | ||
|
|
c1ba4764b5 | ||
|
|
7cb3cb7353 | ||
|
|
604abaf81c | ||
|
|
8b157bb13f | ||
|
|
a8c71dcd20 | ||
|
|
363a8f6282 | ||
|
|
5b314cf1c3 | ||
|
|
02783bd7c6 | ||
|
|
d5c918d258 | ||
|
|
6b044335cd | ||
|
|
cbe20d3740 | ||
|
|
21bc84e837 | ||
|
|
203359ed7f | ||
|
|
24a26a2e94 | ||
|
|
0a7521060a | ||
|
|
6b5a9aa992 | ||
|
|
2dfdaa4d70 | ||
|
|
f2504494fe | ||
|
|
256858d2e5 | ||
|
|
10873bfe35 | ||
|
|
e939f1c1d1 | ||
|
|
b2c8cb655c | ||
|
|
4bdbf02c2d | ||
|
|
f83b2a0940 | ||
|
|
76ec74cbf1 | ||
|
|
8ae5da1472 |
@@ -0,0 +1,17 @@
|
||||
version: 3.1.{build}
|
||||
branches:
|
||||
only:
|
||||
- dev
|
||||
environment:
|
||||
matrix:
|
||||
- COMPILER: mingw
|
||||
MINGW_DIR: c:\msys64\mingw32
|
||||
|
||||
before_build:
|
||||
- set Path=%MINGW_DIR%\bin;%Path%
|
||||
|
||||
build_script:
|
||||
- set Path=%MINGW_DIR%\bin;c:\msys64\usr\bin;
|
||||
- bash autogen.sh
|
||||
- cd src/lib
|
||||
- make
|
||||
@@ -0,0 +1,3 @@
|
||||
*.sh -crlf
|
||||
*.ac -crlf
|
||||
*.am -crlf
|
||||
@@ -0,0 +1,23 @@
|
||||
name: CIFuzz
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
Fuzzing:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Build Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'ndpi'
|
||||
dry-run: false
|
||||
- name: Run Fuzzers
|
||||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||
with:
|
||||
oss-fuzz-project-name: 'ndpi'
|
||||
fuzz-seconds: 600
|
||||
dry-run: false
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@v1
|
||||
if: failure()
|
||||
with:
|
||||
name: artifacts
|
||||
path: ./out/artifacts
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @name Suspicious packet->payload based integer arithmetic
|
||||
* @description An arithmetic operation influenced array access is suspicious
|
||||
* if it uses an integer value that is likely to be network-controlled, and
|
||||
* may require a closer manual audit.
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @id cpp/packet-payload-integer-arithmetic
|
||||
* @tags audit security
|
||||
*/
|
||||
|
||||
import cpp
|
||||
|
||||
import semmle.code.cpp.dataflow.TaintTracking
|
||||
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
|
||||
|
||||
/** A source of an integer value that is likely to come from the network.
|
||||
* This is produced by an invocation of a macro of the form `ntoh*` or `get_u_int*_t`,
|
||||
* called with `packet->payload` as an argument.
|
||||
*/
|
||||
|
||||
class NetworkMacro extends Macro {
|
||||
NetworkMacro() { this.getName().regexpMatch("^ntoh(ll|l|s)") }
|
||||
}
|
||||
|
||||
class NetworkIntegerSource extends Expr {
|
||||
NetworkIntegerSource() {
|
||||
exists(MacroInvocation mi |
|
||||
this = mi.getExpr() and
|
||||
mi.getUnexpandedArgument(0).regexpMatch(".*packet->payload.*") |
|
||||
// catch all get_u_int*_t(x)
|
||||
mi.getMacroName().regexpMatch("^get_u_int(64|32|16|8)_t") and
|
||||
// dedup ntoh*(get_u_int*_t(x)) since we'll catch those in the next case
|
||||
not mi.getOutermostMacroAccess().getMacro() instanceof NetworkMacro
|
||||
or
|
||||
// catch all ntoh*(x) ... this will also catch the nested cases
|
||||
mi.getMacro() instanceof NetworkMacro
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class ArithmeticOperation extends Operation {
|
||||
ArithmeticOperation() {
|
||||
this instanceof UnaryArithmeticOperation or this instanceof BinaryArithmeticOperation
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkToArrayAccess extends TaintTracking::Configuration {
|
||||
NetworkToArrayAccess() { this = "NetworkToArrayAccess" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
source.asExpr() instanceof NetworkIntegerSource
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(ArrayExpr ae | sink.asExpr() = ae.getArrayOffset())
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkToArithmetic extends TaintTracking::Configuration {
|
||||
NetworkToArithmetic() { this = "NetworkToArithmetic" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
source.asExpr() instanceof NetworkIntegerSource
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists (Assignment assign |
|
||||
sink.asExpr() = assign.getRValue().(ArithmeticOperation) or
|
||||
sink.asExpr() = assign.(AssignArithmeticOperation)
|
||||
) or
|
||||
exists(LocalVariable var |
|
||||
sink.asExpr() = var.getInitializer().getExpr().(ArithmeticOperation)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// find audit candidates based on suspicious network integer use
|
||||
from NetworkIntegerSource source, Expr sink1, Expr sink2, NetworkToArithmetic config1, NetworkToArrayAccess config2
|
||||
where config1.hasFlow(DataFlow::exprNode(source), DataFlow::exprNode(sink1))
|
||||
// or this if you want integer arithmeric _OR_ array accesses
|
||||
and config2.hasFlow(DataFlow::exprNode(source), DataFlow::exprNode(sink2))
|
||||
select source, "Suspicious use of network integer arithmetic."
|
||||
+114
-7
@@ -7,20 +7,74 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
dist: bionic
|
||||
arch: arm64
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
dist: bionic
|
||||
arch: arm64
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
|
||||
# Targets below have been disabled as we have no way
|
||||
# to debug on tsuch platforms at the moment
|
||||
# - os: linux
|
||||
# compiler: gcc
|
||||
# dist: bionic
|
||||
# arch: s390x
|
||||
# addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - libpcap-dev
|
||||
# - libjson-c-dev
|
||||
# - autogen
|
||||
#
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# dist: bionic
|
||||
# arch: s390x
|
||||
# addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - libpcap-dev
|
||||
# - libjson-c-dev
|
||||
# - autogen
|
||||
|
||||
- os: linux
|
||||
compiler: gcc-8
|
||||
addons:
|
||||
@@ -30,9 +84,11 @@ matrix:
|
||||
packages:
|
||||
- g++-8
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
- MATRIX_EVAL="CC=gcc-8"
|
||||
|
||||
- os: linux
|
||||
compiler: gcc-9
|
||||
@@ -43,9 +99,11 @@ matrix:
|
||||
packages:
|
||||
- g++-9
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
|
||||
- MATRIX_EVAL="CC=gcc-9"
|
||||
|
||||
- os: linux
|
||||
compiler: clang-8
|
||||
@@ -57,9 +115,11 @@ matrix:
|
||||
packages:
|
||||
- clang-8
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
|
||||
- MATRIX_EVAL="CC=clang-8"
|
||||
|
||||
- os: linux
|
||||
compiler: clang-7
|
||||
@@ -71,13 +131,57 @@ matrix:
|
||||
packages:
|
||||
- clang-7
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
|
||||
- MATRIX_EVAL="CC=clang-7"
|
||||
|
||||
- name: fuzza
|
||||
env: CXXFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" CFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=address" QA_FUZZ=asan CC=clang-7 && CXX=clang++-7 ASAN_SYMBOLIZER_PATH=/usr/local/clang-7.0.0/bin/llvm-symbolizer
|
||||
os: linux
|
||||
compiler: clang-7
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
packages:
|
||||
- clang-7
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
- name: fuzzm
|
||||
env: CXXFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" CFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=memory" QA_FUZZ=msan CC=clang && CXX=clang++
|
||||
os: linux
|
||||
compiler: clang
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
- name: fuzzu
|
||||
env: CXXFLAGS="-g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fsanitize=fuzzer-no-link -fno-sanitize=alignment" CFLAGS="-g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fno-sanitize-recover=undefined,integer -fsanitize=fuzzer-no-link -fno-sanitize=alignment" LDFLAGS="-g3 -Og -fsanitize=undefined -fno-sanitize=alignment" QA_FUZZ=ubsan CC=clang-7 && CXX=clang++-7
|
||||
os: linux
|
||||
compiler: clang-7
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
packages:
|
||||
- clang-7
|
||||
- libpcap-dev
|
||||
- libgcrypt20-dev
|
||||
- libjson-c-dev
|
||||
- autogen
|
||||
|
||||
|
||||
|
||||
before_install:
|
||||
before_install:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
|
||||
before_script:
|
||||
@@ -85,12 +189,15 @@ before_script:
|
||||
# - lcov --directory . --zerocounters
|
||||
|
||||
script:
|
||||
- ./configure
|
||||
- if [ -n "$QA_FUZZ" ]; then ./configure --enable-fuzztargets ; else ./configure ; fi
|
||||
- make
|
||||
- make -C example ndpiSimpleIntegration
|
||||
- make dist
|
||||
|
||||
#after_script:
|
||||
- cd tests
|
||||
- ./do.sh
|
||||
- ./do-unit.sh
|
||||
|
||||
#after_success:
|
||||
#- cd ${TRAVIS_BUILD_DIR}
|
||||
|
||||
+145
-6
@@ -1,5 +1,145 @@
|
||||
# CHANGELOG
|
||||
|
||||
#### nDPI 3.4 (October 2020)
|
||||
|
||||
## New Features
|
||||
* Completely reworked and extended QUIC dissector
|
||||
* Added flow risk concept to move nDPI towards result interpretation
|
||||
* Added ndpi_dpi2json() API call
|
||||
* Added DGA risk for names that look like a DGA
|
||||
* Added HyperLogLog cardinality estimator API calls
|
||||
* Added ndpi_bin_XXX API calls to handle bin handling
|
||||
* Fully fuzzy tested code that has greatly improved reliability and robustness
|
||||
|
||||
## New Supported Protocols and Services
|
||||
* QUIC
|
||||
* SMBv1
|
||||
* WebSocket
|
||||
* TLS: added ESNI support
|
||||
* SOAP
|
||||
* DNScrypt
|
||||
|
||||
## Improvements
|
||||
* Python CFFI bindings
|
||||
* Various TLS extensions and fixes including extendede metadata support
|
||||
* Added various pcap files for testing corner cases in protocols
|
||||
* Various improvements in JSON/Binary data serialization
|
||||
* CiscoVPN
|
||||
* H323
|
||||
* MDNS
|
||||
* MySQL 8
|
||||
* IEC 60870-5-104
|
||||
* DoH/DoT dissection improvements
|
||||
* Office365 renamed to Microsoft365
|
||||
* Major protocol dissection improvement in particular with unknwon traffic
|
||||
* Improvement in Telegram v6 protocol support
|
||||
* HTTP improvements to detect file download/upload and binary files
|
||||
* BitTorrent and WhatsApp dissection improvement
|
||||
* Spotify
|
||||
* Added detection of malformed packets
|
||||
* Fuzzy testing support has been greatly improved
|
||||
* SSH code cleanup
|
||||
|
||||
## Fixes
|
||||
* Fixed various memory leaks and race conditions in protocol decoding
|
||||
* NATS, CAPWAP dissector
|
||||
* Removed HyperScan support that greatly simplified the code
|
||||
* ARM platform fixes on memory alignment
|
||||
* Wireshark extcap support
|
||||
* DPDK support
|
||||
* OpenWRT, OpenBSD support
|
||||
* MINGW compiler support
|
||||
|
||||
## MISC
|
||||
* Created demo app for nDPI newcomers
|
||||
* Removed obsolete pplive and pando protocols
|
||||
|
||||
#### nDPI 3.2 (February 2020)
|
||||
|
||||
## New Features
|
||||
* New API calls
|
||||
* Protocol detection: ndpi_is_protocol_detected
|
||||
* Categories: ndpi_load_categories_file / ndpi_load_category
|
||||
* JSON/TLV serialization: ndpi_serialize_string_boolean / ndpi_serialize_uint32_boolean
|
||||
* Patricia tree: ndpi_load_ipv4_ptree
|
||||
* Module initialization: ndpi_init_detection_module / ndpi_finalize_initalization
|
||||
* Base64 encoding: ndpi_base64_encode
|
||||
* JSON exprot: ndpi_flow2json
|
||||
* Print protocol: ndpi_get_l4_proto_name / ndpi_get_l4_proto_info
|
||||
* Libfuzz integration
|
||||
* Implemented Community ID hash (API call ndpi_flowv6_flow_hash and ndpi_flowv4_flow_hash)
|
||||
* Detection of RCE in HTTP GET requests via PCRE
|
||||
* Integration of the libinjection library to detect SQL injections and XSS type attacks in HTTP requests
|
||||
|
||||
## New Supported Protocols and Services
|
||||
* TLS
|
||||
* Added ALPN support
|
||||
* Added export of supported version in TLS header
|
||||
* Added Telnet dissector with metadata extraction
|
||||
* Added Zabbix dissector
|
||||
* Added POP3/IMAP metadata extraction
|
||||
* Added FTP user/password extraction
|
||||
* Added NetBIOS metadata extraction
|
||||
* Added Kerberos metadata extraction
|
||||
* Implemented SQL Injection and XSS attack detection
|
||||
* Host-based detection improvements and changes
|
||||
* Added Microsoft range
|
||||
* Added twitch.tv website
|
||||
* Added brasilbandalarga.com.br and .eaqbr.com.br as EAQ
|
||||
* Added 20.180.0.0/14, 20.184.0.0/13 range as Skype
|
||||
* Added 52.84.0.0/14 range as Amazon
|
||||
* Added ^pastebin.com
|
||||
* Changed 13.64.0.0/11 range from Skype to Microsoft
|
||||
* Refreshed Whatsapp server list, added *whatsapp-*.fbcdn.net IPs
|
||||
* Added public DNSoverHTTPS servers
|
||||
|
||||
## Improvements
|
||||
* Reworked and improved the TLS dissector
|
||||
* Reworked Kerberos dissector
|
||||
* Improved DNS response decoding
|
||||
* Support for DNS continuous flow dissection
|
||||
* Improved Python bindings
|
||||
* Improved Ethereum support
|
||||
* Improved categories detection with streaming and HTTP
|
||||
* Support for IP-based detection to compute the application protocol
|
||||
* Renamed protocol 104 to IEC60870 (more meaningful)
|
||||
* Added failed authentication support with FTP
|
||||
* Renamed DNSoverHTTPS to handle bot DoH and DoT
|
||||
* Implemented stacked DPI decoding
|
||||
* Improvements for CapWAP and Bloomberg
|
||||
* Improved SMB dissection
|
||||
* Improved SSH dissection
|
||||
* Added capwap support
|
||||
* Modified API signatures for ndpi_ssl_version2str / ndpi_detection_giveup
|
||||
* Removed ndpi_pref_http_dont_dissect_response / ndpi_pref_dns_dont_dissect_response (replaced by ndpi_extra_dissection_possible)
|
||||
|
||||
## Fixes
|
||||
* Fixed memory invalid access in SMTP and leaks in TLS
|
||||
* Fixed a few memory leaks
|
||||
* Fixrd invalid memory access in a few protocol dissectors (HTTP, memcached, Citrix, STUN, DNS, Amazon Video, TLS, Viber)
|
||||
* Fixed IPv6 address format across the various platforms/distributions
|
||||
* Fixed infinite loop in ndpi_workflow_process_packet
|
||||
* Fixed SHA1 certificate detection
|
||||
* Fixed custom protocol detection
|
||||
* Fixed SMTP dissection (including email)
|
||||
* Fixed Telnet dissection and invalid password report
|
||||
* Fixed invalid category matching in HTTP
|
||||
* Fixed Skype and STUN false positives
|
||||
* Fixed SQL Injection detection
|
||||
* Fixed invalid SMBv1 detection
|
||||
* Fixed SSH dissection
|
||||
* Fixed ndpi_ssl_version2str
|
||||
* Fixed ndpi_extra_dissection_possible
|
||||
* Fixed out of bounds read in ndpi_match_custom_category
|
||||
|
||||
## Misc
|
||||
* ndpiReader
|
||||
* CSV output enhancements
|
||||
* Added tunnelling decapsulation
|
||||
* Improved HTTP reporting
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
#### nDPI 3.0 (October 2019)
|
||||
|
||||
## New Features
|
||||
@@ -67,7 +207,6 @@
|
||||
* Fix DNS rsp_addr missing in some tiny responses
|
||||
* Various hardening fixes
|
||||
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
#### nDPI 2.8 (March 2019)
|
||||
@@ -143,12 +282,12 @@
|
||||
## Other
|
||||
|
||||
* Deb and RPM packages: ndpi with shared libraries and binaries, ndpi-dev with headers and static libraries
|
||||
* Protocols now have an optional subprotocol: Spotify cannot have subprotocols, DNS can (DNS.Spotify)
|
||||
* Protocols now have an optional subprotocol: Spotify cannot have subprotocols, DNS can (DNS.Spotify)
|
||||
* New API functions:
|
||||
- ndpi_fill_ip_protocol_category to handle ICMP flows category
|
||||
- ndpi_flowv4_flow_hash and ndpi_flowv6_flow_hash to support the Community ID Flow Hashing (https://github.com/corelight/community-id-spec)
|
||||
- ndpi_protocol2id to print the protocol as ID
|
||||
- ndpi_get_custom_category_match to search host in custom categories
|
||||
* ndpi_fill_ip_protocol_category to handle ICMP flows category
|
||||
* ndpi_flowv4_flow_hash and ndpi_flowv6_flow_hash to support the Community ID Flow Hashing (https://github.com/corelight/community-id-spec)
|
||||
* ndpi_protocol2id to print the protocol as ID
|
||||
* ndpi_get_custom_category_match to search host in custom categories
|
||||
* Changed ndpi_detection_giveup API: guess is now part of the call
|
||||
* Added DPDK support to ndpiReader
|
||||
* Removed Musical.ly protocol (service no longer used)
|
||||
|
||||
+9
-2
@@ -1,7 +1,14 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
SUBDIRS = src/lib example tests
|
||||
SUBDIRS = src/lib @EXTRA_TARGETS@
|
||||
|
||||
if BUILD_FUZZTARGETS
|
||||
SUBDIRS += fuzz
|
||||
endif
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libndpi.pc
|
||||
|
||||
EXTRA_DIST = autogen.sh
|
||||
EXTRA_DIST = README.md CHANGELOG.md CONTRIBUTING.md README.protocols autogen.sh configure.seed wireshark python windows utils packages doc/nDPI_QuickStartGuide.pages doc/nDPI_QuickStartGuide.pdf example/MacOS example/Win32
|
||||
|
||||
changelog:
|
||||
git log --since={`curl -s https://github.com/ntop/ndpi/releases | grep datetime | head -n1 | egrep -o "[0-9]+\-[0-9]+\-[0-9]+"`} --name-only --pretty=format:" - %s" | grep "^ " > Changelog.latest
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
[](https://travis-ci.org/ntop/nDPI)
|
||||
[](https://lgtm.com/projects/g/ntop/nDPI/context:cpp)
|
||||
[](https://lgtm.com/projects/g/ntop/nDPI/alerts)
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:ndpi)
|
||||
|
||||
## What is nDPI ?
|
||||
|
||||
nDPI is an open source LGPLv3 library for deep-packet inspection. Based on OpenDPI it includes ntop extensions. We have tried to push them into the OpenDPI source tree but nobody answered emails so we have decided to create our own source tree
|
||||
nDPI® is an open source LGPLv3 library for deep-packet inspection. Based on OpenDPI it includes ntop extensions. We have tried to push them into the OpenDPI source tree but nobody answered emails so we have decided to create our own source tree
|
||||
|
||||
### How To Compile nDPI
|
||||
|
||||
@@ -41,21 +42,15 @@ The entire procedure of adding new protocols in detail:
|
||||
10. make check
|
||||
|
||||
### How to use nDPI to Block Selected Traffic
|
||||
|
||||
You can use nDPI to selectively block selected Internet traffic by embedding it onto an application (remember that nDPI is just a library). Both [ntopng](https://github.com/ntop/ntopng) and [nProbe cento](http://www.ntop.org/products/netflow/nprobe-cento/) can do this.
|
||||
|
||||
### nDPI-Related Projects
|
||||
- [nfstream](https://github.com/aouinizied/nfstream)
|
||||
|
||||
### DISCLAIMER
|
||||
While we do our best to detect network protocols, we cannot guarantee that our software is error free and 100% accurate in protocol detection. Please make sure that you respect the privacy of users and you have proper authorization to listen, capture and inspect network traffic.
|
||||
|
||||
### Creating A Source File Tar Ball
|
||||
|
||||
If you want to distribute a source tar file of nDPI do:
|
||||
|
||||
- make dist
|
||||
|
||||
To ensure that a tar file includes all necessary files and to run tests on distribution do:
|
||||
|
||||
- make distcheck
|
||||
nDPI is a registered trademark in the US and EU.
|
||||
|
||||
[ntopng_logo]: https://camo.githubusercontent.com/0f789abcef232035c05e0d2e82afa3cc3be46485/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031312f30382f6e746f706e672d69636f6e2d313530783135302e706e67
|
||||
|
||||
|
||||
+5
-4
@@ -5,17 +5,18 @@ Prerequisites
|
||||
- GNU autotools/libtool
|
||||
- libpcap or PF_RING (optional but recommended)
|
||||
- apt-get install libjson-c-dev (for JSON support)
|
||||
- libgcrypt20-dev (for QUIC support)
|
||||
|
||||
On Ubuntu/Debian
|
||||
- apt-get install build-essential
|
||||
- apt-get install git autoconf automake autogen libpcap-dev libtool
|
||||
- apt-get install git autoconf automake autogen libpcap-dev libtool libgcrypt20-dev
|
||||
|
||||
On Fedora/CentOS
|
||||
- yum groupinstall "Development tools"
|
||||
- yum install git autoconf automake autogen libpcap-devel libtool
|
||||
- yum install git autoconf automake autogen libpcap-devel libtool libgcrypt-devel
|
||||
|
||||
On MacOSX (using http://brew.sh)
|
||||
brew install autoconf automake libtool git
|
||||
brew install autoconf automake libtool git libgcrypt
|
||||
|
||||
On FreeBSD
|
||||
- pkg install autoconf automake libtool gmake git
|
||||
- pkg install autoconf automake libtool gmake git libgcrypt
|
||||
|
||||
+16
-2
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
NDPI_MAJOR="3"
|
||||
NDPI_MINOR="0"
|
||||
NDPI_MINOR="4"
|
||||
NDPI_PATCH="0"
|
||||
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
|
||||
|
||||
@@ -12,10 +12,17 @@ AUTOMAKE=$(command -v automake)
|
||||
LIBTOOL=$(command -v libtool)
|
||||
LIBTOOLIZE=$(command -v libtoolize)
|
||||
AUTORECONF=$(command -v autoreconf)
|
||||
PKG_CONFIG=$(command -v pkg-config)
|
||||
FUZZY=
|
||||
|
||||
if test -z $AUTOCONF; then
|
||||
echo "autoconf is missing: please install it and try again"
|
||||
exit
|
||||
else
|
||||
V=`autoconf --version | head -1 | cut -d ' ' -f 4`
|
||||
if [ "$V" = '2.63' ]; then
|
||||
FUZZY="dnl> "
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z $AUTOMAKE; then
|
||||
@@ -33,11 +40,17 @@ if test -z $AUTORECONF; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if test -z $PKG_CONFIG; then
|
||||
echo "pkg-config is missing: please install it (apt-get install pkg-config) and try again"
|
||||
exit
|
||||
fi
|
||||
|
||||
cat configure.seed | sed \
|
||||
-e "s/@NDPI_MAJOR@/$NDPI_MAJOR/g" \
|
||||
-e "s/@NDPI_MINOR@/$NDPI_MINOR/g" \
|
||||
-e "s/@NDPI_PATCH@/$NDPI_PATCH/g" \
|
||||
-e "s/@NDPI_VERSION_SHORT@/$NDPI_VERSION_SHORT/g" \
|
||||
-e "s/@FUZZY@/$FUZZY/g" \
|
||||
> configure.ac
|
||||
|
||||
autoreconf -ivf
|
||||
@@ -45,4 +58,5 @@ cat configure | sed "s/#define PACKAGE/#define NDPI_PACKAGE/g" | sed "s/#define
|
||||
cat configure.tmp > configure
|
||||
|
||||
chmod +x configure
|
||||
./configure $*
|
||||
./configure $@
|
||||
|
||||
|
||||
+135
-81
@@ -1,15 +1,39 @@
|
||||
AC_INIT([libndpi], [@NDPI_VERSION_SHORT@])
|
||||
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
|
||||
EXTRA_TARGETS="example tests tests/unit"
|
||||
AC_ARG_WITH(only-libndpi, AS_HELP_STRING([--with-only-libndpi], [Build only libndpi (no examples, tests etc)]))
|
||||
AS_IF([test "${with_only_libndpi+set}" = set],[
|
||||
EXTRA_TARGETS=""
|
||||
])
|
||||
|
||||
AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer]))
|
||||
AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no])
|
||||
AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"])
|
||||
|
||||
AS_IF([test "${with_sanitizer+set}" = set],[
|
||||
CFLAGS="${CFLAGS} -g3 -O0 -Wno-unused-value -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak -fno-omit-frame-pointer"
|
||||
LDFLAGS="${LDFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak"
|
||||
])
|
||||
|
||||
LT_INIT
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC_STDC
|
||||
SYSTEM=`uname -s`
|
||||
if test $SYSTEM = "Darwin"; then
|
||||
dnl> AC_PROG_CC(clang gcc)
|
||||
AM_PROG_CC_C_O(clang gcc)
|
||||
AC_PROG_CXX(clang++ g++)
|
||||
AC_PROG_CC_STDC(clang gcc)
|
||||
else
|
||||
dnl> AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC_STDC
|
||||
fi
|
||||
AC_LANG_WERROR
|
||||
AX_PTHREAD
|
||||
|
||||
@@ -27,33 +51,45 @@ if test -d ".git"; then :
|
||||
GIT_DATE=`git log -1 --format=%cd`
|
||||
#
|
||||
# On CentOS 6 `git rev-list HEAD --count` does not work
|
||||
#
|
||||
#
|
||||
#
|
||||
GIT_NUM=`git log --pretty=oneline | wc -l | tr -d '[[:space:]]'`
|
||||
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_NUM}-${GIT_TAG}"
|
||||
|
||||
A=`git log src/include/ndpi_typedefs.h|wc -l`
|
||||
B=`git log src/include/ndpi_protocol_ids.h|wc -l`
|
||||
C=`git log src/include/ndpi_api.h.in|wc -l`
|
||||
NDPI_API_VERSION=$((A+B+C))
|
||||
else
|
||||
GIT_RELEASE="${PACKAGE_VERSION}"
|
||||
GIT_DATE=`date -u -r CHANGELOG.md`
|
||||
NDPI_API_VERSION=`date +%s | cut -c7-10`
|
||||
fi
|
||||
|
||||
NDPI_API_VERSION=`echo $NDPI_API_VERSION | sed 's/^0*//'`
|
||||
|
||||
AC_DEFINE_UNQUOTED(NDPI_GIT_RELEASE, "${GIT_RELEASE}", [GIT Release])
|
||||
AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change])
|
||||
|
||||
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h])
|
||||
dnl> used by json-c
|
||||
JSONC_INC=`pkg-config --cflags json-c`
|
||||
CFLAGS="${CFLAGS} ${JSONC_INC}"
|
||||
|
||||
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h json.h])
|
||||
|
||||
ADDITIONAL_LIBS=
|
||||
PCAP_HOME=$HOME/PF_RING/userland
|
||||
|
||||
DPDK_TARGET=
|
||||
AC_MSG_CHECKING([DPDK (used by ndpiReader)])
|
||||
if test -d $HOME/DPDK; then :
|
||||
echo "Enabling DPDK support in ndpiReader"
|
||||
AC_MSG_RESULT(yes)
|
||||
DPDK_TARGET=dpdk
|
||||
else
|
||||
echo "DPDK support disabled (missing $HOME/DPDK)"
|
||||
AC_MSG_RESULT([no (missing $HOME/DPDK)])
|
||||
fi
|
||||
|
||||
if test -d $PCAP_HOME; then :
|
||||
echo -n ""
|
||||
else
|
||||
if ! test -d $PCAP_HOME; then :
|
||||
PCAP_HOME=`pwd`/../../PF_RING/userland
|
||||
fi
|
||||
SHORT_MACHINE=`uname -m | cut -b1-3`
|
||||
@@ -64,96 +100,114 @@ else
|
||||
fi
|
||||
|
||||
MACHINE=`uname -m`
|
||||
SYSTEM=`uname -s`
|
||||
if test $SYSTEM = "Darwin"; then
|
||||
CC=clang
|
||||
fi
|
||||
|
||||
|
||||
AC_ARG_WITH(hyperscan, [ --with-hyperscan Enable nDPI build with Intel Hyperscan])
|
||||
|
||||
AS_IF([test "${with_hyperscan+set}" = set],[
|
||||
BKP=$LIBS
|
||||
LIBS="$LIBS -lstdc++ -lm"
|
||||
AC_CHECK_LIB([hs], [hs_compile_multi], AC_DEFINE_UNQUOTED(HAVE_HYPERSCAN, 1, [Intel Hyperscan is present]))
|
||||
LIBS=$BKP
|
||||
CUSTOM_NDPI=
|
||||
|
||||
AS_IF([test "x$ac_cv_lib_hs_hs_compile_multi" = xyes],[
|
||||
AC_CHECK_LIB([m], [pow])
|
||||
AC_CHECK_LIB([stdc++], [main])
|
||||
PKG_CHECK_MODULES([HS],[libhs])
|
||||
LDFLAGS="$LDFLAGS $HS_LIBS"
|
||||
AC_MSG_RESULT([compiling with Intel Hyperscan])
|
||||
],[
|
||||
AC_MSG_RESULT([Intel Hyperscan not found, exiting. See https://github.com/intel/hyperscan/blob/master/doc/dev-reference/getting_started.rst for install/build instructions])
|
||||
exit 1
|
||||
])
|
||||
])
|
||||
|
||||
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
|
||||
echo "Using libpcap from $PCAP_HOME"
|
||||
PCAP_INC="-I $PCAP_HOME/libpcap"
|
||||
PCAP_LIB="$PCAP_HOME/libpcap/libpcap.a $PCAP_HOME/lib/libpfring.a $LIBNUMA `$PCAP_HOME/lib/pfring_config --libs`"
|
||||
|
||||
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
|
||||
AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"])
|
||||
# The dlopen() function is in libdl on GLIBC-based systems
|
||||
# and in the C library for *BSD systems
|
||||
AC_CHECK_LIB([dl], [dlopen, dlsym], [DL_LIB="-ldl"],
|
||||
[AC_CHECK_LIB([c], [dlopen, dlsym], [DL_LIB="-lc"],
|
||||
[AC_MSG_ERROR([unable to find the dlopen(), dlsym() functions]) ]) ])
|
||||
else
|
||||
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
|
||||
|
||||
if test $ac_cv_lib_pcap_pcap_open_live = "no"; then :
|
||||
echo ""
|
||||
echo "ERROR: Missing libpcap(-dev) library required to compile the example application"
|
||||
echo "ERROR: Please install it and try again"
|
||||
exit
|
||||
fi
|
||||
if test -d ../nDPI-custom; then :
|
||||
CUSTOM_NDPI="-DCUSTOM_NDPI_PROTOCOLS"
|
||||
AC_MSG_RESULT([Compiling with custom nDPI protocols])
|
||||
fi
|
||||
|
||||
dnl> https://github.com/json-c/json-c
|
||||
AC_ARG_ENABLE([json-c],
|
||||
AS_HELP_STRING([--disable-json-c], [Disable json-c support]))
|
||||
|
||||
AS_IF([test "x$enable_json_c" != "xno"], [
|
||||
PKG_CHECK_MODULES([JSONC],[json-c],
|
||||
[
|
||||
CFLAGS="$CFLAGS $JSONC_CFLAGS"
|
||||
LDFLAGS="$LDFLAGS $JSONC_LIBS"
|
||||
AC_CHECK_LIB(json-c, json_object_new_object, AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present]))
|
||||
],
|
||||
[
|
||||
JSONC_HOME="$HOME/json-c"
|
||||
if test -d "$JSONC_HOME"; then :
|
||||
CFLAGS="$CFLAGS -I $JSONC_HOME"
|
||||
LDFLAGS="$LDFLAGS $JSONC_HOME/.libs/libjson-c.a"
|
||||
AC_MSG_RESULT([Found json-c in $JSONC_HOME])
|
||||
AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present])
|
||||
fi
|
||||
])
|
||||
])
|
||||
case "$host" in
|
||||
*-*-mingw32*|*-*-msys)
|
||||
CFLAGS="${CFLAGS} -DOS_WIN32"
|
||||
LDFLAGS="${LDFLAGS} -lws2_32 -lucrtbase"
|
||||
BUILD_MINGW=1
|
||||
;;
|
||||
*)
|
||||
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
|
||||
echo "Using libpcap from $PCAP_HOME"
|
||||
PCAP_INC="-I $PCAP_HOME/libpcap"
|
||||
PCAP_LIB="$PCAP_HOME/libpcap/libpcap.a $PCAP_HOME/lib/libpfring.a $LIBNUMA `$PCAP_HOME/lib/pfring_config --libs`"
|
||||
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
|
||||
AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"])
|
||||
# The dlopen() function is in libdl on GLIBC-based systems
|
||||
# and in the C library for *BSD systems
|
||||
AC_CHECK_LIB([dl], [dlopen, dlsym], [DL_LIB="-ldl"],[AC_CHECK_LIB([c], [dlopen, dlsym], [DL_LIB="-lc"],[AC_MSG_ERROR([unable to find the dlopen(), dlsym() functions]) ]) ])
|
||||
else
|
||||
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
|
||||
if test $ac_cv_lib_pcap_pcap_open_live = "no"; then :
|
||||
echo ""
|
||||
echo "ERROR: Missing libpcap(-dev) library required to compile the example application"
|
||||
echo "ERROR: Please install it and try again"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_ENABLE([debug-messages],
|
||||
AS_HELP_STRING([--enable-debug-messages], [Define NDPI_ENABLE_DEBUG_MESSAGES=1]), [
|
||||
AC_DEFINE(NDPI_ENABLE_DEBUG_MESSAGES, 1, [Enable ndpi_debug_messages]) ])
|
||||
|
||||
@FUZZY@ AS_IF([test "x$enable_fuzztargets" = "xyes"], [
|
||||
@FUZZY@ AC_PROG_CXX
|
||||
@FUZZY@ AC_LANG_PUSH(C++)
|
||||
@FUZZY@ tmp_saved_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
@FUZZY@ AX_CHECK_COMPILE_FLAG([-fsanitize=fuzzer],,
|
||||
@FUZZY@ [AC_MSG_ERROR([--enable-fuzztargets requires -fsanitize=fuzzer which is only supported by LLVM])],
|
||||
@FUZZY@ [-Werror])
|
||||
@FUZZY@ AS_IF([test "x$LIB_FUZZING_ENGINE" = "x"], [
|
||||
@FUZZY@ LIB_FUZZING_ENGINE=-fsanitize=fuzzer
|
||||
@FUZZY@ AC_SUBST(LIB_FUZZING_ENGINE)
|
||||
@FUZZY@ ])
|
||||
@FUZZY@ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $LIB_FUZZING_ENGINE"
|
||||
@FUZZY@ AC_MSG_CHECKING([whether $CXX accepts $LIB_FUZZING_ENGINE])
|
||||
@FUZZY@ AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
@FUZZY@ #include <sys/types.h>
|
||||
@FUZZY@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size);
|
||||
@FUZZY@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size) {
|
||||
@FUZZY@ (void)Data;
|
||||
@FUZZY@ (void)Size;
|
||||
@FUZZY@ return 0;
|
||||
@FUZZY@ }
|
||||
@FUZZY@ ]])],
|
||||
@FUZZY@ [ AC_MSG_RESULT(yes)
|
||||
@FUZZY@ has_sanitizefuzzer=yes],
|
||||
@FUZZY@ [ AC_MSG_RESULT(no) ]
|
||||
@FUZZY@ )
|
||||
@FUZZY@ _AC_LANG_PREFIX[]FLAGS=$tmp_saved_flags
|
||||
@FUZZY@ AC_LANG_POP()
|
||||
@FUZZY@ ])
|
||||
AM_CONDITIONAL([HAS_FUZZLDFLAGS], [test "x$has_sanitizefuzzer" = "xyes"])
|
||||
|
||||
AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np]))
|
||||
|
||||
AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile python/Makefile])
|
||||
dnl> GCRYPT
|
||||
AC_ARG_ENABLE([gcrypt],
|
||||
[AS_HELP_STRING([--disable-gcrypt], [Avoid compiling with libgcrypt/libgpg-error, even if they are present. QUIC sub-classification may be missing])],
|
||||
[:],
|
||||
[AC_CHECK_LIB(gcrypt, gcry_cipher_checktag)
|
||||
AC_CHECK_LIB(gpg-error, gpg_strerror_r)])
|
||||
if test "x$ac_cv_lib_gcrypt_gcry_cipher_checktag" = xyes; then :
|
||||
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lgcrypt"
|
||||
fi
|
||||
|
||||
dnl> PCRE
|
||||
AC_ARG_WITH(pcre, [ --with-pcre Enable nDPI build with libpcre])
|
||||
if test "${with_pcre+set}" = set; then :
|
||||
AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE_UNQUOTED(HAVE_PCRE, 1, [libpcre(-dev) is present]))
|
||||
if test "x$ac_cv_lib_pcre_pcre_compile" = xyes; then :
|
||||
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lpcre"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile tests/unit/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile python/Makefile fuzz/Makefile src/include/ndpi_api.h])
|
||||
AC_CONFIG_HEADERS(src/include/ndpi_config.h)
|
||||
AC_SUBST(GIT_RELEASE)
|
||||
AC_SUBST(NDPI_MAJOR)
|
||||
AC_SUBST(NDPI_MINOR)
|
||||
AC_SUBST(NDPI_PATCH)
|
||||
AC_SUBST(NDPI_VERSION_SHORT)
|
||||
AC_SUBST(SVN_DATE)
|
||||
AC_SUBST(JSON_C_LIB)
|
||||
AC_SUBST(PCAP_INC)
|
||||
AC_SUBST(PCAP_LIB)
|
||||
AC_SUBST(ADDITIONAL_LIBS)
|
||||
AC_SUBST(DL_LIB)
|
||||
AC_SUBST(DPDK_TARGET)
|
||||
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
|
||||
|
||||
AC_SUBST(CUSTOM_NDPI)
|
||||
AC_SUBST(NDPI_API_VERSION)
|
||||
AC_SUBST(EXTRA_TARGETS)
|
||||
AC_SUBST(BUILD_MINGW)
|
||||
AC_OUTPUT
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -17,11 +17,11 @@ include $(RTE_SDK)/mk/rte.vars.mk
|
||||
APP = ndpiReader.dpdk
|
||||
LIBNDPI = $(PWD)/../src/lib/libndpi.a
|
||||
|
||||
SRCS-y := reader_util.c ndpiReader.c
|
||||
SRCS-y := reader_util.c intrusion_detection.c ndpiReader.c
|
||||
|
||||
CFLAGS += -g
|
||||
CFLAGS += -Wno-strict-prototypes -Wno-missing-prototypes -Wno-missing-declarations -Wno-unused-parameter -I $(PWD)/../src/include @CFLAGS@ -DUSE_DPDK
|
||||
LDLIBS = $(LIBNDPI) @PCAP_LIB@ -lpthread @LDFLAGS@
|
||||
LDLIBS = $(LIBNDPI) @PCAP_LIB@ @LIBS@ -lpthread -lm @LDFLAGS@
|
||||
|
||||
include $(RTE_SDK)/mk/rte.extapp.mk
|
||||
|
||||
|
||||
+36
-11
@@ -1,25 +1,44 @@
|
||||
CC=@CC@
|
||||
CXX=@CXX@
|
||||
CFLAGS=-g -I../src/include @CFLAGS@
|
||||
LIBNDPI=../src/lib/libndpi.a
|
||||
LDFLAGS=$(LIBNDPI) @PCAP_LIB@ -lpthread -lm @LDFLAGS@
|
||||
OBJS=ndpiReader.o reader_util.o
|
||||
BUILD_MINGW=@BUILD_MINGW@
|
||||
SRCHOME=../src
|
||||
CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@
|
||||
LIBNDPI=$(SRCHOME)/lib/libndpi.a
|
||||
LDFLAGS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ -lpthread -lm @LDFLAGS@
|
||||
HEADERS=intrusion_detection.h reader_util.h $(SRCHOME)/include/ndpi_api.h \
|
||||
$(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h
|
||||
OBJS=ndpiReader.o reader_util.o intrusion_detection.o
|
||||
PREFIX?=@prefix@
|
||||
|
||||
ifneq ($(BUILD_MINGW),)
|
||||
all:
|
||||
@echo 'Examples disabled due to mingw build.'
|
||||
|
||||
else
|
||||
|
||||
all: ndpiReader @DPDK_TARGET@
|
||||
|
||||
ndpiReader: $(OBJS) $(LIBNDPI)
|
||||
$(CXX) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
|
||||
EXECUTABLE_SOURCES := ndpiReader.c ndpiSimpleIntegration.c
|
||||
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
|
||||
|
||||
libndpiReader.a: $(COMMON_SOURCES:%.c=%.o) $(LIBNDPI)
|
||||
ar rsv libndpiReader.a $(COMMON_SOURCES:%.c=%.o)
|
||||
|
||||
ndpiReader: libndpiReader.a $(LIBNDPI) ndpiReader.o
|
||||
$(CC) $(CFLAGS) ndpiReader.o libndpiReader.a -o $@ $(LDFLAGS)
|
||||
|
||||
ndpiSimpleIntegration: ndpiSimpleIntegration.o
|
||||
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
|
||||
|
||||
%.o: %.c $(HEADERS) Makefile
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
install:
|
||||
install: ndpiReader
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin/
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/sbin/ndpi
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/share/ndpi
|
||||
cp ndpiReader $(DESTDIR)$(PREFIX)/bin/
|
||||
cp protos.txt $(DESTDIR)$(PREFIX)/sbin/ndpi/ndpiProtos.txt
|
||||
cp mining_hosts.txt $(DESTDIR)$(PREFIX)/sbin/ndpi/ndpiCustomCategory.txt
|
||||
cp protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt
|
||||
cp mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt
|
||||
[ -f build/app/ndpiReader.dpdk ] && cp build/app/ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
|
||||
[ -f ndpiReader.dpdk ] && cp ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
|
||||
|
||||
@@ -27,7 +46,7 @@ dpdk:
|
||||
make -f Makefile.dpdk
|
||||
|
||||
check:
|
||||
cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I../src/include -I/usr/local/include/json-c *.c
|
||||
cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I$(SRCHOME)/include *.c
|
||||
|
||||
clean:
|
||||
/bin/rm -f *.o ndpiReader ndpiReader.dpdk
|
||||
@@ -35,6 +54,12 @@ clean:
|
||||
/bin/rm -f _install _postbuild _postinstall _preinstall
|
||||
/bin/rm -rf build
|
||||
|
||||
distdir:
|
||||
cp categories.txt mining_hosts.txt protos.txt README.DPDK '$(distdir)/'
|
||||
find . -maxdepth 1 -type f -name '*.c' -o -name '*.h' -o -name '*.py' | xargs -I'{}' cp '{}' '$(distdir)/{}'
|
||||
|
||||
distclean: clean
|
||||
/bin/rm -f Makefile.dpdk
|
||||
/bin/rm -f Makefile
|
||||
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
* intrusion_detection.c
|
||||
*
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "intrusion_detection.h"
|
||||
|
||||
double normalize(ndpi_norm_value* tresholds){
|
||||
if(tresholds->upper_bound != tresholds->lower_bound){
|
||||
tresholds->norm_value = (tresholds->value - tresholds->lower_bound) / (tresholds->upper_bound - tresholds->lower_bound);
|
||||
}else{
|
||||
if(tresholds->value > tresholds->upper_bound){
|
||||
tresholds->norm_value = 1 + (tresholds->value - tresholds->lower_bound) / tresholds->upper_bound;
|
||||
}else{
|
||||
tresholds->norm_value = 1 - (tresholds->value - tresholds->lower_bound) / tresholds->upper_bound;
|
||||
}
|
||||
|
||||
}
|
||||
if(tresholds->norm_value >= 0){
|
||||
return tresholds->norm_value * tresholds->weight;
|
||||
}
|
||||
else{
|
||||
return (1 - tresholds->norm_value) * tresholds->weight;
|
||||
}
|
||||
}
|
||||
|
||||
double get_flow_score(ndpi_norm_value* scores, int n_metrics){
|
||||
double flow_score = 0;
|
||||
for(int i=0; i<n_metrics; i++){
|
||||
flow_score += normalize(&scores[i]);
|
||||
}
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
double Ddos_score(struct ndpi_flow_info* flow){
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* pktlen_c_to_s_avg */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 70.0;
|
||||
scores[i].upper_bound = 263.4799999999999;
|
||||
scores[i].weight = 0.21257330032661592;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_c_to_s);
|
||||
|
||||
/* pktlen_s_to_c_max */
|
||||
i++;
|
||||
scores[i].lower_bound = 90.0;
|
||||
scores[i].upper_bound = 2974.0;
|
||||
scores[i].weight = 0.21073785073559176;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 72.7;
|
||||
scores[i].upper_bound = 1130.4199999999996;
|
||||
scores[i].weight = 0.21257330032661592;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_stddev */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 906.0;
|
||||
scores[i].weight = 0.20990954527912953;
|
||||
scores[i].value = ndpi_data_stddev(flow->pktlen_s_to_c);
|
||||
|
||||
/* fin */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.07710300166602348;
|
||||
scores[i].value = flow->fin_count;
|
||||
|
||||
/* s_to_c_fin */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.07710300166602348;
|
||||
scores[i].value = flow->dst2src_fin_count;
|
||||
|
||||
// sum = 1.0
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Dos_goldeneye_score(struct ndpi_flow_info* flow){
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* pktlen_s_to_c_max */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 74.0;
|
||||
scores[i].upper_bound = 3292.6699999999764;
|
||||
scores[i].weight = 0.3123007140611667;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
|
||||
/* pktlen_s_to_c_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 68.7;
|
||||
scores[i].upper_bound = 1354.0569999999987;
|
||||
scores[i].weight = 0.23802038891633356;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_stddev */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 959.4469999999993;
|
||||
scores[i].weight = 0.3111779763775991;
|
||||
scores[i].value = ndpi_data_stddev(flow->pktlen_s_to_c);
|
||||
|
||||
/* syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.0464364305923564;
|
||||
scores[i].value = flow->syn_count;
|
||||
|
||||
/* c_to_s_syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 1.0;
|
||||
scores[i].weight = 0.04562805946018772;
|
||||
scores[i].value = flow->src2dst_syn_count;
|
||||
|
||||
/* s_to_c_syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.0464364305923564;
|
||||
scores[i].value = flow->dst2src_syn_count;
|
||||
|
||||
// sum = 0.9999999999999998
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Dos_hulk_score(struct ndpi_flow_info* flow){
|
||||
double f = (double)flow->first_seen_ms/1000.0, l = (double)flow->last_seen_ms/1000.0;
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* duration */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 539.40668006422;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = (l - f);
|
||||
|
||||
/* src2dst_packets */
|
||||
i++;
|
||||
scores[i].lower_bound = 2.0;
|
||||
scores[i].upper_bound = 41.0;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = flow->src2dst_packets;
|
||||
|
||||
/* dst2src_packets */
|
||||
i++;
|
||||
scores[i].lower_bound = 2.0;
|
||||
scores[i].upper_bound = 45.0;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = flow->dst2src_packets;
|
||||
|
||||
/* src2dst_bytes */
|
||||
i++;
|
||||
scores[i].lower_bound = 146.0;
|
||||
scores[i].upper_bound = 6306.300000000001;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = flow->src2dst_bytes;
|
||||
|
||||
/* ack */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 82.0;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = flow->ack_count;
|
||||
|
||||
/* syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = flow->syn_count;
|
||||
|
||||
// sum = 0.9999999999999999
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Dos_slow_score(struct ndpi_flow_info* flow){
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* pktlen_s_to_c_max */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 90.0;
|
||||
scores[i].upper_bound = 3135.0;
|
||||
scores[i].weight = 0.1760747755022144;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 80.37100000000001;
|
||||
scores[i].upper_bound = 1292.5900000000008;
|
||||
scores[i].weight = 0.17600137023171597;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
|
||||
|
||||
/* dst2src_bytes */
|
||||
i++;
|
||||
scores[i].lower_bound = 262.0;
|
||||
scores[i].upper_bound = 53227.80000000002;
|
||||
scores[i].weight = 0.16919914849886225;
|
||||
scores[i].value = flow->dst2src_bytes;
|
||||
|
||||
/* syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.168000195747388;
|
||||
scores[i].value = flow->syn_count;
|
||||
|
||||
/* c_to_s_syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 1.0;
|
||||
scores[i].weight = 0.14272431427243143;
|
||||
scores[i].value = flow->src2dst_syn_count;
|
||||
|
||||
/* s_to_c_syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.168000195747388;
|
||||
scores[i].value = flow->dst2src_syn_count;
|
||||
|
||||
// sum = 1.0
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Ftp_patator_score(struct ndpi_flow_info* flow){
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* iat_flow_min */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 24.0;
|
||||
scores[i].weight = 0.002732919254658385;
|
||||
scores[i].value = ndpi_data_min(flow->iat_flow);
|
||||
|
||||
/* pktlen_s_to_c_max */
|
||||
i++;
|
||||
scores[i].lower_bound = 90.0;
|
||||
scores[i].upper_bound = 3393.0;
|
||||
scores[i].weight = 0.007453416149068323;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 81.3;
|
||||
scores[i].upper_bound = 1315.021;
|
||||
scores[i].weight = 0.9833540372670807;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
|
||||
|
||||
/* dst2src_bytes */
|
||||
i++;
|
||||
scores[i].lower_bound = 256.0;
|
||||
scores[i].upper_bound = 56434.0;
|
||||
scores[i].weight = 0.0034782608695652175;
|
||||
scores[i].value = flow->dst2src_bytes;
|
||||
|
||||
/* fin */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.0014906832298136647;
|
||||
scores[i].value = flow->fin_count;
|
||||
|
||||
/* rst */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.0014906832298136647;
|
||||
scores[i].value = flow->rst_count;
|
||||
|
||||
// sum = 1.0
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Hearthbleed_score(struct ndpi_flow_info* flow){
|
||||
double f = (double)flow->first_seen_ms/1000.0, l = (double)flow->last_seen_ms/1000.0;
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* iat_flow_max */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 595213.3999999999;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = ndpi_data_max(flow->iat_flow);
|
||||
|
||||
/* iat_flow_stddev */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 245377.74799999973;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = ndpi_data_stddev(flow->iat_flow);
|
||||
|
||||
/* pktlen_s_to_c_max */
|
||||
i++;
|
||||
scores[i].lower_bound = 74.0;
|
||||
scores[i].upper_bound = 3380.0;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 70.0;
|
||||
scores[i].upper_bound = 1344.6399999999996;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_stddev */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 944.6399999999996;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = ndpi_data_stddev(flow->pktlen_s_to_c);
|
||||
|
||||
/* duration */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 711.6677598000391;
|
||||
scores[i].weight = 0.16666666666666666;
|
||||
scores[i].value = (l - f);
|
||||
|
||||
// sum = 0.9999999999999999
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Infiltration_score(struct ndpi_flow_info* flow){
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* pktlen_c_to_s_max */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 72.0;
|
||||
scores[i].upper_bound = 1840.739999999998;
|
||||
scores[i].weight = 0.11937557392102846;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_c_to_s);
|
||||
|
||||
/* pktlen_c_to_s_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 70.0;
|
||||
scores[i].upper_bound = 296.56599999999816;
|
||||
scores[i].weight = 0.12526782981328435;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_c_to_s);
|
||||
|
||||
/* pktlen_s_to_c_max */
|
||||
i++;
|
||||
scores[i].lower_bound = 90.0;
|
||||
scores[i].upper_bound = 3496.1399999999776;
|
||||
scores[i].weight = 0.13927150290786652;
|
||||
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
|
||||
|
||||
/* pktlen_s_to_c_avg */
|
||||
i++;
|
||||
scores[i].lower_bound = 72.6;
|
||||
scores[i].upper_bound = 1367.7959999999991;
|
||||
scores[i].weight = 0.12182430364248545;
|
||||
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
|
||||
|
||||
/* src2dst_bytes */
|
||||
i++;
|
||||
scores[i].lower_bound = 144.0;
|
||||
scores[i].upper_bound = 7847.69999999999;
|
||||
scores[i].weight = 0.12059993878175697;
|
||||
scores[i].value = flow->src2dst_bytes;
|
||||
|
||||
/* dst2src_bytes */
|
||||
i++;
|
||||
scores[i].lower_bound = 236.0;
|
||||
scores[i].upper_bound = 74486.7799999998;
|
||||
scores[i].weight = 0.3736608509335782;
|
||||
scores[i].value = flow->dst2src_bytes;
|
||||
|
||||
// sum = 1.0
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
|
||||
double Ssh_patator_score(struct ndpi_flow_info* flow){
|
||||
int n_metrics = 6;
|
||||
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
|
||||
/* fin */
|
||||
int i = 0;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.0033738191632928477;
|
||||
scores[i].value = flow->fin_count;
|
||||
|
||||
/* psh */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 30.0;
|
||||
scores[i].weight = 0.33076923076923076;
|
||||
scores[i].value = flow->psh_count;
|
||||
|
||||
/* c_to_s_syn */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 1.0;
|
||||
scores[i].weight = 0.0004048582995951417;
|
||||
scores[i].value = flow->src2dst_syn_count;
|
||||
|
||||
/* c_to_s_psh */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 12.0;
|
||||
scores[i].weight = 0.33130904183535764;
|
||||
scores[i].value = flow->src2dst_psh_count;
|
||||
|
||||
/* s_to_c_fin */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 2.0;
|
||||
scores[i].weight = 0.0033738191632928477;
|
||||
scores[i].value = flow->dst2src_fin_count;
|
||||
|
||||
/* s_to_c_psh */
|
||||
i++;
|
||||
scores[i].lower_bound = 0.0;
|
||||
scores[i].upper_bound = 30.0;
|
||||
scores[i].weight = 0.33076923076923076;
|
||||
scores[i].value = flow->dst2src_psh_count;
|
||||
|
||||
// sum = 1.0
|
||||
double flow_score = get_flow_score(scores, n_metrics);
|
||||
free(scores);
|
||||
return flow_score;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* intrusion_detection.h
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _INTRUSION_DETECTION_H_
|
||||
#define _INTRUSION_DETECTION_H_
|
||||
|
||||
/*
|
||||
Code to detect attacks reported in
|
||||
|
||||
https://www.unb.ca/cic/datasets/ids-2017.html
|
||||
https://www.unb.ca/cic/datasets/ids-2018.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "reader_util.h"
|
||||
#include "ndpi_api.h"
|
||||
|
||||
typedef struct norm_values{
|
||||
double upper_bound;
|
||||
double lower_bound;
|
||||
double weight;
|
||||
double value;
|
||||
double norm_value;
|
||||
}ndpi_norm_value;
|
||||
|
||||
double normalize(ndpi_norm_value* tresholds);
|
||||
|
||||
double get_flow_score(ndpi_norm_value* scores, int n_metrics);
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
double Ddos_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Dos_goldeneye_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Dos_hulk_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Dos_slow_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Ftp_patator_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Hearthbleed_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Infiltration_score(struct ndpi_flow_info* flow);
|
||||
|
||||
double Ssh_patator_score(struct ndpi_flow_info* flow);
|
||||
|
||||
#endif /* _INTRUSION_DETECTION_H_ */
|
||||
Executable
+136
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2019 - ntop.org
|
||||
#
|
||||
# nDPI is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# nDPI is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# Usage
|
||||
#
|
||||
# 1) Generate a CSV file using the ndpiReader tool. Example:
|
||||
# ./ndpiReader -C sample.json -i sample.pcap
|
||||
#
|
||||
# 2) Open Google Chrome and type in the URL 'chrome://tracing/'
|
||||
#
|
||||
# 3) Inside Chrome click on 'Load' or drop sample.json in the
|
||||
# Chrome window to visualize the output
|
||||
#
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
protos = {}
|
||||
lastId = 1
|
||||
|
||||
def get_timestamp(seen):
|
||||
tok = seen.split(".")
|
||||
return int(tok[0]) * 1000 + int(tok[1])
|
||||
|
||||
def get_record(toks, csv_fields):
|
||||
global protos
|
||||
global lastId
|
||||
|
||||
if len(toks) < 11:
|
||||
return None
|
||||
|
||||
record = dict()
|
||||
ndpiProtocol = toks[10]
|
||||
|
||||
ndpi_protos = ndpiProtocol.split(".")
|
||||
if(len(ndpi_protos) == 1):
|
||||
app_proto = ndpi_protos[0]
|
||||
else:
|
||||
app_proto = ndpi_protos[1]
|
||||
|
||||
id = protos.get(ndpiProtocol)
|
||||
if(id == None):
|
||||
lastId = lastId + 1
|
||||
protos[ndpiProtocol] = lastId
|
||||
id = lastId
|
||||
#print(ndpiProtocol+"="+str(id))
|
||||
|
||||
ip_address = toks[5]
|
||||
server_name = toks[11]
|
||||
record["cat"] = "flow"
|
||||
record["pid"] = ip_address
|
||||
record["tid"] = ndpiProtocol # id
|
||||
record["ts"] = get_timestamp(toks[2])
|
||||
record["ph"] = "X"
|
||||
record["name"] = app_proto
|
||||
|
||||
if(server_name == ""):
|
||||
args = {}
|
||||
else:
|
||||
args = { "name": server_name }
|
||||
record["args"] = args
|
||||
record["dur"] = get_timestamp(toks[3]) - record["ts"]
|
||||
|
||||
# if we do not have the legend we just return
|
||||
if csv_fields is None:
|
||||
return record
|
||||
|
||||
# Otherwise we just add everything we find as a string
|
||||
if(0):
|
||||
idx = 0
|
||||
for tok in toks:
|
||||
name = csv_fields[idx]
|
||||
idx += 1
|
||||
record["args"][name] = str(tok)
|
||||
|
||||
return record
|
||||
|
||||
def get_record_dict(filename):
|
||||
csv_fields = None
|
||||
records = []
|
||||
fin = open(filename, "r");
|
||||
for line in fin:
|
||||
line = line.replace("\n","")
|
||||
|
||||
# Get the legend if present
|
||||
if line[0] == '#':
|
||||
csv_fields = []
|
||||
line = line.replace("#", "")
|
||||
toks = line.split(",")
|
||||
for tok in toks:
|
||||
csv_fields.append(tok)
|
||||
continue
|
||||
|
||||
toks = line.split(",")
|
||||
flow_id = int(toks[0])
|
||||
record = get_record(toks, csv_fields)
|
||||
if record is None:
|
||||
print("Error while parsing " + line)
|
||||
continue
|
||||
|
||||
records.append(record)
|
||||
|
||||
json_dict = dict()
|
||||
json_dict["traceEvents"] = records
|
||||
|
||||
return json_dict
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
print("ndpi2json <csv_file> <json_file>")
|
||||
sys.exit(0)
|
||||
|
||||
record_dict = get_record_dict(sys.argv[1])
|
||||
#print(record_dict)
|
||||
#json_string = json.dumps(json_dict)
|
||||
#print(json_string)
|
||||
|
||||
with open(sys.argv[2], 'w') as fp:
|
||||
json.dump(record_dict, fp)
|
||||
print("Written " + str(len(record_dict["traceEvents"])) + " records")
|
||||
+849
-1462
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+22
-9
@@ -10,19 +10,32 @@ tcp:3000@ntop
|
||||
# Format:
|
||||
# host:"<value>",host:"<value>",.....@<subproto>
|
||||
|
||||
host:"googlesyndication.com"@Google
|
||||
host:"venere.com"@Venere
|
||||
host:"kataweb.it",host:"repubblica.it"@Repubblica
|
||||
host:"ntop"@ntop
|
||||
host:"atv-ext.amazon.com",host:"*.api.amazon.com",host:"*.api.amazonvideo.com"@AmazonVideo
|
||||
host:"*.amazonaws.com"@AmazonVideo
|
||||
host:"*.netflix.com"@Netflix
|
||||
host:"disneyplus.com"host:"cdn.registerdisney.go.com",host:"disney-portal.my.onetrust.com",host:"disneyplus.bn5x.net",host:"disney-plus.net"@DisneyPlus
|
||||
host:"*.lvlt.dash.us.aiv-cdn.net.c.footprint.net"@AmazonVideo
|
||||
host:"api-global.netflix.com"@Netflix
|
||||
# IP based Subprotocols
|
||||
# Format:
|
||||
# ip:<value>,ip:<value>,.....@<subproto>
|
||||
|
||||
ip:213.75.170.11@CustomProtocol
|
||||
ip:8.248.73.247@AmazonPrime
|
||||
#
|
||||
# NOTES
|
||||
# 1) the port of a custom protocol is optional but if
|
||||
# specified it must match the port.
|
||||
# 2) you can specify up to 1 port per IP address
|
||||
# 3) if you specify a custom ip:<IP>:<PORT> rule,
|
||||
# even if the <PORT> doesn't match the <IP>
|
||||
# (if best match during the search) will
|
||||
# have priority as best match. Example if
|
||||
# you specify a <Google IP>:<port 9999> and
|
||||
# in your traffic have match for such IP but
|
||||
# with a port other than 9999, the IP address
|
||||
# begin a best match will hve preference over
|
||||
# <Google IP> so this protocol will not be
|
||||
# detected as <L7 proto>.Google but only
|
||||
# as <L7 proto>
|
||||
#
|
||||
|
||||
ip:213.75.170.11/32:443@CustomProtocol
|
||||
ip:8.248.73.247:443@AmazonPrime
|
||||
ip:54.80.47.130@AmazonPrime
|
||||
|
||||
|
||||
+646
-270
File diff suppressed because it is too large
Load Diff
+65
-21
@@ -31,7 +31,9 @@
|
||||
|
||||
#include "uthash.h"
|
||||
#include <pcap.h>
|
||||
#include "ndpi_includes.h"
|
||||
#include "ndpi_classify.h"
|
||||
#include "ndpi_typedefs.h"
|
||||
|
||||
#ifdef USE_DPDK
|
||||
#include <rte_eal.h>
|
||||
@@ -49,6 +51,7 @@
|
||||
#define PREFETCH_OFFSET 3
|
||||
|
||||
extern int dpdk_port_init(int port, struct rte_mempool *mbuf_pool);
|
||||
extern int dpdk_port_deinit(int port);
|
||||
#endif
|
||||
|
||||
/* ETTA Spec defiintions for feature readiness */
|
||||
@@ -93,7 +96,7 @@ typedef struct ndpi_ja3_info {
|
||||
|
||||
// external hash table (host ip -> <ip string, hash table ja3c, hash table ja3s>)
|
||||
// used to aggregate ja3 fingerprints by hosts
|
||||
typedef struct ndpi_host_ja3_fingerprints{
|
||||
typedef struct ndpi_host_ja3_fingerprints {
|
||||
u_int32_t ip;
|
||||
char *ip_string;
|
||||
char *dns_name;
|
||||
@@ -126,13 +129,13 @@ struct flow_metrics {
|
||||
|
||||
struct ndpi_entropy {
|
||||
// Entropy fields
|
||||
struct timeval src2dst_last_pkt_time, dst2src_last_pkt_time, flow_last_pkt_time;
|
||||
pkt_timeval src2dst_last_pkt_time, dst2src_last_pkt_time, flow_last_pkt_time;
|
||||
u_int16_t src2dst_pkt_len[MAX_NUM_PKTS]; /*!< array of packet appdata lengths */
|
||||
struct timeval src2dst_pkt_time[MAX_NUM_PKTS]; /*!< array of arrival times */
|
||||
pkt_timeval src2dst_pkt_time[MAX_NUM_PKTS]; /*!< array of arrival times */
|
||||
u_int16_t dst2src_pkt_len[MAX_NUM_PKTS]; /*!< array of packet appdata lengths */
|
||||
struct timeval dst2src_pkt_time[MAX_NUM_PKTS]; /*!< array of arrival times */
|
||||
struct timeval src2dst_start; /*!< first packet arrival time */
|
||||
struct timeval dst2src_start; /*!< first packet arrival time */
|
||||
pkt_timeval dst2src_pkt_time[MAX_NUM_PKTS]; /*!< array of arrival times */
|
||||
pkt_timeval src2dst_start; /*!< first packet arrival time */
|
||||
pkt_timeval dst2src_start; /*!< first packet arrival time */
|
||||
u_int32_t src2dst_opackets; /*!< non-zero packet counts */
|
||||
u_int32_t dst2src_opackets; /*!< non-zero packet counts */
|
||||
u_int16_t src2dst_pkt_count; /*!< packet counts */
|
||||
@@ -160,49 +163,78 @@ typedef struct ndpi_flow_info {
|
||||
u_int16_t dst_port;
|
||||
u_int8_t detection_completed, protocol, bidirectional, check_extra_packets;
|
||||
u_int16_t vlan_id;
|
||||
ndpi_packet_tunnel tunnel_type;
|
||||
struct ndpi_flow_struct *ndpi_flow;
|
||||
char src_name[48], dst_name[48];
|
||||
u_int8_t ip_version;
|
||||
u_int64_t first_seen, last_seen;
|
||||
u_int32_t cwr_count, src2dst_cwr_count, dst2src_cwr_count;
|
||||
u_int32_t ece_count, src2dst_ece_count, dst2src_ece_count;
|
||||
u_int32_t urg_count, src2dst_urg_count, dst2src_urg_count;
|
||||
u_int32_t ack_count, src2dst_ack_count, dst2src_ack_count;
|
||||
u_int32_t psh_count, src2dst_psh_count, dst2src_psh_count;
|
||||
u_int32_t syn_count, src2dst_syn_count, dst2src_syn_count;
|
||||
u_int32_t fin_count, src2dst_fin_count, dst2src_fin_count;
|
||||
u_int32_t rst_count, src2dst_rst_count, dst2src_rst_count;
|
||||
u_int32_t c_to_s_init_win, s_to_c_init_win;
|
||||
u_int64_t first_seen_ms, last_seen_ms;
|
||||
u_int64_t src2dst_bytes, dst2src_bytes;
|
||||
u_int64_t src2dst_goodput_bytes, dst2src_goodput_bytes;
|
||||
u_int32_t src2dst_packets, dst2src_packets;
|
||||
u_int32_t has_human_readeable_strings;
|
||||
char human_readeable_string_buffer[32];
|
||||
|
||||
|
||||
// result only, not used for flow identification
|
||||
ndpi_protocol detected_protocol;
|
||||
|
||||
// Flow data analysis
|
||||
struct ndpi_analyze_struct *iat_c_to_s, *iat_s_to_c, *iat_flow,
|
||||
*pktlen_c_to_s, *pktlen_s_to_c;
|
||||
|
||||
char info[96];
|
||||
char host_server_name[256];
|
||||
|
||||
char info[160];
|
||||
char flow_extra_info[16];
|
||||
char host_server_name[240];
|
||||
char bittorent_hash[41];
|
||||
char dhcp_fingerprint[48];
|
||||
|
||||
ndpi_risk risk;
|
||||
|
||||
struct {
|
||||
u_int16_t ssl_version;
|
||||
char client_info[64], server_info[64],
|
||||
client_hassh[33], server_hassh[33],
|
||||
server_organization[64],
|
||||
char client_requested_server_name[64], server_info[64],
|
||||
client_hassh[33], server_hassh[33], *server_names,
|
||||
*tls_alpn, *tls_supported_versions,
|
||||
*tls_issuerDN, *tls_subjectDN,
|
||||
ja3_client[33], ja3_server[33],
|
||||
sha1_cert_fingerprint[20];
|
||||
u_int8_t sha1_cert_fingerprint_set;
|
||||
struct {
|
||||
u_int16_t cipher_suite;
|
||||
char *esni;
|
||||
} encrypted_sni;
|
||||
time_t notBefore, notAfter;
|
||||
u_int16_t server_cipher;
|
||||
ndpi_cipher_weakness client_unsafe_cipher, server_unsafe_cipher;
|
||||
ndpi_cipher_weakness client_unsafe_cipher, server_unsafe_cipher;
|
||||
} ssh_tls;
|
||||
|
||||
struct {
|
||||
char url[256];
|
||||
char url[256], content_type[64], user_agent[128];
|
||||
u_int response_status_code;
|
||||
} http;
|
||||
|
||||
|
||||
struct {
|
||||
char username[32], password[32];
|
||||
} telnet;
|
||||
|
||||
void *src_id, *dst_id;
|
||||
|
||||
struct ndpi_entropy entropy;
|
||||
struct ndpi_entropy last_entropy;
|
||||
|
||||
|
||||
/* Payload lenght bins */
|
||||
#ifdef DIRECTION_BINS
|
||||
struct ndpi_bin payload_len_bin_src2dst, payload_len_bin_dst2src;
|
||||
#else
|
||||
struct ndpi_bin payload_len_bin;
|
||||
#endif
|
||||
} ndpi_flow_info_t;
|
||||
|
||||
|
||||
@@ -277,7 +309,8 @@ void ndpi_free_flow_info_half(struct ndpi_flow_info *flow);
|
||||
/* Process a packet and update the workflow */
|
||||
struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
|
||||
const struct pcap_pkthdr *header,
|
||||
const u_char *packet);
|
||||
const u_char *packet,
|
||||
FILE * csv_fp);
|
||||
|
||||
|
||||
/* flow callbacks for complete detected flow
|
||||
@@ -296,12 +329,23 @@ static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow *
|
||||
|
||||
/* compare two nodes in workflow */
|
||||
int ndpi_workflow_node_cmp(const void *a, const void *b);
|
||||
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
|
||||
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow, FILE * csv_fp);
|
||||
u_int32_t ethernet_crc32(const void* data, size_t n_bytes);
|
||||
void ndpi_flow_info_free_data(struct ndpi_flow_info *flow);
|
||||
void ndpi_flow_info_freer(void *node);
|
||||
const char* print_cipher_id(u_int32_t cipher);
|
||||
float ndpi_flow_get_byte_count_entropy(const uint32_t byte_count[256], unsigned int num_bytes);
|
||||
|
||||
extern int nDPI_LogLevel;
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
#define LOG(log_level, args...) \
|
||||
{ \
|
||||
if(log_level <= nDPI_LogLevel) \
|
||||
printf(args); \
|
||||
}
|
||||
#else
|
||||
#define LOG(...) {}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
bin_PROGRAMS = fuzz_process_packet fuzz_ndpi_reader fuzz_ndpi_reader_with_main
|
||||
|
||||
fuzz_process_packet_SOURCES = fuzz_process_packet.c
|
||||
fuzz_process_packet_CFLAGS =
|
||||
fuzz_process_packet_LDADD = ../src/lib/libndpi.a
|
||||
fuzz_process_packet_LDFLAGS = $(ADDITIONAL_LIBS) $(LIBS)
|
||||
if HAS_FUZZLDFLAGS
|
||||
fuzz_process_packet_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_process_packet_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
endif
|
||||
# force usage of CXX for linker
|
||||
fuzz_process_packet_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_process_packet_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
fuzz_ndpi_reader_SOURCES = fuzz_ndpi_reader.c
|
||||
fuzz_ndpi_reader_CFLAGS = -I../example/
|
||||
fuzz_ndpi_reader_LDADD = ../src/lib/libndpi.a
|
||||
fuzz_ndpi_reader_LDFLAGS = ../example/libndpiReader.a $(PCAP_LIB) $(ADDITIONAL_LIBS) $(LIBS)
|
||||
if HAS_FUZZLDFLAGS
|
||||
fuzz_ndpi_reader_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_ndpi_reader_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
endif
|
||||
# force usage of CXX for linker
|
||||
fuzz_ndpi_reader_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_ndpi_reader_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
fuzz_ndpi_reader_with_main_SOURCES = fuzz_ndpi_reader.c
|
||||
fuzz_ndpi_reader_with_main_CFLAGS = -I../example/ -DBUILD_MAIN
|
||||
fuzz_ndpi_reader_with_main_LDADD = ../src/lib/libndpi.a
|
||||
fuzz_ndpi_reader_with_main_LDFLAGS = ../example/libndpiReader.a $(PCAP_LIB) $(ADDITIONAL_LIBS) $(LIBS)
|
||||
# force usage of CXX for linker
|
||||
fuzz_ndpi_reader_with_main_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_ndpi_reader_with_main_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
# required for Google oss-fuzz
|
||||
# see https://github.com/google/oss-fuzz/tree/master/projects/ndpi
|
||||
testpcaps := $(wildcard ../tests/pcap/*.pcap)
|
||||
|
||||
fuzz_ndpi_reader_seed_corpus.zip: $(testpcaps)
|
||||
zip -r fuzz_ndpi_reader_seed_corpus.zip $(testpcaps)
|
||||
@@ -0,0 +1,163 @@
|
||||
#include "reader_util.h"
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#include <pcap/pcap.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct ndpi_workflow_prefs *prefs = NULL;
|
||||
|
||||
int nDPI_LogLevel = 0;
|
||||
char *_debug_protocols = NULL;
|
||||
u_int32_t current_ndpi_memory = 0, max_ndpi_memory = 0;
|
||||
u_int8_t enable_protocol_guess = 1, enable_payload_analyzer = 0;
|
||||
u_int8_t enable_joy_stats = 0;
|
||||
u_int8_t human_readeable_string_len = 5;
|
||||
u_int8_t max_num_udp_dissected_pkts = 16 /* 8 is enough for most protocols, Signal requires more */, max_num_tcp_dissected_pkts = 80 /* due to telnet */;
|
||||
|
||||
int bufferToFile(const char * name, const uint8_t *Data, size_t Size) {
|
||||
FILE * fd;
|
||||
if (remove(name) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror("remove failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
fd = fopen(name, "wb");
|
||||
if (fd == NULL) {
|
||||
perror("open failed");
|
||||
return -2;
|
||||
}
|
||||
if (fwrite (Data, 1, Size, fd) != Size) {
|
||||
fclose(fd);
|
||||
return -3;
|
||||
}
|
||||
fclose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
pcap_t * pkts;
|
||||
const u_char *pkt;
|
||||
struct pcap_pkthdr *header;
|
||||
int r;
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
char * pcap_path = tempnam("/tmp", "fuzz-ndpi-reader");
|
||||
|
||||
if (prefs == NULL) {
|
||||
prefs = calloc(sizeof(struct ndpi_workflow_prefs), 1);
|
||||
if (prefs == NULL) {
|
||||
//should not happen
|
||||
return 1;
|
||||
}
|
||||
prefs->decode_tunnels = 1;
|
||||
prefs->num_roots = 16;
|
||||
prefs->max_ndpi_flows = 1024;
|
||||
prefs->quiet_mode = 0;
|
||||
}
|
||||
bufferToFile(pcap_path, Data, Size);
|
||||
|
||||
pkts = pcap_open_offline(pcap_path, errbuf);
|
||||
if (pkts == NULL) {
|
||||
remove(pcap_path);
|
||||
free(pcap_path);
|
||||
return 0;
|
||||
}
|
||||
struct ndpi_workflow * workflow = ndpi_workflow_init(prefs, pkts);
|
||||
// enable all protocols
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(workflow->ndpi_struct, &all);
|
||||
memset(workflow->stats.protocol_counter, 0,
|
||||
sizeof(workflow->stats.protocol_counter));
|
||||
memset(workflow->stats.protocol_counter_bytes, 0,
|
||||
sizeof(workflow->stats.protocol_counter_bytes));
|
||||
memset(workflow->stats.protocol_flows, 0,
|
||||
sizeof(workflow->stats.protocol_flows));
|
||||
ndpi_finalize_initalization(workflow->ndpi_struct);
|
||||
|
||||
r = pcap_next_ex(pkts, &header, &pkt);
|
||||
while (r > 0) {
|
||||
if(header->caplen >= 42 /* ARP+ size */) {
|
||||
/* allocate an exact size buffer to check overflows */
|
||||
uint8_t *packet_checked = malloc(header->caplen);
|
||||
|
||||
if(packet_checked) {
|
||||
memcpy(packet_checked, pkt, header->caplen);
|
||||
ndpi_workflow_process_packet(workflow, header, packet_checked, NULL);
|
||||
free(packet_checked);
|
||||
}
|
||||
}
|
||||
|
||||
r = pcap_next_ex(pkts, &header, &pkt);
|
||||
}
|
||||
ndpi_workflow_free(workflow);
|
||||
pcap_close(pkts);
|
||||
|
||||
remove(pcap_path);
|
||||
free(pcap_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BUILD_MAIN
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
FILE * pcap_file;
|
||||
long pcap_file_size;
|
||||
uint8_t * pcap_buffer;
|
||||
int test_retval;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s: [pcap-file]\n",
|
||||
(argc > 0 ? argv[0] : "fuzz_ndpi_reader_with_main"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
pcap_file = fopen(argv[1], "r");
|
||||
if (pcap_file == NULL) {
|
||||
perror("fopen failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fseek(pcap_file, 0, SEEK_END) != 0) {
|
||||
perror("fseek(SEEK_END) failed");
|
||||
fclose(pcap_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pcap_file_size = ftell(pcap_file);
|
||||
if (pcap_file_size < 0) {
|
||||
perror("ftell failed");
|
||||
fclose(pcap_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fseek(pcap_file, 0, SEEK_SET) != 0) {
|
||||
perror("fseek(0, SEEK_SET) failed");
|
||||
fclose(pcap_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pcap_buffer = malloc(pcap_file_size);
|
||||
if (pcap_buffer == NULL) {
|
||||
perror("malloc failed");
|
||||
fclose(pcap_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fread(pcap_buffer, sizeof(*pcap_buffer), pcap_file_size, pcap_file) != pcap_file_size) {
|
||||
perror("fread failed");
|
||||
fclose(pcap_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_retval = LLVMFuzzerTestOneInput(pcap_buffer, pcap_file_size);
|
||||
fclose(pcap_file);
|
||||
free(pcap_buffer);
|
||||
|
||||
return test_retval;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct ndpi_detection_module_struct *ndpi_info_mod = NULL;
|
||||
struct ndpi_id_struct *src;
|
||||
struct ndpi_id_struct *dst;
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
if (ndpi_info_mod == NULL) {
|
||||
ndpi_info_mod = ndpi_init_detection_module(ndpi_no_prefs);
|
||||
NDPI_PROTOCOL_BITMASK all;
|
||||
NDPI_BITMASK_SET_ALL(all);
|
||||
ndpi_set_protocol_detection_bitmask2(ndpi_info_mod, &all);
|
||||
src = ndpi_malloc(SIZEOF_ID_STRUCT);
|
||||
dst = ndpi_malloc(SIZEOF_ID_STRUCT);
|
||||
}
|
||||
|
||||
struct ndpi_flow_struct *ndpi_flow = ndpi_flow_malloc(SIZEOF_FLOW_STRUCT);
|
||||
memset(ndpi_flow, 0, SIZEOF_FLOW_STRUCT);
|
||||
memset(src, 0, SIZEOF_ID_STRUCT);
|
||||
memset(dst, 0, SIZEOF_ID_STRUCT);
|
||||
ndpi_detection_process_packet(ndpi_info_mod, ndpi_flow, Data, Size, 0, src, dst);
|
||||
ndpi_free_flow(ndpi_flow);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -6,5 +6,5 @@ includedir=@includedir@
|
||||
Name: libndpi
|
||||
Description: deep packet inspection library
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lndpi
|
||||
Libs: -L${libdir} -lndpi @ADDITIONAL_LIBS@
|
||||
Cflags: -I${includedir}/ndpi
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check whether the given FLAG works with the current language's compiler
|
||||
# or gives an error. (Warnings, however, are ignored)
|
||||
#
|
||||
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||
# success/failure.
|
||||
#
|
||||
# If EXTRA-FLAGS is defined, it is added to the current language's default
|
||||
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
|
||||
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
|
||||
# force the compiler to issue an error when a bad flag is given.
|
||||
#
|
||||
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
|
||||
#
|
||||
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
|
||||
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
||||
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 6
|
||||
|
||||
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
|
||||
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
|
||||
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
|
||||
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
|
||||
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
|
||||
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
|
||||
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
|
||||
[AS_VAR_SET(CACHEVAR,[yes])],
|
||||
[AS_VAR_SET(CACHEVAR,[no])])
|
||||
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
|
||||
AS_VAR_IF(CACHEVAR,yes,
|
||||
[m4_default([$2], :)],
|
||||
[m4_default([$3], :)])
|
||||
AS_VAR_POPDEF([CACHEVAR])dnl
|
||||
])dnl AX_CHECK_COMPILE_FLAGS
|
||||
@@ -1,22 +1,22 @@
|
||||
#
|
||||
# Copyright (C) 2018 - ntop.org
|
||||
# Copyright (C) 2018-20 - ntop.org
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libndpi
|
||||
PKG_VERSION:=1333.ab2f3ce
|
||||
PKG_VERSION:=17022020
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/ntop/nDPI.git
|
||||
PKG_SOURCE_VERSION:=ab2f3cefc89017d73e67faa4eb4011e7e3f2044d
|
||||
PKG_SOURCE_VERSION:=1f921562d1d7962f1d23ca5b59c25f9b65073460
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
PKG_MAINTAINER:=Emanuele Faranda <faranda@ntop.org>
|
||||
PKG_MAINTAINER:=Luca Deri <deri@ntop.org>
|
||||
PKG_LICENSE:=GPL3
|
||||
PKG_BUILD_DEPENDS:=+libpcap
|
||||
PKG_BUILD_DEPENDS:=
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
# autogen fix
|
||||
@@ -27,7 +27,6 @@ include $(INCLUDE_DIR)/package.mk
|
||||
define Package/libndpi
|
||||
SECTION:=network
|
||||
CATEGORY:=Network
|
||||
#DEPENDS:=+libc +libjson-c +libpthread
|
||||
TITLE:=nDPI Deep Packet Inspection Library
|
||||
URL:=https://www.ntop.org
|
||||
endef
|
||||
@@ -37,8 +36,7 @@ define Package/libndpi/description
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--with-pic \
|
||||
--disable-json-c \
|
||||
--with-only-libndpi
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
Howto Compile lindpi on OpenWRT
|
||||
-------------------------------
|
||||
|
||||
cd myopenwrt_directory
|
||||
mkdir package/network/services/libndpi
|
||||
cd package/network/services/libndpi
|
||||
cp ~/nDPI/packages/openwrt/Makefile .
|
||||
cd myopenwrt_directory
|
||||
make menuconfig
|
||||
|
||||
Go under network and select
|
||||
|
||||
<M> libndpi.............................. nDPI Deep Packet Inspection Library
|
||||
|
||||
|
||||
Build Commands
|
||||
--------------
|
||||
|
||||
If you want to build just libndpi do:
|
||||
make -j1 V=s package/network/services/libndpi/clean
|
||||
make -j1 V=s package/network/services/libndpi/compile
|
||||
|
||||
Other Documents
|
||||
---------------
|
||||
https://openwrt.org/packages/pkgdata/libndpi
|
||||
@@ -29,8 +29,8 @@ build-rpm: build-src cleanup-rpm
|
||||
tar cvfz $(HOME)/rpmbuild/SOURCES/ndpi-@PACKAGE_VERSION@.tgz ndpi-@PACKAGE_VERSION@
|
||||
@rm -f $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE)
|
||||
@rpmbuild -bb ./$(APPL).spec --define "buildnumber $(GIT_REVISION)"
|
||||
@if [[ $EUID -ne 0 ]]; then ./rpm-sign.exp $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE); fi
|
||||
@if [[ $EUID -ne 0 ]]; then ./rpm-sign.exp $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(DEV_PACKAGE); fi
|
||||
@if [[ $EUID -ne 0 ]]; then @RPM_SIGN_CMD@ $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE); fi
|
||||
@if [[ $EUID -ne 0 ]]; then @RPM_SIGN_CMD@ $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(DEV_PACKAGE); fi
|
||||
@echo ""
|
||||
@echo "Package contents:"
|
||||
@rpm -qpl $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE)
|
||||
|
||||
Vendored
+12
@@ -583,6 +583,7 @@ PACKAGE_URL=''
|
||||
|
||||
ac_subst_vars='LTLIBOBJS
|
||||
LIBOBJS
|
||||
RPM_SIGN_CMD
|
||||
MAJOR_RELEASE
|
||||
GIT_REVISION
|
||||
KERNEL
|
||||
@@ -1698,6 +1699,16 @@ PACKAGE_VERSION=`../version.sh --release`
|
||||
MAJOR_RELEASE=`../version.sh --major-release`
|
||||
GIT_REVISION=`../version.sh --revision`
|
||||
|
||||
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 3|cut -d '.' -f 1`
|
||||
if test $CENTOS_RELEASE = "release"; then
|
||||
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 4|cut -d '.' -f 1`
|
||||
fi
|
||||
|
||||
RPM_SIGN_CMD="rpm --addsign"
|
||||
if test "$CENTOS_RELEASE" -ne 8; then
|
||||
RPM_SIGN_CMD="./rpm-sign.exp"
|
||||
fi
|
||||
|
||||
ac_config_files="$ac_config_files Makefile ndpi.spec"
|
||||
|
||||
|
||||
@@ -1710,6 +1721,7 @@ ac_config_files="$ac_config_files Makefile ndpi.spec"
|
||||
|
||||
|
||||
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
# tests run on this system so they can be shared between configure
|
||||
|
||||
@@ -29,6 +29,16 @@ PACKAGE_VERSION=`../version.sh --release`
|
||||
MAJOR_RELEASE=`../version.sh --major-release`
|
||||
GIT_REVISION=`../version.sh --revision`
|
||||
|
||||
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 3|cut -d '.' -f 1`
|
||||
if test $CENTOS_RELEASE = "release"; then
|
||||
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 4|cut -d '.' -f 1`
|
||||
fi
|
||||
|
||||
RPM_SIGN_CMD="rpm --addsign"
|
||||
if test "$CENTOS_RELEASE" -ne 8; then
|
||||
RPM_SIGN_CMD="./rpm-sign.exp"
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([Makefile ndpi.spec])
|
||||
|
||||
AC_SUBST(PACKAGE_VERSION)
|
||||
@@ -39,6 +49,7 @@ AC_SUBST(DATE)
|
||||
AC_SUBST(KERNEL)
|
||||
AC_SUBST(GIT_REVISION)
|
||||
AC_SUBST(MAJOR_RELEASE)
|
||||
AC_SUBST(RPM_SIGN_CMD)
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||
%{?el6:Requires: glibc >= 2.3.4 numactl coreutils }
|
||||
AutoReqProv: no
|
||||
|
||||
%define debug_package %{nil}
|
||||
|
||||
%description
|
||||
nDPI Open and Extensible LGPLv3 Deep Packet Inspection Library.
|
||||
|
||||
@@ -75,6 +77,8 @@ rm -fr $RPM_BUILD_ROOT
|
||||
/usr/local/lib/libndpi.so.@MAJOR_RELEASE@
|
||||
/usr/local/lib/libndpi.so.@PACKAGE_VERSION@
|
||||
/usr/local/bin/ndpiReader
|
||||
/usr/local/share/ndpi/ndpiCustomCategory.txt
|
||||
/usr/local/share/ndpi/ndpiProtos.txt
|
||||
/etc/ld.so.conf.d/ndpi.conf
|
||||
%{libdir}/pkgconfig/libndpi.pc
|
||||
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
CC=@CC@
|
||||
CFLAGS=-I. -I../src/include -I./src/lib/third_party/include -shared -Wl,
|
||||
CFLAGS=-I. -I../src/include -I./src/lib/third_party/include @CFLAGS@ @CUSTOM_NDPI@ -shared
|
||||
#LIBNDPI=../src/lib/libndpi.so.@NDPI_VERSION_SHORT@
|
||||
LIBNDPI=../src/lib/libndpi.a
|
||||
LDFLAGS=$(CFILE) $(LIBNDPI) -lpcap
|
||||
LDFLAGS=$(CFILE) $(LIBNDPI) -lpcap @ADDITIONAL_LIBS@
|
||||
SHARE = -soname,ndpi_wrap
|
||||
SO=ndpi_wrap.so
|
||||
OBJS = ndpi_wrap.o
|
||||
@@ -19,7 +19,7 @@ endif
|
||||
all: $(SO)
|
||||
|
||||
$(SO): $(CFILE) $(LIBNDPI) Makefile
|
||||
$(CC) $(CFLAGS)$(SHARE) -o $@ $(PIC) $(LDFLAGS)
|
||||
$(CC) $(CFLAGS) -Wl,$(SHARE) -o $@ $(PIC) $(LDFLAGS)
|
||||
# ln -s $(LIBNDPI) .
|
||||
|
||||
clean:
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
This direcgory contains the Python bindings for nDPI
|
||||
|
||||
Usage:
|
||||
- python3 ndpi_example.py <interface>
|
||||
- python3 ndpi_example.py <pcap_file>
|
||||
|
||||
Code courtesy of Massimo Puddu
|
||||
@@ -0,0 +1,43 @@
|
||||
nDPI Python bindings
|
||||
--------------------
|
||||
|
||||
This directory contains the Python3 bindings for nDPI. We provide both cffi and ctypes based bindings.
|
||||
|
||||
**cffi bindings**
|
||||
|
||||
Files:
|
||||
|
||||
* ndpi.py
|
||||
|
||||
Example (using `nfstream <https://github.com/aouinizied/nfstream>`_ package):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip3 install nfstream
|
||||
python3 flow_printer.py <interface>
|
||||
python3 flow_printer.py <pcap_file>
|
||||
|
||||
Code courtesy:
|
||||
|
||||
* Zied Aouini
|
||||
|
||||
**ctypes bindings**
|
||||
|
||||
Files:
|
||||
|
||||
* ndpi_typestruct.py
|
||||
* ndpi_wrap.c
|
||||
* Makefile.in
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip3 install scapy
|
||||
python3 ndpi_example.py <interface>
|
||||
python3 ndpi_example.py <pcap_file>
|
||||
|
||||
Code courtesy:
|
||||
|
||||
* Massimo Puddu
|
||||
* Zied Aouini
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
flow_printer.py
|
||||
Copyright (C) 2019-20 - NFStream Developers
|
||||
This file is part of NFStream, a Flexible Network Data Analysis Framework (https://www.nfstream.org/).
|
||||
NFStream is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
NFStream is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public License along with NFStream.
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
from nfstream import NFStreamer
|
||||
import sys
|
||||
|
||||
# Example must run with nfstream >= 6.1.1
|
||||
path = sys.argv[1]
|
||||
flow_streamer = NFStreamer(source=path, statistical_analysis=False, performance_report=1)
|
||||
result = {}
|
||||
try:
|
||||
for flow in flow_streamer:
|
||||
print(flow)
|
||||
try:
|
||||
result[flow.application_name] += flow.bidirectional_packets
|
||||
except KeyError:
|
||||
result[flow.application_name] = flow.bidirectional_packets
|
||||
print("\nSummary (Application Name: Packets):")
|
||||
print(result)
|
||||
except KeyboardInterrupt:
|
||||
print("\nSummary (Application Name: Packets):")
|
||||
print(result)
|
||||
print("Terminated.")
|
||||
+1459
File diff suppressed because it is too large
Load Diff
+88
-67
@@ -1,43 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# ndpi_example.py
|
||||
#
|
||||
# Copyright (C) 2011-19 - ntop.org
|
||||
#
|
||||
# nDPI is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# nDPI is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
file: ndpi_example.py
|
||||
This file is part of nDPI.
|
||||
|
||||
Copyright (C) 2011-19 - ntop.org
|
||||
Copyright (C) 2019 - Zied Aouini <aouinizied@gmail.com> (Incremental improvements)
|
||||
|
||||
nDPI is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
nDPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with nDPI.
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from ndpi_typestruct import *
|
||||
from ctypes import *
|
||||
from scapy.all import *
|
||||
|
||||
import sys
|
||||
|
||||
# ------- return type & pcapstruct to declare -------
|
||||
|
||||
|
||||
class workflow(Structure):
|
||||
class WorkFlow(Structure):
|
||||
_fields_ = [("src_ip", c_uint32),
|
||||
("dst_ip", c_uint32),
|
||||
("src_port", c_uint16),
|
||||
("dst_port", c_uint16),
|
||||
("protocol", c_uint8),
|
||||
("packets", c_uint32),
|
||||
("detected_protocol", ndpi_protocol),
|
||||
("detected_protocol", NDPIProtocol),
|
||||
("detection_completed", c_uint8),
|
||||
("id", c_uint32),
|
||||
("src_id", POINTER(ndpi_id_struct)),
|
||||
("dst_id", POINTER(ndpi_id_struct)),
|
||||
("flow", POINTER(ndpi_flow_struct))]
|
||||
("src_id", POINTER(NDPIIdStruct)),
|
||||
("dst_id", POINTER(NDPIIdStruct)),
|
||||
("flow", POINTER(NDPIFlowStruct))]
|
||||
|
||||
|
||||
CMCFUN = CFUNCTYPE(c_int, c_void_p, c_void_p)
|
||||
@@ -48,17 +49,19 @@ FREE = CFUNCTYPE(None, c_void_p)
|
||||
def node_proto_guess_walker(nodo, which, depth, user_data):
|
||||
global ndpi_info_mod
|
||||
|
||||
flow = cast(nodo, POINTER(POINTER(workflow))).contents.contents
|
||||
if which == 0 or which == 3: #execute only preorder operation of the tree
|
||||
flow = cast(nodo, POINTER(POINTER(WorkFlow))).contents.contents
|
||||
if which == 0 or which == 3: # execute only preorder operation of the tree
|
||||
if flow.detection_completed == 0: # order for tree operation
|
||||
flow.detected_protocol = ndpi.ndpi_detection_giveup(ndpi_info_mod, flow.flow, flow.protocol,
|
||||
int(socket.ntohl(flow.src_ip)), 1)
|
||||
flow.detected_protocol = ndpi.ndpi_detection_giveup(ndpi_info_mod,
|
||||
flow.flow,
|
||||
1,
|
||||
cast(addressof(c_uint8(0)), POINTER(c_uint8)))
|
||||
count_protocol[flow.detected_protocol.app_protocol] += flow.packets
|
||||
|
||||
|
||||
def py_cmp_fun(a, b):
|
||||
fa = cast(a, POINTER(workflow))
|
||||
fb = cast(b, POINTER(workflow))
|
||||
fa = cast(a, POINTER(WorkFlow))
|
||||
fb = cast(b, POINTER(WorkFlow))
|
||||
|
||||
if fa.contents.src_ip < fb.contents.src_ip: return -1
|
||||
elif fa.contents.src_ip > fb.contents.src_ip: return 1
|
||||
@@ -83,7 +86,7 @@ free_walk = FREE(freer)
|
||||
|
||||
# --------------------------------------
|
||||
|
||||
# number of anylized packet
|
||||
# number of analyzed packet
|
||||
packet_number = 0
|
||||
flow_count = 0
|
||||
max_num_udp_dissected_pkts = 16
|
||||
@@ -103,6 +106,8 @@ if ndpi.ndpi_get_api_version() != ndpi.ndpi_wrap_get_api_version():
|
||||
ndpi_info_mod = ndpi.ndpi_init_detection_module()
|
||||
if ndpi_info_mod is None:
|
||||
sys.exit(-1)
|
||||
else:
|
||||
ndpi_ndpi_finalize_initalization(ndpi_info_mod)
|
||||
|
||||
|
||||
def ip2int(ip):
|
||||
@@ -113,30 +118,34 @@ def ip2int(ip):
|
||||
return int(struct.unpack("!I", packedIP)[0])
|
||||
|
||||
|
||||
def get_flow(packet):
|
||||
def get_flow(pkt):
|
||||
global flows_root
|
||||
global flows_root_ref
|
||||
global flow_count
|
||||
|
||||
ip_packet = packet[1]
|
||||
ip_packet = pkt[1]
|
||||
ip_protocol = ip_packet.proto
|
||||
transport_packet = None
|
||||
|
||||
if ip_protocol == 6 or ip_protocol == 17: transport_packet = packet[2]
|
||||
if ip_protocol == 6 or ip_protocol == 17:
|
||||
transport_packet = pkt[2]
|
||||
if transport_packet is not None:
|
||||
# to avoid two nodes in one binary tree for a flow
|
||||
ip_src = ip2int(ip_packet.src)
|
||||
ip_dst = ip2int(ip_packet.dst)
|
||||
src_port = transport_packet.sport
|
||||
dst_port = transport_packet.dport
|
||||
else: return None
|
||||
# set flows to correct type and data
|
||||
ndpi_flow = pointer(ndpi_flow_struct())
|
||||
memset(ndpi_flow, 0, sizeof(ndpi_flow_struct))
|
||||
if ip_src > ip_dst:
|
||||
flow = workflow(ip_src, ip_dst, src_port, dst_port, int(ip_packet.proto), 0, ndpi_protocol(), 0, 0, pointer(ndpi_id_struct()), pointer(ndpi_id_struct()), ndpi_flow)
|
||||
else:
|
||||
flow = workflow(ip_dst, ip_src, dst_port, src_port, int(ip_packet.proto), 0, ndpi_protocol(), 0, 0, pointer(ndpi_id_struct()), pointer(ndpi_id_struct()), ndpi_flow)
|
||||
return None
|
||||
# set flows to correct type and data
|
||||
ndpi_flow = pointer(NDPIFlowStruct())
|
||||
memset(ndpi_flow, 0, sizeof(NDPIFlowStruct))
|
||||
if ip_src > ip_dst:
|
||||
flow = WorkFlow(ip_src, ip_dst, src_port, dst_port, int(ip_packet.proto), 0, NDPIProtocol(), 0, 0,
|
||||
pointer(NDPIIdStruct()), pointer(NDPIIdStruct()), ndpi_flow)
|
||||
else:
|
||||
flow = WorkFlow(ip_dst, ip_src, dst_port, src_port, int(ip_packet.proto), 0, NDPIProtocol(), 0, 0,
|
||||
pointer(NDPIIdStruct()), pointer(NDPIIdStruct()), ndpi_flow)
|
||||
flow_ref = pointer(flow)
|
||||
res = ndpi.ndpi_tfind(flow_ref, flows_root_ref, cmp_func)
|
||||
if res is None:
|
||||
@@ -144,41 +153,45 @@ def get_flow(packet):
|
||||
lista.append(flow)
|
||||
flow_count += 1
|
||||
return pointer(flow)
|
||||
flow = cast(res, POINTER(POINTER(workflow))).contents
|
||||
flow = cast(res, POINTER(POINTER(WorkFlow))).contents
|
||||
return flow
|
||||
|
||||
|
||||
def packetcaptured(packet):
|
||||
def packetcaptured(pkt):
|
||||
global packet_number
|
||||
global start_time
|
||||
global ndpi_info_mod
|
||||
|
||||
flow = None
|
||||
h = pcap_pkthdr()
|
||||
h = PcapPktHdr()
|
||||
|
||||
#getting flow
|
||||
# getting flow
|
||||
try:
|
||||
flow = get_flow(packet)
|
||||
flow = get_flow(pkt)
|
||||
except AttributeError:
|
||||
pass # ignore packet
|
||||
pass # ignore packet
|
||||
if flow is None: return
|
||||
|
||||
#filling pcap_pkthdr
|
||||
h.len = h.caplen = len(packet)
|
||||
h.ts.tv_sec = int(packet["IP"].time/1000000)
|
||||
h.ts.tv_usec = int(packet["IP"].time)
|
||||
# filling pcap_pkthdr
|
||||
h.len = h.caplen = len(pkt)
|
||||
h.ts.tv_sec = int(pkt["IP"].time/1000000)
|
||||
h.ts.tv_usec = int(pkt["IP"].time)
|
||||
|
||||
# real work
|
||||
if int(packet[1].frag) == 0: # not fragmented packet
|
||||
if int(pkt[1].frag) == 0: # not fragmented packet
|
||||
flow.contents.packets += 1
|
||||
packet_number += 1
|
||||
# get ndpi_iphdr address
|
||||
iphdr_addr = cast(c_char_p(packet[1].build()), c_void_p)
|
||||
iphdr_addr = cast(c_char_p(pkt[1].build()), c_void_p)
|
||||
ndpi_flow = flow.contents.flow
|
||||
|
||||
if flow.contents.detection_completed is 0:
|
||||
flow.contents.detected_protocol = ndpi.ndpi_detection_process_packet(ndpi_info_mod, ndpi_flow, cast(iphdr_addr, POINTER(c_uint8)),
|
||||
int(packet[1].len), h.ts.tv_usec, flow.contents.src_id, flow.contents.dst_id)
|
||||
flow.contents.detected_protocol = ndpi.ndpi_detection_process_packet(ndpi_info_mod,
|
||||
ndpi_flow,
|
||||
cast(iphdr_addr, POINTER(c_uint8)),
|
||||
int(pkt[1].len),
|
||||
h.ts.tv_usec,
|
||||
flow.contents.src_id,
|
||||
flow.contents.dst_id)
|
||||
|
||||
flow1 = flow.contents.detected_protocol
|
||||
|
||||
@@ -187,27 +200,32 @@ def packetcaptured(packet):
|
||||
if flow.contents.protocol == 6: valid = flow.contents.packets > max_num_tcp_dissected_pkts
|
||||
elif flow.contents.protocol == 17: valid = flow.contents.packets > max_num_udp_dissected_pkts
|
||||
|
||||
#should we continue anylizing packet or not?
|
||||
# should we continue anylizing packet or not?
|
||||
if valid or flow1.app_protocol is not 0:
|
||||
if valid or flow1.master_protocol is not 91: #or # 91 is NDPI_PROTOCOL_TLS
|
||||
flow.contents.detection_completed = 1 #protocol found
|
||||
if valid or flow1.master_protocol is not 91: # or # 91 is NDPI_PROTOCOL_TLS
|
||||
flow.contents.detection_completed = 1 # protocol found
|
||||
if flow1.app_protocol is 0:
|
||||
flow.contents.detected_protocol = ndpi.ndpi_detection_giveup(ndpi_info_mod, ndpi_flow, 1)
|
||||
|
||||
flow.contents.detected_protocol = ndpi.ndpi_detection_giveup(ndpi_info_mod,
|
||||
ndpi_flow,
|
||||
1,
|
||||
cast(addressof(c_uint8(0)),
|
||||
POINTER(c_uint8)))
|
||||
|
||||
|
||||
def result():
|
||||
global flows_root_ref
|
||||
global ndpi_info_mod
|
||||
print('\nnumber of anylized packet ' + str(packet_number))
|
||||
print('number of flows ' + str(flow_count))
|
||||
print('\nnumber of analyzed packet: ' + str(packet_number))
|
||||
print('number of flows: ' + str(flow_count))
|
||||
|
||||
ndpi.ndpi_twalk(flows_root_ref.contents, guess_walker, None)
|
||||
|
||||
print('\nDetected protocols:')
|
||||
for i in range(0, ndpi.ndpi_get_num_supported_protocols(ndpi_info_mod)):
|
||||
if count_protocol[i] > 0:
|
||||
print(cast(ndpi.ndpi_get_proto_name(ndpi_info_mod, i), c_char_p).value + ': '.encode('UTF-8') + str(count_protocol[i]).encode('UTF-8'))
|
||||
print("{}: {} packets".format(
|
||||
cast(ndpi.ndpi_get_proto_name(ndpi_info_mod, i), c_char_p).value.decode('utf-8'),
|
||||
str(count_protocol[i])))
|
||||
|
||||
|
||||
def free(ndpi_struct):
|
||||
@@ -216,16 +234,16 @@ def free(ndpi_struct):
|
||||
|
||||
|
||||
def initialize(ndpi_struct):
|
||||
all = NDPI_PROTOCOL_BITMASK()
|
||||
all = NDPIProtocolBitMask()
|
||||
ndpi.ndpi_wrap_NDPI_BITMASK_SET_ALL(pointer(all))
|
||||
ndpi.ndpi_set_protocol_detection_bitmask2(ndpi_struct, pointer(all))
|
||||
|
||||
|
||||
print('Using nDPI ' + str(cast(ndpi.ndpi_revision(), c_char_p).value))
|
||||
print('Using nDPI ' + cast(ndpi.ndpi_revision(), c_char_p).value.decode("utf-8"))
|
||||
|
||||
initialize(ndpi_info_mod)
|
||||
|
||||
if(len(sys.argv) != 2):
|
||||
if len(sys.argv) != 2:
|
||||
print("\nUsage: ndpi_example.py <device>")
|
||||
sys.exit(0)
|
||||
|
||||
@@ -247,6 +265,9 @@ else:
|
||||
sniff(iface=sys.argv[1], prn=packetcaptured)
|
||||
except KeyboardInterrupt:
|
||||
print('\nInterrupted\n')
|
||||
except PermissionError:
|
||||
sys.exit('\nRoot privilege required for live capture on interface: {}\n'.format(sys.argv[1]))
|
||||
|
||||
|
||||
result()
|
||||
free(ndpi_info_mod)
|
||||
|
||||
+447
-356
File diff suppressed because it is too large
Load Diff
@@ -1,10 +0,0 @@
|
||||
plibrary_includedir=$(includedir)/libndpi-@VERSION@/libndpi
|
||||
|
||||
library_include_HEADERS = ndpi_api.h \
|
||||
ndpi_define.h \
|
||||
ndpi_typedefs.h \
|
||||
ndpi_main.h \
|
||||
ndpi_protocol_ids.h \
|
||||
ndpi_protocols.h \
|
||||
ndpi_win32.h \
|
||||
ndpi_includes.h
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ndpi_api.h
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -34,7 +34,7 @@ extern "C" {
|
||||
/* The #define below is used for apps that dynamically link with nDPI to make
|
||||
sure that datastructures and in sync across versions
|
||||
*/
|
||||
#define NDPI_API_VERSION 1
|
||||
#define NDPI_API_VERSION @NDPI_API_VERSION@
|
||||
|
||||
#define SIZEOF_ID_STRUCT ( sizeof(struct ndpi_id_struct) )
|
||||
#define SIZEOF_FLOW_STRUCT ( sizeof(struct ndpi_flow_struct) )
|
||||
@@ -78,9 +78,34 @@ extern "C" {
|
||||
*/
|
||||
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the flow tcp struct
|
||||
*
|
||||
* @return the size of the flow tcp struct
|
||||
*
|
||||
*/
|
||||
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_tcp_struct(void);
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the flow udp struct
|
||||
*
|
||||
* @return the size of the flow udp struct
|
||||
*
|
||||
*/
|
||||
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_udp_struct(void);
|
||||
|
||||
/*
|
||||
Same as the API call above but used for matching raw id's added
|
||||
via ndpi_add_string_value_to_automa()
|
||||
*/
|
||||
int ndpi_match_string_value(void *_automa, char *string_to_match,
|
||||
u_int match_len, u_int32_t *num);
|
||||
|
||||
/**
|
||||
* nDPI personal allocation and free functions
|
||||
**/
|
||||
**/
|
||||
void * ndpi_malloc(size_t size);
|
||||
void * ndpi_calloc(unsigned long count, size_t size);
|
||||
void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
|
||||
@@ -112,7 +137,7 @@ extern "C" {
|
||||
* NULL if the substring is not found
|
||||
*
|
||||
*/
|
||||
char* ndpi_strncasestr(const char *s, const char *find, size_t slen);
|
||||
const char* ndpi_strncasestr(const char *s, const char *find, size_t slen);
|
||||
|
||||
/**
|
||||
* Returns the nDPI protocol id for IP-based protocol detection
|
||||
@@ -126,6 +151,21 @@ extern "C" {
|
||||
u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct in_addr *pin);
|
||||
|
||||
/**
|
||||
* Returns the nDPI protocol id for IP+port-based protocol detection
|
||||
*
|
||||
* @par ndpi_struct = the struct created for the protocol detection
|
||||
* @par pin = IP host address (MUST BE in network byte order):
|
||||
* See man(7) ip for details
|
||||
* @par port = The port (MUST BE in network byte order) or
|
||||
* 0 if ignored
|
||||
* @return the nDPI protocol ID
|
||||
*
|
||||
*/
|
||||
u_int16_t ndpi_network_port_ptree_match(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct in_addr *pin /* network byte order */,
|
||||
u_int16_t port /* network byte order */);
|
||||
|
||||
/**
|
||||
* Init single protocol match
|
||||
*
|
||||
@@ -138,11 +178,27 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* Returns a new initialized detection module
|
||||
* Note that before you can use it you can still load
|
||||
* hosts and do other things. As soon as you are ready to use
|
||||
* it do not forget to call first ndpi_finalize_initalization()
|
||||
*
|
||||
* You can call this function multiple times, (i.e. to create multiple
|
||||
* indipendent detection contexts) but all these calls MUST NOT run
|
||||
* in parallel
|
||||
*
|
||||
* @par prefs = load preferences
|
||||
* @return the initialized detection module
|
||||
*
|
||||
*/
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(void);
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs prefs);
|
||||
|
||||
/**
|
||||
* Completes the initialization (2nd step)
|
||||
*
|
||||
* @par ndpi_str = the struct created for the protocol detection
|
||||
*
|
||||
*/
|
||||
void ndpi_finalize_initalization(struct ndpi_detection_module_struct *ndpi_str);
|
||||
|
||||
/**
|
||||
* Frees the memory allocated in the specified flow
|
||||
@@ -206,19 +262,8 @@ extern "C" {
|
||||
*/
|
||||
void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const NDPI_PROTOCOL_BITMASK * detection_bitmask);
|
||||
|
||||
/**
|
||||
* Function to be called to see in case of unknown match to see if there is
|
||||
* a partial match that has been prevented by the current nDPI preferences configuration
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the flow given for the detection module
|
||||
* @return the detected protocol even if the flow is not completed;
|
||||
*
|
||||
*/
|
||||
ndpi_protocol ndpi_get_partial_detection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
/**
|
||||
|
||||
/**
|
||||
* Function to be called before we give up with detection for a given flow.
|
||||
* This function reduces the NDPI_UNKNOWN_PROTOCOL detection
|
||||
*
|
||||
@@ -239,13 +284,13 @@ extern "C" {
|
||||
* (like SSL getting both client and server certificate even if we already know after
|
||||
* seeing the client certificate what the protocol is)
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = pointer to the connection state machine
|
||||
* @par packet = unsigned char pointer to the Layer 3 (IP header)
|
||||
* @par packetlen = the length of the packet
|
||||
* @par current_tick = the current timestamp for the packet
|
||||
* @par src = pointer to the source subscriber state machine
|
||||
* @par dst = pointer to the destination subscriber state machine
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = pointer to the connection state machine
|
||||
* @par packet = unsigned char pointer to the Layer 3 (IP header)
|
||||
* @par packetlen = the length of the packet
|
||||
* @par packet_time_ms = the current timestamp for the packet (expressed in msec)
|
||||
* @par src = pointer to the source subscriber state machine
|
||||
* @par dst = pointer to the destination subscriber state machine
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
@@ -253,7 +298,7 @@ extern "C" {
|
||||
struct ndpi_flow_struct *flow,
|
||||
const unsigned char *packet,
|
||||
const unsigned short packetlen,
|
||||
const u_int64_t current_tick,
|
||||
const u_int64_t packet_time_ms,
|
||||
struct ndpi_id_struct *src,
|
||||
struct ndpi_id_struct *dst);
|
||||
|
||||
@@ -261,13 +306,13 @@ extern "C" {
|
||||
* Processes one packet and returns the ID of the detected protocol.
|
||||
* This is the MAIN PACKET PROCESSING FUNCTION.
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = pointer to the connection state machine
|
||||
* @par packet = unsigned char pointer to the Layer 3 (IP header)
|
||||
* @par packetlen = the length of the packet
|
||||
* @par current_tick = the current timestamp for the packet
|
||||
* @par src = pointer to the source subscriber state machine
|
||||
* @par dst = pointer to the destination subscriber state machine
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = pointer to the connection state machine
|
||||
* @par packet = unsigned char pointer to the Layer 3 (IP header)
|
||||
* @par packetlen = the length of the packet
|
||||
* @par packet_time_ms = the current timestamp for the packet (expressed in msec)
|
||||
* @par src = pointer to the source subscriber state machine
|
||||
* @par dst = pointer to the destination subscriber state machine
|
||||
* @return the detected ID of the protocol
|
||||
*
|
||||
*/
|
||||
@@ -275,7 +320,7 @@ extern "C" {
|
||||
struct ndpi_flow_struct *flow,
|
||||
const unsigned char *packet,
|
||||
const unsigned short packetlen,
|
||||
const u_int64_t current_tick,
|
||||
const u_int64_t packet_time_ms,
|
||||
struct ndpi_id_struct *src,
|
||||
struct ndpi_id_struct *dst);
|
||||
/**
|
||||
@@ -289,7 +334,7 @@ extern "C" {
|
||||
*/
|
||||
u_int16_t ndpi_get_flow_masterprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
|
||||
/**
|
||||
* API call that is called internally by ndpi_detection_process_packet or by apps
|
||||
* that want to avoid calling ndpi_detection_process_packet as they have already
|
||||
@@ -299,12 +344,14 @@ extern "C" {
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the flow given for the detection module
|
||||
* @par ndpi_selection_bitmask = the protocol selected bitmask
|
||||
* @return number of protocol dissector that have been tried (0 = no more dissectors)
|
||||
*
|
||||
*/
|
||||
void ndpi_check_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet);
|
||||
u_int32_t ndpi_check_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet);
|
||||
|
||||
|
||||
/**
|
||||
* Query the pointer to the layer 4 packet
|
||||
*
|
||||
@@ -390,7 +437,7 @@ extern "C" {
|
||||
char *string_to_match,
|
||||
u_int string_to_match_len,
|
||||
ndpi_protocol_match_result *ret_match,
|
||||
u_int16_t master_protocol_id);
|
||||
u_int16_t master_protocol_id);
|
||||
|
||||
/**
|
||||
* Check if the string content passed match with a protocol
|
||||
@@ -505,6 +552,21 @@ extern "C" {
|
||||
u_int8_t ndpi_is_subprotocol_informative(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
u_int16_t protoId);
|
||||
|
||||
/**
|
||||
* Set hostname-based protocol
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par flow = the flow to which this communication belongs to
|
||||
* @par master_protocol = the master protocol for this flow
|
||||
* @par name = the host name
|
||||
* @par name_len = length of the host name
|
||||
*
|
||||
*/
|
||||
int ndpi_match_hostname_protocol(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t master_protocol,
|
||||
char *name, u_int name_len);
|
||||
|
||||
/**
|
||||
* Get protocol category as string
|
||||
*
|
||||
@@ -726,7 +788,7 @@ extern "C" {
|
||||
* @return 0 in case of no error, or -1 if an error occurred.
|
||||
*
|
||||
*/
|
||||
int ndpi_add_string_value_to_automa(void *_automa, char *str, unsigned long num);
|
||||
int ndpi_add_string_value_to_automa(void *_automa, char *str, u_int32_t num);
|
||||
|
||||
/**
|
||||
* Add a string to match to an automata. Same as ndpi_add_string_value_to_automa() with num set to 1
|
||||
@@ -768,12 +830,13 @@ extern "C" {
|
||||
u_int32_t daddr,
|
||||
ndpi_protocol *ret);
|
||||
int ndpi_match_custom_category(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
char *name, u_int name_len, unsigned long *id);
|
||||
char *name, u_int name_len, ndpi_protocol_category_t *id);
|
||||
void ndpi_fill_protocol_category(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
ndpi_protocol *ret);
|
||||
int ndpi_get_custom_category_match(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
char *name_or_ip, u_int name_len, unsigned long *id);
|
||||
char *name_or_ip, u_int name_len,
|
||||
ndpi_protocol_category_t *id);
|
||||
int ndpi_set_detection_preferences(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
ndpi_detection_preference pref,
|
||||
int value);
|
||||
@@ -781,12 +844,13 @@ extern "C" {
|
||||
/* Tells to called on what l4 protocol given application protocol can be found */
|
||||
ndpi_l4_proto_info ndpi_get_l4_proto_info(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t ndpi_proto_id);
|
||||
const char* ndpi_get_l4_proto_name(ndpi_l4_proto_info proto);
|
||||
|
||||
|
||||
ndpi_proto_defaults_t* ndpi_get_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod);
|
||||
u_int ndpi_get_ndpi_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod);
|
||||
u_int ndpi_get_ndpi_num_custom_protocols(struct ndpi_detection_module_struct *ndpi_mod);
|
||||
u_int ndpi_get_ndpi_detection_module_size(void);
|
||||
void ndpi_set_log_level(struct ndpi_detection_module_struct *ndpi_mod, u_int l);
|
||||
void ndpi_set_debug_bitmask(struct ndpi_detection_module_struct *ndpi_mod, NDPI_PROTOCOL_BITMASK debug_bitmask);
|
||||
|
||||
/* LRU cache */
|
||||
struct ndpi_lru_cache* ndpi_lru_cache_init(u_int32_t num_entries);
|
||||
@@ -794,18 +858,21 @@ extern "C" {
|
||||
u_int8_t ndpi_lru_find_cache(struct ndpi_lru_cache *c, u_int32_t key,
|
||||
u_int16_t *value, u_int8_t clean_key_when_found);
|
||||
void ndpi_lru_add_to_cache(struct ndpi_lru_cache *c, u_int32_t key, u_int16_t value);
|
||||
|
||||
|
||||
/**
|
||||
* Add a string to match to an automata
|
||||
* Find a protocol id associated with a string automata
|
||||
*
|
||||
* @par The automata initialized with ndpi_init_automa();
|
||||
* @par The (sub)string to search
|
||||
* @par The (sub)string length
|
||||
* @par The id associated with the matched string or 0 id not found.
|
||||
* @par The protocol id associated with the matched string or 0 id not found.
|
||||
* @return 0 in case of match, or -1 if no match, or -2 if an error occurred.
|
||||
*
|
||||
*/
|
||||
int ndpi_match_string_id(void *_automa, char *string_to_match, u_int match_len, unsigned long *id);
|
||||
int ndpi_match_string_protocol_id(void *_automa, char *string_to_match, u_int match_len,
|
||||
u_int16_t *protocol_id,
|
||||
ndpi_protocol_category_t *category,
|
||||
ndpi_protocol_breed_t *breed);
|
||||
|
||||
/* Utility functions to set ndpi malloc/free/print wrappers */
|
||||
void set_ndpi_malloc(void* (*__ndpi_malloc)(size_t size));
|
||||
@@ -817,7 +884,8 @@ extern "C" {
|
||||
//void * ndpi_malloc(size_t size);
|
||||
//void * ndpi_calloc(unsigned long count, size_t size);
|
||||
//void ndpi_free(void *ptr);
|
||||
u_int8_t ndpi_get_api_version(void);
|
||||
u_int16_t ndpi_get_api_version(void);
|
||||
const char *ndpi_get_gcrypt_version(void);
|
||||
|
||||
/* https://github.com/corelight/community-id-spec */
|
||||
int ndpi_flowv4_flow_hash(u_int8_t l4_proto, u_int32_t src_ip, u_int32_t dst_ip, u_int16_t src_port, u_int16_t dst_port,
|
||||
@@ -826,75 +894,454 @@ extern "C" {
|
||||
u_int16_t src_port, u_int16_t dst_port, u_int8_t icmp_type, u_int8_t icmp_code,
|
||||
u_char *hash_buf, u_int8_t hash_buf_len);
|
||||
u_int8_t ndpi_extra_dissection_possible(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
struct ndpi_flow_struct *flow);
|
||||
u_int8_t ndpi_is_safe_ssl_cipher(u_int32_t cipher);
|
||||
const char* ndpi_cipher2str(u_int32_t cipher);
|
||||
const char* ndpi_tunnel2str(ndpi_packet_tunnel tt);
|
||||
u_int16_t ndpi_guess_host_protocol_id(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
int ndpi_has_human_readeable_string(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
char *buffer, u_int buffer_size,
|
||||
u_int8_t min_string_match_len, /* Will return 0 if no string > min_string_match_len have been found */
|
||||
char *outbuf, u_int outbuf_len);
|
||||
char* ndpi_ssl_version2str(u_int16_t version, u_int8_t *unknown_tls_version);
|
||||
char* ndpi_ssl_version2str(struct ndpi_flow_struct *flow,
|
||||
u_int16_t version, u_int8_t *unknown_tls_version);
|
||||
void ndpi_patchIPv6Address(char *str);
|
||||
void ndpi_user_pwd_payload_copy(u_int8_t *dest, u_int dest_len, u_int offset,
|
||||
const u_int8_t *src, u_int src_len);
|
||||
u_char* ndpi_base64_decode(const u_char *src, size_t len, size_t *out_len);
|
||||
char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len); /* NOTE: caller MUST free the returned pointer */
|
||||
void ndpi_string_sha1_hash(const uint8_t *message, size_t len, u_char *hash /* 20-bytes */);
|
||||
|
||||
/* Serializer */
|
||||
int ndpi_init_serializer_ll(ndpi_serializer *serializer, ndpi_serialization_format fmt,
|
||||
u_int32_t buffer_size);
|
||||
int ndpi_load_ipv4_ptree(struct ndpi_detection_module_struct *ndpi_str,
|
||||
const char *path, u_int16_t protocol_id);
|
||||
int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
ndpi_protocol l7_protocol,
|
||||
ndpi_serializer *serializer);
|
||||
int ndpi_flow2json(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int8_t ip_version,
|
||||
u_int8_t l4_protocol, u_int16_t vlan_id,
|
||||
u_int32_t src_v4, u_int32_t dst_v4,
|
||||
struct ndpi_in6_addr *src_v6, struct ndpi_in6_addr *dst_v6,
|
||||
u_int16_t src_port, u_int16_t dst_port,
|
||||
ndpi_protocol l7_protocol,
|
||||
ndpi_serializer *serializer);
|
||||
|
||||
void ndpi_md5(const u_char *data, size_t data_len, u_char hash[16]);
|
||||
|
||||
const char* ndpi_http_method2str(ndpi_http_method m);
|
||||
ndpi_http_method ndpi_http_str2method(const char* method, ssize_t method_len);
|
||||
|
||||
/* ptree (trie) API */
|
||||
ndpi_ptree_t* ndpi_ptree_create(void);
|
||||
int ndpi_ptree_insert(ndpi_ptree_t *tree, const ndpi_ip_addr_t *addr, u_int8_t bits, u_int32_t user_data);
|
||||
int ndpi_ptree_match_addr(ndpi_ptree_t *tree, const ndpi_ip_addr_t *addr, u_int32_t *user_data);
|
||||
void ndpi_ptree_destroy(ndpi_ptree_t *tree);
|
||||
|
||||
/* General purpose utilities */
|
||||
u_int64_t ndpi_htonll(u_int64_t v);
|
||||
u_int64_t ndpi_ntohll(u_int64_t v);
|
||||
|
||||
/* DGA */
|
||||
int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
struct ndpi_flow_struct *flow,
|
||||
char *name, u_int8_t is_hostname);
|
||||
|
||||
/* Serializer (supports JSON, TLV, CSV) */
|
||||
|
||||
/**
|
||||
* Initialize a serializer handle (allocated by the caller).
|
||||
* @param serializer The serializer handle
|
||||
* @param fmt The serialization format (ndpi_serialization_format_json, ndpi_serialization_format_tlv, ndpi_serialization_format_csv)
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_init_serializer(ndpi_serializer *serializer, ndpi_serialization_format fmt);
|
||||
void ndpi_term_serializer(ndpi_serializer *serializer);
|
||||
void ndpi_reset_serializer(ndpi_serializer *serializer);
|
||||
int ndpi_serialize_string_int32(ndpi_serializer *serializer,
|
||||
const char *key, int32_t value);
|
||||
int ndpi_serialize_string_int64(ndpi_serializer *serializer,
|
||||
const char *key, int64_t value);
|
||||
int ndpi_serialize_uint32_uint32(ndpi_serializer *serializer,
|
||||
u_int32_t key, u_int32_t value);
|
||||
int ndpi_serialize_uint32_uint64(ndpi_serializer *serializer,
|
||||
u_int32_t key, u_int64_t value);
|
||||
int ndpi_serialize_uint32_int32(ndpi_serializer *serializer,
|
||||
u_int32_t key, int32_t value);
|
||||
int ndpi_serialize_uint32_int64(ndpi_serializer *serializer,
|
||||
u_int32_t key, int64_t value);
|
||||
int ndpi_serialize_uint32_float(ndpi_serializer *serializer,
|
||||
u_int32_t key, float value,
|
||||
const char *format /* e.f. "%.2f" */);
|
||||
int ndpi_serialize_uint32_string(ndpi_serializer *serializer,
|
||||
u_int32_t key, const char *value);
|
||||
int ndpi_serialize_string_uint32(ndpi_serializer *serializer,
|
||||
const char *key, u_int32_t value);
|
||||
int ndpi_serialize_string_uint32_format(ndpi_serializer *serializer,
|
||||
const char *key, u_int32_t value,
|
||||
const char *format);
|
||||
int ndpi_serialize_string_uint64(ndpi_serializer *serializer,
|
||||
const char *key, u_int64_t value);
|
||||
int ndpi_serialize_string_string(ndpi_serializer *serializer,
|
||||
const char *key, const char *value);
|
||||
int ndpi_serialize_string_binary(ndpi_serializer *_serializer,
|
||||
const char *key, const char *_value,
|
||||
u_int16_t vlen);
|
||||
|
||||
int ndpi_serialize_string_float(ndpi_serializer *serializer,
|
||||
const char *key, float value,
|
||||
const char *format /* e.f. "%.2f" */);
|
||||
/**
|
||||
* Initialize a serializer handle. Same as ndpi_init_serializer, but with some low-level settings.
|
||||
* @param serializer The serializer handle
|
||||
* @param fmt The serialization format (ndpi_serialization_format_json, ndpi_serialization_format_tlv, ndpi_serialization_format_csv)
|
||||
* @param buffer_size The initial internal buffer_size
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_init_serializer_ll(ndpi_serializer *serializer, ndpi_serialization_format fmt, u_int32_t buffer_size);
|
||||
|
||||
/**
|
||||
* Release all allocated data structure.
|
||||
* @param serializer The serializer handle
|
||||
*/
|
||||
void ndpi_term_serializer(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Reset the serializer (cleanup the internal buffer to start a new serialization)
|
||||
* @param serializer The serializer handle
|
||||
*/
|
||||
void ndpi_reset_serializer(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a 32-bit unsigned int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_uint32(ndpi_serializer *serializer, u_int32_t key, u_int32_t value);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a 64-bit unsigned int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_uint64(ndpi_serializer *serializer, u_int32_t key, u_int64_t value);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a 32-bit signed int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_int32(ndpi_serializer *serializer, u_int32_t key, int32_t value);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a 64-bit signed int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_int64(ndpi_serializer *serializer, u_int32_t key, int64_t value);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a float value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @param format The float value format
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_float(ndpi_serializer *serializer, u_int32_t key, float value, const char *format /* e.f. "%.2f" */);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a string value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_string(ndpi_serializer *serializer, u_int32_t key, const char *value);
|
||||
|
||||
/**
|
||||
* Serialize a 32-bit unsigned int key and a boolean value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_uint32_boolean(ndpi_serializer *serializer, u_int32_t key, u_int8_t value);
|
||||
|
||||
/**
|
||||
* Serialize an unterminated string key and a 32-bit signed int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_binary_int32(ndpi_serializer *_serializer, const char *key, u_int16_t klen, int32_t value);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a 32-bit signed int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_int32(ndpi_serializer *serializer, const char *key, int32_t value);
|
||||
|
||||
/**
|
||||
* Serialize an unterminated string key and a 64-bit signed int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_binary_int64(ndpi_serializer *_serializer, const char *key, u_int16_t klen, int64_t value);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a 64-bit signed int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_int64(ndpi_serializer *serializer, const char *key, int64_t value);
|
||||
|
||||
/**
|
||||
* Serialize an unterminated string key and a 32-bit unsigned int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer, const char *key, u_int16_t klen, u_int32_t value);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a 32-bit unsigned int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_uint32(ndpi_serializer *serializer, const char *key, u_int32_t value);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a float value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @param format The float format
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_uint32_format(ndpi_serializer *serializer, const char *key, u_int32_t value, const char *format);
|
||||
|
||||
/**
|
||||
* Serialize an unterminated string key and a 64-bit unsigned int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_binary_uint64(ndpi_serializer *_serializer, const char *key, u_int16_t klen, u_int64_t value);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a 64-bit unsigned int value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_uint64(ndpi_serializer *serializer, const char *key, u_int64_t value);
|
||||
|
||||
/**
|
||||
* Serialize an unterminated string key and an unterminated string value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @param value The field value
|
||||
* @param vlen The value length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_binary_binary(ndpi_serializer *_serializer, const char *key, u_int16_t klen, const char *_value, u_int16_t vlen);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a string value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_string(ndpi_serializer *serializer, const char *key, const char *value);
|
||||
|
||||
/**
|
||||
* Serialize a string key and an unterminated string value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @param vlen The value length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_binary(ndpi_serializer *serializer, const char *key, const char *_value, u_int16_t vlen);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a raw value (this is a string which is added to the JSON without any quote or escaping)
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @param vlen The value length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_raw(ndpi_serializer *_serializer, const char *key, const char *_value, u_int16_t vlen);
|
||||
|
||||
/**
|
||||
* Serialize an unterminated string key and a float value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @param value The field value
|
||||
* @param format The float format
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_binary_float(ndpi_serializer *_serializer, const char *key, u_int16_t klen, float value, const char *format /* e.f. "%.2f" */);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a a float value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @param format The float format
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_float(ndpi_serializer *serializer, const char *key, float value, const char *format /* e.f. "%.2f" */);
|
||||
|
||||
/**
|
||||
* Serialize a string key and a boolean value
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_string_boolean(ndpi_serializer *serializer, const char *key, u_int8_t value);
|
||||
|
||||
/**
|
||||
* Serialize a raw record in an array (this is a low-level function and its use is not recommended)
|
||||
* @param serializer The serializer handle
|
||||
* @param record The record value
|
||||
* @param record_len The record length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_raw_record(ndpi_serializer *_serializer, u_char *record, u_int32_t record_len);
|
||||
|
||||
/**
|
||||
* Serialize an End-Of-Record (the current object becomes is terminated and added to an array,
|
||||
* and a new object is created where the next items will be added)
|
||||
* @param serializer The serializer handle
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_end_of_record(ndpi_serializer *serializer);
|
||||
int ndpi_serialize_start_of_block(ndpi_serializer *_serializer,
|
||||
const char *key);
|
||||
int ndpi_serialize_end_of_block(ndpi_serializer *_serializer);
|
||||
char* ndpi_serializer_get_buffer(ndpi_serializer *_serializer, u_int32_t *buffer_len);
|
||||
u_int32_t ndpi_serializer_get_buffer_len(ndpi_serializer *_serializer);
|
||||
int ndpi_serializer_set_buffer_len(ndpi_serializer *_serializer, u_int32_t l);
|
||||
|
||||
/**
|
||||
* Serialize the start of a list with an unterminated string key, where the next serialized items
|
||||
* will be added (note: keys for the new items are ignored)
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_start_of_list_binary(ndpi_serializer *_serializer, const char *key, u_int16_t klen);
|
||||
|
||||
/**
|
||||
* Serialize the start of a list, where the next serialized items will be added (note: keys for
|
||||
* the new items are ignored)
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_start_of_list(ndpi_serializer *serializer, const char *key);
|
||||
|
||||
/**
|
||||
* Serialize the end of a list
|
||||
* @param serializer The serializer handle
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_end_of_list(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Serialize the start of a block with an unterminated string key
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param klen The key length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_start_of_block_binary(ndpi_serializer *_serializer, const char *key, u_int16_t klen);
|
||||
|
||||
/**
|
||||
* Serialize the start of a block with a string key
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_start_of_block(ndpi_serializer *serializer, const char *key);
|
||||
|
||||
/**
|
||||
* Serialize the end of a block
|
||||
* @param serializer The serializer handle
|
||||
* @param key The field name or ID
|
||||
* @param value The field value
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serialize_end_of_block(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Return the serialized buffer
|
||||
* @param serializer The serializer handle
|
||||
* @param buffer_len The buffer length (out)
|
||||
* @return The buffer
|
||||
*/
|
||||
char* ndpi_serializer_get_buffer(ndpi_serializer *serializer, u_int32_t *buffer_len);
|
||||
|
||||
/**
|
||||
* Return the current serialized buffer length
|
||||
* @param serializer The serializer handle
|
||||
* @return The buffer length
|
||||
*/
|
||||
u_int32_t ndpi_serializer_get_buffer_len(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Return the real internal buffer size (containing the serialized buffer)
|
||||
* @param serializer The serializer handle
|
||||
* @return The internal buffer size
|
||||
*/
|
||||
u_int32_t ndpi_serializer_get_internal_buffer_size(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Change the serializer buffer length
|
||||
* @param serializer The serializer handle
|
||||
* @param l The new buffer length
|
||||
* @return 0 on success, a negative number otherwise
|
||||
*/
|
||||
int ndpi_serializer_set_buffer_len(ndpi_serializer *serializer, u_int32_t l);
|
||||
|
||||
/**
|
||||
* Return the configured serialization format
|
||||
* @param serializer The serializer handle
|
||||
* @return The serialization format
|
||||
*/
|
||||
ndpi_serialization_format ndpi_serializer_get_format(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Set the CSV separator
|
||||
* @param serializer The serializer handle
|
||||
* @param separator The separator
|
||||
*/
|
||||
void ndpi_serializer_set_csv_separator(ndpi_serializer *serializer, char separator);
|
||||
|
||||
/**
|
||||
* Return the header automatically built from keys (CSV only)
|
||||
* @param serializer The serializer handle
|
||||
* @param buffer_len The buffer length (out)
|
||||
* @return The header
|
||||
*/
|
||||
char* ndpi_serializer_get_header(ndpi_serializer *serializer, u_int32_t *buffer_len);
|
||||
|
||||
/**
|
||||
* Create a snapshot of the internal buffer for later rollback (ndpi_serializer_rollback_snapshot)
|
||||
* @param serializer The serializer handle
|
||||
*/
|
||||
void ndpi_serializer_create_snapshot(ndpi_serializer *serializer);
|
||||
|
||||
/**
|
||||
* Rollback to the latest snapshot
|
||||
* @param serializer The serializer handle
|
||||
*/
|
||||
void ndpi_serializer_rollback_snapshot(ndpi_serializer *serializer);
|
||||
|
||||
/* Deserializer */
|
||||
|
||||
/* Deserializer (supports TLV only) */
|
||||
|
||||
int ndpi_init_deserializer(ndpi_deserializer *deserializer,
|
||||
ndpi_serializer *serializer);
|
||||
int ndpi_init_deserializer_buf(ndpi_deserializer *deserializer,
|
||||
u_int8_t *serialized_buffer,
|
||||
u_int32_t serialized_buffer_len);
|
||||
|
||||
|
||||
ndpi_serialization_format ndpi_deserialize_get_format(ndpi_deserializer *_deserializer);
|
||||
ndpi_serialization_type ndpi_deserialize_get_item_type(ndpi_deserializer *deserializer, ndpi_serialization_type *key_type);
|
||||
int ndpi_deserialize_next(ndpi_deserializer *deserializer);
|
||||
@@ -916,21 +1363,69 @@ extern "C" {
|
||||
struct ndpi_analyze_struct* ndpi_alloc_data_analysis(u_int16_t _max_series_len);
|
||||
void ndpi_init_data_analysis(struct ndpi_analyze_struct *s, u_int16_t _max_series_len);
|
||||
void ndpi_free_data_analysis(struct ndpi_analyze_struct *d);
|
||||
void ndpi_reset_data_analysis(struct ndpi_analyze_struct *d);
|
||||
void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value);
|
||||
|
||||
float ndpi_data_average(struct ndpi_analyze_struct *s);
|
||||
/* Sliding-window only */
|
||||
float ndpi_data_window_average(struct ndpi_analyze_struct *s);
|
||||
|
||||
float ndpi_data_window_variance(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_window_stddev(struct ndpi_analyze_struct *s);
|
||||
|
||||
/* All data */
|
||||
float ndpi_data_average(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_entropy(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_variance(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_stddev(struct ndpi_analyze_struct *s);
|
||||
u_int32_t ndpi_data_last(struct ndpi_analyze_struct *s);
|
||||
u_int32_t ndpi_data_min(struct ndpi_analyze_struct *s);
|
||||
u_int32_t ndpi_data_max(struct ndpi_analyze_struct *s);
|
||||
float ndpi_data_ratio(u_int32_t sent, u_int32_t rcvd);
|
||||
|
||||
|
||||
const char* ndpi_data_ratio2str(float ratio);
|
||||
|
||||
|
||||
void ndpi_data_print_window_values(struct ndpi_analyze_struct *s); /* debug */
|
||||
|
||||
ndpi_risk_enum ndpi_validate_url(char *url);
|
||||
|
||||
u_int8_t ndpi_is_protocol_detected(struct ndpi_detection_module_struct *ndpi_str,
|
||||
ndpi_protocol proto);
|
||||
void ndpi_serialize_risk(ndpi_serializer *serializer, struct ndpi_flow_struct *flow);
|
||||
|
||||
const char* ndpi_risk2str(ndpi_risk_enum risk);
|
||||
|
||||
/* ******************************* */
|
||||
|
||||
/* HyperLogLog cardinality estimator */
|
||||
|
||||
/* Memory lifecycle */
|
||||
int ndpi_hll_init(struct ndpi_hll *hll, u_int8_t bits);
|
||||
void ndpi_hll_destroy(struct ndpi_hll *hll);
|
||||
void ndpi_hll_reset(struct ndpi_hll *hll);
|
||||
|
||||
/* Add values */
|
||||
void ndpi_hll_add(struct ndpi_hll *hll, const char *data, size_t data_len);
|
||||
void ndpi_hll_add_number(struct ndpi_hll *hll, u_int32_t value) ;
|
||||
|
||||
/* Get cardinality estimation */
|
||||
double ndpi_hll_count(struct ndpi_hll *hll);
|
||||
|
||||
/* ******************************* */
|
||||
|
||||
int ndpi_init_bin(struct ndpi_bin *b, enum ndpi_bin_family f, u_int8_t num_bins);
|
||||
void ndpi_free_bin(struct ndpi_bin *b);
|
||||
struct ndpi_bin* ndpi_clone_bin(struct ndpi_bin *b);
|
||||
void ndpi_inc_bin(struct ndpi_bin *b, u_int8_t slot_id, u_int32_t val);
|
||||
void ndpi_set_bin(struct ndpi_bin *b, u_int8_t slot_id, u_int32_t value);
|
||||
u_int32_t ndpi_get_bin_value(struct ndpi_bin *b, u_int8_t slot_id);
|
||||
void ndpi_reset_bin(struct ndpi_bin *b);
|
||||
void ndpi_normalize_bin(struct ndpi_bin *b);
|
||||
char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf, u_int out_buf_len);
|
||||
float ndpi_bin_similarity(struct ndpi_bin *b1, struct ndpi_bin *b2, u_int8_t normalize_first);
|
||||
int ndpi_cluster_bins(struct ndpi_bin *bins, u_int16_t num_bins,
|
||||
u_int8_t num_clusters, u_int16_t *cluster_ids,
|
||||
struct ndpi_bin *centroids);
|
||||
|
||||
u_int32_t ndpi_quick_16_byte_hash(u_int8_t *in_16_bytes_long);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+13
-14
@@ -43,8 +43,7 @@
|
||||
#ifndef NDPI_CLASSIFY_H
|
||||
#define NDPI_CLASSIFY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include "ndpi_includes.h"
|
||||
|
||||
/* constants */
|
||||
#define NUM_PARAMETERS_SPLT_LOGREG 208
|
||||
@@ -67,27 +66,27 @@ extern float parameters_bd[NUM_PARAMETERS_BD_LOGREG];
|
||||
extern float parameters_splt[NUM_PARAMETERS_SPLT_LOGREG];
|
||||
|
||||
/* Classifier functions */
|
||||
float ndpi_classify(const unsigned short *pkt_len, const struct timeval *pkt_time,
|
||||
const unsigned short *pkt_len_twin, const struct timeval *pkt_time_twin,
|
||||
struct timeval start_time, struct timeval start_time_twin, uint32_t max_num_pkt_len,
|
||||
float ndpi_classify(const unsigned short *pkt_len, const pkt_timeval *pkt_time,
|
||||
const unsigned short *pkt_len_twin, const pkt_timeval *pkt_time_twin,
|
||||
pkt_timeval start_time, pkt_timeval start_time_twin, uint32_t max_num_pkt_len,
|
||||
uint16_t sp, uint16_t dp, uint32_t op, uint32_t ip, uint32_t np_o, uint32_t np_i,
|
||||
uint32_t ob, uint32_t ib, uint16_t use_bd, const uint32_t *bd, const uint32_t *bd_t);
|
||||
|
||||
void ndpi_merge_splt_arrays(const uint16_t *pkt_len, const struct timeval *pkt_time,
|
||||
const uint16_t *pkt_len_twin, const struct timeval *pkt_time_twin,
|
||||
struct timeval start_time, struct timeval start_time_twin,
|
||||
void ndpi_merge_splt_arrays(const uint16_t *pkt_len, const pkt_timeval *pkt_time,
|
||||
const uint16_t *pkt_len_twin, const pkt_timeval *pkt_time_twin,
|
||||
pkt_timeval start_time, pkt_timeval start_time_twin,
|
||||
uint16_t s_idx, uint16_t r_idx,
|
||||
uint16_t *merged_lens, uint16_t *merged_times);
|
||||
|
||||
void ndpi_update_params(classifier_type_codes_t param_type, const char *param_file);
|
||||
|
||||
void ndpi_flow_info_freer(void *node);
|
||||
unsigned int ndpi_timer_eq(const struct timeval *a, const struct timeval *b);
|
||||
unsigned int ndpi_timer_lt(const struct timeval *a, const struct timeval *b);
|
||||
void ndpi_timer_sub(const struct timeval *a, const struct timeval *b, struct timeval *result);
|
||||
void ndpi_timer_clear(struct timeval *a);
|
||||
unsigned int ndpi_timeval_to_milliseconds(struct timeval ts);
|
||||
unsigned int ndpi_timeval_to_microseconds(struct timeval ts);
|
||||
unsigned int ndpi_timer_eq(const pkt_timeval *a, const pkt_timeval *b);
|
||||
unsigned int ndpi_timer_lt(const pkt_timeval *a, const pkt_timeval *b);
|
||||
void ndpi_timer_sub(const pkt_timeval *a, const pkt_timeval *b, pkt_timeval *result);
|
||||
void ndpi_timer_clear(pkt_timeval *a);
|
||||
unsigned int ndpi_timeval_to_milliseconds(pkt_timeval ts);
|
||||
unsigned int ndpi_timeval_to_microseconds(pkt_timeval ts);
|
||||
void ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len);
|
||||
|
||||
#endif /* NDPI_CLASSIFY_H */
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
#include <endian.h>
|
||||
#define __BYTE_ORDER BYTE_ORDER
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__
|
||||
#endif /* __LITTLE_ENDIAN__ */
|
||||
#else
|
||||
#define __BIG_ENDIAN__
|
||||
#endif/* BYTE_ORDER */
|
||||
@@ -179,6 +181,8 @@
|
||||
#define NDPI_JABBER_FT_TIMEOUT 5
|
||||
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
|
||||
|
||||
#include "ndpi_config.h" /* To have access to NDPI_ENABLE_DEBUG_MESSAGES */
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
#define NDPI_LOG(proto, m, log_level, args...) \
|
||||
{ \
|
||||
@@ -187,7 +191,7 @@
|
||||
(*(mod->ndpi_debug_printf))(proto, mod, log_level, __FILE__, __FUNCTION__, __LINE__, args); \
|
||||
}
|
||||
|
||||
/* We must define NDPI_CURRENT_PROTO before include ndpi_main.h !!!
|
||||
/* We must define NDPI_CURRENT_PROTO before include ndpi_main.h !!!
|
||||
*
|
||||
* #include "ndpi_protocol_ids.h"
|
||||
* #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_XXXX
|
||||
@@ -196,7 +200,7 @@
|
||||
*/
|
||||
|
||||
#ifndef NDPI_CURRENT_PROTO
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTO_UNKNOWN
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_UNKNOWN
|
||||
#endif
|
||||
|
||||
#define NDPI_LOG_ERR(mod, args...) \
|
||||
@@ -274,6 +278,12 @@
|
||||
#define NDPI_BITMASK_SET_ALL(a) NDPI_ONE(&a)
|
||||
#define NDPI_BITMASK_SET(a, b) { memcpy(&a, &b, sizeof(NDPI_PROTOCOL_BITMASK)); }
|
||||
|
||||
#define NDPI_SET_BIT(num, n) num |= 1UL << ( n )
|
||||
#define NDPI_CLR_BIT(num, n) num &= ~(1UL << ( n ))
|
||||
#define NDPI_CLR_BIT(num, n) num &= ~(1UL << ( n ))
|
||||
#define NDPI_ISSET_BIT(num, n) (num & (1UL << ( n )))
|
||||
#define NDPI_ZERO_BIT(num) num = 0
|
||||
|
||||
/* this is a very very tricky macro *g*,
|
||||
* the compiler will remove all shifts here if the protocol is static...
|
||||
*/
|
||||
@@ -304,10 +314,10 @@
|
||||
#define NDPI_ICMPV6_PROTOCOL_TYPE 0x3a
|
||||
|
||||
/* the get_uXX will return raw network packet bytes !! */
|
||||
#define get_u_int8_t(X,O) (*(u_int8_t *)(((u_int8_t *)X) + O))
|
||||
#define get_u_int16_t(X,O) (*(u_int16_t *)(((u_int8_t *)X) + O))
|
||||
#define get_u_int32_t(X,O) (*(u_int32_t *)(((u_int8_t *)X) + O))
|
||||
#define get_u_int64_t(X,O) (*(u_int64_t *)(((u_int8_t *)X) + O))
|
||||
#define get_u_int8_t(X,O) (*(u_int8_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#define get_u_int16_t(X,O) (*(u_int16_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#define get_u_int32_t(X,O) (*(u_int32_t *)((&(((u_int8_t *)X)[O]))))
|
||||
#define get_u_int64_t(X,O) (*(u_int64_t *)((&(((u_int8_t *)X)[O]))))
|
||||
|
||||
/* new definitions to get little endian from network bytes */
|
||||
#define get_ul8(X,O) get_u_int8_t(X,O)
|
||||
@@ -328,7 +338,7 @@
|
||||
#define match_first_bytes(payload,st) (memcmp((payload),(st),(sizeof(st)-1))==0)
|
||||
|
||||
#if defined(WIN32) && !defined(snprintf)
|
||||
#define snprintf _snprintf
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define NDPI_MAX_DNS_REQUESTS 16
|
||||
@@ -343,6 +353,10 @@
|
||||
#define NDPI_CIPHER_WEAK 1
|
||||
#define NDPI_CIPHER_INSECURE 2
|
||||
|
||||
#define NDPI_OPTIMAL_HLL_NUM_BUCKETS 16
|
||||
|
||||
#define NDPI_MAX_NUM_TLS_APPL_BLOCKS 8
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#if defined __NetBSD__ || defined __OpenBSD__
|
||||
#include <netinet/in_systm.h>
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#if defined __OpenBSD__
|
||||
#include <pthread.h>
|
||||
|
||||
#endif
|
||||
@@ -67,4 +67,10 @@
|
||||
|
||||
#endif /* Win32 */
|
||||
|
||||
#if defined __OpenBSD__
|
||||
#include "ndpi_includes_OpenBSD.h"
|
||||
#else
|
||||
typedef struct timeval pkt_timeval;
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
#endif /* __NDPI_INCLUDES_H__ */
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* ndpi_includes_OpenBSD.h
|
||||
*
|
||||
* Copyright (C) 2011-16 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NDPI_INCLUDES_OPENBSD_H__
|
||||
#define __NDPI_INCLUDES_OPENBSD_H__
|
||||
|
||||
#ifndef IPPROTO_SCTP
|
||||
#define IPPROTO_SCTP 132
|
||||
#endif /* IPPROTO_SCTP */
|
||||
|
||||
#include <net/bpf.h>
|
||||
|
||||
typedef struct bpf_timeval pkt_timeval;
|
||||
|
||||
#endif /* __NDPI_INCLUDES_OPENBSD_H__ */
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ndpi_main.h
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -114,6 +114,7 @@ extern "C" {
|
||||
|
||||
extern int ndpi_parse_ip_string(const char *ip_str, ndpi_ip_addr_t *parsed_ip);
|
||||
extern char *ndpi_get_ip_string(const ndpi_ip_addr_t * ip, char *buf, u_int buf_len);
|
||||
extern u_int8_t ndpi_is_ipv6(const ndpi_ip_addr_t *ip);
|
||||
|
||||
extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id);
|
||||
u_int16_t ndpi_get_proto_by_name(struct ndpi_detection_module_struct *ndpi_mod, const char *name);
|
||||
@@ -131,7 +132,7 @@ extern "C" {
|
||||
u_int16_t** tcp_master_proto,
|
||||
u_int16_t** udp_master_proto);
|
||||
#/* NDPI_PROTOCOL_NETBIOS */
|
||||
int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len);
|
||||
int ndpi_netbios_name_interpret(char *in, size_t inlen, char *out, u_int out_len);
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
@@ -149,6 +150,10 @@ extern "C" {
|
||||
#define ndpi_match_strprefix(payload, payload_len, str) \
|
||||
ndpi_match_prefix((payload), (payload_len), (str), (sizeof(str)-1))
|
||||
|
||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi_str, const u_int8_t ** l4ptr, u_int16_t * l4len, u_int8_t * nxt_hdr);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
/*
|
||||
* ndpi_protocol_ids.h
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -23,12 +22,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NDPI_API_H__
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __NDPI_PROTOCOLS_DEFAULT_H__
|
||||
#define __NDPI_PROTOCOLS_DEFAULT_H__
|
||||
#ifndef __NDPI_PROTOCOLS_IDS_H__
|
||||
#define __NDPI_PROTOCOLS_IDS_H__
|
||||
|
||||
#define NDPI_DETECTION_SUPPORT_IPV6
|
||||
#define NDPI_PROTOCOL_SIZE 2
|
||||
@@ -75,24 +70,24 @@ typedef enum {
|
||||
NDPI_PROTOCOL_SKYPE_CALL = 38, /* Skype call and videocalls */
|
||||
NDPI_PROTOCOL_SIGNAL = 39,
|
||||
NDPI_PROTOCOL_MEMCACHED = 40, /* Memcached - Darryl Sokoloski <darryl@egloo.ca> */
|
||||
NDPI_PROTOCOL_SMBV23 = 41, /* SMB version 2/3 */
|
||||
NDPI_PROTOCOL_SMBV23 = 41, /* SMB version 2/3 */
|
||||
NDPI_PROTOCOL_MINING = 42, /* Bitcoin, Ethereum, ZCash, Monero */
|
||||
NDPI_PROTOCOL_NEST_LOG_SINK = 43, /* Nest Log Sink (Nest Protect) - Darryl Sokoloski <darryl@egloo.ca> */
|
||||
NDPI_PROTOCOL_MODBUS = 44, /* Modbus */
|
||||
NDPI_PROTOCOL_WHATSAPP_CALL = 45, /* WhatsApp video ad audio calls go here */
|
||||
NDPI_PROTOCOL_DATASAVER = 46, /* Protocols used to save data on Internet communications */
|
||||
NDPI_PROTOCOL_DATASAVER = 46, /* Protocols used to save data on Internet communications */
|
||||
NDPI_PROTOCOL_XBOX = 47,
|
||||
NDPI_PROTOCOL_QQ = 48,
|
||||
NDPI_PROTOCOL_TIKTOK = 49,
|
||||
NDPI_PROTOCOL_RTSP = 50,
|
||||
NDPI_PROTOCOL_MAIL_IMAPS = 51,
|
||||
NDPI_PROTOCOL_ICECAST = 52,
|
||||
NDPI_PROTOCOL_PPLIVE = 53, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
NDPI_PROTOCOL_FREE_53 = 53,
|
||||
NDPI_PROTOCOL_PPSTREAM = 54,
|
||||
NDPI_PROTOCOL_ZATTOO = 55,
|
||||
NDPI_PROTOCOL_SHOUTCAST = 56,
|
||||
NDPI_PROTOCOL_SOPCAST = 57,
|
||||
NDPI_PROTOCOL_TVANTS = 58,
|
||||
NDPI_PROTOCOL_DISCORD = 58,
|
||||
NDPI_PROTOCOL_TVUPLAYER = 59,
|
||||
NDPI_PROTOCOL_HTTP_DOWNLOAD = 60,
|
||||
NDPI_PROTOCOL_QQLIVE = 61,
|
||||
@@ -102,10 +97,10 @@ typedef enum {
|
||||
NDPI_PROTOCOL_IRC = 65,
|
||||
NDPI_PROTOCOL_AYIYA = 66,
|
||||
NDPI_PROTOCOL_UNENCRYPTED_JABBER = 67,
|
||||
NDPI_PROTOCOL_MSN = 68,
|
||||
NDPI_PROTOCOL_OSCAR = 69,
|
||||
NDPI_PROTOCOL_NATS = 68,
|
||||
NDPI_PROTOCOL_FREE_69 = 69, /* Free */
|
||||
NDPI_PROTOCOL_YAHOO = 70,
|
||||
NDPI_PROTOCOL_BATTLEFIELD = 71,
|
||||
NDPI_PROTOCOL_FREE_71 = 71, /* Free */
|
||||
NDPI_PROTOCOL_GOOGLE_PLUS = 72,
|
||||
NDPI_PROTOCOL_IP_VRRP = 73,
|
||||
NDPI_PROTOCOL_STEAM = 74, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
@@ -124,7 +119,7 @@ typedef enum {
|
||||
NDPI_PROTOCOL_RTP = 87,
|
||||
NDPI_PROTOCOL_RDP = 88,
|
||||
NDPI_PROTOCOL_VNC = 89,
|
||||
NDPI_PROTOCOL_PCANYWHERE = 90,
|
||||
NDPI_PROTOCOL_FREE90 = 90, /* Free */
|
||||
NDPI_PROTOCOL_TLS = 91,
|
||||
NDPI_PROTOCOL_SSH = 92,
|
||||
NDPI_PROTOCOL_USENET = 93,
|
||||
@@ -217,7 +212,7 @@ typedef enum {
|
||||
NDPI_PROTOCOL_CNN = 180, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
NDPI_PROTOCOL_MEGACO = 181, /* Gianluca Costa <g.costa@xplico.org> */
|
||||
NDPI_PROTOCOL_REDIS = 182,
|
||||
NDPI_PROTOCOL_PANDO = 183, /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
NDPI_PROTOCOL_FREE_183 = 183,
|
||||
NDPI_PROTOCOL_VHUA = 184,
|
||||
NDPI_PROTOCOL_TELEGRAM = 185, /* Gianluca Costa <g.costa@xplico.org> */
|
||||
NDPI_PROTOCOL_VEVO = 186,
|
||||
@@ -230,19 +225,19 @@ typedef enum {
|
||||
NDPI_PROTOCOL_KAKAOTALK = 193, /* KakaoTalk Chat (no voice call) */
|
||||
NDPI_PROTOCOL_KAKAOTALK_VOICE = 194, /* KakaoTalk Voice */
|
||||
NDPI_PROTOCOL_TWITCH = 195, /* Edoardo Dominici <edoaramis@gmail.com> */
|
||||
NDPI_PROTOCOL_DNS_OVER_HTTPS = 196,
|
||||
NDPI_PROTOCOL_DOH_DOT = 196, /* DoH (DNS over HTTPS), DoT (DNS over TLS) */
|
||||
NDPI_PROTOCOL_WECHAT = 197,
|
||||
NDPI_PROTOCOL_MPEGTS = 198,
|
||||
NDPI_PROTOCOL_SNAPCHAT = 199,
|
||||
NDPI_PROTOCOL_SINA = 200,
|
||||
NDPI_PROTOCOL_HANGOUT_DUO = 201, /* Google Hangout ad Duo (merged as they are very similar) */
|
||||
NDPI_PROTOCOL_HANGOUT_DUO = 201, /* Google Hangout ad Duo (merged as they are very similar) */
|
||||
NDPI_PROTOCOL_IFLIX = 202, /* www.vizuamatix.com R&D team & M.Mallawaarachchie <manoj_ws@yahoo.com> */
|
||||
NDPI_PROTOCOL_GITHUB = 203,
|
||||
NDPI_PROTOCOL_BJNP = 204,
|
||||
NDPI_PROTOCOL_LINE = 205, /* https://en.wikipedia.org/wiki/Line_(software) */
|
||||
NDPI_PROTOCOL_FREE_205 = 205,
|
||||
NDPI_PROTOCOL_WIREGUARD = 206,
|
||||
NDPI_PROTOCOL_SMPP = 207, /* Damir Franusic <df@release14.org> */
|
||||
NDPI_PROTOCOL_DNSCRYPT = 208,
|
||||
NDPI_PROTOCOL_DNSCRYPT = 208, /* Toni Uhlig <matzeton@googlemail.com> */
|
||||
NDPI_PROTOCOL_TINC = 209, /* William Guglielmo <william@deselmo.com> */
|
||||
NDPI_PROTOCOL_DEEZER = 210,
|
||||
NDPI_PROTOCOL_INSTAGRAM = 211, /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
|
||||
@@ -253,7 +248,7 @@ typedef enum {
|
||||
NDPI_PROTOCOL_IMO = 216,
|
||||
NDPI_PROTOCOL_GOOGLE_DRIVE = 217,
|
||||
NDPI_PROTOCOL_OCS = 218,
|
||||
NDPI_PROTOCOL_OFFICE_365 = 219,
|
||||
NDPI_PROTOCOL_MICROSOFT_365 = 219,
|
||||
NDPI_PROTOCOL_CLOUDFLARE = 220,
|
||||
NDPI_PROTOCOL_MS_ONE_DRIVE = 221,
|
||||
NDPI_PROTOCOL_MQTT = 222,
|
||||
@@ -270,8 +265,8 @@ typedef enum {
|
||||
NDPI_PROTOCOL_LINKEDIN = 233, /* Paulo Angelo <pa@pauloangelo.com> */
|
||||
NDPI_PROTOCOL_SOUNDCLOUD = 234,
|
||||
NDPI_PROTOCOL_CSGO = 235, /* Counter-Strike Global Offensive, Dota = 2 */
|
||||
NDPI_PROTOCOL_LISP = 236,
|
||||
NDPI_PROTOCOL_DIAMETER = 237,
|
||||
NDPI_PROTOCOL_LISP = 236,
|
||||
NDPI_PROTOCOL_DIAMETER = 237,
|
||||
NDPI_PROTOCOL_APPLE_PUSH = 238,
|
||||
NDPI_PROTOCOL_GOOGLE_SERVICES = 239,
|
||||
NDPI_PROTOCOL_AMAZON_VIDEO = 240,
|
||||
@@ -279,14 +274,27 @@ typedef enum {
|
||||
NDPI_PROTOCOL_WHATSAPP_FILES = 242, /* Videos, pictures, voice messages... */
|
||||
NDPI_PROTOCOL_TARGUS_GETDATA = 243,
|
||||
NDPI_PROTOCOL_DNP3 = 244,
|
||||
NDPI_PROTOCOL_104 = 245,
|
||||
/*
|
||||
NDPI_PROTOCOL_IEC60870 = 245, /* https://en.wikipedia.org/wiki/IEC_60870-5 */
|
||||
NDPI_PROTOCOL_BLOOMBERG = 246,
|
||||
NDPI_PROTOCOL_CAPWAP = 247,
|
||||
NDPI_PROTOCOL_ZABBIX = 248,
|
||||
NDPI_PROTOCOL_S7COMM = 249,
|
||||
NDPI_PROTOCOL_MSTEAMS = 250,
|
||||
NDPI_PROTOCOL_WEBSOCKET = 251, /* Leonn Paiva <leonn.paiva@gmail.com> */
|
||||
NDPI_PROTOCOL_ANYDESK = 252, /* Toni Uhlig <matzeton@googlemail.com> */
|
||||
NDPI_PROTOCOL_SOAP = 253, /* Toni Uhlig <matzeton@googlemail.com> */
|
||||
|
||||
#ifdef CUSTOM_NDPI_PROTOCOLS
|
||||
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
IMPORTANT
|
||||
before allocating a new identifier please fill up
|
||||
one of those named NDPI_PROTOCOL_FREE_XXX and not used
|
||||
(placeholders to avoid protocol renumbering)
|
||||
*/
|
||||
|
||||
|
||||
/* IMPORTANT:NDPI_LAST_IMPLEMENTED_PROTOCOL MUST BE THE LAST ELEMENT */
|
||||
NDPI_LAST_IMPLEMENTED_PROTOCOL
|
||||
} ndpi_protocol_id_t;
|
||||
@@ -294,4 +302,5 @@ typedef enum {
|
||||
#define NDPI_PROTOCOL_NO_MASTER_PROTO NDPI_PROTOCOL_UNKNOWN
|
||||
#define NDPI_MAX_SUPPORTED_PROTOCOLS NDPI_LAST_IMPLEMENTED_PROTOCOL
|
||||
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
|
||||
#endif
|
||||
|
||||
#endif /* __NDPI_PROTOCOL_IDS_H__ */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ndpi_protocols.h
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -51,165 +51,6 @@ u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struc
|
||||
|
||||
void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
|
||||
/* Applications and other protocols. */
|
||||
void ndpi_search_diameter(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_lisp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_directconnect(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_applejuice_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_i23v5(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_socrates(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_msn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_yahoo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_oscar(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_sip(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_imo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mail_pop_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_http_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_http_subprotocol_conf(struct ndpi_detection_module_struct *ndpi_struct, char *attr, char *value, int protocol_id);
|
||||
void ndpi_search_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_usenet_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rtsp_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_vmware(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ssl_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mms_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_icecast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_shoutcast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_veohtv_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_openft_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_stun(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_tvants_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_sopcast(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ppstream(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_pplive(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mgcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_zattoo(struct ndpi_detection_module_struct*ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_qq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_feidian(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_thunder(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_activesync(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_in_non_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_vnc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_steam(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_halflife2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_xbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_smb_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_telnet_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ntp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_nfs(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rtp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ssdp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_worldofwarcraft(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_postgres_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mysql_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_quake(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_secondlife(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_pcanywhere(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_kontiki(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_syslog(struct ndpi_detection_module_struct*ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_netbios(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mdns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ldap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_warcraft3(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_xdmcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_tftp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mssql_tds(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_pptp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_stealthnet(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_checkmk(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_maplestory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_world_of_kung_fu(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_guildwars_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_sflow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_radius(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_wsus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_teamview(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_lotus_notes(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_gtp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_spotify(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_openvpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_noe(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_viber(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_teamspeak(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_corba(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_oracle(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rsync(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rtcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_skinny(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_tor(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_whois_das(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_socks5(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_socks4(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rtmp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_pando(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_megaco(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_redis(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_zmq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_vhua(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_telegram(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_kakaotalk_voice(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mpegts(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_starcraft(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_coap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mqtt (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_rx(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_bjnp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_smpp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_tinc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_csgo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_ajp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_memcached(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_nest_log_sink(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_wireguard(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_targus_getdata(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_apple_push(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_amazon_video(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
/* --- INIT FUNCTIONS --- */
|
||||
void init_diameter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_aimini_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
@@ -217,7 +58,6 @@ void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
void init_armagetron_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ayiya_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_amqp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_bgp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_lisp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
@@ -262,12 +102,11 @@ void init_mail_imap_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
void init_mail_pop_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mail_smtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_maplestory_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mdns_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_megaco_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mgpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mining_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mms_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_msn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_nats_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mpegts_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mssql_tds_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mysql_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
@@ -280,11 +119,7 @@ void init_ntp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3
|
||||
void init_openft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_openvpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_oracle_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_oscar_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pando_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pcanywhere_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_postgres_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pplive_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ppstream_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pptp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_qq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
@@ -326,7 +161,6 @@ void init_telnet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_i
|
||||
void init_tftp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_thunder_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_tor_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_tvants_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_tvuplayer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_usenet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_upnp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
@@ -341,7 +175,6 @@ void init_world_of_warcraft_dissector(struct ndpi_detection_module_struct *ndpi_
|
||||
void init_world_of_kung_fu_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_xbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_xdmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_yahoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_zattoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_zmq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_stracraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
@@ -369,9 +202,15 @@ void init_memcached_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
void init_nest_log_sink_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ookla_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_modbus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_line_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_capwap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_zabbix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_wireguard_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_targus_getdata_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dnp3_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_104_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_s7comm_dissector(struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_websocket_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_soap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dnscrypt_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
|
||||
#endif /* __NDPI_PROTOCOLS_H__ */
|
||||
|
||||
+235
-125
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ndpi_typedefs.h
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -42,12 +42,60 @@ typedef enum {
|
||||
ndpi_l4_proto_tcp_and_udp,
|
||||
} ndpi_l4_proto_info;
|
||||
|
||||
typedef enum {
|
||||
ndpi_no_tunnel = 0,
|
||||
ndpi_gtp_tunnel,
|
||||
ndpi_capwap_tunnel,
|
||||
ndpi_tzsp_tunnel,
|
||||
ndpi_l2tp_tunnel,
|
||||
} ndpi_packet_tunnel;
|
||||
|
||||
/*
|
||||
NOTE
|
||||
When the typedef below is modified don't forget to update
|
||||
- ndpi_risk2str (in ndpi_utils.c)
|
||||
- https://github.com/ntop/ntopng/blob/dev/scripts/lua/modules/flow_risk_utils.lua
|
||||
- ndpi_risk_enum (in python/ndpi.py)
|
||||
*/
|
||||
typedef enum {
|
||||
NDPI_NO_RISK = 0,
|
||||
NDPI_URL_POSSIBLE_XSS,
|
||||
NDPI_URL_POSSIBLE_SQL_INJECTION,
|
||||
NDPI_URL_POSSIBLE_RCE_INJECTION,
|
||||
NDPI_BINARY_APPLICATION_TRANSFER,
|
||||
NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT,
|
||||
NDPI_TLS_SELFSIGNED_CERTIFICATE,
|
||||
NDPI_TLS_OBSOLETE_VERSION,
|
||||
NDPI_TLS_WEAK_CIPHER,
|
||||
NDPI_TLS_CERTIFICATE_EXPIRED,
|
||||
NDPI_TLS_CERTIFICATE_MISMATCH, /* 10 */
|
||||
NDPI_HTTP_SUSPICIOUS_USER_AGENT,
|
||||
NDPI_HTTP_NUMERIC_IP_HOST,
|
||||
NDPI_HTTP_SUSPICIOUS_URL,
|
||||
NDPI_HTTP_SUSPICIOUS_HEADER,
|
||||
NDPI_TLS_NOT_CARRYING_HTTPS,
|
||||
NDPI_SUSPICIOUS_DGA_DOMAIN,
|
||||
NDPI_MALFORMED_PACKET,
|
||||
NDPI_SSH_OBSOLETE_CLIENT_VERSION_OR_CIPHER,
|
||||
NDPI_SSH_OBSOLETE_SERVER_VERSION_OR_CIPHER,
|
||||
NDPI_SMB_INSECURE_VERSION, /* 20 */
|
||||
NDPI_TLS_SUSPICIOUS_ESNI_USAGE,
|
||||
NDPI_UNSAFE_PROTOCOL,
|
||||
NDPI_DNS_SUSPICIOUS_TRAFFIC,
|
||||
NDPI_TLS_MISSING_SNI,
|
||||
|
||||
/* Leave this as last member */
|
||||
NDPI_MAX_RISK /* must be <= 31 due to (**) */
|
||||
} ndpi_risk_enum;
|
||||
|
||||
typedef u_int32_t ndpi_risk; /* (**) */
|
||||
|
||||
/* NDPI_VISIT */
|
||||
typedef enum {
|
||||
ndpi_preorder,
|
||||
ndpi_postorder,
|
||||
ndpi_endorder,
|
||||
ndpi_leaf
|
||||
ndpi_preorder,
|
||||
ndpi_postorder,
|
||||
ndpi_endorder,
|
||||
ndpi_leaf
|
||||
} ndpi_VISIT;
|
||||
|
||||
/* NDPI_NODE */
|
||||
@@ -431,6 +479,10 @@ PACK_ON struct tinc_cache_entry {
|
||||
u_int16_t dst_port;
|
||||
} PACK_OFF;
|
||||
|
||||
/*
|
||||
In case the typedef below is modified, please update
|
||||
ndpi_http_method2str (ndpi_utils.c)
|
||||
*/
|
||||
typedef enum {
|
||||
NDPI_HTTP_METHOD_UNKNOWN = 0,
|
||||
NDPI_HTTP_METHOD_OPTIONS,
|
||||
@@ -478,18 +530,12 @@ struct ndpi_id_struct {
|
||||
/* NDPI_PROTOCOL_GNUTELLA */
|
||||
u_int32_t gnutella_ts;
|
||||
|
||||
/* NDPI_PROTOCOL_BATTLEFIELD */
|
||||
u_int32_t battlefield_ts;
|
||||
|
||||
/* NDPI_PROTOCOL_THUNDER */
|
||||
u_int32_t thunder_ts;
|
||||
|
||||
/* NDPI_PROTOCOL_RTSP */
|
||||
u_int32_t rtsp_timer;
|
||||
|
||||
/* NDPI_PROTOCOL_OSCAR */
|
||||
u_int32_t oscar_last_safe_access_time;
|
||||
|
||||
/* NDPI_PROTOCOL_ZATTOO */
|
||||
u_int32_t zattoo_ts;
|
||||
|
||||
@@ -530,9 +576,6 @@ struct ndpi_id_struct {
|
||||
/* NDPI_PROTOCOL_IRC */
|
||||
u_int8_t irc_number_of_port;
|
||||
|
||||
/* NDPI_PROTOCOL_OSCAR */
|
||||
u_int8_t oscar_ssl_session_id[33];
|
||||
|
||||
/* NDPI_PROTOCOL_UNENCRYPTED_JABBER */
|
||||
u_int8_t jabber_voice_stun_used_ports;
|
||||
|
||||
@@ -623,17 +666,20 @@ struct ndpi_flow_tcp_struct {
|
||||
/* NDPI_PROTOCOL_TELNET */
|
||||
u_int32_t telnet_stage:2; // 0 - 2
|
||||
|
||||
void* tls_srv_cert_fingerprint_ctx;
|
||||
struct {
|
||||
struct {
|
||||
u_int8_t *buffer;
|
||||
u_int buffer_len, buffer_used;
|
||||
} message;
|
||||
|
||||
void* srv_cert_fingerprint_ctx; /* SHA-1 */
|
||||
|
||||
/* NDPI_PROTOCOL_TLS */
|
||||
u_int8_t tls_seen_client_cert:1,
|
||||
tls_seen_server_cert:1,
|
||||
tls_seen_certificate:1,
|
||||
tls_srv_cert_fingerprint_found:1,
|
||||
tls_srv_cert_fingerprint_processed:1,
|
||||
tls_stage:2, _pad:1; // 0 - 5
|
||||
int16_t tls_record_offset, tls_fingerprint_len; /* Need to be signed */
|
||||
u_int8_t tls_sha1_certificate_fingerprint[20];
|
||||
/* NDPI_PROTOCOL_TLS */
|
||||
u_int8_t hello_processed:1, certificate_processed:1, subprotocol_detected:1,
|
||||
fingerprint_set:1, _pad:4;
|
||||
u_int8_t sha1_certificate_fingerprint[20], num_tls_blocks;
|
||||
int16_t tls_application_blocks_len[NDPI_MAX_NUM_TLS_APPL_BLOCKS]; /* + = src->dst, - = dst->src */
|
||||
} tls;
|
||||
|
||||
/* NDPI_PROTOCOL_POSTGRES */
|
||||
u_int32_t postgres_stage:3;
|
||||
@@ -671,6 +717,9 @@ struct ndpi_flow_tcp_struct {
|
||||
/* NDPI_PROTOCOL_MAIL_IMAP */
|
||||
u_int32_t mail_imap_stage:3, mail_imap_starttls:2;
|
||||
|
||||
/* NDPI_PROTOCOL_SOAP */
|
||||
u_int32_t soap_stage:1;
|
||||
|
||||
/* NDPI_PROTOCOL_SKYPE */
|
||||
u_int8_t skype_packet_id;
|
||||
|
||||
@@ -695,24 +744,14 @@ struct ndpi_flow_tcp_struct {
|
||||
|
||||
/* NDPI_PROTOCOL_NEST_LOG_SINK */
|
||||
u_int8_t nest_log_sink_matches;
|
||||
}
|
||||
#ifndef WIN32
|
||||
__attribute__ ((__packed__))
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
/* ************************************************** */
|
||||
|
||||
struct ndpi_flow_udp_struct {
|
||||
/* NDPI_PROTOCOL_BATTLEFIELD */
|
||||
u_int32_t battlefield_msg_id;
|
||||
|
||||
/* NDPI_PROTOCOL_SNMP */
|
||||
u_int32_t snmp_msg_id;
|
||||
|
||||
/* NDPI_PROTOCOL_BATTLEFIELD */
|
||||
u_int32_t battlefield_stage:3;
|
||||
|
||||
/* NDPI_PROTOCOL_SNMP */
|
||||
u_int32_t snmp_stage:2;
|
||||
|
||||
@@ -754,11 +793,7 @@ struct ndpi_flow_udp_struct {
|
||||
/* NDPI_PROTOCOL_WIREGUARD */
|
||||
u_int8_t wireguard_stage;
|
||||
u_int32_t wireguard_peer_index[2];
|
||||
}
|
||||
#ifndef WIN32
|
||||
__attribute__ ((__packed__))
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
/* ************************************************** */
|
||||
|
||||
@@ -777,15 +812,10 @@ struct ndpi_packet_struct {
|
||||
const u_int8_t *generic_l4_ptr; /* is set only for non tcp-udp traffic */
|
||||
const u_int8_t *payload;
|
||||
|
||||
u_int32_t tick_timestamp;
|
||||
u_int64_t tick_timestamp_l;
|
||||
u_int64_t current_time_ms;
|
||||
|
||||
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
|
||||
u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_SIZE];
|
||||
|
||||
#ifndef WIN32
|
||||
__attribute__ ((__packed__))
|
||||
#endif
|
||||
u_int16_t protocol_stack_info;
|
||||
|
||||
struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET];
|
||||
@@ -794,6 +824,7 @@ struct ndpi_packet_struct {
|
||||
struct ndpi_int_one_line_struct forwarded_line;
|
||||
struct ndpi_int_one_line_struct referer_line;
|
||||
struct ndpi_int_one_line_struct content_line;
|
||||
struct ndpi_int_one_line_struct content_disposition_line;
|
||||
struct ndpi_int_one_line_struct accept_line;
|
||||
struct ndpi_int_one_line_struct user_agent_line;
|
||||
struct ndpi_int_one_line_struct http_url_name;
|
||||
@@ -829,6 +860,7 @@ struct ndpi_detection_module_struct;
|
||||
struct ndpi_flow_struct;
|
||||
|
||||
struct ndpi_call_function_struct {
|
||||
u_int16_t ndpi_protocol_id;
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
NDPI_PROTOCOL_BITMASK excluded_protocol_bitmask;
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask;
|
||||
@@ -893,6 +925,12 @@ typedef enum {
|
||||
NDPI_PROTOCOL_CATEGORY_SHOPPING,
|
||||
NDPI_PROTOCOL_CATEGORY_PRODUCTIVITY,
|
||||
NDPI_PROTOCOL_CATEGORY_FILE_SHARING,
|
||||
/*
|
||||
The category below is used by sites who are used
|
||||
to test connectivity
|
||||
*/
|
||||
NDPI_PROTOCOL_CATEGORY_CONNECTIVITY_CHECK,
|
||||
NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
|
||||
|
||||
/* Some custom categories */
|
||||
CUSTOM_CATEGORY_MINING = 99,
|
||||
@@ -926,10 +964,8 @@ typedef enum {
|
||||
} ndpi_protocol_category_t;
|
||||
|
||||
typedef enum {
|
||||
ndpi_pref_http_dont_dissect_response = 0,
|
||||
ndpi_pref_dns_dont_dissect_response,
|
||||
ndpi_pref_direction_detect_disable,
|
||||
ndpi_pref_disable_metadata_export,
|
||||
ndpi_pref_direction_detect_disable = 0,
|
||||
ndpi_pref_enable_tls_block_dissection
|
||||
} ndpi_detection_preference;
|
||||
|
||||
/* ntop extensions */
|
||||
@@ -939,6 +975,7 @@ typedef struct ndpi_proto_defaults {
|
||||
u_int8_t can_have_a_subprotocol;
|
||||
u_int16_t protoId, protoIdx;
|
||||
u_int16_t master_tcp_protoId[2], master_udp_protoId[2]; /* The main protocols on which this sub-protocol sits on */
|
||||
u_int16_t tcp_default_ports[MAX_DEFAULT_PORTS], udp_default_ports[MAX_DEFAULT_PORTS];
|
||||
ndpi_protocol_breed_t protoBreed;
|
||||
void (*func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow);
|
||||
} ndpi_proto_defaults_t;
|
||||
@@ -964,7 +1001,7 @@ typedef struct ndpi_proto {
|
||||
ndpi_protocol_category_t category;
|
||||
} ndpi_protocol;
|
||||
|
||||
#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN }
|
||||
#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_CATEGORY_UNSPECIFIED }
|
||||
|
||||
#define NUM_CUSTOM_CATEGORIES 5
|
||||
#define CUSTOM_CATEGORY_LABEL_LEN 32
|
||||
@@ -974,28 +1011,28 @@ typedef struct ndpi_proto {
|
||||
/* Needed to have access to HAVE_* defines */
|
||||
#include "ndpi_config.h"
|
||||
|
||||
#ifdef HAVE_HYPERSCAN
|
||||
#include <hs/hs.h>
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
struct hs_list {
|
||||
char *expression;
|
||||
unsigned int id;
|
||||
struct hs_list *next;
|
||||
};
|
||||
|
||||
struct hs {
|
||||
hs_database_t *database;
|
||||
hs_scratch_t *scratch;
|
||||
struct pcre_struct {
|
||||
pcre *compiled;
|
||||
pcre_extra *optimized;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ndpi_stun_cache,
|
||||
ndpi_hangout_cache
|
||||
} ndpi_lru_cache_type;
|
||||
|
||||
struct ndpi_detection_module_struct {
|
||||
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||
NDPI_PROTOCOL_BITMASK generic_http_packet_bitmask;
|
||||
|
||||
u_int32_t current_ts;
|
||||
u_int32_t ticks_per_second;
|
||||
|
||||
u_int16_t num_tls_blocks_to_follow;
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
void *user_data;
|
||||
#endif
|
||||
@@ -1045,15 +1082,10 @@ struct ndpi_detection_module_struct {
|
||||
content_automa, /* Used for HTTP subprotocol_detection */
|
||||
subprotocol_automa, /* Used for HTTP subprotocol_detection */
|
||||
bigrams_automa, impossible_bigrams_automa; /* TOR */
|
||||
|
||||
/* IMPORTANT: please update ndpi_finalize_initalization() whenever you add a new automa */
|
||||
|
||||
struct {
|
||||
#ifdef HAVE_HYPERSCAN
|
||||
struct hs *hostnames;
|
||||
unsigned int num_to_load;
|
||||
struct hs_list *to_load;
|
||||
#else
|
||||
ndpi_automa hostnames, hostnames_shadow;
|
||||
#endif
|
||||
void *ipAddresses, *ipAddresses_shadow; /* Patricia */
|
||||
u_int8_t categories_loaded;
|
||||
} custom_categories;
|
||||
@@ -1065,16 +1097,12 @@ struct ndpi_detection_module_struct {
|
||||
u_int32_t irc_timeout;
|
||||
/* gnutella parameters */
|
||||
u_int32_t gnutella_timeout;
|
||||
/* battlefield parameters */
|
||||
u_int32_t battlefield_timeout;
|
||||
/* thunder parameters */
|
||||
u_int32_t thunder_timeout;
|
||||
/* SoulSeek parameters */
|
||||
u_int32_t soulseek_connection_ip_tick_timeout;
|
||||
/* rtsp parameters */
|
||||
u_int32_t rtsp_connection_timeout;
|
||||
/* tvants parameters */
|
||||
u_int32_t tvants_connection_timeout;
|
||||
/* rstp */
|
||||
u_int32_t orb_rstp_ts_timeout;
|
||||
/* yahoo */
|
||||
@@ -1103,14 +1131,18 @@ struct ndpi_detection_module_struct {
|
||||
/* NDPI_PROTOCOL_STUN and subprotocols */
|
||||
struct ndpi_lru_cache *stun_cache;
|
||||
|
||||
/* NDPI_PROTOCOL_MSTEAMS */
|
||||
struct ndpi_lru_cache *msteams_cache;
|
||||
|
||||
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
|
||||
|
||||
u_int8_t http_dont_dissect_response:1, dns_dont_dissect_response:1,
|
||||
direction_detect_disable:1, /* disable internal detection of packet direction */
|
||||
disable_metadata_export:1 /* No metadata is exported */
|
||||
;
|
||||
u_int8_t direction_detect_disable:1, /* disable internal detection of packet direction */ _pad:7;
|
||||
|
||||
void *hyperscan; /* Intel Hyperscan */
|
||||
void (*ndpi_notify_lru_add_handler_ptr)(ndpi_lru_cache_type cache_type, u_int32_t proto, u_int32_t app_proto);
|
||||
|
||||
#ifdef CUSTOM_NDPI_PROTOCOLS
|
||||
#include "../../../nDPI-custom/custom_ndpi_typedefs.h"
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* NDPI_LIB_COMPILATION */
|
||||
@@ -1121,16 +1153,19 @@ typedef enum {
|
||||
ndpi_cipher_insecure = NDPI_CIPHER_INSECURE
|
||||
} ndpi_cipher_weakness;
|
||||
|
||||
/*
|
||||
NOTE
|
||||
When the struct below is modified don't forget to update
|
||||
- ndpi_flow_struct (in python/ndpi.py)
|
||||
*/
|
||||
struct ndpi_flow_struct {
|
||||
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
|
||||
#ifndef WIN32
|
||||
__attribute__ ((__packed__))
|
||||
#endif
|
||||
u_int16_t protocol_stack_info;
|
||||
|
||||
/* init parameter, internal used to set up timestamp,... */
|
||||
u_int16_t guessed_protocol_id, guessed_host_protocol_id, guessed_category, guessed_header_category;
|
||||
u_int8_t l4_proto, protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1;
|
||||
u_int8_t l4_proto, protocol_id_already_guessed:1, host_already_guessed:1, fail_with_unknown:1,
|
||||
init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1;
|
||||
|
||||
/*
|
||||
if ndpi_struct->direction_detect_disable == 1
|
||||
@@ -1153,14 +1188,20 @@ struct ndpi_flow_struct {
|
||||
struct ndpi_flow_udp_struct udp;
|
||||
} l4;
|
||||
|
||||
/* Place textual flow info here */
|
||||
char flow_extra_info[16];
|
||||
|
||||
/*
|
||||
Pointer to src or dst that identifies the
|
||||
server of this connection
|
||||
*/
|
||||
struct ndpi_id_struct *server_id;
|
||||
/* HTTP host or DNS query */
|
||||
u_char host_server_name[256];
|
||||
|
||||
u_char host_server_name[240];
|
||||
u_int8_t initial_binary_bytes[8], initial_binary_bytes_len;
|
||||
u_int8_t risk_checked;
|
||||
ndpi_risk risk; /* Issues found with this flow [bitmask of ndpi_risk] */
|
||||
|
||||
/*
|
||||
This structure below will not not stay inside the protos
|
||||
structure below as HTTP is used by many subprotocols
|
||||
@@ -1170,12 +1211,22 @@ struct ndpi_flow_struct {
|
||||
*/
|
||||
struct {
|
||||
ndpi_http_method method;
|
||||
char *url, *content_type;
|
||||
char *url, *content_type, *user_agent;
|
||||
u_int8_t num_request_headers, num_response_headers;
|
||||
u_int8_t request_version; /* 0=1.0 and 1=1.1. Create an enum for this? */
|
||||
u_int16_t response_status_code; /* 200, 404, etc. */
|
||||
} http;
|
||||
|
||||
/*
|
||||
Put outside of the union to avoid issues in case the protocol
|
||||
is remapped to somethign pther than Kerberos due to a faulty
|
||||
dissector
|
||||
*/
|
||||
struct {
|
||||
char *pktbuf;
|
||||
u_int16_t pktbuf_maxlen, pktbuf_currlen;
|
||||
} kerberos_buf;
|
||||
|
||||
union {
|
||||
/* the only fields useful for nDPI and ntopng */
|
||||
struct {
|
||||
@@ -1190,16 +1241,23 @@ struct ndpi_flow_struct {
|
||||
} ntp;
|
||||
|
||||
struct {
|
||||
char cname[24], realm[24];
|
||||
char hostname[48], domain[48], username[48];
|
||||
} kerberos;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
u_int16_t ssl_version;
|
||||
char client_certificate[64], server_certificate[64], server_organization[64];
|
||||
char ssl_version_str[12];
|
||||
u_int16_t ssl_version, server_names_len;
|
||||
char client_requested_server_name[64], *server_names,
|
||||
*alpn, *tls_supported_versions, *issuerDN, *subjectDN;
|
||||
u_int32_t notBefore, notAfter;
|
||||
char ja3_client[33], ja3_server[33];
|
||||
u_int16_t server_cipher;
|
||||
|
||||
struct {
|
||||
u_int16_t cipher_suite;
|
||||
char *esni;
|
||||
} encrypted_sni;
|
||||
ndpi_cipher_weakness server_unsafe_cipher;
|
||||
} ssl;
|
||||
|
||||
@@ -1220,9 +1278,13 @@ struct ndpi_flow_struct {
|
||||
} imo;
|
||||
|
||||
struct {
|
||||
char answer[96];
|
||||
} mdns;
|
||||
|
||||
u_int8_t username_detected:1, username_found:1,
|
||||
password_detected:1, password_found:1,
|
||||
_pad:4;
|
||||
u_int8_t character_id;
|
||||
char username[32], password[32];
|
||||
} telnet;
|
||||
|
||||
struct {
|
||||
char version[32];
|
||||
} ubntac2;
|
||||
@@ -1234,6 +1296,11 @@ struct ndpi_flow_struct {
|
||||
u_char nat_ip[24];
|
||||
} http;
|
||||
|
||||
struct {
|
||||
u_int8_t auth_found:1, auth_failed:1, _pad:5;
|
||||
char username[16], password[16];
|
||||
} ftp_imap_pop_smtp;
|
||||
|
||||
struct {
|
||||
/* Bittorrent hash */
|
||||
u_char hash[20];
|
||||
@@ -1264,12 +1331,8 @@ struct ndpi_flow_struct {
|
||||
/* NDPI_PROTOCOL_DIRECTCONNECT */
|
||||
u_int8_t directconnect_stage:2; // 0 - 1
|
||||
|
||||
/* NDPI_PROTOCOL_YAHOO */
|
||||
u_int8_t sip_yahoo_voice:1;
|
||||
|
||||
/* NDPI_PROTOCOL_HTTP */
|
||||
u_int8_t http_detected:1;
|
||||
u_int16_t http_upper_protocol, http_lower_protocol;
|
||||
|
||||
/* NDPI_PROTOCOL_RTSP */
|
||||
u_int8_t rtsprdt_stage:2, rtsp_control_flow:1;
|
||||
@@ -1286,9 +1349,6 @@ struct ndpi_flow_struct {
|
||||
/* NDPI_PROTOCOL_THUNDER */
|
||||
u_int8_t thunder_stage:2; // 0 - 3
|
||||
|
||||
/* NDPI_PROTOCOL_OSCAR */
|
||||
u_int8_t oscar_ssl_voice_stage:3, oscar_video_voice:1;
|
||||
|
||||
/* NDPI_PROTOCOL_FLORENSIA */
|
||||
u_int8_t florensia_stage:1;
|
||||
|
||||
@@ -1304,15 +1364,9 @@ struct ndpi_flow_struct {
|
||||
/* NDPI_PROTOCOL_RTMP */
|
||||
u_int8_t rtmp_stage:2;
|
||||
|
||||
/* NDPI_PROTOCOL_PANDO */
|
||||
u_int8_t pando_stage:3;
|
||||
|
||||
/* NDPI_PROTOCOL_STEAM */
|
||||
u_int16_t steam_stage:3, steam_stage1:3, steam_stage2:2, steam_stage3:2;
|
||||
|
||||
/* NDPI_PROTOCOL_PPLIVE */
|
||||
u_int8_t pplive_stage1:3, pplive_stage2:2, pplive_stage3:2;
|
||||
|
||||
/* NDPI_PROTOCOL_STARCRAFT */
|
||||
u_int8_t starcraft_udp_stage : 3; // 0-7
|
||||
|
||||
@@ -1327,10 +1381,7 @@ struct ndpi_flow_struct {
|
||||
/* NDPI_PROTOCOL_CSGO */
|
||||
u_int8_t csgo_strid[18],csgo_state,csgo_s2;
|
||||
u_int32_t csgo_id2;
|
||||
|
||||
/* NDPI_PROTOCOL_1KXUN || NDPI_PROTOCOL_IQIYI */
|
||||
u_int16_t kxun_counter, iqiyi_counter;
|
||||
|
||||
|
||||
/* internal structures to save functions calls */
|
||||
struct ndpi_packet_struct packet;
|
||||
struct ndpi_flow_struct *flow;
|
||||
@@ -1339,14 +1390,14 @@ struct ndpi_flow_struct {
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *string_to_match, *string2_to_match, *pattern_to_match, *proto_name;
|
||||
char *string_to_match, *proto_name;
|
||||
int protocol_id;
|
||||
ndpi_protocol_category_t protocol_category;
|
||||
ndpi_protocol_breed_t protocol_breed;
|
||||
} ndpi_protocol_match;
|
||||
|
||||
typedef struct {
|
||||
char *string_to_match, *hyperscan_string_to_match;
|
||||
char *string_to_match;
|
||||
ndpi_protocol_category_t protocol_category;
|
||||
} ndpi_category_match;
|
||||
|
||||
@@ -1356,6 +1407,15 @@ typedef struct {
|
||||
u_int8_t value;
|
||||
} ndpi_network;
|
||||
|
||||
typedef u_int32_t ndpi_init_prefs;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ndpi_no_prefs = 0,
|
||||
ndpi_dont_load_tor_hosts,
|
||||
ndpi_dont_init_libgcrypt,
|
||||
} ndpi_prefs;
|
||||
|
||||
typedef struct {
|
||||
int protocol_id;
|
||||
ndpi_protocol_category_t protocol_category;
|
||||
@@ -1369,8 +1429,9 @@ typedef enum {
|
||||
ndpi_serialization_format_csv
|
||||
} ndpi_serialization_format;
|
||||
|
||||
/* Note: key supports string and uint32 (compressed to uint8/uint16) only,
|
||||
* this is also enforced by the API */
|
||||
/* Note:
|
||||
* - up to 16 types (TLV encoding: "4 bit key type" << 4 | "4 bit value type")
|
||||
* - key supports string and uint32 (compressed to uint8/uint16) only, this is also enforced by the API */
|
||||
typedef enum {
|
||||
ndpi_serialization_unknown = 0,
|
||||
ndpi_serialization_end_of_record,
|
||||
@@ -1383,28 +1444,47 @@ typedef enum {
|
||||
ndpi_serialization_int32,
|
||||
ndpi_serialization_int64,
|
||||
ndpi_serialization_float,
|
||||
ndpi_serialization_string
|
||||
ndpi_serialization_string,
|
||||
ndpi_serialization_start_of_block,
|
||||
ndpi_serialization_end_of_block,
|
||||
ndpi_serialization_start_of_list,
|
||||
ndpi_serialization_end_of_list
|
||||
} ndpi_serialization_type;
|
||||
|
||||
#define NDPI_SERIALIZER_DEFAULT_HEADER_SIZE 1024
|
||||
#define NDPI_SERIALIZER_DEFAULT_BUFFER_SIZE 8192
|
||||
#define NDPI_SERIALIZER_DEFAULT_BUFFER_INCR 1024
|
||||
|
||||
#define NDPI_SERIALIZER_STATUS_COMMA (1 << 0)
|
||||
#define NDPI_SERIALIZER_STATUS_ARRAY (1 << 1)
|
||||
#define NDPI_SERIALIZER_STATUS_EOR (1 << 2)
|
||||
#define NDPI_SERIALIZER_STATUS_SOB (1 << 3)
|
||||
#define NDPI_SERIALIZER_STATUS_COMMA (1 << 0)
|
||||
#define NDPI_SERIALIZER_STATUS_ARRAY (1 << 1)
|
||||
#define NDPI_SERIALIZER_STATUS_EOR (1 << 2)
|
||||
#define NDPI_SERIALIZER_STATUS_SOB (1 << 3)
|
||||
#define NDPI_SERIALIZER_STATUS_NOT_EMPTY (1 << 4)
|
||||
#define NDPI_SERIALIZER_STATUS_LIST (1 << 5)
|
||||
#define NDPI_SERIALIZER_STATUS_SOL (1 << 6)
|
||||
#define NDPI_SERIALIZER_STATUS_HDR_DONE (1 << 7)
|
||||
|
||||
typedef struct {
|
||||
u_int32_t size_used;
|
||||
} ndpi_private_serializer_buffer_status;
|
||||
|
||||
typedef struct {
|
||||
u_int32_t flags;
|
||||
u_int32_t size_used;
|
||||
ndpi_private_serializer_buffer_status buffer;
|
||||
ndpi_private_serializer_buffer_status header;
|
||||
} ndpi_private_serializer_status;
|
||||
|
||||
typedef struct {
|
||||
u_int32_t initial_size;
|
||||
u_int32_t size;
|
||||
u_int8_t *data;
|
||||
} ndpi_private_serializer_buffer;
|
||||
|
||||
typedef struct {
|
||||
ndpi_private_serializer_status status;
|
||||
u_int32_t initial_buffer_size;
|
||||
u_int32_t buffer_size;
|
||||
ndpi_private_serializer_buffer buffer;
|
||||
ndpi_private_serializer_buffer header;
|
||||
ndpi_serialization_format fmt;
|
||||
u_int8_t *buffer;
|
||||
char csv_separator[2];
|
||||
u_int8_t has_snapshot;
|
||||
ndpi_private_serializer_status snapshot;
|
||||
@@ -1426,11 +1506,10 @@ typedef struct {
|
||||
struct ndpi_analyze_struct {
|
||||
u_int32_t *values;
|
||||
u_int32_t min_val, max_val, sum_total, num_data_entries, next_value_insert_index;
|
||||
u_int16_t num_values_array_len /* lenght of the values array */;
|
||||
u_int16_t num_values_array_len /* length of the values array */;
|
||||
|
||||
struct {
|
||||
/* https://www.johndcook.com/blog/standard_deviation/ */
|
||||
float mu, q;
|
||||
u_int64_t sum_square_total;
|
||||
} stddev;
|
||||
};
|
||||
|
||||
@@ -1438,4 +1517,35 @@ struct ndpi_analyze_struct {
|
||||
#define MAX_SERIES_LEN 512
|
||||
#define MIN_SERIES_LEN 8
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
typedef struct ndpi_ptree ndpi_ptree_t;
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
struct ndpi_hll {
|
||||
u_int8_t bits;
|
||||
size_t size;
|
||||
u_int8_t *registers;
|
||||
};
|
||||
|
||||
/* **************************************** */
|
||||
|
||||
enum ndpi_bin_family {
|
||||
ndpi_bin_family8,
|
||||
ndpi_bin_family16,
|
||||
ndpi_bin_family32
|
||||
};
|
||||
|
||||
struct ndpi_bin {
|
||||
u_int8_t num_bins, is_empty;
|
||||
enum ndpi_bin_family family;
|
||||
|
||||
union {
|
||||
u_int8_t *bins8; /* num_bins bins */
|
||||
u_int16_t *bins16; /* num_bins bins */
|
||||
u_int32_t *bins32; /* num_bins bins */
|
||||
} u;
|
||||
};
|
||||
|
||||
#endif /* __NDPI_TYPEDEFS_H__ */
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#define __mingw_forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__))
|
||||
#endif
|
||||
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT _WIN32_WINNT_WIN8
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
@@ -39,6 +41,7 @@
|
||||
#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */
|
||||
#include <process.h> /* for getpid() and the exec..() family */
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
@@ -48,6 +51,17 @@
|
||||
|
||||
#define IPVERSION 4 /* on *nix it is defined in netinet/ip.h */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
|
||||
#endif
|
||||
|
||||
#ifndef IPPROTO_SCTP
|
||||
#define IPPROTO_SCTP 132
|
||||
#endif
|
||||
|
||||
#undef gettimeofday
|
||||
#define gettimeofday mingw_gettimeofday
|
||||
|
||||
extern char* strsep(char **sp, char *sep);
|
||||
|
||||
typedef unsigned char u_char;
|
||||
@@ -75,6 +89,15 @@ typedef unsigned __int64 u_int64_t;
|
||||
|
||||
extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */);
|
||||
|
||||
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
|
||||
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
|
||||
#define strtok_r strtok_s
|
||||
#define timegm _mkgmtime
|
||||
|
||||
static inline struct tm * localtime_r(const time_t *timep, struct tm * result)
|
||||
{
|
||||
struct tm *timeinfo;
|
||||
timeinfo = localtime(timep);
|
||||
return timeinfo;
|
||||
}
|
||||
|
||||
#endif /* __NDPI_WIN32_H__ */
|
||||
|
||||
+17
-4
@@ -14,7 +14,8 @@ prefix = @prefix@
|
||||
libdir = ${prefix}/lib
|
||||
includedir = ${prefix}/include/ndpi
|
||||
CC = @CC@
|
||||
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g -Wall
|
||||
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -Wall @CFLAGS@ @CUSTOM_NDPI@
|
||||
LDFLAGS = @LDFLAGS@ @ADDITIONAL_LIBS@ @LIBS@
|
||||
RANLIB = ranlib
|
||||
|
||||
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) $(patsubst ./%.c, ./%.o, $(wildcard ./*.c))
|
||||
@@ -28,13 +29,19 @@ NDPI_LIBS = $(NDPI_LIB_STATIC) $(NDPI_LIB_SHARED)
|
||||
ifneq ($(OS),Windows_NT)
|
||||
OS := $(shell uname)
|
||||
endif
|
||||
BUILD_MINGW = @BUILD_MINGW@
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
CC=clang
|
||||
SONAME_FLAG=
|
||||
else
|
||||
ifneq ($(BUILD_MINGW),)
|
||||
NDPI_LIB_SHARED_BASE = libndpi
|
||||
NDPI_LIB_SHARED = $(NDPI_LIB_SHARED_BASE)-@NDPI_VERSION_SHORT@.dll
|
||||
else
|
||||
SONAME_FLAG=-Wl,-soname,$(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
|
||||
endif
|
||||
endif
|
||||
|
||||
all: $(NDPI_LIBS)
|
||||
|
||||
@@ -42,10 +49,10 @@ ndpi_main.c: ndpi_content_match.c.inc
|
||||
|
||||
$(NDPI_LIB_STATIC): $(OBJECTS)
|
||||
ar rc $@ $(OBJECTS)
|
||||
$(RANLIB) $@
|
||||
$(RANLIB) $@
|
||||
|
||||
$(NDPI_LIB_SHARED): $(OBJECTS)
|
||||
$(CC) -shared -fPIC $(SONAME_FLAG) -o $@ $(OBJECTS)
|
||||
$(CC) -shared -fPIC $(SONAME_FLAG) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE)
|
||||
ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
|
||||
|
||||
@@ -53,7 +60,13 @@ $(NDPI_LIB_SHARED): $(OBJECTS)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
/bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo $(NDPI_LIB_SHARED)
|
||||
/bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo libndpi.so*
|
||||
|
||||
distdir:
|
||||
cp ndpi_content_match.c.inc '$(distdir)/'
|
||||
find . -type d | xargs -I'{}' mkdir -p '$(distdir)/{}'
|
||||
find ../include -type f -name '*.h' | xargs -I'{}' cp '{}' '$(distdir)/{}'
|
||||
find . -type f -name '*.c' -o -name '*.h' | xargs -I'{}' cp '{}' '$(distdir)/{}'
|
||||
|
||||
distclean: clean
|
||||
/bin/rm -f Makefile
|
||||
|
||||
+632
-22
@@ -40,7 +40,7 @@ void ndpi_init_data_analysis(struct ndpi_analyze_struct *ret, u_int16_t _max_ser
|
||||
u_int32_t len;
|
||||
|
||||
memset(ret, 0, sizeof(struct ndpi_analyze_struct));
|
||||
|
||||
|
||||
if(_max_series_len > MAX_SERIES_LEN) _max_series_len = MAX_SERIES_LEN;
|
||||
ret->num_values_array_len = _max_series_len;
|
||||
|
||||
@@ -61,8 +61,8 @@ struct ndpi_analyze_struct* ndpi_alloc_data_analysis(u_int16_t _max_series_len)
|
||||
struct ndpi_analyze_struct *ret = ndpi_malloc(sizeof(struct ndpi_analyze_struct));
|
||||
|
||||
if(ret != NULL)
|
||||
ndpi_init_data_analysis(ret, _max_series_len);
|
||||
|
||||
ndpi_init_data_analysis(ret, _max_series_len);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -75,12 +75,18 @@ void ndpi_free_data_analysis(struct ndpi_analyze_struct *d) {
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
void ndpi_reset_data_analysis(struct ndpi_analyze_struct *d) {
|
||||
memset(d, 0, sizeof(struct ndpi_analyze_struct));
|
||||
memset(d->values, 0, sizeof(u_int32_t)*d->num_values_array_len);
|
||||
d->num_data_entries = 0;
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
/*
|
||||
Add a new point to analyze
|
||||
*/
|
||||
void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value) {
|
||||
float tmp_mu;
|
||||
|
||||
if(s->sum_total == 0)
|
||||
s->min_val = s->max_val = value;
|
||||
else {
|
||||
@@ -89,18 +95,22 @@ void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value) {
|
||||
}
|
||||
|
||||
s->sum_total += value, s->num_data_entries++;
|
||||
|
||||
|
||||
if(s->num_values_array_len) {
|
||||
s->values[s->next_value_insert_index] = value;
|
||||
|
||||
if(++s->next_value_insert_index == s->num_values_array_len)
|
||||
s->next_value_insert_index = 0;
|
||||
}
|
||||
|
||||
/* Update stddev */
|
||||
tmp_mu = s->stddev.mu;
|
||||
s->stddev.mu = ((s->stddev.mu * (s->num_data_entries - 1)) + value) / s->num_data_entries;
|
||||
s->stddev.q = s->stddev.q + (value - tmp_mu)*(value - s->stddev.mu);
|
||||
|
||||
/*
|
||||
Optimized stddev calculation
|
||||
|
||||
https://www.khanacademy.org/math/probability/data-distributions-a1/summarizing-spread-distributions/a/calculating-standard-deviation-step-by-step
|
||||
https://math.stackexchange.com/questions/683297/how-to-calculate-standard-deviation-without-detailed-historical-data
|
||||
http://mathcentral.uregina.ca/QQ/database/QQ.09.02/carlos1.html
|
||||
*/
|
||||
s->stddev.sum_square_total += value * value;
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
@@ -112,6 +122,16 @@ float ndpi_data_average(struct ndpi_analyze_struct *s) {
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
u_int32_t ndpi_data_last(struct ndpi_analyze_struct *s) {
|
||||
if((s->num_data_entries == 0) || (s->sum_total == 0))
|
||||
return(0);
|
||||
|
||||
if(s->next_value_insert_index == 0)
|
||||
return(s->values[s->num_values_array_len-1]);
|
||||
else
|
||||
return(s->values[s->next_value_insert_index-1]);
|
||||
}
|
||||
|
||||
/* Return min/max on all values */
|
||||
u_int32_t ndpi_data_min(struct ndpi_analyze_struct *s) { return(s->min_val); }
|
||||
u_int32_t ndpi_data_max(struct ndpi_analyze_struct *s) { return(s->max_val); }
|
||||
@@ -120,11 +140,17 @@ u_int32_t ndpi_data_max(struct ndpi_analyze_struct *s) { return(s->max_val); }
|
||||
|
||||
/* Compute the variance on all values */
|
||||
float ndpi_data_variance(struct ndpi_analyze_struct *s) {
|
||||
return(s->num_data_entries ? (s->stddev.q / s->num_data_entries) : 0);
|
||||
return(s->num_data_entries ? (float)(s->stddev.sum_square_total - ((s->sum_total * s->sum_total) / (s->num_data_entries))) / (float)s->num_data_entries : 0);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
/*
|
||||
See the link below for "Population and sample standard deviation review"
|
||||
https://www.khanacademy.org/math/statistics-probability/summarizing-quantitative-data/variance-standard-deviation-sample/a/population-and-sample-standard-deviation-review
|
||||
|
||||
In nDPI we use an approximate stddev calculation to avoid storing all data in memory
|
||||
*/
|
||||
/* Compute the standard deviation on all values */
|
||||
float ndpi_data_stddev(struct ndpi_analyze_struct *s) {
|
||||
return(sqrt(ndpi_data_variance(s)));
|
||||
@@ -137,10 +163,13 @@ float ndpi_data_window_average(struct ndpi_analyze_struct *s) {
|
||||
if(s->num_values_array_len) {
|
||||
float sum = 0.0;
|
||||
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
|
||||
|
||||
|
||||
if(n == 0)
|
||||
return(0);
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
sum += s->values[i];
|
||||
|
||||
|
||||
return((float)sum / (float)n);
|
||||
} else
|
||||
return(0);
|
||||
@@ -148,6 +177,32 @@ float ndpi_data_window_average(struct ndpi_analyze_struct *s) {
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
/* Compute the variance only on the sliding window */
|
||||
float ndpi_data_window_variance(struct ndpi_analyze_struct *s) {
|
||||
if(s->num_values_array_len) {
|
||||
float sum = 0.0, avg = ndpi_data_window_average(s);
|
||||
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
|
||||
|
||||
if(n == 0)
|
||||
return(0);
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
sum += pow(s->values[i]-avg, 2);
|
||||
|
||||
return((float)sum / (float)n);
|
||||
} else
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
/* Compute the variance only on the sliding window */
|
||||
float ndpi_data_window_stddev(struct ndpi_analyze_struct *s) {
|
||||
return(sqrt(ndpi_data_window_variance(s)));
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
/*
|
||||
Compute entropy on the last sliding window values
|
||||
*/
|
||||
@@ -155,17 +210,17 @@ float ndpi_data_entropy(struct ndpi_analyze_struct *s) {
|
||||
if(s->num_values_array_len) {
|
||||
int i;
|
||||
float sum = 0.0, total = 0.0;
|
||||
|
||||
|
||||
for(i=0; i<s->num_values_array_len; i++)
|
||||
total += s->values[i];
|
||||
|
||||
|
||||
for (i=0; i<s->num_values_array_len; i++) {
|
||||
float tmp = (float)s->values[i] / (float)total;
|
||||
|
||||
|
||||
if(tmp > FLT_EPSILON)
|
||||
sum -= tmp * logf(tmp);
|
||||
sum -= tmp * logf(tmp);
|
||||
}
|
||||
|
||||
|
||||
return(sum / logf(2.0));
|
||||
} else
|
||||
return(0);
|
||||
@@ -176,10 +231,10 @@ float ndpi_data_entropy(struct ndpi_analyze_struct *s) {
|
||||
void ndpi_data_print_window_values(struct ndpi_analyze_struct *s) {
|
||||
if(s->num_values_array_len) {
|
||||
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
|
||||
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
printf("[%u: %u]", i, s->values[i]);
|
||||
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
@@ -196,12 +251,567 @@ void ndpi_data_print_window_values(struct ndpi_analyze_struct *s) {
|
||||
float ndpi_data_ratio(u_int32_t sent, u_int32_t rcvd) {
|
||||
float s = (float)((int64_t)sent + (int64_t)rcvd);
|
||||
float d = (float)((int64_t)sent - (int64_t)rcvd);
|
||||
|
||||
|
||||
return((s == 0) ? 0 : (d/s));
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
const char* ndpi_data_ratio2str(float ratio) {
|
||||
if(ratio < -0.2) return("Download");
|
||||
else if(ratio > 0.2) return("Upload");
|
||||
else return("Mixed");
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
/* ********************************************************************************* */
|
||||
|
||||
#include "third_party/src/hll/hll.c"
|
||||
#include "third_party/src/hll/MurmurHash3.c"
|
||||
|
||||
int ndpi_hll_init(struct ndpi_hll *hll, u_int8_t bits) {
|
||||
return(hll_init(hll, bits));
|
||||
}
|
||||
|
||||
void ndpi_hll_destroy(struct ndpi_hll *hll) {
|
||||
hll_destroy(hll);
|
||||
}
|
||||
|
||||
void ndpi_hll_reset(struct ndpi_hll *hll) {
|
||||
hll_reset(hll);
|
||||
}
|
||||
|
||||
void ndpi_hll_add(struct ndpi_hll *hll, const char *data, size_t data_len) {
|
||||
hll_add(hll, (const void *)data, data_len);
|
||||
}
|
||||
|
||||
void ndpi_hll_add_number(struct ndpi_hll *hll, u_int32_t value) {
|
||||
hll_add(hll, (const void *)&value, sizeof(value));
|
||||
}
|
||||
|
||||
double ndpi_hll_count(struct ndpi_hll *hll) {
|
||||
return(hll_count(hll));
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
/* ********************************************************************************* */
|
||||
|
||||
int ndpi_init_bin(struct ndpi_bin *b, enum ndpi_bin_family f, u_int8_t num_bins) {
|
||||
b->num_bins = num_bins, b->family = f, b->is_empty = 1;
|
||||
|
||||
switch(f) {
|
||||
case ndpi_bin_family8:
|
||||
if((b->u.bins8 = (u_int8_t*)ndpi_calloc(num_bins, sizeof(u_int8_t))) == NULL)
|
||||
return(-1);
|
||||
break;
|
||||
|
||||
case ndpi_bin_family16:
|
||||
if((b->u.bins16 = (u_int16_t*)ndpi_calloc(num_bins, sizeof(u_int16_t))) == NULL)
|
||||
return(-1);
|
||||
break;
|
||||
|
||||
case ndpi_bin_family32:
|
||||
if((b->u.bins32 = (u_int32_t*)ndpi_calloc(num_bins, sizeof(u_int32_t))) == NULL)
|
||||
return(-1);
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
void ndpi_free_bin(struct ndpi_bin *b) {
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
free(b->u.bins8);
|
||||
break;
|
||||
case ndpi_bin_family16:
|
||||
free(b->u.bins16);
|
||||
break;
|
||||
case ndpi_bin_family32:
|
||||
free(b->u.bins32);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
struct ndpi_bin* ndpi_clone_bin(struct ndpi_bin *b) {
|
||||
struct ndpi_bin *out = (struct ndpi_bin*)ndpi_malloc(sizeof(struct ndpi_bin));
|
||||
|
||||
if(!out) return(NULL);
|
||||
|
||||
out->num_bins = b->num_bins, out->family = b->family, out->is_empty = b->is_empty;
|
||||
|
||||
switch(out->family) {
|
||||
case ndpi_bin_family8:
|
||||
if((out->u.bins8 = (u_int8_t*)ndpi_calloc(out->num_bins, sizeof(u_int8_t))) == NULL) {
|
||||
free(out);
|
||||
return(NULL);
|
||||
} else
|
||||
memcpy(out->u.bins8, b->u.bins8, out->num_bins*sizeof(u_int8_t));
|
||||
break;
|
||||
|
||||
case ndpi_bin_family16:
|
||||
if((out->u.bins16 = (u_int16_t*)ndpi_calloc(out->num_bins, sizeof(u_int16_t))) == NULL) {
|
||||
free(out);
|
||||
return(NULL);
|
||||
} else
|
||||
memcpy(out->u.bins16, b->u.bins16, out->num_bins*sizeof(u_int16_t));
|
||||
break;
|
||||
|
||||
case ndpi_bin_family32:
|
||||
if((out->u.bins32 = (u_int32_t*)ndpi_calloc(out->num_bins, sizeof(u_int32_t))) == NULL) {
|
||||
free(out);
|
||||
return(NULL);
|
||||
} else
|
||||
memcpy(out->u.bins32, b->u.bins32, out->num_bins*sizeof(u_int32_t));
|
||||
break;
|
||||
}
|
||||
|
||||
return(out);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
void ndpi_set_bin(struct ndpi_bin *b, u_int8_t slot_id, u_int32_t val) {
|
||||
if(slot_id >= b->num_bins) slot_id = 0;
|
||||
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
b->u.bins8[slot_id] = (u_int8_t)val;
|
||||
break;
|
||||
case ndpi_bin_family16:
|
||||
b->u.bins16[slot_id] = (u_int16_t)val;
|
||||
break;
|
||||
case ndpi_bin_family32:
|
||||
b->u.bins32[slot_id] = (u_int32_t)val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
void ndpi_inc_bin(struct ndpi_bin *b, u_int8_t slot_id, u_int32_t val) {
|
||||
b->is_empty = 0;
|
||||
|
||||
if(slot_id >= b->num_bins) slot_id = 0;
|
||||
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
b->u.bins8[slot_id] += (u_int8_t)val;
|
||||
break;
|
||||
case ndpi_bin_family16:
|
||||
b->u.bins16[slot_id] += (u_int16_t)val;
|
||||
break;
|
||||
case ndpi_bin_family32:
|
||||
b->u.bins32[slot_id] += (u_int32_t)val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
u_int32_t ndpi_get_bin_value(struct ndpi_bin *b, u_int8_t slot_id) {
|
||||
if(slot_id >= b->num_bins) slot_id = 0;
|
||||
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
return(b->u.bins8[slot_id]);
|
||||
break;
|
||||
case ndpi_bin_family16:
|
||||
return(b->u.bins16[slot_id]);
|
||||
break;
|
||||
case ndpi_bin_family32:
|
||||
return(b->u.bins32[slot_id]);
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
void ndpi_reset_bin(struct ndpi_bin *b) {
|
||||
b->is_empty = 1;
|
||||
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
memset(b->u.bins8, 0, sizeof(u_int8_t)*b->num_bins);
|
||||
break;
|
||||
case ndpi_bin_family16:
|
||||
memset(b->u.bins16, 0, sizeof(u_int16_t)*b->num_bins);
|
||||
break;
|
||||
case ndpi_bin_family32:
|
||||
memset(b->u.bins32, 0, sizeof(u_int32_t)*b->num_bins);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* ********************************************************************************* */
|
||||
|
||||
/*
|
||||
Each bin slot is transformed in a % with respect to the value total
|
||||
*/
|
||||
void ndpi_normalize_bin(struct ndpi_bin *b) {
|
||||
u_int8_t i;
|
||||
u_int32_t tot = 0;
|
||||
|
||||
if(b->is_empty) return;
|
||||
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
for(i=0; i<b->num_bins; i++) tot += b->u.bins8[i];
|
||||
|
||||
if(tot > 0) {
|
||||
for(i=0; i<b->num_bins; i++)
|
||||
b->u.bins8[i] = (b->u.bins8[i]*100) / tot;
|
||||
}
|
||||
break;
|
||||
case ndpi_bin_family16:
|
||||
for(i=0; i<b->num_bins; i++) tot += b->u.bins16[i];
|
||||
|
||||
if(tot > 0) {
|
||||
for(i=0; i<b->num_bins; i++)
|
||||
b->u.bins16[i] = (b->u.bins16[i]*100) / tot;
|
||||
}
|
||||
break;
|
||||
case ndpi_bin_family32:
|
||||
for(i=0; i<b->num_bins; i++) tot += b->u.bins32[i];
|
||||
|
||||
if(tot > 0) {
|
||||
for(i=0; i<b->num_bins; i++)
|
||||
b->u.bins32[i] = (b->u.bins32[i]*100) / tot;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf, u_int out_buf_len) {
|
||||
u_int8_t i;
|
||||
u_int len = 0;
|
||||
|
||||
if(!out_buf) return(out_buf); else out_buf[0] = '\0';
|
||||
|
||||
if(normalize_first)
|
||||
ndpi_normalize_bin(b);
|
||||
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
for(i=0; i<b->num_bins; i++) {
|
||||
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
len += rc;
|
||||
}
|
||||
break;
|
||||
|
||||
case ndpi_bin_family16:
|
||||
for(i=0; i<b->num_bins; i++) {
|
||||
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
len += rc;
|
||||
}
|
||||
break;
|
||||
|
||||
case ndpi_bin_family32:
|
||||
for(i=0; i<b->num_bins; i++) {
|
||||
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
len += rc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return(out_buf);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
// #define COSINE_SIMILARITY
|
||||
|
||||
/*
|
||||
Determines how similar are two bins
|
||||
|
||||
Cosine Similiarity
|
||||
0 = Very differet
|
||||
... (gray zone)
|
||||
1 = Alike
|
||||
|
||||
See https://en.wikipedia.org/wiki/Cosine_similarity for more details
|
||||
|
||||
---
|
||||
Euclidean similarity
|
||||
|
||||
0 = alike
|
||||
...
|
||||
the higher the more different
|
||||
*/
|
||||
float ndpi_bin_similarity(struct ndpi_bin *b1, struct ndpi_bin *b2, u_int8_t normalize_first) {
|
||||
u_int8_t i;
|
||||
|
||||
if(
|
||||
// (b1->family != b2->family) ||
|
||||
(b1->num_bins != b2->num_bins))
|
||||
return(-1);
|
||||
|
||||
if(normalize_first)
|
||||
ndpi_normalize_bin(b1), ndpi_normalize_bin(b2);
|
||||
|
||||
#ifdef COSINE_SIMILARITY
|
||||
{
|
||||
u_int32_t sumxx = 0, sumxy = 0, sumyy = 0;
|
||||
|
||||
for(i=0; i<b1->num_bins; i++) {
|
||||
u_int32_t a = ndpi_get_bin_value(b1, i);
|
||||
u_int32_t b = ndpi_get_bin_value(b2, i);
|
||||
|
||||
sumxx += a*a, sumyy += b*b, sumxy += a*b;
|
||||
}
|
||||
|
||||
if((sumxx == 0) || (sumyy == 0))
|
||||
return(0);
|
||||
else
|
||||
return((float)sumxy / sqrt((float)(sumxx * sumyy)));
|
||||
}
|
||||
#else
|
||||
{
|
||||
u_int32_t sum = 0;
|
||||
|
||||
for(i=0; i<b1->num_bins; i++) {
|
||||
u_int32_t a = ndpi_get_bin_value(b1, i);
|
||||
u_int32_t b = ndpi_get_bin_value(b2, i);
|
||||
u_int32_t diff = (a > b) ? (a - b) : (b - a);
|
||||
|
||||
if(a != b) sum += pow(diff, 2);
|
||||
|
||||
// printf("[a: %u][b: %u][sum: %u]\n", a, b, sum);
|
||||
}
|
||||
|
||||
/* The lower the more similar */
|
||||
return(sqrt(sum));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
#define MAX_NUM_CLUSTERS 128
|
||||
|
||||
/*
|
||||
Clusters bins into 'num_clusters'
|
||||
- (in) bins: a vection 'num_bins' long of bins to cluster
|
||||
- (in) 'num_clusters': number of desired clusters 0...(num_clusters-1)
|
||||
- (out) 'cluster_ids': a vector 'num_bins' long containing the id's of each clustered bin
|
||||
- (out) 'centroids': an optional 'num_clusters' long vector of (centroid) bins
|
||||
See
|
||||
- https://en.wikipedia.org/wiki/K-means_clustering
|
||||
*/
|
||||
int ndpi_cluster_bins(struct ndpi_bin *bins, u_int16_t num_bins,
|
||||
u_int8_t num_clusters, u_int16_t *cluster_ids,
|
||||
struct ndpi_bin *centroids) {
|
||||
u_int16_t i, j, max_iterations = 25, num_iterations, num_moves;
|
||||
u_int8_t verbose = 0, alloc_centroids = 0;
|
||||
char out_buf[256];
|
||||
float *bin_score;
|
||||
u_int16_t num_cluster_elems[MAX_NUM_CLUSTERS] = { 0 };
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
if(num_clusters > num_bins) num_clusters = num_bins;
|
||||
if(num_clusters > MAX_NUM_CLUSTERS) num_clusters = MAX_NUM_CLUSTERS;
|
||||
|
||||
if(verbose)
|
||||
printf("Distributing %u bins over %u clusters\n", num_bins, num_clusters);
|
||||
|
||||
if((bin_score = (float*)ndpi_calloc(num_bins, sizeof(float))) == NULL)
|
||||
return(-2);
|
||||
|
||||
if(centroids == NULL) {
|
||||
alloc_centroids = 1;
|
||||
|
||||
if((centroids = (struct ndpi_bin*)ndpi_malloc(sizeof(struct ndpi_bin)*num_clusters)) == NULL) {
|
||||
ndpi_free(bin_score);
|
||||
return(-2);
|
||||
} else {
|
||||
for(i=0; i<num_clusters; i++)
|
||||
ndpi_init_bin(¢roids[i], ndpi_bin_family32 /* Use 32 bit to avoid overlaps */, bins[0].num_bins);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the id's */
|
||||
memset(cluster_ids, 0, sizeof(u_int16_t) * num_bins);
|
||||
|
||||
/* Randomly pick a cluster id */
|
||||
for(i=0; i<num_bins; i++) {
|
||||
u_int cluster_id = rand() % num_clusters;
|
||||
|
||||
cluster_ids[i] = cluster_id;
|
||||
|
||||
if(verbose)
|
||||
printf("Initializing cluster %u for bin %u: %s\n",
|
||||
cluster_id, i,
|
||||
ndpi_print_bin(&bins[i], 0, out_buf, sizeof(out_buf)));
|
||||
|
||||
num_cluster_elems[cluster_id]++;
|
||||
}
|
||||
|
||||
num_iterations = 0;
|
||||
|
||||
/* Now let's try to find a better arrangement */
|
||||
while(num_iterations++ < max_iterations) {
|
||||
|
||||
/* Compute the centroids for each cluster */
|
||||
memset(bin_score, 0, num_bins*sizeof(float));
|
||||
|
||||
if(verbose) {
|
||||
printf("\nIteration %u\n", num_iterations);
|
||||
|
||||
for(j=0; j<num_clusters; j++)
|
||||
printf("Cluster %u: %u bins\n", j, num_cluster_elems[j]);
|
||||
}
|
||||
|
||||
for(i=0; i<num_clusters; i++)
|
||||
ndpi_reset_bin(¢roids[i]);
|
||||
|
||||
for(i=0; i<num_bins; i++) {
|
||||
for(j=0; j<bins[i].num_bins; j++) {
|
||||
ndpi_inc_bin(¢roids[cluster_ids[i]], j, ndpi_get_bin_value(&bins[i], j));
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<num_clusters; i++) {
|
||||
ndpi_normalize_bin(¢roids[i]);
|
||||
|
||||
if(verbose)
|
||||
printf("Centroid [%u] %s\n", i,
|
||||
ndpi_print_bin(¢roids[i], 0, out_buf, sizeof(out_buf)));
|
||||
}
|
||||
|
||||
/* Now let's check if there are bins to move across clusters */
|
||||
num_moves = 0;
|
||||
|
||||
for(i=0; i<num_bins; i++) {
|
||||
u_int16_t j;
|
||||
float best_similarity, current_similarity = 0;
|
||||
u_int8_t cluster_id = 0;
|
||||
|
||||
if(verbose)
|
||||
printf("Analysing bin %u [cluster: %u]\n",
|
||||
i, cluster_ids[i]);
|
||||
|
||||
#ifdef COSINE_SIMILARITY
|
||||
best_similarity = -1;
|
||||
#else
|
||||
best_similarity = 99999999999;
|
||||
#endif
|
||||
|
||||
for(j=0; j<num_clusters; j++) {
|
||||
float similarity;
|
||||
|
||||
if(centroids[j].is_empty) continue;
|
||||
|
||||
similarity = ndpi_bin_similarity(&bins[i], ¢roids[j], 0);
|
||||
|
||||
if(j == cluster_ids[i])
|
||||
current_similarity = similarity;
|
||||
|
||||
if(verbose)
|
||||
printf("Bin %u / centroid %u [similarity: %f]\n", i, j, similarity);
|
||||
|
||||
#ifdef COSINE_SIMILARITY
|
||||
if(similarity > best_similarity) {
|
||||
cluster_id = j, best_similarity = similarity;
|
||||
}
|
||||
#else
|
||||
if(similarity < best_similarity) {
|
||||
cluster_id = j, best_similarity = similarity;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if((best_similarity == current_similarity) && (num_cluster_elems[cluster_ids[i]] > 1)) {
|
||||
/*
|
||||
In case of identical similarity let's leave things as they are
|
||||
this unless this is a cluster with only one element
|
||||
*/
|
||||
cluster_id = cluster_ids[i];
|
||||
}
|
||||
|
||||
bin_score[i] = best_similarity;
|
||||
|
||||
if(cluster_ids[i] != cluster_id) {
|
||||
if(verbose)
|
||||
printf("Moved bin %u from cluster %u -> %u [similarity: %f]\n",
|
||||
i, cluster_ids[i], cluster_id, best_similarity);
|
||||
|
||||
num_cluster_elems[cluster_ids[i]]--;
|
||||
num_cluster_elems[cluster_id]++;
|
||||
|
||||
cluster_ids[i] = cluster_id;
|
||||
num_moves++;
|
||||
}
|
||||
}
|
||||
|
||||
if(num_moves == 0)
|
||||
break;
|
||||
|
||||
if(verbose) {
|
||||
for(j=0; j<num_clusters; j++)
|
||||
printf("Cluster %u: %u bins\n", j, num_cluster_elems[j]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
for(j=0; j<num_clusters; j++) {
|
||||
if(num_cluster_elems[j] == 0) {
|
||||
u_int16_t candidate;
|
||||
float score;
|
||||
|
||||
if(verbose)
|
||||
printf("\nCluster %u is empty: need to rebalance\n", j);
|
||||
|
||||
#ifdef COSINE_SIMILARITY
|
||||
score = 99999999999;
|
||||
|
||||
for(i=0; i<num_bins; i++) {
|
||||
if((cluster_ids[i] != j) && (bin_score[i] < score) && (num_cluster_elems[cluster_ids[i]] > 1))
|
||||
score = bin_score[i], candidate = i;
|
||||
}
|
||||
#else
|
||||
score = 0;
|
||||
|
||||
for(i=0; i<num_bins; i++) {
|
||||
if((cluster_ids[i] != j) && (bin_score[i] > score) && (num_cluster_elems[cluster_ids[i]] > 1))
|
||||
score = bin_score[i], candidate = i;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(verbose)
|
||||
printf("Rebalance: moving bin %u from cluster %u -> %u [similarity: %f]\n",
|
||||
candidate, cluster_ids[candidate], j, score);
|
||||
|
||||
num_cluster_elems[cluster_ids[candidate]]--;
|
||||
num_cluster_elems[j]++;
|
||||
cluster_ids[candidate] = j;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} /* while(...) */
|
||||
|
||||
if(alloc_centroids) {
|
||||
for(i=0; i<num_clusters; i++)
|
||||
ndpi_free_bin(¢roids[i]);
|
||||
|
||||
ndpi_free(centroids);
|
||||
}
|
||||
|
||||
ndpi_free(bin_score);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* ********************************************************************************* */
|
||||
|
||||
+469
-467
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* ndpi_community_id.c
|
||||
*
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "ndpi_config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "ndpi_api.h"
|
||||
#include "ndpi_config.h"
|
||||
#include "ndpi_includes.h"
|
||||
|
||||
#include <time.h>
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#include "ndpi_sha1.h"
|
||||
|
||||
#define NDPI_ICMP6_ECHO_REQUEST 128
|
||||
#define NDPI_ICMP6_ECHO_REPLY 129
|
||||
#define NDPI_MLD_LISTENER_QUERY 130
|
||||
#define NDPI_MLD_LISTENER_REPORT 131
|
||||
|
||||
#define NDPI_ROUTER_SOLICIT 133
|
||||
#define NDPI_ROUTER_ADVERT 134
|
||||
#define NDPI_NEIGHBOR_SOLICIT 135
|
||||
#define NDPI_NEIGHBOR_ADVERT 136
|
||||
|
||||
#define NDPI_ICMP_ECHOREPLY 0
|
||||
#define NDPI_ICMP_ECHO 8
|
||||
#define NDPI_ICMP_ROUTERADVERT 9
|
||||
#define NDPI_ICMP_ROUTERSOLICIT 10
|
||||
#define NDPI_ICMP_TIMESTAMP 13
|
||||
#define NDPI_ICMP_TIMESTAMPREPLY 14
|
||||
#define NDPI_ICMP_INFO_REQUEST 15
|
||||
#define NDPI_ICMP_INFO_REPLY 16
|
||||
#define NDPI_ICMP_MASKREQ 17
|
||||
#define NDPI_ICMP_MASKREPLY 18
|
||||
|
||||
#define NDPI_ICMP6_WRUREQUEST 139
|
||||
#define NDPI_ICMP6_WRUREPLY 140
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
static ssize_t ndpi_community_id_buf_copy(u_int8_t * const dst, const void * const src, ssize_t len) {
|
||||
if(src)
|
||||
memcpy(dst, src, len);
|
||||
else
|
||||
memset(dst, 0, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
/*
|
||||
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L56
|
||||
*/
|
||||
static u_int8_t ndpi_community_id_icmp_type_to_code_v4(u_int8_t icmp_type, u_int8_t icmp_code, int *is_one_way) {
|
||||
*is_one_way = 0;
|
||||
|
||||
switch(icmp_type) {
|
||||
case NDPI_ICMP_ECHO:
|
||||
return NDPI_ICMP_ECHOREPLY;
|
||||
case NDPI_ICMP_ECHOREPLY:
|
||||
return NDPI_ICMP_ECHO;
|
||||
case NDPI_ICMP_TIMESTAMP:
|
||||
return NDPI_ICMP_TIMESTAMPREPLY;
|
||||
case NDPI_ICMP_TIMESTAMPREPLY:
|
||||
return NDPI_ICMP_TIMESTAMP;
|
||||
case NDPI_ICMP_INFO_REQUEST:
|
||||
return NDPI_ICMP_INFO_REPLY;
|
||||
case NDPI_ICMP_INFO_REPLY:
|
||||
return NDPI_ICMP_INFO_REQUEST;
|
||||
case NDPI_ICMP_ROUTERSOLICIT:
|
||||
return NDPI_ICMP_ROUTERADVERT;
|
||||
case NDPI_ICMP_ROUTERADVERT:
|
||||
return NDPI_ICMP_ROUTERSOLICIT;
|
||||
case NDPI_ICMP_MASKREQ:
|
||||
return NDPI_ICMP_MASKREPLY;
|
||||
case NDPI_ICMP_MASKREPLY:
|
||||
return NDPI_ICMP_MASKREQ;
|
||||
default:
|
||||
*is_one_way = 1;
|
||||
return icmp_code;
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
/*
|
||||
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L83
|
||||
*/
|
||||
static u_int8_t ndpi_community_id_icmp_type_to_code_v6(u_int8_t icmp_type, u_int8_t icmp_code, int *is_one_way) {
|
||||
*is_one_way = 0;
|
||||
|
||||
switch(icmp_type) {
|
||||
case NDPI_ICMP6_ECHO_REQUEST:
|
||||
return NDPI_ICMP6_ECHO_REPLY;
|
||||
case NDPI_ICMP6_ECHO_REPLY:
|
||||
return NDPI_ICMP6_ECHO_REQUEST;
|
||||
case NDPI_ROUTER_SOLICIT:
|
||||
return NDPI_ROUTER_ADVERT;
|
||||
case NDPI_ROUTER_ADVERT:
|
||||
return NDPI_ROUTER_SOLICIT;
|
||||
case NDPI_NEIGHBOR_SOLICIT:
|
||||
return NDPI_NEIGHBOR_ADVERT;
|
||||
case NDPI_NEIGHBOR_ADVERT:
|
||||
return NDPI_NEIGHBOR_SOLICIT;
|
||||
case NDPI_MLD_LISTENER_QUERY:
|
||||
return NDPI_MLD_LISTENER_REPORT;
|
||||
case NDPI_MLD_LISTENER_REPORT:
|
||||
return NDPI_MLD_LISTENER_QUERY;
|
||||
case NDPI_ICMP6_WRUREQUEST:
|
||||
return NDPI_ICMP6_WRUREPLY;
|
||||
case NDPI_ICMP6_WRUREPLY:
|
||||
return NDPI_ICMP6_WRUREQUEST;
|
||||
// Home Agent Address Discovery Request Message and reply
|
||||
case 144:
|
||||
return 145;
|
||||
case 145:
|
||||
return 144;
|
||||
default:
|
||||
*is_one_way = 1;
|
||||
return icmp_code;
|
||||
}
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
/*
|
||||
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L164
|
||||
*/
|
||||
static int ndpi_community_id_peer_v4_is_less_than(u_int32_t ip1, u_int32_t ip2, u_int16_t p1, u_int16_t p2) {
|
||||
int comp = memcmp(&ip1, &ip2, sizeof(u_int32_t));
|
||||
return comp < 0 || (comp == 0 && p1 < p2);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
static int ndpi_community_id_peer_v6_is_less_than(struct ndpi_in6_addr *ip1, struct ndpi_in6_addr *ip2, u_int16_t p1, u_int16_t p2) {
|
||||
int comp = memcmp(ip1, ip2, sizeof(struct ndpi_in6_addr));
|
||||
|
||||
return comp < 0 || (comp == 0 && p1 < p2);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
void ndpi_string_sha1_hash(const uint8_t *message, size_t len, u_char *hash /* 20-bytes */) {
|
||||
SHA1_CTX ctx;
|
||||
|
||||
SHA1Init(&ctx);
|
||||
SHA1Update(&ctx, message, len);
|
||||
SHA1Final(hash, &ctx);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
/*
|
||||
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L285
|
||||
*/
|
||||
static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int16_t off, u_int8_t l4_proto,
|
||||
u_int16_t src_port, u_int16_t dst_port,
|
||||
char *hash_buf, u_int8_t hash_buf_len) {
|
||||
u_int8_t pad = 0;
|
||||
uint32_t hash[5];
|
||||
char *community_id;
|
||||
|
||||
/* L4 proto */
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], &l4_proto, sizeof(l4_proto));
|
||||
|
||||
/* Pad */
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], &pad, sizeof(pad));
|
||||
|
||||
/* Source and destination ports */
|
||||
switch(l4_proto) {
|
||||
case IPPROTO_ICMP:
|
||||
case IPPROTO_ICMPV6:
|
||||
case IPPROTO_SCTP:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], &src_port, sizeof(src_port));
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], &dst_port, sizeof(dst_port));
|
||||
break;
|
||||
}
|
||||
|
||||
/* Compute SHA1 */
|
||||
ndpi_string_sha1_hash(comm_buf, off, (u_char*)hash);
|
||||
|
||||
/* Base64 encoding */
|
||||
community_id = ndpi_base64_encode((u_int8_t*)hash, sizeof(hash));
|
||||
|
||||
if(community_id == NULL)
|
||||
return -1;
|
||||
|
||||
#if 0 /* Debug Info */
|
||||
printf("Hex output: ");
|
||||
for(int i = 0; i < off; i++)
|
||||
printf("%.2x ", comm_buf[i]);
|
||||
printf("\n");
|
||||
|
||||
printf("Sha1 sum: ");
|
||||
for(int i = 0; i < 5; i++)
|
||||
printf("%.2x ", ntohl(hash[i]));
|
||||
printf("\n");
|
||||
|
||||
printf("Base64: %s\n", community_id);
|
||||
#endif
|
||||
|
||||
if(hash_buf_len < 2 || hash_buf_len-2 < strlen(community_id)+1) {
|
||||
ndpi_free(community_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Writing hash */
|
||||
hash_buf[0] = '1';
|
||||
hash_buf[1] = ':';
|
||||
strcpy(&hash_buf[2], community_id);
|
||||
ndpi_free(community_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
/*
|
||||
NOTE:
|
||||
- Leave fields empty/zero when information is missing (e.g. with ICMP ports are zero)
|
||||
- The hash_buf most be 30+1 bits or longer
|
||||
- Return code: 0 = OK, -1 otherwise
|
||||
*/
|
||||
|
||||
int ndpi_flowv4_flow_hash(u_int8_t l4_proto, u_int32_t src_ip, u_int32_t dst_ip,
|
||||
u_int16_t src_port, u_int16_t dst_port,
|
||||
u_int8_t icmp_type, u_int8_t icmp_code,
|
||||
u_char *hash_buf, u_int8_t hash_buf_len) {
|
||||
/*
|
||||
Input buffer (40 bytes)
|
||||
2 - Seed
|
||||
16 - IPv6 src
|
||||
16 - IPv6 dst
|
||||
1 - L4 proto
|
||||
1 - Pad
|
||||
2 - Port src
|
||||
2 - Port dst
|
||||
*/
|
||||
u_int8_t comm_buf[40] = { 0 };
|
||||
u_int16_t off = 0;
|
||||
u_int16_t seed = 0;
|
||||
u_int32_t *ip_a_ptr, *ip_b_ptr;
|
||||
u_int16_t port_a, port_b;
|
||||
int icmp_one_way = 0;
|
||||
|
||||
/* Adjust the ports according to the specs */
|
||||
switch(l4_proto) {
|
||||
case IPPROTO_ICMP:
|
||||
src_port = icmp_type;
|
||||
dst_port = ndpi_community_id_icmp_type_to_code_v4(icmp_type, icmp_code, &icmp_one_way);
|
||||
break;
|
||||
case IPPROTO_SCTP:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
/* src/dst port ok */
|
||||
break;
|
||||
default:
|
||||
src_port = dst_port = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert tuple to NBO */
|
||||
src_ip = htonl(src_ip);
|
||||
dst_ip = htonl(dst_ip);
|
||||
src_port = htons(src_port);
|
||||
dst_port = htons(dst_port);
|
||||
|
||||
/*
|
||||
The community id hash doesn't have the definition of client and server, it just sorts IP addresses
|
||||
and ports to make sure the smaller ip address is the first. This performs this check and
|
||||
possibly swap client ip and port.
|
||||
*/
|
||||
if(icmp_one_way || ndpi_community_id_peer_v4_is_less_than(src_ip, dst_ip, src_port, dst_port)) {
|
||||
ip_a_ptr = &src_ip, ip_b_ptr = &dst_ip;
|
||||
port_a = src_port, port_b = dst_port;
|
||||
} else {
|
||||
/* swap flow peers */
|
||||
ip_a_ptr = &dst_ip, ip_b_ptr = &src_ip;
|
||||
port_a = dst_port, port_b = src_port;
|
||||
}
|
||||
|
||||
/* Seed */
|
||||
off = ndpi_community_id_buf_copy(&comm_buf[off], &seed, sizeof(seed));
|
||||
|
||||
/* Source and destination IPs */
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_a_ptr, sizeof(src_ip));
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_b_ptr, sizeof(dst_ip));
|
||||
|
||||
return ndpi_community_id_finalize_and_compute_hash(comm_buf, off,
|
||||
l4_proto, port_a, port_b, (char*)hash_buf, hash_buf_len);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
|
||||
int ndpi_flowv6_flow_hash(u_int8_t l4_proto, struct ndpi_in6_addr *src_ip, struct ndpi_in6_addr *dst_ip,
|
||||
u_int16_t src_port, u_int16_t dst_port,
|
||||
u_int8_t icmp_type, u_int8_t icmp_code,
|
||||
u_char *hash_buf, u_int8_t hash_buf_len) {
|
||||
u_int8_t comm_buf[40] = { 0 };
|
||||
u_int16_t off = 0;
|
||||
u_int16_t seed = 0;
|
||||
struct ndpi_in6_addr *ip_a_ptr, *ip_b_ptr;
|
||||
u_int16_t port_a, port_b;
|
||||
int icmp_one_way = 0;
|
||||
|
||||
switch(l4_proto) {
|
||||
case IPPROTO_ICMPV6:
|
||||
src_port = icmp_type;
|
||||
dst_port = ndpi_community_id_icmp_type_to_code_v6(icmp_type, icmp_code, &icmp_one_way);
|
||||
break;
|
||||
case IPPROTO_SCTP:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
/* src/dst port ok */
|
||||
break;
|
||||
default:
|
||||
src_port = dst_port = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Convert tuple to NBO */
|
||||
src_port = htons(src_port);
|
||||
dst_port = htons(dst_port);
|
||||
|
||||
if(icmp_one_way || ndpi_community_id_peer_v6_is_less_than(src_ip, dst_ip, src_port, dst_port)) {
|
||||
ip_a_ptr = src_ip, ip_b_ptr = dst_ip;
|
||||
port_a = src_port, port_b = dst_port;
|
||||
} else {
|
||||
ip_a_ptr = dst_ip, ip_b_ptr = src_ip;
|
||||
port_a = dst_port, port_b = src_port;
|
||||
}
|
||||
|
||||
/* Seed */
|
||||
off = ndpi_community_id_buf_copy(&comm_buf[off], &seed, sizeof(seed));
|
||||
|
||||
/* Source and destination IPs */
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_a_ptr, sizeof(struct ndpi_in6_addr));
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_b_ptr, sizeof(struct ndpi_in6_addr));
|
||||
|
||||
return ndpi_community_id_finalize_and_compute_hash(comm_buf, off,
|
||||
l4_proto, port_a, port_b, (char*)hash_buf, hash_buf_len);
|
||||
}
|
||||
|
||||
/* **************************************************** */
|
||||
+1179
-731
File diff suppressed because it is too large
Load Diff
+3139
-2729
File diff suppressed because it is too large
Load Diff
+1112
-471
File diff suppressed because it is too large
Load Diff
+1091
-25
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
* afp.c
|
||||
*
|
||||
* Copyright (C) 2009-11 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* aimini.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -63,7 +63,7 @@ static void set_ajp_detected(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
/* If no custom protocol has been detected */
|
||||
/* if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) */
|
||||
ndpi_int_reset_protocol(flow);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, flow->guessed_host_protocol_id, NDPI_PROTOCOL_AJP);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AJP, flow->guessed_host_protocol_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* amazon_video.c
|
||||
*
|
||||
* Copyright (C) 2018 by ntop.org
|
||||
* Copyright (C) 2018-20 by ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -28,37 +28,36 @@
|
||||
#include "ndpi_api.h"
|
||||
|
||||
static void ndpi_check_amazon_video(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
|
||||
struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search Amazon Prime\n");
|
||||
|
||||
if((packet->tcp != NULL) &&
|
||||
(packet->payload[0] == 0xFE &&
|
||||
packet->payload[1] == 0xED &&
|
||||
packet->payload[2] == 0xFA &&
|
||||
packet->payload[3] == 0xCE))
|
||||
{
|
||||
if(packet->payload_packet_len > 4) {
|
||||
if((packet->tcp != NULL) &&
|
||||
(packet->payload[0] == 0xFE &&
|
||||
packet->payload[1] == 0xED &&
|
||||
packet->payload[2] == 0xFA &&
|
||||
packet->payload[3] == 0xCE)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found Amazon Video on TCP\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
else if((packet->udp != NULL) &&
|
||||
(packet->payload[0] == 0xDE &&
|
||||
packet->payload[1] == 0xAD &&
|
||||
packet->payload[2] == 0xBE &&
|
||||
packet->payload[3] == 0xEF))
|
||||
{
|
||||
} else if((packet->udp != NULL) &&
|
||||
(packet->payload[0] == 0xDE &&
|
||||
packet->payload[1] == 0xAD &&
|
||||
packet->payload[2] == 0xBE &&
|
||||
packet->payload[3] == 0xEF)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found Amazon Video on UDP\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_UNKNOWN);
|
||||
} else {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void ndpi_search_amazon_video(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
void ndpi_search_amazon_video(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search amazon_video\n");
|
||||
@@ -69,8 +68,8 @@ void ndpi_search_amazon_video(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
|
||||
|
||||
void init_amazon_video_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
void init_amazon_video_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
|
||||
ndpi_set_bitmask_protocol_detection("AMAZON_VIDEO", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_AMAZON_VIDEO,
|
||||
ndpi_search_amazon_video,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* amqp.c
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* applejuice.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* armagetron.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* flash.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* ftp.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* manolito.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* popo.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* secondlife.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* ayiya.c
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -57,7 +57,7 @@ void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
u_int32_t epoch = ntohl(a->epoch), now;
|
||||
u_int32_t fiveyears = 86400 * 365 * 5;
|
||||
|
||||
now = flow->packet.tick_timestamp;
|
||||
now = flow->packet.current_time_ms;
|
||||
|
||||
if((epoch >= (now - fiveyears)) && (epoch <= (now+86400 /* 1 day */))) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found AYIYA\n");
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* battlefield.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_BATTLEFIELD
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
static void ndpi_int_battlefield_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
struct ndpi_id_struct *src = flow->src;
|
||||
struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BATTLEFIELD, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if (src != NULL) {
|
||||
src->battlefield_ts = packet->tick_timestamp;
|
||||
}
|
||||
if (dst != NULL) {
|
||||
dst->battlefield_ts = packet->tick_timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
struct ndpi_id_struct *src = flow->src;
|
||||
struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_BATTLEFIELD) {
|
||||
if (src != NULL && ((u_int32_t)
|
||||
(packet->tick_timestamp - src->battlefield_ts) < ndpi_struct->battlefield_timeout)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct,
|
||||
"battlefield : save src connection packet detected\n");
|
||||
src->battlefield_ts = packet->tick_timestamp;
|
||||
} else if (dst != NULL && ((u_int32_t)
|
||||
(packet->tick_timestamp - dst->battlefield_ts) < ndpi_struct->battlefield_timeout)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct,
|
||||
"battlefield : save dst connection packet detected\n");
|
||||
dst->battlefield_ts = packet->tick_timestamp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_BATTLEFIELD)) {
|
||||
if (flow->l4.udp.battlefield_stage == 0 || flow->l4.udp.battlefield_stage == 1 + packet->packet_direction) {
|
||||
if (packet->payload_packet_len > 8 && get_u_int16_t(packet->payload, 0) == htons(0xfefd)) {
|
||||
flow->l4.udp.battlefield_msg_id = get_u_int32_t(packet->payload, 2);
|
||||
flow->l4.udp.battlefield_stage = 1 + packet->packet_direction;
|
||||
return;
|
||||
}
|
||||
} else if (flow->l4.udp.battlefield_stage == 2 - packet->packet_direction) {
|
||||
if (packet->payload_packet_len > 8 && get_u_int32_t(packet->payload, 0) == flow->l4.udp.battlefield_msg_id) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found Battlefield message and reply detected\n");
|
||||
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flow->l4.udp.battlefield_stage == 0) {
|
||||
if (packet->payload_packet_len == 46 && packet->payload[2] == 0 && packet->payload[4] == 0
|
||||
&& get_u_int32_t(packet->payload, 7) == htonl(0x98001100)) {
|
||||
flow->l4.udp.battlefield_stage = 3 + packet->packet_direction;
|
||||
return;
|
||||
}
|
||||
} else if (flow->l4.udp.battlefield_stage == 4 - packet->packet_direction) {
|
||||
if (packet->payload_packet_len == 7
|
||||
&& (packet->payload[0] == 0x02 || packet->payload[packet->payload_packet_len - 1] == 0xe0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found Battlefield message and reply detected\n");
|
||||
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (packet->payload_packet_len == 18 && memcmp(&packet->payload[5], "battlefield2\x00", 13) == 0) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found Battlefield 2 hello packet detected\n");
|
||||
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
} else if (packet->payload_packet_len > 10 &&
|
||||
(memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x50\xb9\x10\x11", 10) == 0
|
||||
|| memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x30\xb9\x10\x11", 10) == 0
|
||||
|| memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\xa0\x98\x00\x11", 10) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found Battlefield safe pattern detected\n");
|
||||
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("BattleField", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_BATTLEFIELD,
|
||||
ndpi_search_battlefield,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* bgp.c
|
||||
*
|
||||
* Copyright (C) 2016-19 - ntop.org
|
||||
* Copyright (C) 2016-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* bittorrent.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -43,7 +43,7 @@ struct ndpi_utp_hdr {
|
||||
u_int16_t sequence_nr, ack_nr;
|
||||
};
|
||||
|
||||
static u_int8_t is_utp_pkt(const u_int8_t *payload, u_int payload_len) {
|
||||
static u_int8_t is_utpv1_pkt(const u_int8_t *payload, u_int payload_len) {
|
||||
struct ndpi_utp_hdr *h = (struct ndpi_utp_hdr*)payload;
|
||||
|
||||
if(payload_len < sizeof(struct ndpi_utp_hdr)) return(0);
|
||||
@@ -52,6 +52,9 @@ static u_int8_t is_utp_pkt(const u_int8_t *payload, u_int payload_len) {
|
||||
if(h->next_extension > 2) return(0);
|
||||
if(ntohl(h->window_size) > 65565) return(0);
|
||||
|
||||
if((h->window_size == 0) && (payload_len != sizeof(struct ndpi_utp_hdr)))
|
||||
return(0);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
|
||||
{
|
||||
if(check_hash) {
|
||||
const char *bt_hash = NULL; /* 20 bytes long */
|
||||
|
||||
|
||||
if(bt_offset == -1) {
|
||||
const char *bt_magic = ndpi_strnstr((const char *)flow->packet.payload,
|
||||
"BitTorrent protocol", flow->packet.payload_packet_len);
|
||||
@@ -72,9 +75,8 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
|
||||
} else
|
||||
bt_hash = (const char*)&flow->packet.payload[28];
|
||||
|
||||
if(!ndpi_struct->disable_metadata_export) {
|
||||
if(bt_hash) memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
|
||||
}
|
||||
if(bt_hash && (flow->packet.payload_packet_len >= (20 + (bt_hash-(const char*)flow->packet.payload))))
|
||||
memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
|
||||
}
|
||||
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN);
|
||||
@@ -376,19 +378,30 @@ static void ndpi_int_search_bittorrent_tcp(struct ndpi_detection_module_struct *
|
||||
return;
|
||||
}
|
||||
|
||||
static u_int8_t is_port(u_int16_t a, u_int16_t b, u_int16_t what) {
|
||||
return(((what == a) || (what == b)) ? 1 : 0);
|
||||
}
|
||||
|
||||
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
char *bt_proto = NULL;
|
||||
|
||||
/* This is broadcast */
|
||||
if(packet->iph
|
||||
&& (((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF))
|
||||
|| (packet->udp
|
||||
&& ((ntohs(packet->udp->source) == 3544) /* teredo.c */
|
||||
|| (ntohs(packet->udp->dest) == 3544))))) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
if(packet->iph) {
|
||||
if((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF))
|
||||
goto exclude_bt;
|
||||
|
||||
if(packet->udp) {
|
||||
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||
|
||||
if(is_port(sport, dport, 3544) /* teredo */
|
||||
|| is_port(sport, dport, 5246) || is_port(sport, dport, 5247)/* CAPWAP */) {
|
||||
exclude_bt:
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_BITTORRENT) {
|
||||
@@ -397,14 +410,16 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
if((packet->tcp != NULL)
|
||||
&& (packet->tcp_retransmission == 0 || packet->num_retried_bytes)) {
|
||||
ndpi_int_search_bittorrent_tcp(ndpi_struct, flow);
|
||||
}
|
||||
else if(packet->udp != NULL) {
|
||||
} else if(packet->udp != NULL) {
|
||||
/* UDP */
|
||||
char *bt_search = "BT-SEARCH * HTTP/1.1\r\n";
|
||||
|
||||
if((ntohs(packet->udp->source) < 1024)
|
||||
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */)
|
||||
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Check for uTP http://www.bittorrent.org/beps/bep_0029.html
|
||||
|
||||
@@ -421,14 +436,10 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
u_int8_t v0_extension = packet->payload[17];
|
||||
u_int8_t v0_flags = packet->payload[18];
|
||||
|
||||
/* Check if this is protocol v1 */
|
||||
u_int8_t v1_version = packet->payload[0];
|
||||
u_int8_t v1_extension = packet->payload[1];
|
||||
u_int32_t v1_window_size = *((u_int32_t*)&packet->payload[12]);
|
||||
|
||||
if(is_utp_pkt(packet->payload, packet->payload_packet_len))
|
||||
if(is_utpv1_pkt(packet->payload, packet->payload_packet_len)) {
|
||||
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
|
||||
goto bittorrent_found;
|
||||
else if((packet->payload[0]== 0x60)
|
||||
} else if((packet->payload[0]== 0x60)
|
||||
&& (packet->payload[1]== 0x0)
|
||||
&& (packet->payload[2]== 0x0)
|
||||
&& (packet->payload[3]== 0x0)
|
||||
@@ -436,14 +447,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
/* Heuristic */
|
||||
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
|
||||
goto bittorrent_found;
|
||||
/* CSGO/DOTA conflict */
|
||||
} else if(flow->packet_counter > 8 && ((v1_version & 0x0f) == 1)
|
||||
&& ((v1_version >> 4) < 5 /* ST_NUM_STATES */)
|
||||
&& (v1_extension < 3 /* EXT_NUM_EXT */)
|
||||
&& (v1_window_size < 32768 /* 32k */)
|
||||
) {
|
||||
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
|
||||
goto bittorrent_found;
|
||||
/* CSGO/DOTA conflict */
|
||||
} else if((v0_flags < 6 /* ST_NUM_STATES */) && (v0_extension < 3 /* EXT_NUM_EXT */)) {
|
||||
u_int32_t ts = ntohl(*((u_int32_t*)&(packet->payload[4])));
|
||||
u_int32_t now;
|
||||
@@ -460,7 +464,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
flow->bittorrent_stage++;
|
||||
|
||||
if(flow->bittorrent_stage < 10) {
|
||||
if(flow->bittorrent_stage < 5) {
|
||||
/* We have detected bittorrent but we need to wait until we get a hash */
|
||||
|
||||
if(packet->payload_packet_len > 19 /* min size */) {
|
||||
@@ -485,6 +489,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* btlib.c
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
* Contributed by Vitaly Lavrov <vel21ripn@gmail.com>
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
@@ -23,12 +23,13 @@
|
||||
*/
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#if 0
|
||||
#ifndef NDPI_NO_STD_INC
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
/*
|
||||
@@ -39,8 +40,11 @@ typedef unsigned long long int u_int64_t;
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef WIN32
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "btlib.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* capwap.c
|
||||
*
|
||||
* Copyright (C) 2019 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CAPWAP
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#define NDPI_CAPWAP_CONTROL_PORT 5246
|
||||
#define NDPI_CAPWAP_DATA_PORT 5247
|
||||
|
||||
|
||||
static void ndpi_int_capwap_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CAPWAP, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
/* ************************************************** */
|
||||
|
||||
static void ndpi_search_setup_capwap(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int16_t sport, dport;
|
||||
|
||||
if(!packet->iph) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||
|
||||
if((dport == NDPI_CAPWAP_CONTROL_PORT)
|
||||
&& (packet->iph->daddr == 0xFFFFFFFF)
|
||||
&& (packet->payload_packet_len >= 16)
|
||||
&& (packet->payload[0] == 0x0)
|
||||
&& (packet->payload[8] == 6 /* Mac len */)
|
||||
)
|
||||
goto capwap_found;
|
||||
|
||||
if(((sport == NDPI_CAPWAP_CONTROL_PORT) || (dport == NDPI_CAPWAP_CONTROL_PORT))
|
||||
&& ((packet->payload[0] == 0x0) || (packet->payload[0] == 0x1))
|
||||
) {
|
||||
u_int16_t msg_len, offset, to_add;
|
||||
|
||||
if(packet->payload[0] == 0x0)
|
||||
offset = 13, to_add = 13;
|
||||
else
|
||||
offset = 15, to_add = 17;
|
||||
|
||||
if (packet->payload_packet_len >= offset + sizeof(u_int16_t)) {
|
||||
msg_len = ntohs(*(u_int16_t*)&packet->payload[offset]);
|
||||
|
||||
if((msg_len+to_add) == packet->payload_packet_len)
|
||||
goto capwap_found;
|
||||
}
|
||||
}
|
||||
|
||||
if(
|
||||
(((dport == NDPI_CAPWAP_DATA_PORT) && (packet->iph->daddr != 0xFFFFFFFF)) || (sport == NDPI_CAPWAP_DATA_PORT))
|
||||
&& (packet->payload_packet_len >= 16)
|
||||
&& (packet->payload[0] == 0x0)
|
||||
) {
|
||||
u_int8_t is_80211_data = (packet->payload[9] & 0x0C) >> 2;
|
||||
|
||||
|
||||
if((sport == NDPI_CAPWAP_DATA_PORT) && (is_80211_data == 2 /* IEEE 802.11 Data */))
|
||||
goto capwap_found;
|
||||
else if(dport == NDPI_CAPWAP_DATA_PORT) {
|
||||
u_int16_t msg_len = ntohs(*(u_int16_t*)&packet->payload[13]);
|
||||
|
||||
if((packet->payload[8] == 1 /* Mac len */)
|
||||
|| (packet->payload[8] == 6 /* Mac len */)
|
||||
|| (packet->payload[8] == 4 /* Wireless len */)
|
||||
|| ((msg_len+15) == packet->payload_packet_len))
|
||||
goto capwap_found;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
|
||||
capwap_found:
|
||||
ndpi_int_capwap_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void ndpi_search_capwap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
if(packet->udp && (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN))
|
||||
ndpi_search_setup_capwap(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_capwap_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("CAPWAP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CAPWAP,
|
||||
ndpi_search_capwap,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* checkmk.c
|
||||
*
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
/*
|
||||
* ciscovpn.c
|
||||
* Copyright (C) 2013 by Remy Mudingay <mudingay@ill.fr>
|
||||
*
|
||||
* Copyright (C) 2013-20 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Dissector developed by Remy Mudingay <mudingay@ill.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -10,12 +26,15 @@
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
/* ****************************************************************** */
|
||||
|
||||
static void ndpi_int_ciscovpn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
/* ****************************************************************** */
|
||||
|
||||
void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
@@ -29,6 +48,7 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over tcp ports\n");
|
||||
}
|
||||
|
||||
if(packet->udp != NULL) {
|
||||
usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over udp ports\n");
|
||||
@@ -36,26 +56,26 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|
||||
if((tdport == 10000 && tsport == 10000) ||
|
||||
((tsport == 443 || tdport == 443) &&
|
||||
(packet->payload_packet_len >= 4) &&
|
||||
(packet->payload[0] == 0x17 &&
|
||||
packet->payload[1] == 0x01 &&
|
||||
packet->payload[2] == 0x00 &&
|
||||
packet->payload[3] == 0x00)
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
/* This is a good query 17010000*/
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
|
||||
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
) {
|
||||
/* This is a good query 17010000*/
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
|
||||
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
else if(((tsport == 443 || tdport == 443) ||
|
||||
(tsport == 80 || tdport == 80)) &&
|
||||
(tsport == 80 || tdport == 80)) &&
|
||||
(packet->payload_packet_len >= 5) &&
|
||||
((packet->payload[0] == 0x17 &&
|
||||
packet->payload[1] == 0x03 &&
|
||||
packet->payload[2] == 0x03 &&
|
||||
packet->payload[3] == 0x00 &&
|
||||
packet->payload[4] == 0x3A)))
|
||||
packet->payload[1] == 0x03 &&
|
||||
packet->payload[2] == 0x03 &&
|
||||
packet->payload[3] == 0x00 &&
|
||||
packet->payload[4] == 0x3A)))
|
||||
{
|
||||
/* TLS signature of Cisco AnyConnect 0X170303003A */
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCO Anyconnect VPN\n");
|
||||
@@ -63,12 +83,13 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
return;
|
||||
}
|
||||
else if(((tsport == 8009 || tdport == 8009) ||
|
||||
(tsport == 8008 || tdport == 8008)) &&
|
||||
(tsport == 8008 || tdport == 8008)) &&
|
||||
(packet->payload_packet_len >= 5) &&
|
||||
((packet->payload[0] == 0x17 &&
|
||||
packet->payload[1] == 0x03 &&
|
||||
packet->payload[2] == 0x03 &&
|
||||
packet->payload[3] == 0x00 &&
|
||||
packet->payload[4] == 0x69)))
|
||||
packet->payload[1] == 0x03 &&
|
||||
packet->payload[2] == 0x03 &&
|
||||
packet->payload[3] == 0x00 &&
|
||||
packet->payload[4] == 0x69)))
|
||||
{
|
||||
/* TCP signature of Cisco AnyConnect 0X1703030069 */
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCO Anyconnect VPN\n");
|
||||
@@ -79,6 +100,7 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
(
|
||||
(usport == 10000 && udport == 10000)
|
||||
&&
|
||||
(packet->payload_packet_len >= 4) &&
|
||||
(packet->payload[0] == 0xfe &&
|
||||
packet->payload[1] == 0x57 &&
|
||||
packet->payload[2] == 0x7e &&
|
||||
@@ -86,15 +108,29 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
/* This is a good query fe577e2b */
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
|
||||
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
} else if(
|
||||
(
|
||||
(usport == 443 || udport == 443)
|
||||
&&
|
||||
(packet->payload_packet_len >= 5) &&
|
||||
(packet->payload[0] == 0x17 &&
|
||||
packet->payload[1] == 0x01 &&
|
||||
packet->payload[2] == 0x00 &&
|
||||
packet->payload[3] == 0x00 &&
|
||||
packet->payload[4] == 0x01)
|
||||
)
|
||||
)
|
||||
{
|
||||
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
|
||||
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if(flow->num_processed_pkts > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* citrix.c
|
||||
*
|
||||
* Copyright (C) 2012-19 - ntop.org
|
||||
* Copyright (C) 2012-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -51,7 +51,7 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
return;
|
||||
} else if(payload_len > 4) {
|
||||
} else if(payload_len > 22) {
|
||||
char citrix_header[] = { 0x1a, 0x43, 0x47, 0x50, 0x2f, 0x30, 0x31 };
|
||||
|
||||
if((memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* collectd.c
|
||||
*
|
||||
* Copyright (C) 2014-19 - ntop.org
|
||||
* Copyright (C) 2014-20 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* crossfire.c
|
||||
*
|
||||
* Copyright (C) 2012-19 - ntop.org
|
||||
* Copyright (C) 2012-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
+47
-32
@@ -29,8 +29,8 @@
|
||||
void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
|
||||
struct ndpi_packet_struct* packet = &flow->packet;
|
||||
|
||||
if (packet->udp != NULL) {
|
||||
if (packet->payload_packet_len < sizeof(uint32_t)) {
|
||||
if(packet->udp != NULL) {
|
||||
if(packet->payload_packet_len < sizeof(uint32_t)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Short csgo packet\n");
|
||||
return;
|
||||
}
|
||||
@@ -38,58 +38,65 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
|
||||
uint32_t w = htonl(get_u_int32_t(packet->payload, 0));
|
||||
NDPI_LOG_DBG2(ndpi_struct, "CSGO: word %08x\n", w);
|
||||
|
||||
if (!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
|
||||
if (!memcmp(packet->payload + 5, "connect0x", 9)) {
|
||||
if(!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
|
||||
if(!memcmp(packet->payload + 5, "connect0x", 9)) {
|
||||
flow->csgo_state++;
|
||||
memcpy(flow->csgo_strid, packet->payload + 5, 18);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "Found csgo connect0x\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
|
||||
if (!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
|
||||
|
||||
if(flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
|
||||
if(!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
|
||||
flow->csgo_state++;
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo connect0x reply\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
|
||||
|
||||
if(packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 8b\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 36 && w == 0x56533031ul) {
|
||||
|
||||
if(packet->payload_packet_len >= 36 && w == 0x56533031ul) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 36 && w == 0x01007364) {
|
||||
|
||||
if(packet->payload_packet_len >= 36 && w == 0x01007364) {
|
||||
uint32_t w2 = htonl(get_u_int32_t(packet->payload, 4));
|
||||
if (w2 == 0x70696e67) {
|
||||
if(w2 == 0x70696e67) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp ping\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
|
||||
|
||||
if(flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
|
||||
uint32_t w2 = get_u_int32_t(packet->payload, 2);
|
||||
if (packet->payload_packet_len == 13) {
|
||||
if (!flow->csgo_s2) {
|
||||
if(packet->payload_packet_len == 13) {
|
||||
if(!flow->csgo_s2) {
|
||||
flow->csgo_id2 = w2;
|
||||
flow->csgo_s2 = 1;
|
||||
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1\n");
|
||||
return;
|
||||
}
|
||||
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
|
||||
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1 DUP\n");
|
||||
return;
|
||||
}
|
||||
flow->csgo_s2 = 3;
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 15) {
|
||||
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
|
||||
if(packet->payload_packet_len == 15) {
|
||||
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 0d1d\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -97,31 +104,39 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
|
||||
}
|
||||
flow->csgo_s2 = 3;
|
||||
}
|
||||
if (packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
|
||||
|
||||
if(packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
|
||||
!memcmp(&packet->payload[3], "lta\000mob\000tpc\000bhj\000bxd\000tae\000urg\000gkh\000", 32)) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
|
||||
|
||||
if(packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
|
||||
!memcmp(&packet->payload[17], "LanSearch", 9)) {
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
if(w == 0) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->packet_counter > 20)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CSGO,
|
||||
ndpi_search_csgo,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CSGO,
|
||||
ndpi_search_csgo,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
+30
-37
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dhcp.c
|
||||
*
|
||||
* Copyright (C) 2016-19 - ntop.org
|
||||
* Copyright (C) 2016-20 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -89,8 +89,10 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
u_int8_t len = ndpi_min(dhcp->options[i+1] /* len as found in the packet */,
|
||||
dhcp_options_size - (i+2) /* 1 for the type and 1 for the value */);
|
||||
|
||||
if(len == 0) break;
|
||||
|
||||
if(len == 0)
|
||||
break;
|
||||
|
||||
|
||||
#ifdef DHCP_DEBUG
|
||||
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] Id=%d [len=%d]\n", id, len);
|
||||
#endif
|
||||
@@ -100,45 +102,36 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|
||||
if(msg_type <= 8) foundValidMsgType = 1;
|
||||
} else if(id == 55 /* Parameter Request List / Fingerprint */) {
|
||||
if(!ndpi_struct->disable_metadata_export) {
|
||||
u_int idx, offset = 0;
|
||||
u_int idx, offset = 0;
|
||||
|
||||
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
|
||||
int rc = snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
|
||||
sizeof(flow->protos.dhcp.fingerprint) - offset,
|
||||
"%s%u", (idx > 0) ? "," : "",
|
||||
(unsigned int)dhcp->options[i+2+idx] & 0xFF);
|
||||
|
||||
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
|
||||
#if 1
|
||||
offset += snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
|
||||
sizeof(flow->protos.dhcp.fingerprint) - offset,
|
||||
"%s%u", (idx > 0) ? "," : "", dhcp->options[i+2+idx] & 0xFF);
|
||||
#else
|
||||
offset += snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
|
||||
sizeof(flow->protos.dhcp.fingerprint) - offset,
|
||||
"%02X", dhcp->options[i+2+idx] & 0xFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
|
||||
if(rc < 0) break; else offset += rc;
|
||||
}
|
||||
|
||||
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
|
||||
} else if(id == 60 /* Class Identifier */) {
|
||||
if(!ndpi_struct->disable_metadata_export) {
|
||||
char *name = (char*)&dhcp->options[i+2];
|
||||
int j = 0;
|
||||
|
||||
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
|
||||
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
|
||||
flow->protos.dhcp.class_ident[j] = '\0';
|
||||
}
|
||||
char *name = (char*)&dhcp->options[i+2];
|
||||
int j = 0;
|
||||
|
||||
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
|
||||
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
|
||||
flow->protos.dhcp.class_ident[j] = '\0';
|
||||
} else if(id == 12 /* Host Name */) {
|
||||
if(!ndpi_struct->disable_metadata_export) {
|
||||
char *name = (char*)&dhcp->options[i+2];
|
||||
int j = 0;
|
||||
|
||||
char *name = (char*)&dhcp->options[i+2];
|
||||
int j = 0;
|
||||
|
||||
#ifdef DHCP_DEBUG
|
||||
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
|
||||
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
|
||||
// while(j < len) { printf( "%c", name[j]); j++; }; printf("\n");
|
||||
#endif
|
||||
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
|
||||
strncpy((char*)flow->host_server_name, name, j);
|
||||
flow->host_server_name[j] = '\0';
|
||||
}
|
||||
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
|
||||
strncpy((char*)flow->host_server_name, name, j);
|
||||
flow->host_server_name[j] = '\0';
|
||||
}
|
||||
|
||||
i += len + 2;
|
||||
@@ -159,8 +152,8 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
}
|
||||
|
||||
|
||||
void init_dhcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
void init_dhcp_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
|
||||
ndpi_set_bitmask_protocol_detection("DHCP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DHCP,
|
||||
ndpi_search_dhcp_udp,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* dhcpv6.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* directconnect.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -85,7 +85,7 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if(src != NULL) {
|
||||
src->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
src->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
if(connection_type == DIRECT_CONNECT_TYPE_PEER) {
|
||||
if(packet->tcp != NULL
|
||||
&& flow->setup_packet_direction != packet->packet_direction && src->detected_directconnect_port == 0) {
|
||||
@@ -101,7 +101,7 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
|
||||
|
||||
}
|
||||
if(dst != NULL) {
|
||||
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
dst->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
if(connection_type == DIRECT_CONNECT_TYPE_PEER) {
|
||||
if(packet->tcp != NULL
|
||||
&& flow->setup_packet_direction == packet->packet_direction && dst->detected_directconnect_port == 0) {
|
||||
@@ -162,9 +162,9 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
if(src != NULL) {
|
||||
if(src->detected_directconnect_port == packet->tcp->source) {
|
||||
if((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
src->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
src->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(src->detected_directconnect_port));
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -176,9 +176,9 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
}
|
||||
if(src->detected_directconnect_ssl_port == packet->tcp->dest) {
|
||||
if((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
src->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
src->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(src->detected_directconnect_ssl_port));
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -194,9 +194,9 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
if(dst != NULL) {
|
||||
if(dst->detected_directconnect_port == packet->tcp->dest) {
|
||||
if((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
dst->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(dst->detected_directconnect_port));
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -208,9 +208,9 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
}
|
||||
if(dst->detected_directconnect_ssl_port == packet->tcp->dest) {
|
||||
if((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
dst->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
NDPI_LOG_DBG(ndpi_struct, "found DC using port %d\n", ntohs(dst->detected_directconnect_ssl_port));
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -319,10 +319,10 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
|
||||
|
||||
if(dst != NULL && dst->detected_directconnect_udp_port == packet->udp->dest) {
|
||||
if((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
|
||||
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
dst->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
NDPI_LOG_INFO(ndpi_struct, "found DC using udp port %d\n", ntohs(dst->detected_directconnect_udp_port));
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
@@ -405,16 +405,16 @@ void ndpi_search_directconnect(struct ndpi_detection_module_struct
|
||||
|
||||
if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) {
|
||||
if(src != NULL && ((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
src->directconnect_last_safe_access_time) <
|
||||
ndpi_struct->directconnect_connection_ip_tick_timeout)) {
|
||||
src->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
src->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
|
||||
} else if(dst != NULL && ((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
(packet->current_time_ms -
|
||||
dst->directconnect_last_safe_access_time) <
|
||||
ndpi_struct->directconnect_connection_ip_tick_timeout)) {
|
||||
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
dst->directconnect_last_safe_access_time = packet->current_time_ms;
|
||||
} else {
|
||||
packet->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
|
||||
NDPI_LOG_DBG2(ndpi_struct, "skipping as unknown due to timeout\n");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* directdownloadlink.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -56,7 +56,7 @@ u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int16_t filename_start = 0;
|
||||
u_int8_t i = 1;
|
||||
u_int16_t i = 1;
|
||||
u_int16_t host_line_len_without_port;
|
||||
|
||||
if (packet->payload_packet_len < 100) {
|
||||
|
||||
+34
-14
@@ -1,41 +1,61 @@
|
||||
/*
|
||||
* dnp3.c
|
||||
* Extension for dnp3 recognition
|
||||
*
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Created by Cesar HM
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DNP3
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DNP3
|
||||
/*
|
||||
https://www.ixiacom.com/company/blog/scada-distributed-network-protocol-dnp3
|
||||
*/
|
||||
|
||||
/* ******************************************************** */
|
||||
|
||||
void ndpi_search_dnp3_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
NDPI_LOG_DBG(ndpi_struct, "search DNP3\n");
|
||||
|
||||
/* Check connection over TCP */
|
||||
NDPI_LOG_DBG(ndpi_struct, "search DNP3\n");
|
||||
|
||||
if(packet->tcp) {
|
||||
/* The payload of DNP3 is 10 bytes long.
|
||||
* Header bytes: 0x0564
|
||||
*/
|
||||
if ( packet->payload_packet_len >= 10 &&
|
||||
packet->payload[0] == 0x05 && packet->payload[1] == 0x64 ){
|
||||
NDPI_LOG_INFO(ndpi_struct, "found DNP3\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DNP3, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if ((packet->payload_packet_len >= 10)
|
||||
&& (packet->payload[0] == 0x05)
|
||||
&& (packet->payload[1] == 0x64)) {
|
||||
NDPI_LOG_INFO(ndpi_struct, "found DNP3\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DNP3, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ******************************************************** */
|
||||
|
||||
void init_dnp3_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
|
||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
|
||||
|
||||
ndpi_set_bitmask_protocol_detection("DNP3", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DNP3,
|
||||
|
||||
+235
-73
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dns.c
|
||||
*
|
||||
* Copyright (C) 2012-19 - ntop.org
|
||||
* Copyright (C) 2012-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -27,10 +27,101 @@
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
|
||||
#define FLAGS_MASK 0x8000
|
||||
|
||||
// #define DNS_DEBUG 1
|
||||
/* #define DNS_DEBUG 1 */
|
||||
|
||||
#define DNS_PORT 53
|
||||
#define LLMNR_PORT 5355
|
||||
#define MDNS_PORT 5353
|
||||
|
||||
static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static void ndpi_check_dns_type(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t dns_type) {
|
||||
/* https://en.wikipedia.org/wiki/List_of_DNS_record_types */
|
||||
|
||||
switch(dns_type) {
|
||||
/* Obsolete record types */
|
||||
case 3:
|
||||
case 4:
|
||||
case 254:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 14:
|
||||
case 253:
|
||||
case 11:
|
||||
case 33:
|
||||
case 10:
|
||||
case 38:
|
||||
case 30:
|
||||
case 25:
|
||||
case 24:
|
||||
case 13:
|
||||
case 17:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
case 26:
|
||||
case 31:
|
||||
case 32:
|
||||
case 34:
|
||||
case 42:
|
||||
case 40:
|
||||
case 27:
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 99:
|
||||
case 56:
|
||||
case 57:
|
||||
case 58:
|
||||
case 104:
|
||||
case 105:
|
||||
case 106:
|
||||
case 107:
|
||||
case 259:
|
||||
NDPI_SET_BIT(flow->risk, NDPI_DNS_SUSPICIOUS_TRAFFIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static u_int16_t checkPort(u_int16_t port) {
|
||||
switch(port) {
|
||||
case DNS_PORT:
|
||||
return(NDPI_PROTOCOL_DNS);
|
||||
break;
|
||||
case LLMNR_PORT:
|
||||
return(NDPI_PROTOCOL_LLMNR);
|
||||
break;
|
||||
case MDNS_PORT:
|
||||
return(NDPI_PROTOCOL_MDNS);
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static u_int16_t checkDNSSubprotocol(u_int16_t sport, u_int16_t dport) {
|
||||
u_int16_t rc = checkPort(sport);
|
||||
|
||||
if(rc == 0)
|
||||
return(checkPort(dport));
|
||||
else
|
||||
return(rc);
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
@@ -45,7 +136,9 @@ static u_int16_t get16(int *i, const u_int8_t *payload) {
|
||||
/* *********************************************** */
|
||||
|
||||
static u_int getNameLength(u_int i, const u_int8_t *payload, u_int payloadLen) {
|
||||
if(payload[i] == 0x00)
|
||||
if(i >= payloadLen)
|
||||
return(0);
|
||||
else if(payload[i] == 0x00)
|
||||
return(1);
|
||||
else if(payload[i] == 0xC0)
|
||||
return(2);
|
||||
@@ -60,18 +153,19 @@ static u_int getNameLength(u_int i, const u_int8_t *payload, u_int payloadLen) {
|
||||
}
|
||||
}
|
||||
/*
|
||||
allowed chars for dns names A-Z 0-9 _ -
|
||||
Perl script for generation map:
|
||||
my @M;
|
||||
for(my $ch=0; $ch < 256; $ch++) {
|
||||
$M[$ch >> 5] |= 1 << ($ch & 0x1f) if chr($ch) =~ /[a-z0-9_-]/i;
|
||||
}
|
||||
print join(',', map { sprintf "0x%08x",$_ } @M),"\n";
|
||||
allowed chars for dns names A-Z 0-9 _ -
|
||||
Perl script for generation map:
|
||||
my @M;
|
||||
for(my $ch=0; $ch < 256; $ch++) {
|
||||
$M[$ch >> 5] |= 1 << ($ch & 0x1f) if chr($ch) =~ /[a-z0-9_-]/i;
|
||||
}
|
||||
print join(',', map { sprintf "0x%08x",$_ } @M),"\n";
|
||||
*/
|
||||
|
||||
static uint32_t dns_validchar[8] = {
|
||||
0x00000000,0x03ff2000,0x87fffffe,0x07fffffe,0,0,0,0
|
||||
};
|
||||
static uint32_t dns_validchar[8] =
|
||||
{
|
||||
0x00000000,0x03ff2000,0x87fffffe,0x07fffffe,0,0,0,0
|
||||
};
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
@@ -83,6 +177,7 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
memcpy(dns_header, (struct ndpi_dns_packet_header*)&flow->packet.payload[x],
|
||||
sizeof(struct ndpi_dns_packet_header));
|
||||
|
||||
dns_header->tr_id = ntohs(dns_header->tr_id);
|
||||
dns_header->flags = ntohs(dns_header->flags);
|
||||
dns_header->num_queries = ntohs(dns_header->num_queries);
|
||||
@@ -98,8 +193,10 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
/* 0x8000 RESPONSE */
|
||||
else if((dns_header->flags & FLAGS_MASK) == 0x8000)
|
||||
*is_query = 0;
|
||||
else
|
||||
else {
|
||||
NDPI_SET_BIT(flow->risk, NDPI_MALFORMED_PACKET);
|
||||
return(1 /* invalid */);
|
||||
}
|
||||
|
||||
if(*is_query) {
|
||||
/* DNS Request */
|
||||
@@ -107,86 +204,116 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
&& (((dns_header->flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|
||||
|| ((dns_header->num_answers == 0) && (dns_header->authority_rrs == 0)))) {
|
||||
/* This is a good query */
|
||||
while(x < flow->packet.payload_packet_len) {
|
||||
while(x+2 < flow->packet.payload_packet_len) {
|
||||
if(flow->packet.payload[x] == '\0') {
|
||||
x++;
|
||||
flow->protos.dns.query_type = get16(&x, flow->packet.payload);
|
||||
#ifdef DNS_DEBUG
|
||||
NDPI_LOG_DBG2(ndpi_struct, "query_type=%2d\n", flow->protos.dns.query_type);
|
||||
printf("[DNS] query_type=%d\n", flow->protos.dns.query_type);
|
||||
printf("[DNS] [request] query_type=%d\n", flow->protos.dns.query_type);
|
||||
#endif
|
||||
break;
|
||||
} else
|
||||
x++;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
NDPI_SET_BIT(flow->risk, NDPI_MALFORMED_PACKET);
|
||||
return(1 /* invalid */);
|
||||
}
|
||||
} else {
|
||||
/* DNS Reply */
|
||||
flow->protos.dns.reply_code = dns_header->flags & 0x0F;
|
||||
|
||||
if((dns_header->num_queries > 0) && (dns_header->num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
|
||||
&& (((dns_header->num_answers > 0) && (dns_header->num_answers <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((dns_header->authority_rrs > 0) && (dns_header->authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((dns_header->additional_rrs > 0) && (dns_header->additional_rrs <= NDPI_MAX_DNS_REQUESTS)))
|
||||
&& ((((dns_header->num_answers > 0) && (dns_header->num_answers <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((dns_header->authority_rrs > 0) && (dns_header->authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((dns_header->additional_rrs > 0) && (dns_header->additional_rrs <= NDPI_MAX_DNS_REQUESTS))))
|
||||
) {
|
||||
/* This is a good reply: we dissect it both for request and response */
|
||||
|
||||
/* Leave the statement below commented necessary in case of call to ndpi_get_partial_detection() */
|
||||
/* if(ndpi_struct->dns_dont_dissect_response == 0) */ {
|
||||
x++;
|
||||
|
||||
if(flow->packet.payload[x] != '\0') {
|
||||
while((x < flow->packet.payload_packet_len)
|
||||
&& (flow->packet.payload[x] != '\0')) {
|
||||
x++;
|
||||
}
|
||||
x++;
|
||||
|
||||
if(x < flow->packet.payload_packet_len && flow->packet.payload[x] != '\0') {
|
||||
while((x < flow->packet.payload_packet_len)
|
||||
&& (flow->packet.payload[x] != '\0')) {
|
||||
x++;
|
||||
}
|
||||
|
||||
x += 4;
|
||||
x++;
|
||||
}
|
||||
|
||||
if(dns_header->num_answers > 0) {
|
||||
u_int16_t rsp_type;
|
||||
u_int16_t num;
|
||||
x += 4;
|
||||
|
||||
for(num = 0; num < dns_header->num_answers; num++) {
|
||||
u_int16_t data_len;
|
||||
if(dns_header->num_answers > 0) {
|
||||
u_int16_t rsp_type;
|
||||
u_int16_t num;
|
||||
|
||||
if((x+6) >= flow->packet.payload_packet_len) {
|
||||
break;
|
||||
}
|
||||
for(num = 0; num < dns_header->num_answers; num++) {
|
||||
u_int16_t data_len;
|
||||
|
||||
if((data_len = getNameLength(x, flow->packet.payload, flow->packet.payload_packet_len)) == 0) {
|
||||
break;
|
||||
} else
|
||||
x += data_len;
|
||||
if((x+6) >= flow->packet.payload_packet_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
rsp_type = get16(&x, flow->packet.payload);
|
||||
flow->protos.dns.rsp_type = rsp_type;
|
||||
if((data_len = getNameLength(x, flow->packet.payload,
|
||||
flow->packet.payload_packet_len)) == 0) {
|
||||
break;
|
||||
} else
|
||||
x += data_len;
|
||||
|
||||
/* here x points to the response "class" field */
|
||||
if((x+12) <= flow->packet.payload_packet_len) {
|
||||
x += 6;
|
||||
data_len = get16(&x, flow->packet.payload);
|
||||
if((x+2) >= flow->packet.payload_packet_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(((x + data_len) <= flow->packet.payload_packet_len)
|
||||
&& (((rsp_type == 0x1) && (data_len == 4)) /* A */
|
||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
|| ((rsp_type == 0x1c) && (data_len == 16)) /* AAAA */
|
||||
rsp_type = get16(&x, flow->packet.payload);
|
||||
|
||||
#ifdef DNS_DEBUG
|
||||
printf("[DNS] [response] response_type=%d\n", rsp_type);
|
||||
#endif
|
||||
)) {
|
||||
|
||||
ndpi_check_dns_type(ndpi_struct, flow, rsp_type);
|
||||
|
||||
flow->protos.dns.rsp_type = rsp_type;
|
||||
|
||||
/* here x points to the response "class" field */
|
||||
if((x+12) <= flow->packet.payload_packet_len) {
|
||||
x += 6;
|
||||
data_len = get16(&x, flow->packet.payload);
|
||||
|
||||
if((x + data_len) <= flow->packet.payload_packet_len) {
|
||||
// printf("[rsp_type: %u][data_len: %u]\n", rsp_type, data_len);
|
||||
|
||||
if(rsp_type == 0x05 /* CNAME */) {
|
||||
x += data_len;
|
||||
continue; /* Skip CNAME */
|
||||
}
|
||||
|
||||
if((((rsp_type == 0x1) && (data_len == 4)) /* A */
|
||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||
|| ((rsp_type == 0x1c) && (data_len == 16)) /* AAAA */
|
||||
#endif
|
||||
)) {
|
||||
memcpy(&flow->protos.dns.rsp_addr, flow->packet.payload + x, data_len);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
return(1 /* invalid */);
|
||||
|
||||
if((flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_DNS)
|
||||
|| (flow->packet.detected_protocol_stack[1] == NDPI_PROTOCOL_DNS)) {
|
||||
/* Request already set the protocol */
|
||||
// flow->extra_packets_func = NULL; /* Removed so the caller can keep dissecting DNS flows */
|
||||
} else {
|
||||
/* We missed the request */
|
||||
u_int16_t s_port = flow->packet.udp ? ntohs(flow->packet.udp->source) : ntohs(flow->packet.tcp->source);
|
||||
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, checkPort(s_port), NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Valid */
|
||||
@@ -199,18 +326,13 @@ static int search_dns_again(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
/* possibly dissect the DNS reply */
|
||||
ndpi_search_dns(ndpi_struct, flow);
|
||||
|
||||
if(flow->protos.dns.num_answers > 0) {
|
||||
/* stop extra processing */
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Possibly more processing */
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
int payload_offset;
|
||||
u_int8_t is_query;
|
||||
u_int16_t s_port = 0, d_port = 0;
|
||||
@@ -230,16 +352,19 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
return;
|
||||
}
|
||||
|
||||
if((s_port == 53 || d_port == 53 || d_port == 5355)
|
||||
if(((s_port == DNS_PORT) || (d_port == DNS_PORT)
|
||||
|| (s_port == MDNS_PORT) || (d_port == MDNS_PORT)
|
||||
|| (d_port == LLMNR_PORT))
|
||||
&& (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header)+payload_offset)) {
|
||||
struct ndpi_dns_packet_header dns_header;
|
||||
int j = 0, max_len, off;
|
||||
int invalid = search_valid_dns(ndpi_struct, flow, &dns_header, payload_offset, &is_query);
|
||||
ndpi_protocol ret;
|
||||
u_int num_queries, idx;
|
||||
|
||||
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
|
||||
ret.app_protocol = (d_port == LLMNR_PORT) ? NDPI_PROTOCOL_LLMNR : ((d_port == MDNS_PORT) ? NDPI_PROTOCOL_MDNS : NDPI_PROTOCOL_DNS);
|
||||
|
||||
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
|
||||
ret.app_protocol = (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS;
|
||||
|
||||
if(invalid) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
@@ -249,6 +374,34 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
max_len = sizeof(flow->host_server_name)-1;
|
||||
off = sizeof(struct ndpi_dns_packet_header) + payload_offset;
|
||||
|
||||
/* Before continuing let's dissect the following queries to see if they are valid */
|
||||
for(idx=off, num_queries=0; (num_queries < dns_header.num_queries) && (idx < flow->packet.payload_packet_len);) {
|
||||
u_int8_t name_len = flow->packet.payload[idx];
|
||||
|
||||
#ifdef DNS_DEBUG
|
||||
printf("[DNS] [name_len: %u]\n", name_len);
|
||||
#endif
|
||||
|
||||
if(name_len == 0) {
|
||||
/* End of query */
|
||||
num_queries++;
|
||||
idx += 5;
|
||||
continue;
|
||||
}
|
||||
|
||||
if((name_len+idx) >= flow->packet.payload_packet_len) {
|
||||
/* Invalid */
|
||||
#ifdef DNS_DEBUG
|
||||
printf("[DNS] Invalid query len [%u >= %u]\n",
|
||||
(name_len+idx),
|
||||
flow->packet.payload_packet_len);
|
||||
#endif
|
||||
NDPI_SET_BIT(flow->risk, NDPI_MALFORMED_PACKET);
|
||||
break;
|
||||
} else
|
||||
idx += name_len+1;
|
||||
}
|
||||
|
||||
while(j < max_len && off < flow->packet.payload_packet_len && flow->packet.payload[off] != '\0') {
|
||||
uint8_t c, cl = flow->packet.payload[off++];
|
||||
|
||||
@@ -261,35 +414,41 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
if(j && j < max_len) flow->host_server_name[j++] = '.';
|
||||
|
||||
while(j < max_len && cl != 0) {
|
||||
u_int32_t shift;
|
||||
|
||||
c = flow->packet.payload[off++];
|
||||
flow->host_server_name[j++] = (dns_validchar[c >> 5] & (1 << (c & 0x1f))) ? c : '_';
|
||||
shift = ((u_int32_t) 1) << (c & 0x1f);
|
||||
flow->host_server_name[j++] = tolower((dns_validchar[c >> 5] & shift) ? c : '_');
|
||||
cl--;
|
||||
}
|
||||
}
|
||||
|
||||
flow->host_server_name[j] = '\0';
|
||||
|
||||
if(j > 0) {
|
||||
ndpi_protocol_match_result ret_match;
|
||||
|
||||
|
||||
ndpi_check_dga_name(ndpi_struct, flow, (char*)flow->host_server_name, 1);
|
||||
|
||||
ret.app_protocol = ndpi_match_host_subprotocol(ndpi_struct, flow,
|
||||
(char *)flow->host_server_name,
|
||||
strlen((const char*)flow->host_server_name),
|
||||
&ret_match,
|
||||
NDPI_PROTOCOL_DNS);
|
||||
|
||||
|
||||
if(ret_match.protocol_category != NDPI_PROTOCOL_CATEGORY_UNSPECIFIED)
|
||||
flow->category = ret_match.protocol_category;
|
||||
|
||||
if(ret.app_protocol == NDPI_PROTOCOL_UNKNOWN)
|
||||
ret.master_protocol = (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS;
|
||||
ret.master_protocol = checkDNSSubprotocol(s_port, d_port);
|
||||
else
|
||||
ret.master_protocol = NDPI_PROTOCOL_DNS;
|
||||
}
|
||||
|
||||
/* Report if this is a DNS query or reply */
|
||||
flow->protos.dns.is_query = is_query;
|
||||
|
||||
if(is_query && (ndpi_struct->dns_dont_dissect_response == 0) && (flow->check_extra_packets == 0)) {
|
||||
|
||||
if(is_query) {
|
||||
/* In this case we say that the protocol has been detected just to let apps carry on with their activities */
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, ret.app_protocol, ret.master_protocol);
|
||||
|
||||
@@ -327,6 +486,9 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 3)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void init_dns_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* dnscrypt.c
|
||||
*
|
||||
* Copyright (C) 2020 - ntop.org
|
||||
*
|
||||
* nDPI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* nDPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DNSCRYPT
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
static void ndpi_int_dnscrypt_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DNSCRYPT, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_dnscrypt(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
static char const * const dnscrypt_initial = "2\rdnscrypt";
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search dnscrypt\n");
|
||||
|
||||
if (flow->packet_counter > 2)
|
||||
{
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
/* dnscrypt protocol version 1: check magic */
|
||||
if (packet->payload_packet_len >= 64 &&
|
||||
strncmp((char*)packet->payload, "r6fnvWj8", strlen("r6fnvWj8")) == 0)
|
||||
{
|
||||
ndpi_int_dnscrypt_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
/* dnscrypt protocol version 1 and 2: resolver ping */
|
||||
if (packet->payload_packet_len > 13 + strlen(dnscrypt_initial) &&
|
||||
strncasecmp((char*)packet->payload + 13, dnscrypt_initial, strlen(dnscrypt_initial)) == 0)
|
||||
{
|
||||
ndpi_int_dnscrypt_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
void init_dnscrypt_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
|
||||
NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection(
|
||||
"DNScrypt", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DNSCRYPT, ndpi_search_dnscrypt, NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN, ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* dofus.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* drda.c
|
||||
*
|
||||
* Copyright (C) 2012-19 - ntop.org
|
||||
* Copyright (C) 2012-20 - ntop.org
|
||||
*
|
||||
* This module is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* eaq.c
|
||||
*
|
||||
* Copyright (C) 2015-19 - ntop.org
|
||||
* Copyright (C) 2015-20 - ntop.org
|
||||
*
|
||||
* This module is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -165,8 +165,11 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
return;
|
||||
}
|
||||
|
||||
if(payload_len == 0) return;
|
||||
|
||||
if(payload_len == 0) {
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
if(flow->edonkey_stage == 0) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "EDONKEY stage 0: \n");
|
||||
@@ -176,7 +179,8 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||
flow->edonkey_stage = packet->packet_direction + 1;
|
||||
}
|
||||
} else
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "EDONKEY stage %u: \n", flow->edonkey_stage);
|
||||
|
||||
@@ -193,8 +197,10 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to EDONKEY, resetting the stage to 0\n");
|
||||
flow->edonkey_stage = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(flow->packet_counter > 5)
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* fasttrack.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -37,47 +37,48 @@ static void ndpi_int_fasttrack_add_connection(struct ndpi_detection_module_struc
|
||||
|
||||
void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search FASTTRACK\n");
|
||||
NDPI_LOG_DBG(ndpi_struct, "search FASTTRACK\n");
|
||||
|
||||
if ( (packet->payload != NULL)
|
||||
&& (packet->payload_packet_len > 6)
|
||||
&& (ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "detected 0d0a at the end of the packet\n");
|
||||
if ( (packet->payload != NULL)
|
||||
&& (packet->payload_packet_len > 6)
|
||||
&& (ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "detected 0d0a at the end of the packet\n");
|
||||
|
||||
if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) {
|
||||
u_int16_t i;
|
||||
for (i = 5; i < (packet->payload_packet_len - 2); i++) {
|
||||
// make shure that the argument to GIVE is numeric
|
||||
if (!(packet->payload[i] >= '0' && packet->payload[i] <= '9')) {
|
||||
goto exclude_fasttrack;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_LOG_INFO(ndpi_struct, "found FASTTRACK\n");
|
||||
ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) {
|
||||
u_int8_t a = 0;
|
||||
NDPI_LOG_DBG2(ndpi_struct, "detected GET /. \n");
|
||||
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||
for (a = 0; a < packet->parsed_lines; a++) {
|
||||
if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0)
|
||||
|| (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct,
|
||||
"found FASTTRACK X-Kazaa-Username: || User-Agent: PeerEnabler/\n");
|
||||
ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) {
|
||||
u_int16_t i;
|
||||
for (i = 5; i < (packet->payload_packet_len - 2); i++) {
|
||||
// make shure that the argument to GIVE is numeric
|
||||
if (!(packet->payload[i] >= '0' && packet->payload[i] <= '9')) {
|
||||
goto exclude_fasttrack;
|
||||
}
|
||||
}
|
||||
|
||||
exclude_fasttrack:
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
NDPI_LOG_INFO(ndpi_struct, "found FASTTRACK\n");
|
||||
ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) {
|
||||
u_int16_t a = 0;
|
||||
NDPI_LOG_DBG2(ndpi_struct, "detected GET /. \n");
|
||||
|
||||
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||
for (a = 0; a < packet->parsed_lines; a++) {
|
||||
if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0)
|
||||
|| (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) {
|
||||
NDPI_LOG_INFO(ndpi_struct,
|
||||
"found FASTTRACK X-Kazaa-Username: || User-Agent: PeerEnabler/\n");
|
||||
ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exclude_fasttrack:
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -85,9 +85,12 @@ void ndpi_search_fbzero(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
char *value = (char*)&packet->payload[data_offset + data_prev_offset];
|
||||
u_int tag_len = t->tag_offset_len-data_prev_offset, max_len;
|
||||
ndpi_protocol_match_result ret_match;
|
||||
|
||||
|
||||
max_len = ndpi_min(tag_len, sizeof(flow->host_server_name)-1);
|
||||
|
||||
if (data_offset + data_prev_offset + max_len >= packet->payload_packet_len) {
|
||||
return;
|
||||
}
|
||||
strncpy((char*)flow->host_server_name, value, max_len);
|
||||
flow->host_server_name[max_len] = '\0';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* fiesta.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* fix.c
|
||||
*
|
||||
* Copyright (C) 2017-19 - ntop.org
|
||||
* Copyright (C) 2017-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
@@ -33,7 +33,7 @@ void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search FIX\n");
|
||||
if(packet->tcp) {
|
||||
if(packet->tcp && packet->payload_packet_len > 5) {
|
||||
// 8=
|
||||
if(packet->payload[0] == 0x38 && packet->payload[1] == 0x3d) {
|
||||
// FIX.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* florensia.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-19 - ntop.org
|
||||
* Copyright (C) 2011-20 - ntop.org
|
||||
*
|
||||
* This file is part of nDPI, an open source deep packet inspection
|
||||
* library based on the OpenDPI and PACE technology by ipoque GmbH
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user