Ports scannés 2019/2024

Ma base Clickhouse étant chargée je ne résiste pas au plaisir d'explorer les données stockées par Ntopng depuis quelques années (# 768 millions de rangs)? Ici j'ai recherché les ports les plus scannés de 2019 à 2024, ces ports sont, pour la plupart, fermés par le parefeu et ne donnent lieu à aucune réponse (OUT_BYTES = 0 dans la table). J'ai limité aux 50 ports les plus actifs sur ces 5 années, je n'ai pas pris en compte l'année 2025 par encore terminéé.
Pour des précisions sur Clickhouse voir ICI.

                       Nombre de hits externes par port de 2019 è 2024
┌──PORT─┬──TOTAL─┬─_2019─┬──_2020─┬─_2021─┬──_2022─┬──_2023─┬──_2024─┐
│    23 │ 672462 │ 47538 │  43369 │ 69247 │ 158195 │ 171361 │ 182752 │
│    22 │ 336644 │ 24613 │  24424 │ 42784 │  72004 │  91921 │  80898 │
│  6379 │ 260763 │  3375 │   6233 │ 55849 │  92393 │  56117 │  46796 │
│   445 │ 236658 │ 89599 │  56914 │ 29198 │  24291 │  17462 │  19194 │
│   465 │ 185839 │     0 │ 122256 │ 41240 │  15681 │   3296 │   3366 │
│  8080 │ 177555 │ 16881 │  66484 │ 24526 │  16628 │  24240 │  28796 │
│  3389 │ 115291 │  8802 │   8226 │ 14746 │  22552 │  27726 │  33239 │
│    81 │  90390 │ 15670 │  16857 │ 13336 │  17868 │  14698 │  11961 │
│  1433 │  84800 │  9393 │  15401 │ 18327 │  15102 │  11562 │  15015 │
│   993 │  77752 │  2078 │   3543 │ 21718 │  16301 │  10589 │  23523 │
│  5222 │  75155 │  3596 │  63430 │   960 │   1282 │   2750 │   3137 │
│    25 │  74353 │  7201 │  30668 │   456 │   6051 │     90 │  29887 │
│  5555 │  73875 │  9498 │  12880 │  9241 │  15565 │  13166 │  13525 │
│  8728 │  71342 │   534 │   1618 │  2565 │    167 │   4135 │  62323 │
│   995 │  66375 │   844 │  56869 │  1376 │   1859 │   2372 │   3055 │
│ 23462 │  53179 │    11 │     30 │    16 │      9 │     14 │  53099 │
│  2375 │  53017 │   896 │   2727 │ 12918 │  16207 │   9132 │  11137 │
│  8443 │  49855 │  2301 │   5584 │  5655 │   8872 │  15505 │  11938 │
│  8081 │  45657 │  2476 │   5238 │  5680 │   6272 │   8041 │  17950 │
│  2323 │  45567 │  8044 │   6430 │  4265 │   8727 │   5406 │  12695 │
│  3306 │  41819 │  5209 │   3537 │  3769 │   5634 │   7383 │  16287 │
│  8088 │  40936 │  3799 │   3998 │  3372 │   4289 │   6562 │  18916 │
│  3478 │  39355 │   218 │  26653 │ 11270 │    326 │    365 │    523 │
│  3074 │  37755 │   107 │  26227 │ 10945 │    132 │    156 │    188 │
│  2376 │  36376 │   509 │   1224 │ 10899 │  14420 │   5831 │   3493 │
│  8545 │  35368 │ 13986 │  12932 │  4509 │   2131 │    486 │   1324 │
│  8888 │  34998 │  2933 │   4265 │  4411 │   5131 │   6541 │  11717 │
│   587 │  32878 │  1004 │  14676 │  5647 │   3134 │   3145 │   5272 │
│  8000 │  32639 │  2844 │   5092 │  4337 │   5560 │   5450 │   9356 │
│  3128 │  30750 │  2374 │   3051 │  2917 │   3505 │   6965 │  11938 │
│  2222 │  30082 │  2471 │   2535 │  2829 │   3389 │   5781 │  13077 │
│  5038 │  28042 │  5372 │   9082 │  5929 │   5419 │   1796 │    444 │
│  9200 │  26705 │  1913 │   3874 │  4391 │   4484 │   4681 │   7362 │
│  9000 │  25346 │  3762 │   3452 │  3842 │   4058 │   4500 │   5732 │
│  5900 │  25169 │  3269 │   3763 │  4337 │   3967 │   3800 │   6033 │
│ 27017 │  24771 │  1945 │   2887 │  2819 │   3152 │   3912 │  10056 │
│   631 │  24602 │  4598 │   9952 │  3077 │   1842 │   2278 │   2855 │
│    21 │  24006 │  2518 │   3470 │  3500 │   4318 │   4577 │   5623 │
│ 34852 │  21665 │     8 │     31 │    14 │      6 │  21588 │     18 │
│  4719 │  20882 │    54 │     83 │    49 │     39 │   8038 │  12619 │
│  5060 │  20487 │  1032 │   1899 │  2893 │   4977 │   4913 │   4773 │
│  5432 │  20292 │   872 │   2514 │  3135 │   3498 │   4185 │   6088 │
│  1080 │  20017 │  1617 │   2124 │  1834 │   2713 │   4115 │   7614 │
│  3390 │  19949 │  3702 │   4455 │  3780 │   2562 │   2438 │   3012 │
│    88 │  19742 │  1898 │   4190 │  1651 │   4812 │   3157 │   4034 │
│  3000 │  19173 │  1044 │   5812 │  2403 │   2392 │   3554 │   3968 │
│   489 │  19011 │    45 │    145 │  1479 │   8637 │   8430 │    275 │
│  8090 │  18902 │  1034 │   1650 │  2406 │   3270 │   3819 │   6723 │
│ 32942 │  18449 │    15 │     24 │    15 │      3 │     17 │  18375 │
│  5500 │  17853 │  9560 │   3828 │  1533 │   1218 │    843 │    871 │
└──PORT─┴──TOTAL─┴─_2019─┴──_2020─┴─_2021─┴──_2022─┴──_2023─┴──_2024─┘

