Skip to content

Commit 35b0024

Browse files
authored
Merge pull request fooinha#49 from gbilic/feature/sort_extensions
Add TLS extensions sorting feature - fixing randomized TLS fingerprints
2 parents 971e60e + 815116e commit 35b0024

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ For details about the ja3 fingerprint algorithm, check initial [project](https:/
1212

1313
### Directives
1414

15-
No directives yet.
15+
Revision 110 of chrome browser introduces TLS ClientHello extensions random permutation, which makes fingerprinting irrelevant with this browser (firefox is planning to do the same).
16+
Using JA3_SORT_EXT cc macro during nginx configure invocation (--with-cc-opt='-DJA3_SORT_EXT') configures the module to sort TLS extensions in the JA3 string. The resulting fincgerprint is not compliant anymore with the JA3 algorithm (at this time of writing), but allow to get back effectiveness of fingerprinting.
1617

1718
### Variables
1819

src/ngx_ssl_ja3.c

+19
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ ngx_ssj_ja3_num_digits(int n)
138138
return c;
139139
}
140140

141+
static void
142+
ngx_sort_ext(unsigned short *ext, int size)
143+
{
144+
for (int i = 0; i < size - 1; i++)
145+
{
146+
for (int j = 0; j < size - i - 1; j++)
147+
{
148+
if (ext[j] > ext[j + 1])
149+
{
150+
int tmp = ext[j];
151+
ext[j] = ext[j + 1];
152+
ext[j + 1] = tmp;
153+
}
154+
}
155+
}
156+
}
141157

142158
#if (NGX_DEBUG)
143159
static void
@@ -370,6 +386,9 @@ ngx_ssl_ja3(ngx_connection_t *c, ngx_pool_t *pool, ngx_ssl_ja3_t *ja3) {
370386
ja3->extensions[ja3->extensions_sz++] = c->ssl->extensions[i];
371387
}
372388
}
389+
#ifdef JA3_SORT_EXT
390+
ngx_sort_ext(ja3->extensions, ja3->extensions_sz);
391+
#endif
373392
}
374393

375394
/* Elliptic curve points */

0 commit comments

Comments
 (0)