zapret/init.d/sysv/custom-nfqws-quic4all-complex

67 lines
2.4 KiB
Plaintext
Raw Normal View History

2022-05-29 20:07:59 +00:00
# this custom script in addition to MODE=nfqws runs desync to all QUIC initial packets, without ipset/hostlist filtering
2022-05-30 06:27:30 +00:00
# and also sends special fake on the first outgoing packet with short header and udp.length>600
2022-05-29 20:07:59 +00:00
# need to add to config : NFQWS_OPT_DESYNC_QUIC="--dpi-desync=fake"
# need to add to config : NFQWS_OPT_DESYNC_QUIC_SHORT_HEADER="--dpi-desync=fake --dpi-desync-any-protocol --dpi-desync-fake-unknown-udp=/opt/zapret/files/fake/quic_short_header.bin --dpi-desync-cutoff=n2"
# NOTE : do not use TTL fooling. chromium QUIC engine breaks sessions if TTL expired in transit received
2022-05-30 06:27:30 +00:00
# this hack was first intended for TSPU but it appeared that it's overkill
# it's enough to send short header fake before initial
2022-05-29 20:07:59 +00:00
QNUM2=$(($QNUM+10))
QNUM3=$(($QNUM+11))
zapret_custom_daemons()
{
# stop logic is managed by procd
local MODE_OVERRIDE=nfqws
local opt
zapret_do_daemons $1
opt="--qnum=$QNUM2 $NFQWS_OPT_BASE $NFQWS_OPT_DESYNC_QUIC"
do_nfqws $1 100 "$opt"
opt="--qnum=$QNUM3 $NFQWS_OPT_BASE $NFQWS_OPT_DESYNC_QUIC_SHORT_HEADER"
do_nfqws $1 101 "$opt"
}
zapret_custom_firewall()
{
# $1 - 1 - run, 0 - stop
local MODE_OVERRIDE=nfqws
local f
local first_packets_only="-m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:3"
local desync="-m mark ! --mark $DESYNC_MARK/$DESYNC_MARK"
2022-05-30 06:27:30 +00:00
local udplen="-m length --length 601:1500"
2022-05-29 20:07:59 +00:00
local short_header4="-m u32 --u32 0>>22&0x3C@8>>24&0xC0=0x40"
zapret_do_firewall_rules_ipt $1
f="-p udp --dport 443"
fw_nfqws_post $1 "$f $desync $first_packets_only" "$f $desync $first_packets_only" $QNUM2
# this for ipv4 only. do not have access to ipv6 enabled TSPU to test
fw_nfqws_post $1 "$f $desync $udplen $short_header4" "" $QNUM3
}
zapret_custom_firewall_nft()
{
# stop logic is not required
local MODE_OVERRIDE=nfqws
local f
local first_packets_only="ct original packets 1-3"
local desync="mark and $DESYNC_MARK == 0"
2022-05-30 06:27:30 +00:00
local udplen="udp length 601-1500"
2022-05-29 20:07:59 +00:00
local short_header4="@th,64,2 1"
zapret_apply_firewall_rules_nft
f="udp dport 443"
nft_fw_nfqws_post $1 "$f $desync $first_packets_only" "$f $desync $first_packets_only" $QNUM2
# this for ipv4 only. do not have access to ipv6 enabled TSPU to test
nft_fw_nfqws_post $1 "$f $desync $udplen $short_header4" "" $QNUM3
# add flow offload exemption for the whole stream because we dont know when short_header rule triggers
nft_add_flow_offload_exemption "$f" "" "QUIC exemption for complex TSPU hack"
}