From 4e28fbeaaefc17ded2e00eeaccfc9728c761141a Mon Sep 17 00:00:00 2001 From: ruti <> Date: Wed, 6 Mar 2024 20:37:59 +0300 Subject: [PATCH] Update version, minor fixes --- desync.c | 39 ++++++++++++++++++--------------------- main.c | 10 ++++++---- readme.txt | 2 +- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/desync.c b/desync.c index bf7da3c..a3a515b 100644 --- a/desync.c +++ b/desync.c @@ -25,8 +25,8 @@ #define memfd_create(name, flags) fileno(tmpfile()) #endif #else - #include #include + #include #include #endif @@ -131,24 +131,20 @@ int send_fake(int sfd, char *buffer, int send_oob(int sfd, char *buffer, ssize_t n, long pos) { - ssize_t size = oob_data.size; - char *data = oob_data.data; + ssize_t size = oob_data.size - 1; + char *data = oob_data.data + 1; - if (pos + 1 < n) { - char rchar = buffer[pos]; - buffer[pos] = data[0]; - - if (send(sfd, buffer, pos + 1, MSG_OOB) < 0) { - uniperror("send"); - buffer[pos] = rchar; - return -1; - } + char rchar = buffer[pos]; + buffer[pos] = oob_data.data[0]; + + if (send(sfd, buffer, pos + 1, MSG_OOB) < 0) { + uniperror("send"); buffer[pos] = rchar; - size--; - data++; - if (size) { - delay(params.sfdelay); - } + return -1; + } + buffer[pos] = rchar; + if (size) { + delay(params.sfdelay); } for (long i = 0; i < size; i++) { if (send(sfd, data + i, 1, MSG_OOB) < 0) { @@ -195,7 +191,8 @@ int desync(int sfd, char *buffer, size_t bfsize, type = IS_HTTP; } if (len && host) { - LOG(LOG_S, "host: %.*s\n", len, host); + LOG(LOG_S, "host: %.*s (%ld)\n", + len, host, host - buffer); } if (type == IS_HTTP && params.mod_http) { @@ -239,7 +236,7 @@ int desync(int sfd, char *buffer, size_t bfsize, } long lp = 0; - if ((!type && params.de_known)) { + if (!type && params.de_known) { } else for (int i = 0; i < params.parts_n; i++) { struct part part = params.parts[i]; @@ -247,13 +244,13 @@ int desync(int sfd, char *buffer, size_t bfsize, long pos = part.pos; if (part.flag == OFFSET_SNI) { if (type != IS_HTTPS) - break; + continue; else pos += (host - buffer); } else if (part.flag == OFFSET_HOST) { if (type != IS_HTTP) - break; + continue; else pos += (host - buffer); } diff --git a/main.c b/main.c index 569319d..5e1d6f5 100644 --- a/main.c +++ b/main.c @@ -23,7 +23,7 @@ #define close(fd) closesocket(fd) #endif -#define VERSION 4 +#define VERSION 5 struct packet fake_tls = { @@ -72,7 +72,9 @@ const char help_text[] = { " -g, --def-ttl TTL for all outgoing connections\n" // desync options " -K, --desync-known Desync only HTTP and TLS with SNI\n" - " -s, --split Split packet at n, +s to add SNI offset\n" + " -s, --split Split packet at n\n" + " +s - add SNI offset\n" + " +h - add HTTP Host offset\n" " -s, --disorder Split and send reverse order\n" " -o, --oob Split and send as OOB data\n" #ifdef FAKE_SUPPORT @@ -80,10 +82,10 @@ const char help_text[] = { " -t, --ttl TTL of fake packets, default 8\n" " -l, --fake-tls \n" " -j, --fake-http Set custom fake packet\n" - " -n, --tls-sni Change SNI in fake CH\n" + " -n, --tls-sni Change SNI in fake ClientHello\n" #endif " -e, --oob-data Set custom OOB data\n" - " -M, --mod-http Modify http: hcsmix,dcsmix,rmspace\n" + " -M, --mod-http Modify HTTP: hcsmix,dcsmix,rmspace\n" " -r, --tlsrec Make TLS record at offset\n" }; diff --git a/readme.txt b/readme.txt index 0598b7f..ddb0fba 100644 --- a/readme.txt +++ b/readme.txt @@ -48,7 +48,7 @@ $ ./ciadpi --disorder 3+sni ! Поведение в Windows отлично: сначала отправляется лишь часть, но затем целый запрос -o, --oob - Подобен --split, но после offset отсылается один или несколько байт OOB данных + Подобен --split, но после части отсылается один или несколько байт OOB данных -f, --fake Подобен --disorder, только перед отправкой первого куска отправляется часть поддельного