Skip to content

Commit

Permalink
Merge pull request #8 from noeltimothy/ja4_extension_length_should_ig…
Browse files Browse the repository at this point in the history
…nore_grease

Ja4 extension length should ignore grease
  • Loading branch information
igr001-galactica authored Oct 10, 2023
2 parents 72ce15b + ff3c503 commit b8033dd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/ja4.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,16 @@ def to_ja4(x, debug_stream):
print (f"computing ja4 for stream {x['stream']}")
ptype = 'q' if x['quic'] else 't'

ext_len = '{:02d}'.format(len(x['extensions']))
cache_update(x, 'client_extensions', x['extensions'], debug_stream)
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]))
cache_update(x, 'client_ciphers', x['ciphers'], debug_stream)

x['extensions'] = [ '0x{:04x}'.format(int(k)) for k in x['extensions'] if k != '0']
x['signature_algorithms'] = [ y[2:] for y in x['signature_algorithms'] ]

# ignore SNI and ALPN extensions
x['extensions'] = [ x for x in x['extensions'] if x not in ['0x0000', '0x0010'] ]
cache_update(x, 'client_extensions', x['extensions'], debug_stream)

# Modified to include original rendering
x['sorted_extensions'], _len, _ = get_hex_sorted(x['extensions'])
x['original_extensions'], _len, _ = get_hex_sorted(x['extensions'], sort=False)
Expand Down

0 comments on commit b8033dd

Please sign in to comment.