Ci-dessous le compte-rendu de Clickhouse pour cette belle requête.

50 rows in set. Elapsed: 5.500 sec. Processed 628.24 million rows, 18.05 GB (114.22 million rows/s., 3.28 GB/s.)
Peak memory usage: 193.52 MiB.

Et pour finir l'ordre SQL lui même :


use local_ntopng;
--
select PORT,sum(CTGEN) AS TOTAL,sum(CT1) as _2019,sum(CT2) as _2020,sum(CT3) as _2021,
		sum(CT4) as _2022,sum(CT5) as _2023,sum(CT6) as _2024
from
(
select YEAR(FIRST_SWITCHED) as ANNEE,L4_DST_PORT as PORT,
	toInt32(count(*)) as CTGEN,toInt32(count(*)) as CT1,toInt32(0) as CT2,toInt32(0) as CT3,
	toInt32(0) as CT4,toInt32(0) as CT5,toInt32(0) as CT6
from flowsv4
where OUT_BYTES < 1
  and YEAR(FIRST_SWITCHED) = 2019
  and PROTOCOL = 6
  and L4_DST_PORT not in (53,80,443,465)
group by 1,2
union all
select YEAR(FIRST_SWITCHED),L4_DST_PORT,toInt32(count(*)),toInt32(0),toInt32(count(*)),
		toInt32(0),toInt32(0),toInt32(0),toInt32(0)
from flowsv4
where OUT_BYTES < 1
  and YEAR(FIRST_SWITCHED) = 2020
  and PROTOCOL = 6
  and L4_DST_PORT not in (53,80,443)
group by 1,2
union all
select YEAR(FIRST_SWITCHED),L4_DST_PORT,toInt32(count(*)),toInt32(0),toInt32(0),
		toInt32(count(*)),toInt32(0),toInt32(0),toInt32(0)
from flowsv4
where OUT_BYTES < 1
  and YEAR(FIRST_SWITCHED) = 2021
  and PROTOCOL = 6
  and L4_DST_PORT not in (53,80,443)
  and IP_SRC_ADDR not between '192.168.1.1' and '192.168.3.254'
group by 1,2
union all
select YEAR(FIRST_SWITCHED),L4_DST_PORT,toInt32(count(*)),toInt32(0),toInt32(0),
		toInt32(0),toInt32(count(*)),toInt32(0),toInt32(0)
from flowsv4
where OUT_BYTES < 1
  and YEAR(FIRST_SWITCHED) = 2022
  and PROTOCOL = 6
  and L4_DST_PORT not in (53,80,443)
  and IP_SRC_ADDR not between '192.168.1.1' and '192.168.3.254'
group by 1,2
union all
select YEAR(FIRST_SWITCHED),L4_DST_PORT,toInt32(count(*)),toInt32(0),toInt32(0),
		toInt32(0),toInt32(0),toInt32(count(*)),toInt32(0)
from flowsv4
where OUT_BYTES < 1
  and YEAR(FIRST_SWITCHED) = 2023
  and PROTOCOL = 6
  and L4_DST_PORT not in (53,80,443)
  and IP_SRC_ADDR not between '192.168.1.1' and '192.168.3.254'
group by 1,2
union all
select YEAR(FIRST_SWITCHED),L4_DST_PORT,toInt32(count(*)),toInt32(0),toInt32(0),
		toInt32(0),toInt32(0),toInt32(0),toInt32(count(*))
from flowsv4
where OUT_BYTES < 1
  and YEAR(FIRST_SWITCHED) = 2024
  and PROTOCOL = 6
  and L4_DST_PORT not in (53,80,443)
  and IP_SRC_ADDR not between '192.168.1.1' and '192.168.3.254'
group by 1,2
)
where PORT < 35000
group by 1
order by 2 desc
limit 50 ;

C'est toujours le port 23 qui tient la tête suivi du port 22 !
Certains ports sont visiblement des "anomalies" avec une grosse fréquentation sur une courte période puis pas grand chose le reste du temps, par exemple le port 23462 ...