Compare commits

...

4 Commits

Author SHA1 Message Date
bol-van
60b97dbed0 nfqws: remove debug printfs 2025-03-24 11:14:38 +03:00
bol-van
e56e4f5f35 update changes 2025-03-24 10:32:02 +03:00
bol-van
5305ea83c8 fakes: GGC kyber with inter-packet CRYPTO frag 2025-03-24 09:44:50 +03:00
bol-van
14b3dd459b nfqws: define reasm buffer sizes 2025-03-24 09:34:37 +03:00
5 changed files with 13 additions and 7 deletions

View File

@ -470,3 +470,4 @@ tpws: detect WSL 1 and warn about non-working options
v70.5 v70.5
nfqws: multiple --dpi-desync-fake-xxx nfqws: multiple --dpi-desync-fake-xxx
nfqws: support of inter-packet fragmented QUIC CRYPTO

View File

@ -66,6 +66,9 @@ const uint8_t fake_tls_clienthello_default[648] = {
#define PKTDATA_MAXDUMP 32 #define PKTDATA_MAXDUMP 32
#define IP_MAXDUMP 80 #define IP_MAXDUMP 80
#define TCP_MAX_REASM 16384
#define UDP_MAX_REASM 16384
bool desync_valid_zero_stage(enum dpi_desync_mode mode) bool desync_valid_zero_stage(enum dpi_desync_mode mode)
{ {
return mode==DESYNC_SYNACK || mode==DESYNC_SYNDATA; return mode==DESYNC_SYNACK || mode==DESYNC_SYNDATA;
@ -954,7 +957,7 @@ static uint8_t dpi_desync_tcp_packet_play(bool replay, size_t reasm_offset, uint
!(ctrack->req_seq_finalized && seq_within(ctrack->seq_last, ctrack->req_seq_start, ctrack->req_seq_end))) !(ctrack->req_seq_finalized && seq_within(ctrack->seq_last, ctrack->req_seq_start, ctrack->req_seq_end)))
{ {
// do not reconstruct unexpected large payload (they are feeding garbage ?) // do not reconstruct unexpected large payload (they are feeding garbage ?)
if (!reasm_orig_start(ctrack,IPPROTO_TCP,TLSRecordLen(dis->data_payload),16384,dis->data_payload,dis->len_payload)) if (!reasm_orig_start(ctrack,IPPROTO_TCP,TLSRecordLen(dis->data_payload),TCP_MAX_REASM,dis->data_payload,dis->len_payload))
{ {
reasm_orig_cancel(ctrack); reasm_orig_cancel(ctrack);
return verdict; return verdict;
@ -1953,13 +1956,15 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
return verdict; // cannot be first packet return verdict; // cannot be first packet
} }
} }
uint8_t defrag[16384]; uint8_t defrag[UDP_MAX_REASM];
size_t hello_offset, hello_len, defrag_len = sizeof(defrag); size_t hello_offset, hello_len, defrag_len = sizeof(defrag);
bool bFull; bool bFull;
if (QUICDefragCrypto(pclean,clean_len,defrag,&defrag_len,&bFull)) if (QUICDefragCrypto(pclean,clean_len,defrag,&defrag_len,&bFull))
{ {
if (bFull) if (bFull)
{ {
DLOG("QUIC initial contains CRYPTO with full fragment coverage\n");
bool bIsHello = IsQUICCryptoHello(defrag, defrag_len, &hello_offset, &hello_len); bool bIsHello = IsQUICCryptoHello(defrag, defrag_len, &hello_offset, &hello_len);
bool bReqFull = bIsHello ? IsTLSHandshakeFull(defrag+hello_offset,hello_len) : false; bool bReqFull = bIsHello ? IsTLSHandshakeFull(defrag+hello_offset,hello_len) : false;
@ -1970,7 +1975,7 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
if (bIsHello && !bReqFull && ReasmIsEmpty(&ctrack->reasm_orig)) if (bIsHello && !bReqFull && ReasmIsEmpty(&ctrack->reasm_orig))
{ {
// preallocate max buffer to avoid reallocs that cause memory copy // preallocate max buffer to avoid reallocs that cause memory copy
if (!reasm_orig_start(ctrack,IPPROTO_UDP,16384,16384,clean,clean_len)) if (!reasm_orig_start(ctrack,IPPROTO_UDP,UDP_MAX_REASM,UDP_MAX_REASM,clean,clean_len))
{ {
reasm_orig_cancel(ctrack); reasm_orig_cancel(ctrack);
return verdict; return verdict;
@ -2021,7 +2026,7 @@ static uint8_t dpi_desync_udp_packet_play(bool replay, size_t reasm_offset, uint
if (ReasmIsEmpty(&ctrack->reasm_orig)) if (ReasmIsEmpty(&ctrack->reasm_orig))
{ {
// preallocate max buffer to avoid reallocs that cause memory copy // preallocate max buffer to avoid reallocs that cause memory copy
if (!reasm_orig_start(ctrack,IPPROTO_UDP,16384,16384,clean,clean_len)) if (!reasm_orig_start(ctrack,IPPROTO_UDP,UDP_MAX_REASM,UDP_MAX_REASM,clean,clean_len))
{ {
reasm_orig_cancel(ctrack); reasm_orig_cancel(ctrack);
return verdict; return verdict;

View File

@ -916,8 +916,8 @@ bool QUICDefragCrypto(const uint8_t *clean,size_t clean_len, uint8_t *defrag,siz
qsort(ranges, range, sizeof(*ranges), cmp_range64); qsort(ranges, range, sizeof(*ranges), cmp_range64);
for(i=0 ; i<range ; i++) //for(i=0 ; i<range ; i++)
printf("RANGE %zu len %zu\n",ranges[i].offset,ranges[i].len); // printf("RANGE %zu len %zu\n",ranges[i].offset,ranges[i].len);
for(i=0,offset=0,*bFull=true ; i<range ; i++) for(i=0,offset=0,*bFull=true ; i<range ; i++)
{ {
@ -929,7 +929,7 @@ bool QUICDefragCrypto(const uint8_t *clean,size_t clean_len, uint8_t *defrag,siz
offset += ranges[i].len; offset += ranges[i].len;
} }
printf("bFull=%d\n",*bFull); //printf("bFull=%u\n",*bFull);
} }
return found; return found;
} }