From 5026199f24ba28f397fe235cb9707093a34ec2e0 Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 17 Jan 2026 19:44:36 +0300 Subject: [PATCH] zapret-antidpi: oob instance cutoff if called not from the very beginning of tcp --- docs/changes.txt | 1 + docs/manual.en.md | 3 ++- docs/manual.md | 3 ++- lua/zapret-antidpi.lua | 9 +++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3067a8c..0bf299b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -193,3 +193,4 @@ v0.8.1 0.8.6 * winws2, blockcheck2: allow multiple instances in windows, linux, freebsd (not openbsd) +* zapret-antidpi: oob instance cutoff if called not from the very beginning of tcp diff --git a/docs/manual.en.md b/docs/manual.en.md index 210303f..63e384e 100644 --- a/docs/manual.en.md +++ b/docs/manual.en.md @@ -3835,8 +3835,9 @@ To enable it, specify "urp=b". - For protocols in which the server initially waits for a client request, `--in-range=-s1` is enough. In Windows `--wf-tcp-in` is not needed. Automatically intercepted incoming packets with the SYN flag are sufficient. - For protocols in which the server sends data before the first message from client all incoming packets before that message should be intercepted. In Windows `--wf-tcp-in` is required. - Cannot be filtered by payload because after the start it's not possible to stop and not to insert the byte. Inserting a byte without OOB breaks the data. -- Hostlist filtering is not possible. - oob is "lasting" desync. If profile switch occurs before oob is finished it must be duplicated to that profile or TCP will break because of sequence desync. +- If this function is called for the first time not from the very beginning of the tcp connection it [cuts off](#instance_cutoff) immediately. +- Hostlist filtering is possible only with '--ipcache-hostname'. - Can't work with functions that resend modified payload. multisplit, multidisorder, fakedsplit, fakeddisorder, etc will send duplicates without OOB. - If the payload is [multi-segment](#handling-multi-packet-payloads), the entire [reasm](#handling-multi-packet-payloads) is sent. OOB is inserted into the segment where urp hits. In this segment the th_urp is normalized by segment offset, the TH_URG flag is set. The rest of the parts are sent as is. The function drops the whole replay then [cuts itself off](#instance_cutoff). diff --git a/docs/manual.md b/docs/manual.md index 6532c1e..c0ff4bd 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -4022,8 +4022,9 @@ function oob(ctx, desync) - Для протоколов, в которых в самом начале сервер ждет запроса от клиента, требуется разрешение входящих в пределах `--in-range=-s1`. В Windows `--wf-tcp-in` не нужен. Достаточно автоматически перехватываемых SYN. К таким протоколам относятся http и tls. - Для протоколов, где сервер что-то шлет до первого сообщения от клиента, требуется разрешить все входящие пакеты до отсылки первого исходящего пакета с данными. В Windows `--wf-tcp-in` обязателен. - Не может быть отфильтровано по пейлоаду, поскольку после начала модификации tcp handshake соскок уже невозможен, иначе поедут sequence. -- Фильтрация по хостлистам невозможна ни в каком виде, даже при `--ipcache-hostname`. Если начал - закончи или не начинай. Это главное правило oob. Никаких решений по отмене ни по каким условиям. - oob - длящаяся десинхронизация. Если возможно переключение профилей до момента окончания работы oob, oob должен быть дублирован в другой профиль, иначе TCP будет сломан из-за десинхронизации sequence. +- Функция помечает специальный флаг, что была вызвана с самого начала соединения. Если управление получено после перескока профиля, происходит немедленный cutoff. +- Фильтрация по хостлистам возможна только при `--ipcache-hostname`. Если в кэше хоста еще нет, и профиль получает управление не с начала соединения, срабатывает предыдущий пункт. - Не может работать с функциями, предполагающими отправку текущего пейлоада - multisplit, multidisorder, fakedsplit, fakeddisorder и тд. Они будут работать, но будут слать дубль без OOB. Ожидаемый результат "разбить на сегменты и всунуть OOB" как в tpws получить таким образом невозможно. - Если пейлоад [многопакетный](#особенности-приема-многопакетных-пейлоадов) - отсылается весь [reasm](#особенности-приема-многопакетных-пейлоадов). OOB вставляется в тот сегмент, куда попал urp. В этом сегменте th_urp нормализуется по смещению сегмента, выставляется флаг TH_URG. Остальные части шлются как есть. Функция дропает весь replay, затем уходит в [cutoff](#instance_cutoff) по обоим направлениям. diff --git a/lua/zapret-antidpi.lua b/lua/zapret-antidpi.lua index 72e2904..9b12ee5 100644 --- a/lua/zapret-antidpi.lua +++ b/lua/zapret-antidpi.lua @@ -1067,6 +1067,15 @@ function oob(ctx, desync) instance_cutoff_shim(ctx, desync) return end + local key = desync.func_instance.."_syn" + if not desync.track.lua_state[key] then + if bitand(desync.dis.tcp.th_flags, TH_SYN+TH_ACK)~=TH_SYN then + DLOG("oob: must be applied since the very beginning of the tcp connection - SYN packet") + instance_cutoff_shim(ctx, desync) + return + end + desync.track.lua_state[key] = true + end if desync.outgoing then -- direct pos - outgoing local pos = pos_get(desync, 's', false)