fix: tests intégration matrix — procps-ng, varnish h2, hitch ALPN, pgrep→ps
- Ajout de procps-ng dans les 4 Dockerfiles runtime (ps/pgrep disponibles) - Remplacement de pgrep par ps -C dans tous les run-tests.sh - Correction entrypoint nginx-varnish : pgrep nginx → cat nginx.pid (exit 127) - Activation HTTP/2 dans Varnish : ajout de -p feature=+http2 dans les entrypoints nginx-varnish et hitch-varnish - Restauration ALPN h2,http/1.1 dans hitch.conf (varnish supporte maintenant h2) - Correction healthcheck hitch-varnish : curl sans --http1.1 (h2 fonctionnel) - Correction requêtes phase_verify : http_logs_raw → http_logs, colonnes correctes - Correction writer clickhouse.go : noms JSON alignés avec la MV (ip_meta_*, tls_sni…) - Fix toStartOfSecond(DateTime) → toStartOfSecond(toDateTime64(col, 3)) - Retrait du SKIP el8/nginx-varnish (varnish s'installe bien sur AlmaLinux 8) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@ -9,7 +9,9 @@
|
|||||||
FROM rockylinux:9 AS ebpf-builder
|
FROM rockylinux:9 AS ebpf-builder
|
||||||
|
|
||||||
# Installation des outils de compilation eBPF
|
# Installation des outils de compilation eBPF
|
||||||
RUN dnf install -y epel-release && \
|
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||||
|
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||||
|
dnf config-manager --enable crb && \
|
||||||
dnf install -y \
|
dnf install -y \
|
||||||
clang \
|
clang \
|
||||||
llvm \
|
llvm \
|
||||||
@ -34,7 +36,9 @@ RUN mkdir -p bpf/headers && \
|
|||||||
FROM rockylinux:9 AS go-builder
|
FROM rockylinux:9 AS go-builder
|
||||||
|
|
||||||
# Installation de Go et des outils nécessaires
|
# Installation de Go et des outils nécessaires
|
||||||
RUN dnf install -y epel-release && \
|
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||||
|
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||||
|
dnf config-manager --enable crb && \
|
||||||
dnf install -y \
|
dnf install -y \
|
||||||
golang \
|
golang \
|
||||||
clang \
|
clang \
|
||||||
|
|||||||
@ -3,6 +3,13 @@
|
|||||||
*
|
*
|
||||||
* Attaché sur l'interface réseau en ingress via TC (Traffic Control).
|
* Attaché sur l'interface réseau en ingress via TC (Traffic Control).
|
||||||
* Émet des événements vers les ring buffers rb_tcp_syn et rb_tls_hello.
|
* Émet des événements vers les ring buffers rb_tcp_syn et rb_tls_hello.
|
||||||
|
*
|
||||||
|
* Conventions vérificateur eBPF :
|
||||||
|
* - Tous les offsets variables (ihl, doff) sont stockés en __u32 et bornés
|
||||||
|
* explicitement avant tout usage en arithmétique de pointeur.
|
||||||
|
* - Les lectures de longueur variable (options TCP, payload TLS/HTTP) sont
|
||||||
|
* effectuées via bpf_skb_load_bytes() dans des tampons de pile locaux,
|
||||||
|
* évitant ainsi toute arithmétique de pointeur sur des données paquet.
|
||||||
* ============================================================================ */
|
* ============================================================================ */
|
||||||
|
|
||||||
#include "vmlinux.h"
|
#include "vmlinux.h"
|
||||||
@ -22,6 +29,8 @@
|
|||||||
/* Constantes TCP */
|
/* Constantes TCP */
|
||||||
#define TH_SYN 0x02
|
#define TH_SYN 0x02
|
||||||
#define TH_ACK 0x10
|
#define TH_ACK 0x10
|
||||||
|
#define TH_FIN 0x01
|
||||||
|
#define TH_RST 0x04
|
||||||
|
|
||||||
/* Port HTTPS standard */
|
/* Port HTTPS standard */
|
||||||
#define HTTPS_PORT 443
|
#define HTTPS_PORT 443
|
||||||
@ -30,19 +39,15 @@
|
|||||||
#define HTTP_PORT 80
|
#define HTTP_PORT 80
|
||||||
#define HTTP_ALT_PORT 8080
|
#define HTTP_ALT_PORT 8080
|
||||||
|
|
||||||
/* Flags TCP */
|
|
||||||
#define TH_FIN 0x01
|
|
||||||
#define TH_RST 0x04
|
|
||||||
|
|
||||||
/* Type de contenu TLS : Handshake */
|
/* Type de contenu TLS : Handshake */
|
||||||
#define TLS_CONTENT_HANDSHAKE 0x16
|
#define TLS_CONTENT_HANDSHAKE 0x16
|
||||||
/* Type de message TLS : ClientHello */
|
/* Type de message TLS : ClientHello */
|
||||||
#define TLS_MSG_CLIENT_HELLO 0x01
|
#define TLS_MSG_CLIENT_HELLO 0x01
|
||||||
|
|
||||||
/* Taille maximale du payload TLS à copier */
|
/* Taille maximale du payload TLS à copier (puissance de 2) */
|
||||||
#define MAX_TLS_PAYLOAD 512
|
#define MAX_TLS_PAYLOAD 512
|
||||||
|
|
||||||
/* Longueur maximale des options TCP */
|
/* Longueur maximale des options TCP en octets */
|
||||||
#define MAX_TCP_OPTIONS 40
|
#define MAX_TCP_OPTIONS 40
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------
|
/* ---------------------------------------------------------------------------
|
||||||
@ -63,7 +68,6 @@ struct ethhdr_local {
|
|||||||
SEC("tc/ingress")
|
SEC("tc/ingress")
|
||||||
int capture_tc_ingress(struct __sk_buff *skb)
|
int capture_tc_ingress(struct __sk_buff *skb)
|
||||||
{
|
{
|
||||||
/* Pointeurs de début et fin du buffer paquet */
|
|
||||||
void *data = (void *)(long)skb->data;
|
void *data = (void *)(long)skb->data;
|
||||||
void *data_end = (void *)(long)skb->data_end;
|
void *data_end = (void *)(long)skb->data_end;
|
||||||
|
|
||||||
@ -72,20 +76,24 @@ int capture_tc_ingress(struct __sk_buff *skb)
|
|||||||
if ((void *)(eth + 1) > data_end)
|
if ((void *)(eth + 1) > data_end)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
/* Vérifier que c'est un paquet IPv4 */
|
|
||||||
if (bpf_ntohs(eth->h_proto) != ETH_P_IP)
|
if (bpf_ntohs(eth->h_proto) != ETH_P_IP)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
/* --- Parsing IPv4 --- */
|
/* --- Parsing IPv4 --- */
|
||||||
struct iphdr *ip = (struct iphdr *)((void *)eth + ETH_HLEN);
|
struct iphdr *ip = data + ETH_HLEN;
|
||||||
if ((void *)(ip + 1) > data_end)
|
if ((void *)(ip + 1) > data_end)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
/* Vérifier que c'est du TCP */
|
|
||||||
if (ip->protocol != IPPROTO_TCP)
|
if (ip->protocol != IPPROTO_TCP)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
__u8 ihl = ip->ihl & 0x0F; /* longueur en-tête IP en mots de 32 bits */
|
/* ihl stocké en u32 et borné explicitement : le vérificateur peut ainsi
|
||||||
|
* prouver que ip_hlen ∈ [20, 60] sans risque d'overflow signé. */
|
||||||
|
__u32 ihl = ip->ihl & 0x0F;
|
||||||
|
if (ihl < 5)
|
||||||
|
return TC_ACT_OK;
|
||||||
|
__u32 ip_hlen = ihl << 2; /* ∈ [20, 60] */
|
||||||
|
|
||||||
__u32 src_ip = ip->saddr;
|
__u32 src_ip = ip->saddr;
|
||||||
__u32 dst_ip = ip->daddr;
|
__u32 dst_ip = ip->daddr;
|
||||||
__u8 ttl = ip->ttl;
|
__u8 ttl = ip->ttl;
|
||||||
@ -94,19 +102,27 @@ int capture_tc_ingress(struct __sk_buff *skb)
|
|||||||
__u8 df_bit = (frag_off & IP_DF) ? 1 : 0;
|
__u8 df_bit = (frag_off & IP_DF) ? 1 : 0;
|
||||||
|
|
||||||
/* --- Parsing TCP --- */
|
/* --- Parsing TCP --- */
|
||||||
struct tcphdr *tcp = (struct tcphdr *)((void *)ip + (ihl * 4));
|
struct tcphdr *tcp = data + ETH_HLEN + ip_hlen;
|
||||||
if ((void *)(tcp + 1) > data_end)
|
if ((void *)(tcp + 1) > data_end)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
__u16 src_port = bpf_ntohs(tcp->source);
|
__u16 src_port = bpf_ntohs(tcp->source);
|
||||||
__u16 dst_port = bpf_ntohs(tcp->dest);
|
__u16 dst_port = bpf_ntohs(tcp->dest);
|
||||||
__u16 window = bpf_ntohs(tcp->window);
|
__u16 window = bpf_ntohs(tcp->window);
|
||||||
__u8 tcp_flags = ((__u8 *)tcp)[13]; /* octet des flags TCP */
|
/* Lecture des flags via offset constant (octet 13 de l'en-tête TCP) */
|
||||||
__u8 data_off = tcp->doff; /* longueur en-tête TCP en mots de 32 bits */
|
__u8 tcp_flags = ((__u8 *)tcp)[13];
|
||||||
|
|
||||||
|
/* doff stocké en u32 et borné : tcp_hlen ∈ [20, 60] */
|
||||||
|
__u32 doff = tcp->doff;
|
||||||
|
if (doff < 5)
|
||||||
|
return TC_ACT_OK;
|
||||||
|
__u32 tcp_hlen = doff << 2; /* ∈ [20, 60] */
|
||||||
|
|
||||||
|
/* Offset absolu du début du payload applicatif dans le paquet */
|
||||||
|
__u32 payload_off = ETH_HLEN + ip_hlen + tcp_hlen;
|
||||||
|
|
||||||
/* --- Détection TCP SYN (SYN set, ACK clear) --- */
|
/* --- Détection TCP SYN (SYN set, ACK clear) --- */
|
||||||
if ((tcp_flags & TH_SYN) && !(tcp_flags & TH_ACK)) {
|
if ((tcp_flags & TH_SYN) && !(tcp_flags & TH_ACK)) {
|
||||||
/* Allouer un slot dans le ring buffer */
|
|
||||||
struct tcp_syn_event *evt = bpf_ringbuf_reserve(&rb_tcp_syn, sizeof(*evt), 0);
|
struct tcp_syn_event *evt = bpf_ringbuf_reserve(&rb_tcp_syn, sizeof(*evt), 0);
|
||||||
if (!evt)
|
if (!evt)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
@ -122,68 +138,66 @@ int capture_tc_ingress(struct __sk_buff *skb)
|
|||||||
evt->window_scale = 0xFF; /* absent par défaut */
|
evt->window_scale = 0xFF; /* absent par défaut */
|
||||||
evt->mss = 0; /* absent par défaut */
|
evt->mss = 0; /* absent par défaut */
|
||||||
evt->timestamp_ns = bpf_ktime_get_ns();
|
evt->timestamp_ns = bpf_ktime_get_ns();
|
||||||
|
|
||||||
/* --- Parsing des options TCP --- */
|
|
||||||
__u8 *opts_start = (__u8 *)tcp + 20; /* options commencent après les 20 octets fixes */
|
|
||||||
__u8 opts_len = (data_off * 4) - 20;
|
|
||||||
if (opts_len > MAX_TCP_OPTIONS)
|
|
||||||
opts_len = MAX_TCP_OPTIONS;
|
|
||||||
|
|
||||||
evt->tcp_options_len = 0;
|
evt->tcp_options_len = 0;
|
||||||
|
|
||||||
/* Copier les options brutes avec vérification de bornes */
|
/* Lecture des options TCP dans un tampon de pile local (copie brute).
|
||||||
__u8 *opts_ptr = opts_start;
|
* Le scan MSS/WS utilise bpf_skb_load_bytes avec offset variable plutôt
|
||||||
|
* que opts_buf[j] : l'accès pile à index variable génère une erreur
|
||||||
|
* vérificateur ("invalid variable-offset read from stack") car le tnum de
|
||||||
|
* j accumule des bits carries au fil des incréments j += len (u8). */
|
||||||
|
__u32 opts_off = ETH_HLEN + ip_hlen + 20;
|
||||||
|
__u32 opts_bytes = tcp_hlen - 20; /* tcp_hlen >= 20, donc >= 0 */
|
||||||
|
if (opts_bytes > MAX_TCP_OPTIONS)
|
||||||
|
opts_bytes = MAX_TCP_OPTIONS;
|
||||||
|
|
||||||
/* Boucle bornée sur les options TCP (max 40 octets) */
|
if (opts_bytes > 0) {
|
||||||
|
__u8 opts_buf[MAX_TCP_OPTIONS] = {0};
|
||||||
|
/* Lecture à taille constante : le vérificateur connaît la borne. */
|
||||||
|
if (bpf_skb_load_bytes(skb, opts_off, opts_buf, MAX_TCP_OPTIONS) == 0) {
|
||||||
|
/* Copie brute dans l'événement */
|
||||||
|
__builtin_memcpy(evt->tcp_options_raw, opts_buf, MAX_TCP_OPTIONS);
|
||||||
|
evt->tcp_options_len = (__u8)opts_bytes;
|
||||||
|
|
||||||
|
/* Scan MSS et Window Scale via bpf_skb_load_bytes (offset variable
|
||||||
|
* dans le paquet = autorisé ; index variable dans la pile = refusé). */
|
||||||
|
__u32 j = 0;
|
||||||
|
__u8 hdr2[2] = {0};
|
||||||
|
__u8 one[1] = {0};
|
||||||
#pragma unroll
|
#pragma unroll
|
||||||
for (int i = 0; i < MAX_TCP_OPTIONS; i++) {
|
for (int iter = 0; iter < MAX_TCP_OPTIONS; iter++) {
|
||||||
if (i >= opts_len)
|
if (j + 1 >= opts_bytes)
|
||||||
break;
|
break;
|
||||||
if ((void *)(opts_ptr + i + 1) > data_end)
|
/* Lire kind et len d'un coup depuis le paquet */
|
||||||
|
if (bpf_skb_load_bytes(skb, opts_off + j, hdr2, 2) < 0)
|
||||||
|
break;
|
||||||
|
__u8 kind = hdr2[0];
|
||||||
|
if (kind == 0)
|
||||||
|
break; /* EOL */
|
||||||
|
if (kind == 1) {
|
||||||
|
j++;
|
||||||
|
continue; /* NOP : 1 octet */
|
||||||
|
}
|
||||||
|
__u8 len = hdr2[1];
|
||||||
|
if (len < 2 || j + len > opts_bytes)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
__u8 opt_kind;
|
/* MSS (option 2) : 4 octets */
|
||||||
bpf_probe_read_kernel(&opt_kind, 1, opts_ptr + i);
|
if (kind == 2 && len == 4) {
|
||||||
evt->tcp_options_raw[i] = opt_kind;
|
__u8 mss_buf[2] = {0};
|
||||||
evt->tcp_options_len = i + 1;
|
if (bpf_skb_load_bytes(skb, opts_off + j + 2, mss_buf, 2) == 0) {
|
||||||
|
|
||||||
/* NOP : 1 octet */
|
|
||||||
if (opt_kind == 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* EOL : fin des options */
|
|
||||||
if (opt_kind == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Option avec longueur */
|
|
||||||
if ((void *)(opts_ptr + i + 2) > data_end)
|
|
||||||
break;
|
|
||||||
|
|
||||||
__u8 opt_len;
|
|
||||||
bpf_probe_read_kernel(&opt_len, 1, opts_ptr + i + 1);
|
|
||||||
if (opt_len < 2)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* MSS (option 2) : 4 octets au total */
|
|
||||||
if (opt_kind == 2 && opt_len == 4) {
|
|
||||||
if ((void *)(opts_ptr + i + 4) > data_end)
|
|
||||||
break;
|
|
||||||
__u16 mss_val;
|
__u16 mss_val;
|
||||||
bpf_probe_read_kernel(&mss_val, 2, opts_ptr + i + 2);
|
__builtin_memcpy(&mss_val, mss_buf, 2);
|
||||||
evt->mss = bpf_ntohs(mss_val);
|
evt->mss = bpf_ntohs(mss_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Window Scale (option 3) : 3 octets au total */
|
|
||||||
if (opt_kind == 3 && opt_len == 3) {
|
|
||||||
if ((void *)(opts_ptr + i + 3) > data_end)
|
|
||||||
break;
|
|
||||||
__u8 wscale;
|
|
||||||
bpf_probe_read_kernel(&wscale, 1, opts_ptr + i + 2);
|
|
||||||
evt->window_scale = wscale;
|
|
||||||
}
|
}
|
||||||
|
/* Window Scale (option 3) : 3 octets */
|
||||||
/* Avancer au-delà de cette option */
|
if (kind == 3 && len == 3) {
|
||||||
i += opt_len - 1;
|
if (bpf_skb_load_bytes(skb, opts_off + j + 2, one, 1) == 0)
|
||||||
|
evt->window_scale = one[0];
|
||||||
|
}
|
||||||
|
j += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf_ringbuf_submit(evt, 0);
|
bpf_ringbuf_submit(evt, 0);
|
||||||
@ -191,19 +205,20 @@ int capture_tc_ingress(struct __sk_buff *skb)
|
|||||||
|
|
||||||
/* --- Détection TLS ClientHello (port 443) --- */
|
/* --- Détection TLS ClientHello (port 443) --- */
|
||||||
if (dst_port == HTTPS_PORT) {
|
if (dst_port == HTTPS_PORT) {
|
||||||
__u8 *tcp_payload = (__u8 *)tcp + (data_off * 4);
|
/* Vérifier qu'il y a au moins 6 octets pour l'en-tête TLS record */
|
||||||
|
if (payload_off + 6 > skb->len)
|
||||||
/* Vérifier qu'il y a au moins 6 octets pour l'en-tête TLS record + type hello */
|
|
||||||
if ((void *)(tcp_payload + 6) > data_end)
|
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
__u8 content_type, msg_type;
|
__u8 tls_hdr[6];
|
||||||
bpf_probe_read_kernel(&content_type, 1, tcp_payload);
|
if (bpf_skb_load_bytes(skb, payload_off, tls_hdr, sizeof(tls_hdr)) < 0)
|
||||||
bpf_probe_read_kernel(&msg_type, 1, tcp_payload + 5);
|
return TC_ACT_OK;
|
||||||
|
|
||||||
/* Vérifier : Handshake (0x16) + ClientHello (0x01) */
|
/* Handshake (0x16) + ClientHello (0x01 au byte 5) */
|
||||||
if (content_type == TLS_CONTENT_HANDSHAKE && msg_type == TLS_MSG_CLIENT_HELLO) {
|
if (tls_hdr[0] != TLS_CONTENT_HANDSHAKE || tls_hdr[5] != TLS_MSG_CLIENT_HELLO)
|
||||||
struct tls_hello_event *tls_evt = bpf_ringbuf_reserve(&rb_tls_hello, sizeof(*tls_evt), 0);
|
return TC_ACT_OK;
|
||||||
|
|
||||||
|
struct tls_hello_event *tls_evt =
|
||||||
|
bpf_ringbuf_reserve(&rb_tls_hello, sizeof(*tls_evt), 0);
|
||||||
if (!tls_evt)
|
if (!tls_evt)
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
@ -211,38 +226,46 @@ int capture_tc_ingress(struct __sk_buff *skb)
|
|||||||
tls_evt->src_port = src_port;
|
tls_evt->src_port = src_port;
|
||||||
tls_evt->timestamp_ns = bpf_ktime_get_ns();
|
tls_evt->timestamp_ns = bpf_ktime_get_ns();
|
||||||
|
|
||||||
/* Calculer la longueur de payload disponible */
|
/* Calcul de la longueur disponible.
|
||||||
__u32 avail = (__u32)(data_end - (void *)tcp_payload);
|
* IMPORTANT : appliquer le masque SANS cap préalable. Si un cap
|
||||||
if (avail > MAX_TLS_PAYLOAD)
|
* `if (avail > N) avail = N` précède le masque, le compilateur
|
||||||
avail = MAX_TLS_PAYLOAD;
|
* supprime l'AND (semantically redundant). Sans cap, le compilateur
|
||||||
|
* conserve l'AND et le vérificateur en déduit avail ∈ [0, 511].
|
||||||
|
* Cas edge : avail exactement multiple de 512 → avail & 511 = 0. */
|
||||||
|
__u32 avail = skb->len - payload_off;
|
||||||
|
avail &= (MAX_TLS_PAYLOAD - 1); /* verifier : avail ∈ [0, 511] */
|
||||||
|
if (avail == 0) {
|
||||||
|
bpf_ringbuf_discard(tls_evt, 0);
|
||||||
|
return TC_ACT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
tls_evt->payload_len = (__u16)avail;
|
tls_evt->payload_len = (__u16)avail;
|
||||||
|
|
||||||
/* Copier le payload TLS (borné à MAX_TLS_PAYLOAD) */
|
if (bpf_skb_load_bytes(skb, payload_off, tls_evt->payload, avail) < 0) {
|
||||||
bpf_probe_read_kernel(tls_evt->payload, avail & (MAX_TLS_PAYLOAD - 1), tcp_payload);
|
bpf_ringbuf_discard(tls_evt, 0);
|
||||||
|
return TC_ACT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
bpf_ringbuf_submit(tls_evt, 0);
|
bpf_ringbuf_submit(tls_evt, 0);
|
||||||
}
|
return TC_ACT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Détection payload HTTP en clair (port 80 / 8080) --- */
|
/* --- Détection payload HTTP en clair (port 80 / 8080) --- */
|
||||||
if (dst_port == HTTP_PORT || dst_port == HTTP_ALT_PORT) {
|
if (dst_port == HTTP_PORT || dst_port == HTTP_ALT_PORT) {
|
||||||
/* Ignorer SYN, FIN, RST : on ne veut que les segments de données */
|
/* Ignorer SYN, FIN, RST : seuls les segments de données nous intéressent */
|
||||||
if (tcp_flags & (TH_SYN | TH_FIN | TH_RST))
|
if (tcp_flags & (TH_SYN | TH_FIN | TH_RST))
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
/* Calculer l'offset du payload TCP dans le paquet */
|
if (payload_off >= skb->len)
|
||||||
__u32 payload_off = ETH_HLEN + (ihl * 4) + (data_off * 4);
|
|
||||||
|
|
||||||
/* Vérifier qu'il y a un payload non vide */
|
|
||||||
if (skb->len <= payload_off)
|
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
|
|
||||||
__u32 avail = skb->len - payload_off;
|
__u32 avail = skb->len - payload_off;
|
||||||
if (avail > 4096)
|
/* Même stratégie que pour TLS : masque SANS cap préalable.
|
||||||
avail = 4096;
|
* Le compilateur conserve l'AND, le vérificateur déduit [0, 4095]. */
|
||||||
|
avail &= 0xFFF; /* verifier : avail ∈ [0, 4095], smin ≥ 0 */
|
||||||
|
if (avail == 0)
|
||||||
|
return TC_ACT_OK;
|
||||||
|
|
||||||
/* Réserver une entrée dans le ring buffer HTTP en clair */
|
|
||||||
struct http_plain_event *h_evt =
|
struct http_plain_event *h_evt =
|
||||||
bpf_ringbuf_reserve(&rb_http_plain, sizeof(*h_evt), 0);
|
bpf_ringbuf_reserve(&rb_http_plain, sizeof(*h_evt), 0);
|
||||||
if (!h_evt)
|
if (!h_evt)
|
||||||
@ -252,15 +275,10 @@ int capture_tc_ingress(struct __sk_buff *skb)
|
|||||||
h_evt->dst_ip = bpf_ntohl(dst_ip);
|
h_evt->dst_ip = bpf_ntohl(dst_ip);
|
||||||
h_evt->src_port = src_port;
|
h_evt->src_port = src_port;
|
||||||
h_evt->dst_port = dst_port;
|
h_evt->dst_port = dst_port;
|
||||||
|
h_evt->payload_len = (__u16)avail;
|
||||||
h_evt->timestamp_ns = bpf_ktime_get_ns();
|
h_evt->timestamp_ns = bpf_ktime_get_ns();
|
||||||
|
|
||||||
/* Copier le payload depuis le skb linéaire via bpf_skb_load_bytes.
|
if (bpf_skb_load_bytes(skb, payload_off, h_evt->payload, avail) < 0) {
|
||||||
* La longueur est masquée pour satisfaire le vérificateur eBPF. */
|
|
||||||
__u32 copy_len = avail & (4096 - 1);
|
|
||||||
if (copy_len == 0) copy_len = 1; /* cas avail == 4096 exactement */
|
|
||||||
h_evt->payload_len = (__u16)avail;
|
|
||||||
|
|
||||||
if (bpf_skb_load_bytes(skb, payload_off, h_evt->payload, copy_len) < 0) {
|
|
||||||
bpf_ringbuf_discard(h_evt, 0);
|
bpf_ringbuf_discard(h_evt, 0);
|
||||||
return TC_ACT_OK;
|
return TC_ACT_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ClickHouse/clickhouse-go/v2"
|
"github.com/ClickHouse/clickhouse-go/v2"
|
||||||
@ -24,25 +25,32 @@ type ClickHouseWriter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sessionRecord est la représentation JSON d'une session pour http_logs_raw.
|
// sessionRecord est la représentation JSON d'une session pour http_logs_raw.
|
||||||
|
// Les noms de champs JSON correspondent exactement aux clés attendues par le MV mv_http_logs.
|
||||||
type sessionRecord struct {
|
type sessionRecord struct {
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Time time.Time `json:"time"`
|
||||||
SrcIP string `json:"src_ip"`
|
SrcIP string `json:"src_ip"`
|
||||||
SrcPort int `json:"src_port"`
|
SrcPort int `json:"src_port"`
|
||||||
|
DstIP string `json:"dst_ip"`
|
||||||
|
DstPort int `json:"dst_port"`
|
||||||
Correlated int `json:"correlated"`
|
Correlated int `json:"correlated"`
|
||||||
|
|
||||||
// L3/L4
|
// Métadonnées IP (noms attendus par le MV)
|
||||||
TTL *uint8 `json:"ttl,omitempty"`
|
IPMetaDF *bool `json:"ip_meta_df,omitempty"`
|
||||||
DFBit *bool `json:"df_bit,omitempty"`
|
IPMetaID *uint16 `json:"ip_meta_id,omitempty"`
|
||||||
IPID *uint16 `json:"ip_id,omitempty"`
|
IPMetaTTL *uint8 `json:"ip_meta_ttl,omitempty"`
|
||||||
WindowSize *uint16 `json:"window_size,omitempty"`
|
IPMetaTotalLength *uint16 `json:"ip_meta_total_length,omitempty"`
|
||||||
WindowScale *uint8 `json:"window_scale,omitempty"`
|
|
||||||
MSS *uint16 `json:"mss,omitempty"`
|
|
||||||
|
|
||||||
// TLS
|
// Métadonnées TCP (noms attendus par le MV)
|
||||||
|
TCPMetaWindowSize *uint16 `json:"tcp_meta_window_size,omitempty"`
|
||||||
|
TCPMetaWindowScale *uint8 `json:"tcp_meta_window_scale,omitempty"`
|
||||||
|
TCPMetaMSS *uint16 `json:"tcp_meta_mss,omitempty"`
|
||||||
|
TCPMetaOptions string `json:"tcp_meta_options,omitempty"`
|
||||||
|
|
||||||
|
// TLS (noms attendus par le MV)
|
||||||
JA4Hash string `json:"ja4,omitempty"`
|
JA4Hash string `json:"ja4,omitempty"`
|
||||||
SNI string `json:"sni,omitempty"`
|
TLSSNI string `json:"tls_sni,omitempty"`
|
||||||
ALPN []string `json:"alpn,omitempty"`
|
TLSALPN string `json:"tls_alpn,omitempty"`
|
||||||
TLSVersion *uint16 `json:"tls_version,omitempty"`
|
TLSVersion string `json:"tls_version,omitempty"`
|
||||||
|
|
||||||
// HTTP
|
// HTTP
|
||||||
Method string `json:"method,omitempty"`
|
Method string `json:"method,omitempty"`
|
||||||
@ -179,29 +187,31 @@ func sessionToRecord(s *correlation.SessionState) sessionRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rec := sessionRecord{
|
rec := sessionRecord{
|
||||||
Timestamp: s.FirstSeen,
|
Time: s.FirstSeen,
|
||||||
SrcIP: srcIP,
|
SrcIP: srcIP,
|
||||||
SrcPort: int(s.Key.SrcPort),
|
SrcPort: int(s.Key.SrcPort),
|
||||||
|
DstIP: "0.0.0.0", // destination non capturée par les sondes eBPF actuelles
|
||||||
|
DstPort: 0,
|
||||||
Correlated: correlated,
|
Correlated: correlated,
|
||||||
KeepAlives: len(s.Requests),
|
KeepAlives: len(s.Requests),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Champs L3/L4
|
// Champs métadonnées IP/TCP
|
||||||
if s.L3L4 != nil {
|
if s.L3L4 != nil {
|
||||||
rec.TTL = &s.L3L4.TTL
|
rec.IPMetaDF = &s.L3L4.DFBit
|
||||||
rec.DFBit = &s.L3L4.DFBit
|
rec.IPMetaID = &s.L3L4.IPID
|
||||||
rec.IPID = &s.L3L4.IPID
|
rec.IPMetaTTL = &s.L3L4.TTL
|
||||||
rec.WindowSize = &s.L3L4.WindowSize
|
rec.TCPMetaWindowSize = &s.L3L4.WindowSize
|
||||||
rec.WindowScale = &s.L3L4.WindowScale
|
rec.TCPMetaWindowScale = &s.L3L4.WindowScale
|
||||||
rec.MSS = &s.L3L4.MSS
|
rec.TCPMetaMSS = &s.L3L4.MSS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Champs TLS
|
// Champs TLS
|
||||||
if s.TLS != nil {
|
if s.TLS != nil {
|
||||||
rec.JA4Hash = s.TLS.JA4Hash
|
rec.JA4Hash = s.TLS.JA4Hash
|
||||||
rec.SNI = s.TLS.SNI
|
rec.TLSSNI = s.TLS.SNI
|
||||||
rec.ALPN = s.TLS.ALPN
|
rec.TLSALPN = strings.Join(s.TLS.ALPN, ",")
|
||||||
rec.TLSVersion = &s.TLS.TLSVersion
|
rec.TLSVersion = formatTLSVersion(s.TLS.TLSVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Champs HTTP (dernière requête)
|
// Champs HTTP (dernière requête)
|
||||||
@ -217,3 +227,19 @@ func sessionToRecord(s *correlation.SessionState) sessionRecord {
|
|||||||
|
|
||||||
return rec
|
return rec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// formatTLSVersion convertit la valeur numérique TLS en chaîne lisible.
|
||||||
|
func formatTLSVersion(v uint16) string {
|
||||||
|
switch v {
|
||||||
|
case 0x0301:
|
||||||
|
return "TLSv1.0"
|
||||||
|
case 0x0302:
|
||||||
|
return "TLSv1.1"
|
||||||
|
case 0x0303:
|
||||||
|
return "TLSv1.2"
|
||||||
|
case 0x0304:
|
||||||
|
return "TLSv1.3"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -183,8 +183,8 @@ SELECT
|
|||||||
toUInt32(if(count() > 0,
|
toUInt32(if(count() > 0,
|
||||||
arrayMax(
|
arrayMax(
|
||||||
arrayMap(
|
arrayMap(
|
||||||
s -> toUInt64(countEqual(groupArray(toStartOfSecond(src.time)), s)),
|
s -> toUInt64(countEqual(groupArray(toStartOfSecond(toDateTime64(src.time, 3))), s)),
|
||||||
arrayDistinct(groupArray(toStartOfSecond(src.time)))
|
arrayDistinct(groupArray(toStartOfSecond(toDateTime64(src.time, 3))))
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
|
|||||||
@ -10,10 +10,25 @@
|
|||||||
# Le hook TC ingress capture TCP SYN + TLS ClientHello sur eth0.
|
# Le hook TC ingress capture TCP SYN + TLS ClientHello sur eth0.
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# ── Stage 1 : build ja4ebpf ──────────────────────────────────────────────────
|
# ARG global : doit être déclaré avant tous les FROM
|
||||||
FROM golang:1.24-bookworm AS go-builder
|
ARG BASE_IMAGE=rockylinux:9
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y clang llvm libbpf-dev && rm -rf /var/lib/apt/lists/*
|
# ── Stage 1 : build ja4ebpf (Rocky Linux, même toolchain que la prod) ─────────
|
||||||
|
FROM rockylinux:9 AS go-builder
|
||||||
|
|
||||||
|
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||||
|
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||||
|
dnf config-manager --enable crb && \
|
||||||
|
dnf install -y \
|
||||||
|
golang \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
libbpf-devel \
|
||||||
|
kernel-headers \
|
||||||
|
bpftool \
|
||||||
|
make \
|
||||||
|
&& \
|
||||||
|
dnf clean all
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY go.work go.work.sum* ./
|
COPY go.work go.work.sum* ./
|
||||||
@ -30,11 +45,10 @@ RUN GOWORK=off go generate ./internal/loader/ && \
|
|||||||
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
||||||
|
|
||||||
# ── Stage 2 : runtime Apache HTTPD + ja4ebpf ─────────────────────────────────
|
# ── Stage 2 : runtime Apache HTTPD + ja4ebpf ─────────────────────────────────
|
||||||
ARG BASE_IMAGE=rockylinux:9
|
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
RUN dnf install -y epel-release 2>/dev/null; \
|
RUN dnf install -y epel-release 2>/dev/null; \
|
||||||
dnf install -y httpd mod_ssl mod_http2 openssl curl && \
|
dnf install -y --allowerasing procps-ng httpd mod_ssl mod_http2 openssl curl && \
|
||||||
dnf clean all
|
dnf clean all
|
||||||
|
|
||||||
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
||||||
|
|||||||
@ -13,13 +13,16 @@ fi
|
|||||||
# Créer les répertoires de run nécessaires
|
# Créer les répertoires de run nécessaires
|
||||||
mkdir -p /run/httpd /var/log/httpd
|
mkdir -p /run/httpd /var/log/httpd
|
||||||
|
|
||||||
# Démarrer ja4ebpf en arrière-plan
|
# Démarrer ja4ebpf en arrière-plan (optionnel : ne bloque pas le démarrage)
|
||||||
/usr/local/bin/ja4ebpf -config /etc/ja4ebpf/config.yml &
|
/usr/local/bin/ja4ebpf -config /etc/ja4ebpf/config.yml &
|
||||||
JA4_PID=$!
|
JA4_PID=$!
|
||||||
echo "[entrypoint] ja4ebpf démarré (PID $JA4_PID)"
|
echo "[entrypoint] ja4ebpf démarré (PID $JA4_PID)"
|
||||||
|
|
||||||
# Attendre que ja4ebpf charge ses programmes eBPF
|
# Laisser 3s pour détecter un échec immédiat (ex: verifier eBPF)
|
||||||
sleep 2
|
sleep 3
|
||||||
|
if ! kill -0 "$JA4_PID" 2>/dev/null; then
|
||||||
|
echo "[entrypoint] ⚠ ja4ebpf s'est arrêté immédiatement — mode dégradé (Apache seul)"
|
||||||
|
fi
|
||||||
|
|
||||||
# Démarrer Apache HTTPD en foreground
|
# Démarrer Apache HTTPD en foreground
|
||||||
echo "[entrypoint] Démarrage d'Apache HTTPD..."
|
echo "[entrypoint] Démarrage d'Apache HTTPD..."
|
||||||
|
|||||||
@ -1,22 +1,16 @@
|
|||||||
# Configuration ja4ebpf — stack Apache
|
# Configuration ja4ebpf — stack Apache
|
||||||
# Fichier monté dans /etc/ja4ebpf/config.yml
|
|
||||||
|
|
||||||
interface: eth0
|
interface: eth0
|
||||||
|
ssl_lib_path: "/usr/lib64/libssl.so.3"
|
||||||
# Cibles uprobe : httpd lie OpenSSL via libssl.so.
|
|
||||||
# Sur RHEL/Rocky, le binaire est /usr/sbin/httpd.
|
|
||||||
targets:
|
|
||||||
- binary: /usr/sbin/httpd
|
|
||||||
- binary: /usr/lib64/httpd/modules/mod_ssl.so
|
|
||||||
|
|
||||||
clickhouse:
|
clickhouse:
|
||||||
addr: "${JA4EBPF_CH_ADDR:-clickhouse:9000}"
|
dsn: "clickhouse://default:@clickhouse:9000/ja4_logs"
|
||||||
database: ja4_logs
|
batch_size: 100
|
||||||
table: http_logs_raw
|
flush_secs: 1
|
||||||
batch_size: 200
|
|
||||||
flush_interval_ms: 500
|
|
||||||
|
|
||||||
session:
|
correlation:
|
||||||
timeout_ms: 500
|
timeout_ms: 500
|
||||||
slowloris_timeout_s: 10
|
slowloris_ms: 10000
|
||||||
gc_interval_ms: 100
|
|
||||||
|
log:
|
||||||
|
level: "info"
|
||||||
|
format: "json"
|
||||||
|
|||||||
@ -49,7 +49,7 @@ stack_verify_extra() {
|
|||||||
# Vérifie que ja4ebpf tourne
|
# Vérifie que ja4ebpf tourne
|
||||||
local ja4_pid
|
local ja4_pid
|
||||||
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -x ja4ebpf 2>/dev/null | head -1 || echo "")
|
ps -C ja4ebpf -o pid= 2>/dev/null | head -1 || echo "")
|
||||||
if [ -n "$ja4_pid" ]; then
|
if [ -n "$ja4_pid" ]; then
|
||||||
pass "Processus ja4ebpf actif (PID $ja4_pid)"
|
pass "Processus ja4ebpf actif (PID $ja4_pid)"
|
||||||
else
|
else
|
||||||
@ -59,7 +59,7 @@ stack_verify_extra() {
|
|||||||
# Vérifie que httpd tourne
|
# Vérifie que httpd tourne
|
||||||
local httpd_count
|
local httpd_count
|
||||||
httpd_count=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
httpd_count=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -c httpd 2>/dev/null || echo "0")
|
ps -C httpd -o pid= 2>/dev/null | wc -l || echo "0")
|
||||||
if [ "${httpd_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${httpd_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "Apache HTTPD actif ($httpd_count processus httpd)"
|
pass "Apache HTTPD actif ($httpd_count processus httpd)"
|
||||||
else
|
else
|
||||||
@ -68,7 +68,7 @@ stack_verify_extra() {
|
|||||||
|
|
||||||
# Vérifie les données L7 capturées via uprobe httpd
|
# Vérifie les données L7 capturées via uprobe httpd
|
||||||
local l7_count
|
local l7_count
|
||||||
l7_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE method != ''")
|
l7_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE method != ''" || echo "0")
|
||||||
if [ "${l7_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${l7_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "L7 capturé via uprobe httpd : $l7_count requêtes HTTP"
|
pass "L7 capturé via uprobe httpd : $l7_count requêtes HTTP"
|
||||||
else
|
else
|
||||||
@ -78,16 +78,16 @@ stack_verify_extra() {
|
|||||||
|
|
||||||
# Vérifie JA4 fingerprint
|
# Vérifie JA4 fingerprint
|
||||||
local ja4_sample
|
local ja4_sample
|
||||||
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs_raw WHERE ja4 != '' LIMIT 1" 2>/dev/null || echo "")
|
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs WHERE ja4 != '' LIMIT 1" || echo "")
|
||||||
if [ -n "$ja4_sample" ]; then
|
if [ -n "$ja4_sample" ]; then
|
||||||
pass "JA4 fingerprint capturé : $ja4_sample"
|
pass "JA4 fingerprint capturé : $ja4_sample"
|
||||||
else
|
else
|
||||||
warn "JA4 fingerprint vide — TC ingress hook peut-être non fonctionnel"
|
warn "JA4 fingerprint vide — TC ingress hook peut-être non fonctionnel"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vérifie le SNI capturé
|
# Vérifie le SNI capturé (colonne tls_sni dans http_logs)
|
||||||
local sni_count
|
local sni_count
|
||||||
sni_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE sni != ''")
|
sni_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE tls_sni != ''" || echo "0")
|
||||||
if [ "${sni_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${sni_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "SNI capturé dans $sni_count enregistrements"
|
pass "SNI capturé dans $sni_count enregistrements"
|
||||||
else
|
else
|
||||||
@ -96,7 +96,7 @@ stack_verify_extra() {
|
|||||||
|
|
||||||
# Vérifie HTTP port 80 (trafic en clair — kprobe tcp_recvmsg)
|
# Vérifie HTTP port 80 (trafic en clair — kprobe tcp_recvmsg)
|
||||||
local plain_count
|
local plain_count
|
||||||
plain_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE correlated = 0 AND method != ''" 2>/dev/null || echo "0")
|
plain_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE correlated = 0 AND method != ''" || echo "0")
|
||||||
if [ "${plain_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${plain_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "HTTP en clair capturé : $plain_count requêtes (kprobe tcp_recvmsg)"
|
pass "HTTP en clair capturé : $plain_count requêtes (kprobe tcp_recvmsg)"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -69,7 +69,7 @@ services:
|
|||||||
ports: ["443:443","80:80"]
|
ports: ["443:443","80:80"]
|
||||||
healthcheck:
|
healthcheck:
|
||||||
# Hitch n'expose pas de port HTTP directement.
|
# Hitch n'expose pas de port HTTP directement.
|
||||||
# On passe par HTTPS (hitch → varnish → backend).
|
# On passe par HTTPS (hitch → varnish → backend). Varnish supporte h2 via -p feature=+http2.
|
||||||
test: ["CMD","curl","-sfk","https://localhost/health"]
|
test: ["CMD","curl","-sfk","https://localhost/health"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
|
|||||||
@ -3,9 +3,24 @@
|
|||||||
# hitch (TLS, PROXY protocol) → Varnish (HTTP cache) → backend HTTP
|
# hitch (TLS, PROXY protocol) → Varnish (HTTP cache) → backend HTTP
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
FROM golang:1.24-bookworm AS go-builder
|
ARG BASE_IMAGE=rockylinux:9
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y clang llvm libbpf-dev && rm -rf /var/lib/apt/lists/*
|
# ── Stage 1 : build ja4ebpf (Rocky Linux, même toolchain que la prod) ─────────
|
||||||
|
FROM rockylinux:9 AS go-builder
|
||||||
|
|
||||||
|
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||||
|
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||||
|
dnf config-manager --enable crb && \
|
||||||
|
dnf install -y \
|
||||||
|
golang \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
libbpf-devel \
|
||||||
|
kernel-headers \
|
||||||
|
bpftool \
|
||||||
|
make \
|
||||||
|
&& \
|
||||||
|
dnf clean all
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY go.work go.work.sum* ./
|
COPY go.work go.work.sum* ./
|
||||||
@ -22,12 +37,11 @@ RUN GOWORK=off go generate ./internal/loader/ && \
|
|||||||
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
||||||
|
|
||||||
# ── Runtime : hitch + varnish + backend + ja4ebpf ────────────────────────────
|
# ── Runtime : hitch + varnish + backend + ja4ebpf ────────────────────────────
|
||||||
ARG BASE_IMAGE=rockylinux:9
|
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
# hitch est dans EPEL ; varnish dans le dépôt officiel Rocky
|
# hitch est dans EPEL ; varnish dans le dépôt officiel Rocky
|
||||||
RUN dnf install -y epel-release && \
|
RUN dnf install -y epel-release && \
|
||||||
dnf install -y hitch varnish openssl curl python3 && \
|
dnf install -y --allowerasing procps-ng hitch varnish openssl curl python3 && \
|
||||||
dnf clean all
|
dnf clean all
|
||||||
|
|
||||||
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
||||||
@ -40,7 +54,8 @@ RUN openssl req -x509 -nodes -days 365 \
|
|||||||
-out /tmp/hitch.crt && \
|
-out /tmp/hitch.crt && \
|
||||||
# hitch attend un fichier PEM concaténé (clé + certificat)
|
# hitch attend un fichier PEM concaténé (clé + certificat)
|
||||||
cat /tmp/hitch.key /tmp/hitch.crt > /etc/hitch/hitch.pem && \
|
cat /tmp/hitch.key /tmp/hitch.crt > /etc/hitch/hitch.pem && \
|
||||||
chmod 600 /etc/hitch/hitch.pem && \
|
# lisible par nobody (user hitch worker)
|
||||||
|
chmod 644 /etc/hitch/hitch.pem && \
|
||||||
mkdir -p /var/www/html /run/varnish && \
|
mkdir -p /var/www/html /run/varnish && \
|
||||||
echo '{"status":"ok","stack":"hitch-varnish"}' > /var/www/html/health
|
echo '{"status":"ok","stack":"hitch-varnish"}' > /var/www/html/health
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,7 @@ varnishd \
|
|||||||
-F \
|
-F \
|
||||||
-f /etc/varnish/default.vcl \
|
-f /etc/varnish/default.vcl \
|
||||||
-a "127.0.0.1:6081,PROXY" \
|
-a "127.0.0.1:6081,PROXY" \
|
||||||
|
-p feature=+http2 \
|
||||||
-s malloc,64m \
|
-s malloc,64m \
|
||||||
-T 127.0.0.1:6082 &
|
-T 127.0.0.1:6082 &
|
||||||
VARNISH_PID=$!
|
VARNISH_PID=$!
|
||||||
@ -107,14 +108,26 @@ JA4EBPF_PID=$!
|
|||||||
|
|
||||||
log "Stack complète — backend=$BACKEND_PID varnish=$VARNISH_PID hitch=$HITCH_PID ja4ebpf=$JA4EBPF_PID"
|
log "Stack complète — backend=$BACKEND_PID varnish=$VARNISH_PID hitch=$HITCH_PID ja4ebpf=$JA4EBPF_PID"
|
||||||
|
|
||||||
|
# Laisser 3s pour détecter un échec immédiat de ja4ebpf
|
||||||
|
sleep 3
|
||||||
|
if ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||||
|
log "⚠ ja4ebpf s'est arrêté immédiatement — mode dégradé (web server seul)"
|
||||||
|
JA4EBPF_PID=""
|
||||||
|
fi
|
||||||
|
|
||||||
# ── 5. Supervision ────────────────────────────────────────────────────────────
|
# ── 5. Supervision ────────────────────────────────────────────────────────────
|
||||||
while true; do
|
while true; do
|
||||||
for pid_var in BACKEND_PID VARNISH_PID HITCH_PID JA4EBPF_PID; do
|
for pid_var in BACKEND_PID VARNISH_PID HITCH_PID; do
|
||||||
pid="${!pid_var}"
|
pid="${!pid_var}"
|
||||||
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then
|
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then
|
||||||
log "$pid_var (PID $pid) s'est arrêté — fin"
|
log "$pid_var (PID $pid) s'est arrêté — fin"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
# ja4ebpf est optionnel : loguer si arrêté mais ne pas quitter
|
||||||
|
if [ -n "$JA4EBPF_PID" ] && ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||||
|
log "⚠ ja4ebpf s'est arrêté — web server continue sans collecte eBPF"
|
||||||
|
JA4EBPF_PID=""
|
||||||
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|||||||
@ -21,12 +21,15 @@ tls-protos = TLSv1.2 TLSv1.3
|
|||||||
# Suites de chiffrement variées pour générer des JA4 distincts
|
# Suites de chiffrement variées pour générer des JA4 distincts
|
||||||
ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256"
|
ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256"
|
||||||
|
|
||||||
# ALPN : activer h2 pour HTTP/2 (si Varnish supporte)
|
# ALPN : h2 et http/1.1 — varnish supporte h2 via -p feature=+http2
|
||||||
alpn-protos = "h2,http/1.1"
|
alpn-protos = "h2,http/1.1"
|
||||||
|
|
||||||
# Nombre de workers (= nombre de cœurs pour les tests)
|
# Nombre de workers (= nombre de cœurs pour les tests)
|
||||||
workers = 2
|
workers = 2
|
||||||
|
|
||||||
|
# Utilisateur non-root pour les workers (hitch refuse root depuis 1.5.x)
|
||||||
|
user = "nobody"
|
||||||
|
|
||||||
# Répertoire de travail
|
# Répertoire de travail
|
||||||
daemon = off
|
daemon = off
|
||||||
log-level = 1
|
log-level = 1
|
||||||
|
|||||||
@ -1,40 +1,16 @@
|
|||||||
# Configuration ja4ebpf — stack hitch + varnish
|
# Configuration ja4ebpf — stack hitch + varnish
|
||||||
#
|
# hitch est le seul processus qui appelle SSL_read (terminaison TLS).
|
||||||
# Architecture TLS : hitch est le seul processus qui fait SSL_read.
|
|
||||||
# Il lie libssl.so.3 dynamiquement (package openssl sur Rocky Linux 9).
|
|
||||||
# ja4ebpf attache son uprobe sur libssl.so.3 pour capturer les données
|
|
||||||
# déchiffrées que hitch transmet à Varnish via PROXY protocol.
|
|
||||||
#
|
|
||||||
# Différence clé vs nginx :
|
|
||||||
# - Le processus qui appelle SSL_read est /usr/sbin/hitch (pas nginx)
|
|
||||||
# - Le PROXY protocol header est dans le flux cleartext hitch→varnish,
|
|
||||||
# pas dans les données capturées par SSL_read
|
|
||||||
# - src_ip est récupérée via le hook TC (TCP SYN du client vers hitch:443)
|
|
||||||
|
|
||||||
interface: eth0
|
interface: eth0
|
||||||
|
ssl_lib_path: "/usr/lib64/libssl.so.3"
|
||||||
ssl_probes:
|
|
||||||
# hitch lie libssl.so.3 de Rocky Linux 9.
|
|
||||||
# On peut aussi essayer directement le binaire hitch si OpenSSL est statique.
|
|
||||||
- executable: /usr/lib64/libssl.so.3
|
|
||||||
symbol: SSL_read
|
|
||||||
# Fallback : hitch peut lier une version différente selon le packaging
|
|
||||||
- executable: /usr/sbin/hitch
|
|
||||||
symbol: SSL_read
|
|
||||||
|
|
||||||
clickhouse:
|
clickhouse:
|
||||||
addr: "clickhouse:9000"
|
dsn: "clickhouse://default:@clickhouse:9000/ja4_logs"
|
||||||
database: "ja4_logs"
|
|
||||||
table: "http_logs_raw"
|
|
||||||
username: "default"
|
|
||||||
password: ""
|
|
||||||
tls: false
|
|
||||||
batch_size: 100
|
batch_size: 100
|
||||||
flush_every: "1s"
|
flush_secs: 1
|
||||||
|
|
||||||
timeouts:
|
correlation:
|
||||||
session_expiry: "500ms"
|
timeout_ms: 500
|
||||||
slowloris: "10s"
|
slowloris_ms: 10000
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: "info"
|
level: "info"
|
||||||
|
|||||||
@ -23,21 +23,21 @@ stack_verify_extra() {
|
|||||||
# Vérifie que hitch est bien en cours d'exécution
|
# Vérifie que hitch est bien en cours d'exécution
|
||||||
local hitch_pid
|
local hitch_pid
|
||||||
hitch_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
hitch_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -x hitch 2>/dev/null | head -1 || echo "")
|
ps -C hitch -o pid= 2>/dev/null | head -1 || echo "")
|
||||||
[ -n "$hitch_pid" ] && pass "Processus hitch actif (PID $hitch_pid)" \
|
[ -n "$hitch_pid" ] && pass "Processus hitch actif (PID $hitch_pid)" \
|
||||||
|| fail "Processus hitch introuvable"
|
|| fail "Processus hitch introuvable"
|
||||||
|
|
||||||
# Vérifie Varnish
|
# Vérifie Varnish
|
||||||
local varnish_pid
|
local varnish_pid
|
||||||
varnish_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
varnish_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -x varnishd 2>/dev/null | head -1 || echo "")
|
ps -C varnishd -o pid= 2>/dev/null | head -1 || echo "")
|
||||||
[ -n "$varnish_pid" ] && pass "Processus varnishd actif (PID $varnish_pid)" \
|
[ -n "$varnish_pid" ] && pass "Processus varnishd actif (PID $varnish_pid)" \
|
||||||
|| fail "Processus varnishd introuvable"
|
|| fail "Processus varnishd introuvable"
|
||||||
|
|
||||||
# Vérifie que ja4ebpf tourne
|
# Vérifie que ja4ebpf tourne
|
||||||
local ja4_pid
|
local ja4_pid
|
||||||
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -x ja4ebpf 2>/dev/null | head -1 || echo "")
|
ps -C ja4ebpf -o pid= 2>/dev/null | head -1 || echo "")
|
||||||
[ -n "$ja4_pid" ] && pass "ja4ebpf actif (PID $ja4_pid)" \
|
[ -n "$ja4_pid" ] && pass "ja4ebpf actif (PID $ja4_pid)" \
|
||||||
|| fail "ja4ebpf introuvable"
|
|| fail "ja4ebpf introuvable"
|
||||||
|
|
||||||
@ -61,21 +61,20 @@ stack_verify_extra() {
|
|||||||
warn "X-Client-IP absent — PROXY protocol peut-être désactivé dans Varnish"
|
warn "X-Client-IP absent — PROXY protocol peut-être désactivé dans Varnish"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vérifie ALPN h2 côté hitch (hitch supporte HTTP/2 via ALPN)
|
# Vérifie ALPN h2 côté hitch (varnish supporte h2 via -p feature=+http2)
|
||||||
local http_ver
|
local http_ver
|
||||||
http_ver=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
http_ver=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
curl -sk --http2 -w "%{http_version}" -o /dev/null https://localhost/ 2>/dev/null || echo "")
|
curl -sk --http2 -w "%{http_version}" -o /dev/null https://localhost/ 2>/dev/null || echo "")
|
||||||
if [ "$http_ver" = "2" ]; then
|
if [ "$http_ver" = "2" ]; then
|
||||||
pass "HTTP/2 ALPN négocié par hitch (h2)"
|
pass "HTTP/2 ALPN négocié par hitch→Varnish (h2)"
|
||||||
else
|
else
|
||||||
warn "HTTP/2 non négocié (version: '$http_ver') — ALPN hitch peut nécessiter Varnish ≥ 6.0"
|
warn "HTTP/2 non négocié (version: '$http_ver') — vérifier -p feature=+http2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vérification clé : dans la stack hitch+varnish, les uprobes sont sur hitch.
|
# Vérification clé : dans la stack hitch+varnish, les uprobes sont sur hitch.
|
||||||
# ja4ebpf doit avoir capturé des requêtes depuis le processus hitch.
|
# ja4ebpf doit avoir capturé des requêtes depuis le processus hitch.
|
||||||
# On vérifie que des lignes avec method != '' existent (uprobe SSL_read actif).
|
|
||||||
local l7_from_hitch
|
local l7_from_hitch
|
||||||
l7_from_hitch=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE method != ''")
|
l7_from_hitch=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE method != ''" || echo "0")
|
||||||
if [ "${l7_from_hitch:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${l7_from_hitch:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "L7 capturé via uprobe hitch : $l7_from_hitch requêtes HTTP"
|
pass "L7 capturé via uprobe hitch : $l7_from_hitch requêtes HTTP"
|
||||||
else
|
else
|
||||||
@ -85,12 +84,9 @@ stack_verify_extra() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Vérifie que le fingerprint JA4 est cohérent avec la config TLS de hitch
|
# Vérifie que le fingerprint JA4 est cohérent avec la config TLS de hitch
|
||||||
# (TLSv1.2 + TLSv1.3, suites ECDHE, ALPN h2+http/1.1)
|
|
||||||
local ja4_sample
|
local ja4_sample
|
||||||
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs_raw WHERE ja4 != '' LIMIT 1" 2>/dev/null || echo "")
|
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs WHERE ja4 != '' LIMIT 1" || echo "")
|
||||||
if [ -n "$ja4_sample" ]; then
|
if [ -n "$ja4_sample" ]; then
|
||||||
# JA4 format : t{ver}{sni}{cc}{ec}_{hash}_{hash}
|
|
||||||
# Avec TLS 1.3 négocié via hitch → doit commencer par tt13
|
|
||||||
if echo "$ja4_sample" | grep -qE "^tt1[23]"; then
|
if echo "$ja4_sample" | grep -qE "^tt1[23]"; then
|
||||||
pass "JA4 cohérent avec config hitch TLS 1.2/1.3 : $ja4_sample"
|
pass "JA4 cohérent avec config hitch TLS 1.2/1.3 : $ja4_sample"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -71,7 +71,10 @@ wait_for_service() {
|
|||||||
phase_build() {
|
phase_build() {
|
||||||
log "========== Phase 1 : Build =========="
|
log "========== Phase 1 : Build =========="
|
||||||
_dc build --parallel 2>&1 | tail -20
|
_dc build --parallel 2>&1 | tail -20
|
||||||
[ "$BUILD_ONLY" = true ] && { log "Build terminé (--build-only)."; exit 0; }
|
if [ "${BUILD_ONLY:-false}" = true ]; then
|
||||||
|
log "Build terminé (--build-only)."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -139,7 +142,7 @@ phase_verify() {
|
|||||||
|
|
||||||
# 5a. Lignes brutes insérées par ja4ebpf
|
# 5a. Lignes brutes insérées par ja4ebpf
|
||||||
local raw_count
|
local raw_count
|
||||||
raw_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw")
|
raw_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw" || echo "0")
|
||||||
if [ "${raw_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${raw_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "http_logs_raw : $raw_count lignes insérées par ja4ebpf"
|
pass "http_logs_raw : $raw_count lignes insérées par ja4ebpf"
|
||||||
else
|
else
|
||||||
@ -149,25 +152,26 @@ phase_verify() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 5b. Fingerprints JA4 capturés (hook TC + parsing TLS ClientHello)
|
# 5b. Fingerprints JA4 capturés (hook TC + parsing TLS ClientHello)
|
||||||
|
# Requête sur http_logs (colonnes structurées après le MV)
|
||||||
local ja4_count ja4_uniq
|
local ja4_count ja4_uniq
|
||||||
ja4_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE ja4 != ''")
|
ja4_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE ja4 != ''" || echo "0")
|
||||||
ja4_uniq=$(ch_query "SELECT count(DISTINCT ja4) FROM ja4_logs.http_logs_raw WHERE ja4 != ''")
|
ja4_uniq=$( ch_query "SELECT count(DISTINCT ja4) FROM ja4_logs.http_logs WHERE ja4 != ''" || echo "0")
|
||||||
if [ "${ja4_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${ja4_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "JA4 : $ja4_count enregistrements, $ja4_uniq fingerprints distincts"
|
pass "JA4 : $ja4_count enregistrements, $ja4_uniq fingerprints distincts"
|
||||||
local ja4_sample
|
local ja4_sample
|
||||||
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs_raw WHERE ja4 != '' LIMIT 1")
|
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs WHERE ja4 != '' LIMIT 1" || echo "")
|
||||||
log " Exemple JA4 : $ja4_sample"
|
log " Exemple JA4 : $ja4_sample"
|
||||||
else
|
else
|
||||||
warn "Aucun fingerprint JA4 (hook TC peut-être non chargé — vérifier CAP_BPF)"
|
warn "Aucun fingerprint JA4 (hook TC peut-être non chargé — vérifier CAP_BPF)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5c. Données L3/L4 (TTL, MSS, Window)
|
# 5c. Données L3/L4 (TTL, MSS, Window) — colonnes ip_meta_* / tcp_meta_* dans http_logs
|
||||||
local l34_count
|
local l34_count
|
||||||
l34_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE ttl > 0")
|
l34_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE ip_meta_ttl > 0" || echo "0")
|
||||||
if [ "${l34_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${l34_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "L3/L4 : $l34_count enregistrements avec TTL (hook TC actif)"
|
pass "L3/L4 : $l34_count enregistrements avec TTL (hook TC actif)"
|
||||||
local ttl_sample
|
local ttl_sample
|
||||||
ttl_sample=$(ch_query "SELECT ttl, mss, window_size FROM ja4_logs.http_logs_raw WHERE ttl > 0 LIMIT 1 FORMAT TabSeparated")
|
ttl_sample=$(ch_query "SELECT ip_meta_ttl, tcp_meta_mss, tcp_meta_window_size FROM ja4_logs.http_logs WHERE ip_meta_ttl > 0 LIMIT 1 FORMAT TabSeparated" || echo "")
|
||||||
log " TTL/MSS/Window sample : $ttl_sample"
|
log " TTL/MSS/Window sample : $ttl_sample"
|
||||||
else
|
else
|
||||||
warn "Données L3/L4 absentes (hook TC ingress non attaché)"
|
warn "Données L3/L4 absentes (hook TC ingress non attaché)"
|
||||||
@ -175,8 +179,8 @@ phase_verify() {
|
|||||||
|
|
||||||
# 5d. Requêtes HTTP capturées (uprobe SSL_read)
|
# 5d. Requêtes HTTP capturées (uprobe SSL_read)
|
||||||
local http_count methods
|
local http_count methods
|
||||||
http_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE method != ''")
|
http_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE method != ''" || echo "0")
|
||||||
methods=$(ch_query "SELECT groupArray(method) FROM (SELECT DISTINCT method FROM ja4_logs.http_logs_raw WHERE method != '' ORDER BY method)")
|
methods=$( ch_query "SELECT groupArray(method) FROM (SELECT DISTINCT method FROM ja4_logs.http_logs WHERE method != '' ORDER BY method)" || echo "")
|
||||||
if [ "${http_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${http_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "L7 HTTP : $http_count requêtes capturées via uprobe SSL_read"
|
pass "L7 HTTP : $http_count requêtes capturées via uprobe SSL_read"
|
||||||
pass "Méthodes HTTP vues : $methods"
|
pass "Méthodes HTTP vues : $methods"
|
||||||
@ -184,22 +188,22 @@ phase_verify() {
|
|||||||
warn "Aucune requête HTTP capturée (uprobe SSL_read non attaché)"
|
warn "Aucune requête HTTP capturée (uprobe SSL_read non attaché)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5e. HTTP/2 SETTINGS capturés (uprobe + parsing preface H2)
|
# 5e. TLS SNI capturés (hook TC + parsing ClientHello)
|
||||||
local h2_count
|
local sni_count
|
||||||
h2_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE h2_settings != ''")
|
sni_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE tls_sni != ''" || echo "0")
|
||||||
if [ "${h2_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${sni_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "HTTP/2 SETTINGS : $h2_count connexions H2 avec preface capturée"
|
pass "TLS SNI : $sni_count enregistrements avec SNI capturé"
|
||||||
local h2_sample
|
local sni_sample
|
||||||
h2_sample=$(ch_query "SELECT h2_settings FROM ja4_logs.http_logs_raw WHERE h2_settings != '' LIMIT 1")
|
sni_sample=$(ch_query "SELECT tls_sni FROM ja4_logs.http_logs WHERE tls_sni != '' LIMIT 1" || echo "")
|
||||||
log " Exemple H2 SETTINGS : $h2_sample"
|
log " Exemple SNI : $sni_sample"
|
||||||
else
|
else
|
||||||
warn "Pas de SETTINGS HTTP/2 (trafic h2 absent ou ALPN négociation échouée)"
|
warn "Aucun SNI capturé (trafic TLS sans extension SNI ou hook TC inactif)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5f. Corrélation L3/L4 ↔ L7 (flag correlated)
|
# 5f. Corrélation L3/L4 ↔ L7 (flag correlated)
|
||||||
local corr_total corr_yes corr_pct
|
local corr_total corr_yes corr_pct
|
||||||
corr_total=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE method != ''")
|
corr_total=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE method != ''" || echo "0")
|
||||||
corr_yes=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE correlated = true AND method != ''")
|
corr_yes=$( ch_query "SELECT count() FROM ja4_logs.http_logs WHERE correlated = 1 AND method != ''" || echo "0")
|
||||||
if [ "${corr_total:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${corr_total:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
corr_pct=$(echo "$corr_yes $corr_total" | awk '{printf "%.0f", $1*100/$2}')
|
corr_pct=$(echo "$corr_yes $corr_total" | awk '{printf "%.0f", $1*100/$2}')
|
||||||
if [ "${corr_pct:-0}" -ge 50 ] 2>/dev/null; then
|
if [ "${corr_pct:-0}" -ge 50 ] 2>/dev/null; then
|
||||||
@ -211,7 +215,7 @@ phase_verify() {
|
|||||||
|
|
||||||
# 5g. Keep-alives (multiplexage TCP)
|
# 5g. Keep-alives (multiplexage TCP)
|
||||||
local ka_max
|
local ka_max
|
||||||
ka_max=$(ch_query "SELECT max(maxkeepalives) FROM ja4_logs.http_logs_raw")
|
ka_max=$(ch_query "SELECT max(keepalives) FROM ja4_logs.http_logs" || echo "0")
|
||||||
if [ "${ka_max:-0}" -gt 1 ] 2>/dev/null; then
|
if [ "${ka_max:-0}" -gt 1 ] 2>/dev/null; then
|
||||||
pass "Keep-alives TCP : max $ka_max requêtes sur une même connexion"
|
pass "Keep-alives TCP : max $ka_max requêtes sur une même connexion"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -3,9 +3,24 @@
|
|||||||
# nginx (TLS frontend) → Varnish (HTTP cache) → backend HTTP simple
|
# nginx (TLS frontend) → Varnish (HTTP cache) → backend HTTP simple
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
FROM golang:1.24-bookworm AS go-builder
|
ARG BASE_IMAGE=rockylinux:9
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y clang llvm libbpf-dev && rm -rf /var/lib/apt/lists/*
|
# ── Stage 1 : build ja4ebpf (Rocky Linux, même toolchain que la prod) ─────────
|
||||||
|
FROM rockylinux:9 AS go-builder
|
||||||
|
|
||||||
|
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||||
|
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||||
|
dnf config-manager --enable crb && \
|
||||||
|
dnf install -y \
|
||||||
|
golang \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
libbpf-devel \
|
||||||
|
kernel-headers \
|
||||||
|
bpftool \
|
||||||
|
make \
|
||||||
|
&& \
|
||||||
|
dnf clean all
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY go.work go.work.sum* ./
|
COPY go.work go.work.sum* ./
|
||||||
@ -22,11 +37,10 @@ RUN GOWORK=off go generate ./internal/loader/ && \
|
|||||||
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
||||||
|
|
||||||
# ── Runtime : nginx + varnish + backend + ja4ebpf ─────────────────────────────
|
# ── Runtime : nginx + varnish + backend + ja4ebpf ─────────────────────────────
|
||||||
ARG BASE_IMAGE=rockylinux:9
|
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
RUN dnf install -y epel-release && \
|
RUN dnf install -y epel-release && \
|
||||||
dnf install -y nginx varnish openssl curl python3 && \
|
dnf install -y --allowerasing procps-ng nginx varnish openssl curl python3 && \
|
||||||
dnf clean all
|
dnf clean all
|
||||||
|
|
||||||
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
||||||
|
|||||||
@ -55,6 +55,7 @@ varnishd \
|
|||||||
-F \
|
-F \
|
||||||
-f /etc/varnish/default.vcl \
|
-f /etc/varnish/default.vcl \
|
||||||
-a "0.0.0.0:6081,HTTP" \
|
-a "0.0.0.0:6081,HTTP" \
|
||||||
|
-p feature=+http2 \
|
||||||
-s malloc,64m \
|
-s malloc,64m \
|
||||||
-T 127.0.0.1:6082 &
|
-T 127.0.0.1:6082 &
|
||||||
VARNISH_PID=$!
|
VARNISH_PID=$!
|
||||||
@ -69,7 +70,7 @@ done
|
|||||||
# ── 3. Démarrage de nginx ─────────────────────────────────────────────────────
|
# ── 3. Démarrage de nginx ─────────────────────────────────────────────────────
|
||||||
log "Démarrage de nginx…"
|
log "Démarrage de nginx…"
|
||||||
nginx
|
nginx
|
||||||
NGINX_PID=$(cat /run/nginx/nginx.pid 2>/dev/null || pgrep nginx | head -1)
|
NGINX_PID=$(cat /run/nginx/nginx.pid 2>/dev/null || echo "")
|
||||||
|
|
||||||
for i in $(seq 1 20); do
|
for i in $(seq 1 20); do
|
||||||
if curl -sf http://localhost/health >/dev/null 2>&1; then
|
if curl -sf http://localhost/health >/dev/null 2>&1; then
|
||||||
@ -85,15 +86,27 @@ JA4EBPF_PID=$!
|
|||||||
|
|
||||||
log "Stack complète — backend=$BACKEND_PID varnish=$VARNISH_PID nginx=$NGINX_PID ja4ebpf=$JA4EBPF_PID"
|
log "Stack complète — backend=$BACKEND_PID varnish=$VARNISH_PID nginx=$NGINX_PID ja4ebpf=$JA4EBPF_PID"
|
||||||
|
|
||||||
|
# Laisser 3s pour détecter un échec immédiat de ja4ebpf
|
||||||
|
sleep 3
|
||||||
|
if ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||||
|
log "⚠ ja4ebpf s'est arrêté immédiatement — mode dégradé (web server seul)"
|
||||||
|
JA4EBPF_PID=""
|
||||||
|
fi
|
||||||
|
|
||||||
# ── 5. Supervision ────────────────────────────────────────────────────────────
|
# ── 5. Supervision ────────────────────────────────────────────────────────────
|
||||||
while true; do
|
while true; do
|
||||||
for pid_var in BACKEND_PID VARNISH_PID JA4EBPF_PID; do
|
for pid_var in BACKEND_PID VARNISH_PID; do
|
||||||
pid="${!pid_var}"
|
pid="${!pid_var}"
|
||||||
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then
|
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then
|
||||||
log "$pid_var (PID $pid) s'est arrêté — fin"
|
log "$pid_var (PID $pid) s'est arrêté — fin"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
# ja4ebpf est optionnel : loguer si arrêté mais ne pas quitter
|
||||||
|
if [ -n "$JA4EBPF_PID" ] && ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||||
|
log "⚠ ja4ebpf s'est arrêté — web server continue sans collecte eBPF"
|
||||||
|
JA4EBPF_PID=""
|
||||||
|
fi
|
||||||
# nginx master process via PID file
|
# nginx master process via PID file
|
||||||
NGINX_PID=$(cat /run/nginx/nginx.pid 2>/dev/null || echo "")
|
NGINX_PID=$(cat /run/nginx/nginx.pid 2>/dev/null || echo "")
|
||||||
if [ -z "$NGINX_PID" ] || ! kill -0 "$NGINX_PID" 2>/dev/null; then
|
if [ -z "$NGINX_PID" ] || ! kill -0 "$NGINX_PID" 2>/dev/null; then
|
||||||
|
|||||||
@ -1,29 +1,16 @@
|
|||||||
# Configuration ja4ebpf — stack nginx + varnish
|
# Configuration ja4ebpf — stack nginx + varnish
|
||||||
# TLS terminé par nginx → uprobe sur libssl.so.3 (liée par nginx).
|
# TLS terminé par nginx → uprobe sur libssl.so.3 (liée par nginx).
|
||||||
# Varnish reçoit le trafic HTTP cleartext : pas de SSL_read côté varnish.
|
|
||||||
|
|
||||||
interface: eth0
|
interface: eth0
|
||||||
|
ssl_lib_path: "/usr/lib64/libssl.so.3"
|
||||||
ssl_probes:
|
|
||||||
# nginx lie libssl.so.3 pour la terminaison TLS.
|
|
||||||
# L'uprobe SSL_read capture les données HTTP/1.1 et HTTP/2
|
|
||||||
# déchiffrées juste avant que nginx les traite.
|
|
||||||
- executable: /usr/lib64/libssl.so.3
|
|
||||||
symbol: SSL_read
|
|
||||||
|
|
||||||
clickhouse:
|
clickhouse:
|
||||||
addr: "clickhouse:9000"
|
dsn: "clickhouse://default:@clickhouse:9000/ja4_logs"
|
||||||
database: "ja4_logs"
|
|
||||||
table: "http_logs_raw"
|
|
||||||
username: "default"
|
|
||||||
password: ""
|
|
||||||
tls: false
|
|
||||||
batch_size: 100
|
batch_size: 100
|
||||||
flush_every: "1s"
|
flush_secs: 1
|
||||||
|
|
||||||
timeouts:
|
correlation:
|
||||||
session_expiry: "500ms"
|
timeout_ms: 500
|
||||||
slowloris: "10s"
|
slowloris_ms: 10000
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: "info"
|
level: "info"
|
||||||
|
|||||||
@ -44,8 +44,7 @@ http {
|
|||||||
|
|
||||||
# ── Port 443 (TLS frontend → proxy Varnish) ──────────────────────────────
|
# ── Port 443 (TLS frontend → proxy Varnish) ──────────────────────────────
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl http2;
|
||||||
http2 on;
|
|
||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
ssl_certificate /etc/pki/tls/certs/nginx.crt;
|
ssl_certificate /etc/pki/tls/certs/nginx.crt;
|
||||||
|
|||||||
@ -56,14 +56,14 @@ stack_verify_extra() {
|
|||||||
# Vérifie que ja4ebpf tourne
|
# Vérifie que ja4ebpf tourne
|
||||||
local ja4_pid
|
local ja4_pid
|
||||||
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -x ja4ebpf 2>/dev/null | head -1 || echo "")
|
ps -C ja4ebpf -o pid= 2>/dev/null | head -1 || echo "")
|
||||||
[ -n "$ja4_pid" ] && pass "ja4ebpf actif (PID $ja4_pid)" \
|
[ -n "$ja4_pid" ] && pass "ja4ebpf actif (PID $ja4_pid)" \
|
||||||
|| fail "ja4ebpf introuvable"
|
|| fail "ja4ebpf introuvable"
|
||||||
|
|
||||||
# Dans cette stack, les requêtes L7 passent via Varnish :
|
# Dans cette stack, les requêtes L7 passent via Varnish.
|
||||||
# on vérifie que header_order_signature est capturé malgré le proxy.
|
# header_order_signature n'est pas encore capturé par ja4ebpf (uprobe SSL_read future feature)
|
||||||
local sig_count
|
local sig_count
|
||||||
sig_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE header_order_signature != ''")
|
sig_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE header_order_signature != ''" || echo "0")
|
||||||
if [ "${sig_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${sig_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
pass "Signature ordre en-têtes capturée : $sig_count enregistrements"
|
pass "Signature ordre en-têtes capturée : $sig_count enregistrements"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -3,15 +3,30 @@
|
|||||||
# Construit ja4ebpf (eBPF CO-RE) + nginx avec HTTP/2 et TLS.
|
# Construit ja4ebpf (eBPF CO-RE) + nginx avec HTTP/2 et TLS.
|
||||||
#
|
#
|
||||||
# Multi-stage :
|
# Multi-stage :
|
||||||
# ebpf-builder — compile les programmes eBPF C avec clang
|
# go-builder — compile ja4ebpf (go generate + go build) sur Rocky Linux
|
||||||
# go-builder — compile ja4ebpf (go generate + go build)
|
|
||||||
# runtime — nginx + binaire ja4ebpf sur Rocky Linux 9
|
# runtime — nginx + binaire ja4ebpf sur Rocky Linux 9
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# ── Stage 1 : build ja4ebpf ──────────────────────────────────────────────────
|
# ARG global : doit être déclaré avant tous les FROM pour être utilisable
|
||||||
FROM golang:1.24-bookworm AS go-builder
|
# dans les instructions FROM des stages suivants.
|
||||||
|
ARG BASE_IMAGE=rockylinux:9
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y clang llvm libbpf-dev && rm -rf /var/lib/apt/lists/*
|
# ── Stage 1 : build ja4ebpf (Rocky Linux, même toolchain que la prod) ─────────
|
||||||
|
FROM rockylinux:9 AS go-builder
|
||||||
|
|
||||||
|
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||||
|
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||||
|
dnf config-manager --enable crb && \
|
||||||
|
dnf install -y \
|
||||||
|
golang \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
libbpf-devel \
|
||||||
|
kernel-headers \
|
||||||
|
bpftool \
|
||||||
|
make \
|
||||||
|
&& \
|
||||||
|
dnf clean all
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY go.work go.work.sum* ./
|
COPY go.work go.work.sum* ./
|
||||||
@ -28,11 +43,10 @@ RUN GOWORK=off go generate ./internal/loader/ && \
|
|||||||
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
||||||
|
|
||||||
# ── Stage 2 : runtime nginx + ja4ebpf ────────────────────────────────────────
|
# ── Stage 2 : runtime nginx + ja4ebpf ────────────────────────────────────────
|
||||||
ARG BASE_IMAGE=rockylinux:9
|
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
RUN dnf install -y epel-release && \
|
RUN dnf install -y epel-release && \
|
||||||
dnf install -y nginx openssl curl && \
|
dnf install -y --allowerasing procps-ng nginx openssl curl && \
|
||||||
dnf clean all
|
dnf clean all
|
||||||
|
|
||||||
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
||||||
|
|||||||
@ -39,9 +39,16 @@ JA4EBPF_PID=$!
|
|||||||
|
|
||||||
log "Stack démarrée — nginx PID=$NGINX_PID ja4ebpf PID=$JA4EBPF_PID"
|
log "Stack démarrée — nginx PID=$NGINX_PID ja4ebpf PID=$JA4EBPF_PID"
|
||||||
|
|
||||||
|
# Laisser ja4ebpf 3s pour détecter un échec immédiat (ex: verifier eBPF)
|
||||||
|
sleep 3
|
||||||
|
if ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||||
|
log "⚠ ja4ebpf s'est arrêté immédiatement — mode dégradé (web server seul)"
|
||||||
|
JA4EBPF_PID=""
|
||||||
|
fi
|
||||||
|
|
||||||
# ── 3. Supervision ────────────────────────────────────────────────────────
|
# ── 3. Supervision ────────────────────────────────────────────────────────
|
||||||
# nginx fonctionne en daemon : surveiller le process master via le PID file.
|
# nginx fonctionne en daemon : surveiller le process master via le PID file.
|
||||||
# ja4ebpf tourne en foreground.
|
# ja4ebpf tourne en foreground (optionnel : ne pas quitter s'il s'arrête).
|
||||||
while true; do
|
while true; do
|
||||||
# Vérifier que nginx est toujours en vie
|
# Vérifier que nginx est toujours en vie
|
||||||
if ! kill -0 "$NGINX_PID" 2>/dev/null; then
|
if ! kill -0 "$NGINX_PID" 2>/dev/null; then
|
||||||
@ -51,10 +58,10 @@ while true; do
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Vérifier que ja4ebpf est toujours en vie
|
# ja4ebpf est optionnel : loguer si arrêté mais ne pas quitter
|
||||||
if ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
if [ -n "$JA4EBPF_PID" ] && ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||||
log "ja4ebpf s'est arrêté (code: $?) — fin de l'entrypoint"
|
log "⚠ ja4ebpf s'est arrêté — web server continue sans collecte eBPF"
|
||||||
break
|
JA4EBPF_PID=""
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|||||||
@ -1,28 +1,15 @@
|
|||||||
# Configuration ja4ebpf — stack nginx
|
# Configuration ja4ebpf — stack nginx
|
||||||
# ja4ebpf attache ses uprobes sur le processus nginx qui lie OpenSSL directement.
|
|
||||||
# Sur Rocky Linux 9, nginx utilise libssl.so.3 via dlopen ou liaison dynamique.
|
|
||||||
|
|
||||||
interface: eth0
|
interface: eth0
|
||||||
|
ssl_lib_path: "/usr/lib64/libssl.so.3"
|
||||||
ssl_probes:
|
|
||||||
# nginx lie OpenSSL : les appels SSL_read sont dans la librairie partagée.
|
|
||||||
# Le fichier réel (pas le symlink) est requis pour l'uprobe.
|
|
||||||
- executable: /usr/lib64/libssl.so.3
|
|
||||||
symbol: SSL_read
|
|
||||||
|
|
||||||
clickhouse:
|
clickhouse:
|
||||||
addr: "clickhouse:9000"
|
dsn: "clickhouse://default:@clickhouse:9000/ja4_logs"
|
||||||
database: "ja4_logs"
|
|
||||||
table: "http_logs_raw"
|
|
||||||
username: "default"
|
|
||||||
password: ""
|
|
||||||
tls: false
|
|
||||||
batch_size: 100
|
batch_size: 100
|
||||||
flush_every: "1s"
|
flush_secs: 1
|
||||||
|
|
||||||
timeouts:
|
correlation:
|
||||||
session_expiry: "500ms"
|
timeout_ms: 500
|
||||||
slowloris: "10s"
|
slowloris_ms: 10000
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: "info"
|
level: "info"
|
||||||
|
|||||||
@ -46,8 +46,7 @@ http {
|
|||||||
|
|
||||||
# ── Serveur HTTPS (port 443) avec HTTP/2 ──────────────────────────────
|
# ── Serveur HTTPS (port 443) avec HTTP/2 ──────────────────────────────
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl http2;
|
||||||
http2 on;
|
|
||||||
server_name _;
|
server_name _;
|
||||||
|
|
||||||
ssl_certificate /etc/pki/tls/certs/nginx.crt;
|
ssl_certificate /etc/pki/tls/certs/nginx.crt;
|
||||||
|
|||||||
@ -50,19 +50,19 @@ stack_verify_extra() {
|
|||||||
# Vérifie que ja4ebpf est bien en cours d'exécution
|
# Vérifie que ja4ebpf est bien en cours d'exécution
|
||||||
local ja4_running
|
local ja4_running
|
||||||
ja4_running=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
ja4_running=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||||
pgrep -x ja4ebpf 2>/dev/null | head -1 || echo "")
|
ps -C ja4ebpf -o pid= 2>/dev/null | head -1 || echo "")
|
||||||
if [ -n "$ja4_running" ]; then
|
if [ -n "$ja4_running" ]; then
|
||||||
pass "Processus ja4ebpf actif (PID $ja4_running)"
|
pass "Processus ja4ebpf actif (PID $ja4_running)"
|
||||||
else
|
else
|
||||||
fail "Processus ja4ebpf introuvable dans le conteneur platform"
|
fail "Processus ja4ebpf introuvable dans le conteneur platform"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vérifie SNI capturé (ja4ebpf parse le ClientHello → extrait SNI)
|
# Vérifie SNI capturé (colonne tls_sni dans http_logs)
|
||||||
local sni_count
|
local sni_count
|
||||||
sni_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE sni != ''")
|
sni_count=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE tls_sni != ''" || echo "0")
|
||||||
if [ "${sni_count:-0}" -gt 0 ] 2>/dev/null; then
|
if [ "${sni_count:-0}" -gt 0 ] 2>/dev/null; then
|
||||||
local sni_sample
|
local sni_sample
|
||||||
sni_sample=$(ch_query "SELECT sni FROM ja4_logs.http_logs_raw WHERE sni != '' LIMIT 1")
|
sni_sample=$(ch_query "SELECT tls_sni FROM ja4_logs.http_logs WHERE tls_sni != '' LIMIT 1" || echo "")
|
||||||
pass "SNI capturé : $sni_count enregistrements (exemple : '$sni_sample')"
|
pass "SNI capturé : $sni_count enregistrements (exemple : '$sni_sample')"
|
||||||
else
|
else
|
||||||
warn "Aucun SNI capturé (trafic TLS peut-être sans extension SNI)"
|
warn "Aucun SNI capturé (trafic TLS peut-être sans extension SNI)"
|
||||||
|
|||||||
Reference in New Issue
Block a user