From 56487ffaef7d815a58b17d95a77421a36fd8dc49 Mon Sep 17 00:00:00 2001 From: "Pinto Spindler, Stephan" <25225092+s-spindler@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:53:27 +0100 Subject: [PATCH 1/2] Cap cipher count at 99 --- python/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/common.py b/python/common.py index eb4342d..ddd2dab 100644 --- a/python/common.py +++ b/python/common.py @@ -102,7 +102,7 @@ def get_hex_sorted(entry, field, sort=True): # remove GREASE and calculate length c = [ x[2:] for x in values if x not in GREASE_TABLE ] - actual_length = len(c) + actual_length = min(len(c), 99) # now remove SNI and ALPN values if field == 'extensions' and sort: From ef3c2edc80b2334f5aca3b9d00e6e97282f9a4b3 Mon Sep 17 00:00:00 2001 From: "Pinto Spindler, Stephan" <25225092+s-spindler@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:53:55 +0100 Subject: [PATCH 2/2] Cap extension count at 99 --- python/ja4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ja4.py b/python/ja4.py index 0ce1ce9..95fb158 100644 --- a/python/ja4.py +++ b/python/ja4.py @@ -173,7 +173,7 @@ def to_ja4s(x, debug_stream): # get extensions in hex in the order they are present (include grease values) x['extensions'] = [ '{:04x}'.format(int(k)) for k in x['extensions'] ] - ext_len = '{:02d}'.format(len(x['extensions'])) + ext_len = '{:02d}'.format(min(len(x['extensions']), 99)) extensions = sha_encode(x['extensions']) # only one cipher for ja4s @@ -209,7 +209,7 @@ def to_ja4(x, debug_stream): ptype = 'q' if x['quic'] else 't' x['extensions'] = [ '0x{:04x}'.format(int(k)) for k in x['extensions'] ] - ext_len = '{:02d}'.format(len([ x for x in x['extensions'] if x not in GREASE_TABLE])) + ext_len = '{:02d}'.format(min(len([ x for x in x['extensions'] if x not in GREASE_TABLE]), 99)) cache_update(x, 'client_ciphers', x['ciphers'], debug_stream) if ('0x000d' in x['extensions']):