Update ja4.py

Added protection against bugs in IPv6 signature extraction (to be fixed in future versions of the plugin)
This commit is contained in:
Joge 2024-06-05 15:23:19 +02:00 committed by GitHub
parent 2514f0bfde
commit 4e73bdca56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,6 +16,10 @@ def get_protocol(packet):
protocol (str): detected protocol, "t" for TCP, "q" for QUIC
payload (scapy.layers.inet.TCP or scapy.layers.inet.UDP): payload of the packet (at transport layer level)
"""
# If the packet is not IPv4, None is returned
# (only IPv4 packets are considered for JA4 fingerprint extraction)
if packet.ip_version != 4:
return None, None
# TCP detection and TCP payload extraction
ip_packet = IP(packet.ip_packet)
if ip_packet.p == IP_PROTO_TCP: