Compare commits

..

26 Commits

Author SHA1 Message Date
bol-van f0b0d89f02 nfqws: relax stun detector 2026-02-24 10:13:53 +03:00
bol-van a08a358342 nfqws: fix broken wifi ssid update 2026-02-24 10:12:38 +03:00
bol-van 61edd29b7e Revert "nfqws: fix broken wifi ssid update"
This reverts commit 7eb195e533.
2026-02-24 10:11:45 +03:00
bol-van 7eb195e533 nfqws: fix broken wifi ssid update 2026-02-24 10:11:11 +03:00
bol-van 3d567b0ac4 nfqws: optimize nfq buffers 2026-02-22 17:32:49 +03:00
bol-van 53eba046ce nfqws: fix quicv2 recognition 2026-02-19 10:05:09 +03:00
bol-van 5ef01d14a9 nfqws: fixes backport from z2 2026-02-16 12:50:52 +03:00
bol-van 0f0e748adb nfqws2: ensure old toolchains do not break 2026-02-16 12:03:42 +03:00
bol-van e0a2116880 Merge pull request #2083 from k0tran/master
Enable seccomp on loongarch64
2026-02-16 11:44:46 +03:00
Ilya Sorochan 3d12e32ee9 enable seccomp on loongarch64 2026-02-16 11:29:02 +03:00
bol-van be57475eee nfqws: fix possible OOB read 2026-02-06 16:14:04 +03:00
bol-van e59efa39db mdig: minor change 2026-02-05 18:51:47 +03:00
bol-van aa8b96d601 nfqws: some protocol.c fixes 2026-02-04 22:10:00 +03:00
bol-van 2d1858ebae update docs 2026-01-29 13:38:05 +03:00
bol-van 119e243b36 blockcheck: fix missing quic fake escape 2026-01-20 09:36:50 +03:00
bol-van c849e55ef0 ask_list default value fix 2026-01-16 14:18:06 +03:00
bol-van ec55c6f551 install_easy: always write FWTYPE 2026-01-16 12:53:55 +03:00
bol-van 6ca597c89c blockcheck: fix suspicious redirection with URI 2026-01-16 12:46:08 +03:00
bol-van 6ac51a4300 nfqws: fix wrong ipfrag help text 2026-01-16 11:01:54 +03:00
bol-van 76764ad6b0 nfqws: fix breaking tcp if ts fooling is enabled but no timestamps present 2026-01-13 17:58:41 +03:00
bol-van 75d2f1195d AI inspired fixes 2026-01-12 20:37:37 +03:00
bol-van c8cb9faf27 AI inspired fix 2026-01-12 16:51:24 +03:00
bol-van a3ba4baa02 update docs 2026-01-12 10:46:58 +03:00
bol-van 2d19ab82d8 update docs 2026-01-12 10:46:25 +03:00
bol-van a775aa7aaa AI inspired fixes 2026-01-10 19:23:42 +03:00
bol-van 0cdbf089cd AI inspired fixes 2026-01-10 18:54:56 +03:00
21 changed files with 210 additions and 150 deletions
+21 -20
View File
@@ -668,7 +668,7 @@ curl_with_dig()
# $2 - domain name # $2 - domain name
# $3 - port # $3 - port
# $4+ - curl params # $4+ - curl params
local dom=$2 port=$3 local dom="$2" port=$3
local sdom suri ip local sdom suri ip
split_by_separator "$dom" / sdom suri split_by_separator "$dom" / sdom suri
@@ -687,12 +687,12 @@ curl_probe()
# $3 - port # $3 - port
# $4 - subst ip # $4 - subst ip
# $5+ - curl params # $5+ - curl params
local ipv=$1 dom=$2 port=$3 subst=$4 local ipv=$1 dom="$2" port=$3 subst=$4
shift; shift; shift; shift shift; shift; shift; shift
if [ -n "$subst" ]; then if [ -n "$subst" ]; then
curl_with_subst_ip $dom $port $subst "$@" curl_with_subst_ip "$dom" $port $subst "$@"
else else
curl_with_dig $ipv $dom $port "$@" curl_with_dig $ipv "$dom" $port "$@"
fi fi
} }
curl_test_http() curl_test_http()
@@ -702,8 +702,8 @@ curl_test_http()
# $3 - subst ip # $3 - subst ip
# $4 - "detail" - detail info # $4 - "detail" - detail info
local code loc hdrt="${HDRTEMP}_${!:-$$}.txt" local code loc hdrt="${HDRTEMP}_${!:-$$}.txt" dom="$(tolower "$2")"
curl_probe $1 $2 $HTTP_PORT "$3" -SsD "$hdrt" -A "$USER_AGENT" --max-time $CURL_MAX_TIME $CURL_OPT "http://$2" -o /dev/null 2>&1 || { curl_probe $1 "$2" $HTTP_PORT "$3" -SsD "$hdrt" -A "$USER_AGENT" --max-time $CURL_MAX_TIME $CURL_OPT "http://$2" -o /dev/null 2>&1 || {
code=$? code=$?
rm -f "$hdrt" rm -f "$hdrt"
return $code return $code
@@ -715,8 +715,9 @@ curl_test_http()
code=$(hdrfile_http_code "$hdrt") code=$(hdrfile_http_code "$hdrt")
[ "$code" = 301 -o "$code" = 302 -o "$code" = 307 -o "$code" = 308 ] && { [ "$code" = 301 -o "$code" = 302 -o "$code" = 307 -o "$code" = 308 ] && {
loc=$(hdrfile_location "$hdrt") loc=$(hdrfile_location "$hdrt")
echo "$loc" | grep -qE "^https?://.*$2(/|$)" || split_by_separator "$dom" / dom
echo "$loc" | grep -vqE '^https?://' || { tolower "$loc" | grep -qE "^https?://.*$dom(/|$)" ||
tolower "$loc" | grep -vqE '^https?://' || {
echo suspicious redirection $code to : $loc echo suspicious redirection $code to : $loc
rm -f "$hdrt" rm -f "$hdrt"
return 254 return 254
@@ -1079,7 +1080,7 @@ ws_curl_test()
# $2 - test function # $2 - test function
# $3 - domain # $3 - domain
# $4,$5,$6, ... - ws params # $4,$5,$6, ... - ws params
local code ws_start=$1 testf=$2 dom=$3 local code ws_start=$1 testf=$2 dom="$3"
[ "$SIMULATE" = 1 ] && { [ "$SIMULATE" = 1 ] && {
n=$(random 0 99) n=$(random 0 99)
@@ -1095,7 +1096,7 @@ ws_curl_test()
shift shift
shift shift
$ws_start "$@" $ws_start "$@"
curl_test $testf $dom curl_test $testf "$dom"
code=$? code=$?
ws_kill ws_kill
return $code return $code
@@ -1108,7 +1109,7 @@ tpws_curl_test()
echo - $1 ipv$IPV $2 : tpws $3 $4 $5 $6 $7 $8 $9${TPWS_EXTRA:+ $TPWS_EXTRA}${TPWS_EXTRA_1:+ "$TPWS_EXTRA_1"}${TPWS_EXTRA_2:+ "$TPWS_EXTRA_2"}${TPWS_EXTRA_3:+ "$TPWS_EXTRA_3"}${TPWS_EXTRA_4:+ "$TPWS_EXTRA_4"}${TPWS_EXTRA_5:+ "$TPWS_EXTRA_5"}${TPWS_EXTRA_6:+ "$TPWS_EXTRA_6"}${TPWS_EXTRA_7:+ "$TPWS_EXTRA_7"}${TPWS_EXTRA_8:+ "$TPWS_EXTRA_8"}${TPW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A_7:+ "$TPWS_EXTRA_7"}${TPWS_EXTRA_8:+ "$TPWS_EXTRA_8"}${TPWS_EXTRA_9:+ "$TPWS_EXTRA_9"}
local testf=$1 dom=$2 strategy code=$? local testf=$1 dom="$2" strategy code=$?
[ "$code" = 0 ] && { [ "$code" = 0 ] && {
shift; shift; shift; shift;
strategy="$@" strategy="$@"
@@ -1122,11 +1123,11 @@ pktws_curl_test()
# $1 - test function # $1 - test function
# $2 - domain # $2 - domain
# $3,$4,$5, ... - nfqws/dvtws params # $3,$4,$5, ... - nfqws/dvtws params
local testf=$1 dom=$2 strategy code local testf=$1 dom="$2" strategy code
shift; shift; shift; shift;
echo - $testf ipv$IPV $dom : $PKTWSD ${WF:+$WF }${PKTWS_EXTRA_PRE:+$PKTWS_EXTRA_PRE }${PKTWS_EXTRA_PRE_1:+"$PKTWS_EXTRA_PRE_1" }${PKTWS_EXTRA_PRE_2:+"$PKTWS_EXTRA_PRE_2" }${PKTWS_EXTRA_PRE_3:+"$PKTWS_EXTRA_PRE_3" }${PKTWS_EXTRA_PRE_4:+"$PKTWS_EXTRA_PRE_4" }${PKTWS_EXTRA_PRE_5:+"$PKTWS_EXTRA_PRE_5" }${PKTWS_EXTRA_PRE_6:+"$PKTWS_EXTRA_PRE_6" }${PKTWS_EXTRA_PRE_7:+"$PKTWS_EXTRA_PRE_7" }${PKTWS_EXTRA_PRE_8:+"$PKTWS_EXTRA_PRE_8" }${PKTWS_EXTRA_PRE_9:+"$PKTWS_EXTRA_PRE_9" }$@${PKTWS_EXTRA:+ $PKTWS_EXTRA}${PKTWS_EXTRA_1:+ "$PKTWS_EXTRA_1"}${PKTWS_EXTRA_2:+ "$PKTWS_EXTRA_2"}${PKTWS_EXTRA_3:+ "$PKTWS_EXTRA_3"}${PKTWS_EXTRA_4:+ "$PKTWS_EXTRA_4"}${PKTWS_EXTRA_5:+ "$PKTWS_EXTRA_5"}${PKTWS_EXTRA_6:+ "$PKTWS_EXTRA_6"}${PKTWS_EXTRA_7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}"$@"${PKTWS_EXTRA:+ $PKTWS_EXTRA}${PKTWS_EXTRA_1:+ "$PKTWS_EXTRA_1"}${PKTWS_EXTRA_2:+ "$PKTWS_EXTRA_2"}${PKTWS_EXTRA_3:+ "$PKTWS_EXTRA_3"}${PKTWS_EXTRA_4:+ "$PKTWS_EXTRA_4"}${PKTWS_EXTRA_5:+ "$PKTWS_EXTRA_5"}${PKTWS_EXTRA_6:+ "$PKTWS_EXTRA_6"}${PKTWS_EXTRA_7:+ "$PKTWS_EXTRA_7"}${PKTWS_EXTRA_8:+ "$PKTWS_EXTRA_8"}${PKTWS_EXTRA_9:+ "$PKTWS_EXTRA_9"}
code=$? code=$?
[ "$code" = 0 ] && { [ "$code" = 0 ] && {
@@ -1152,11 +1153,11 @@ xxxws_curl_test_update()
# $2 - test function # $2 - test function
# $3 - domain # $3 - domain
# $4,$5,$6, ... - nfqws/dvtws params # $4,$5,$6, ... - nfqws/dvtws params
local code xxxf=$1 testf=$2 dom=$3 local code xxxf=$1 testf=$2 dom="$3"
shift shift
shift shift
shift shift
$xxxf $testf $dom "$@" $xxxf $testf "$dom" "$@"
code=$? code=$?
[ $code = 0 ] && strategy="${strategy:-$@}" [ $code = 0 ] && strategy="${strategy:-$@}"
return $code return $code
@@ -1317,13 +1318,13 @@ pktws_curl_test_update_vary()
[ "$fake" = "-" ] && continue [ "$fake" = "-" ] && continue
if [ -n "$splits" ]; then if [ -n "$splits" ]; then
for pos in $splits ; do for pos in $splits ; do
pktws_curl_test_update $testf $domain --dpi-desync=$desync "$@" --dpi-desync-split-pos=$pos $fake && { pktws_curl_test_update $testf "$domain" --dpi-desync=$desync "$@" --dpi-desync-split-pos=$pos $fake && {
[ "$SCANLEVEL" = force ] || return 0 [ "$SCANLEVEL" = force ] || return 0
ret=0 ret=0
} }
done done
else else
pktws_curl_test_update $testf $domain --dpi-desync=$desync "$@" $fake && { pktws_curl_test_update $testf "$domain" --dpi-desync=$desync "$@" $fake && {
[ "$SCANLEVEL" = force ] || return 0 [ "$SCANLEVEL" = force ] || return 0
ret=0 ret=0
} }
@@ -1572,7 +1573,7 @@ pktws_check_domain_http3_bypass_()
for fake in '' "--dpi-desync-fake-quic=$ZAPRET_BASE/files/fake/quic_initial_www_google_com.bin"; do for fake in '' "--dpi-desync-fake-quic=$ZAPRET_BASE/files/fake/quic_initial_www_google_com.bin"; do
for rep in '' 2 5 10 20; do for rep in '' 2 5 10 20; do
pktws_curl_test_update $1 $2 --dpi-desync=fake ${fake:+$fake }${rep:+--dpi-desync-repeats=$rep} && [ "$SCANLEVEL" != force ] && { pktws_curl_test_update $1 $2 --dpi-desync=fake ${fake:+"$fake" }${rep:+--dpi-desync-repeats=$rep} && [ "$SCANLEVEL" != force ] && {
[ "$SCANLEVEL" = quick ] && return [ "$SCANLEVEL" = quick ] && return
break break
} }
@@ -1698,7 +1699,7 @@ check_dpi_ip_block()
# $1 - test function # $1 - test function
# $2 - domain # $2 - domain
local blocked_dom=$2 local blocked_dom="$2"
local blocked_ip blocked_ips unblocked_ip local blocked_ip blocked_ips unblocked_ip
echo echo
@@ -2188,7 +2189,7 @@ check_dns_()
if find_working_public_dns ; then if find_working_public_dns ; then
echo comparing system resolver to public DNS : $PUBDNS echo comparing system resolver to public DNS : $PUBDNS
for dom in $DNSCHECK_DOM; do for dom in $DNSCHECK_DOM; do
if check_dns_spoof $dom $PUBDNS ; then if check_dns_spoof "$dom" $PUBDNS ; then
echo $dom : MISMATCH echo $dom : MISMATCH
echo -- system resolver : echo -- system resolver :
cat "$DNSCHECK_DIG1" cat "$DNSCHECK_DIG1"
+4
View File
@@ -109,6 +109,10 @@ split_by_separator()
[ -n "$3" ] && eval $3="\$before" [ -n "$3" ] && eval $3="\$before"
[ -n "$4" ] && eval $4="\$after" [ -n "$4" ] && eval $4="\$after"
} }
tolower()
{
echo "$@" | tr 'A-Z' 'a-z'
}
dir_is_not_empty() dir_is_not_empty()
{ {
+6 -7
View File
@@ -36,12 +36,11 @@ ask_list()
# $3 - (optional) default value # $3 - (optional) default value
local M_DEFAULT local M_DEFAULT
eval M_DEFAULT="\$$1" eval M_DEFAULT="\$$1"
local M_ALL=$M_DEFAULT local M_DEFAULT_VAR="$M_DEFAULT"
local M="" local M="" m
local m
[ -n "$3" ] && { find_str_in_list "$M_DEFAULT" "$2" || M_DEFAULT="$3" ;} [ -n "$3" ] && { find_str_in_list "$M_DEFAULT" "$2" || M_DEFAULT="$3" ;}
n=1 n=1
for m in $2; do for m in $2; do
echo $n : $m echo $n : $m
@@ -53,6 +52,6 @@ ask_list()
[ -z "$M" ] && M="$M_DEFAULT" [ -z "$M" ] && M="$M_DEFAULT"
echo selected : $M echo selected : $M
eval $1="\"$M\"" eval $1="\"$M\""
[ "$M" != "$M_OLD" ] [ "$M" != "$M_DEFAULT_VAR" ]
} }
+4 -7
View File
@@ -256,7 +256,7 @@ check_system()
get_free_space_mb() get_free_space_mb()
{ {
df -m $PWD | awk '/[0-9]%/{print $(NF-2)}' df -m "$1" | awk '/[0-9]%/{print $(NF-2)}'
} }
get_ram_kb() get_ram_kb()
{ {
@@ -522,11 +522,6 @@ install_openwrt_firewall()
{ {
echo \* installing firewall script $1 echo \* installing firewall script $1
[ -n "MODE" ] || {
echo should specify MODE in $ZAPRET_CONFIG
exitp 7
}
echo "linking : $FW_SCRIPT_SRC => $OPENWRT_FW_INCLUDE" echo "linking : $FW_SCRIPT_SRC => $OPENWRT_FW_INCLUDE"
ln -fs "$FW_SCRIPT_SRC" "$OPENWRT_FW_INCLUDE" ln -fs "$FW_SCRIPT_SRC" "$OPENWRT_FW_INCLUDE"
@@ -832,7 +827,9 @@ select_fwtype()
echo WARNING ! if you need large lists it may be necessary to fall back to iptables+ipset firewall echo WARNING ! if you need large lists it may be necessary to fall back to iptables+ipset firewall
} }
echo select firewall type : echo select firewall type :
ask_list FWTYPE "iptables nftables" "$FWTYPE" && write_config_var FWTYPE ask_list FWTYPE "iptables nftables" "$FWTYPE"
# always write config var to prevent auto discovery every time
write_config_var FWTYPE
} }
dry_run_tpws_() dry_run_tpws_()
+1 -1
View File
@@ -43,7 +43,7 @@ ipt6_add_del()
} }
ipt6a_add_del() ipt6a_add_del()
{ {
on_off_function ipt6 ipt6a_del "$@" on_off_function ipt6a ipt6_del "$@"
} }
is_ipt_flow_offload_avail() is_ipt_flow_offload_avail()
+9
View File
@@ -591,3 +591,12 @@ blockcheck: fix tpws test regression
nfqws,tpws: memleak fix nfqws,tpws: memleak fix
mdig: --eagain, --eagain-delay mdig: --eagain, --eagain-delay
73.8
nfqws: fix breaking tcp if ts fooling is enabled but no timestamps present
73.9
blockcheck: fix detection of http redirection if domain/URI specified
install_easy: fix writing of ask_list variables
+5 -3
View File
@@ -207,8 +207,8 @@ nfqws takes the following parameters:
--dpi-desync-fakedsplit-mod=mod[,mod] ; mods can be none,altorder=0|1|2|3 + 0|8|16 --dpi-desync-fakedsplit-mod=mod[,mod] ; mods can be none,altorder=0|1|2|3 + 0|8|16
--dpi-desync-hostfakesplit-midhost=marker+N|marker-N ; additionally split real hostname at specified marker. must be within host..endhost or won't be splitted. --dpi-desync-hostfakesplit-midhost=marker+N|marker-N ; additionally split real hostname at specified marker. must be within host..endhost or won't be splitted.
--dpi-desync-hostfakesplit-mod=mod[,mod] ; can be none, host=<hostname>, altorder=0|1 --dpi-desync-hostfakesplit-mod=mod[,mod] ; can be none, host=<hostname>, altorder=0|1
--dpi-desync-ipfrag-pos-tcp=<8..9216> ; ip frag position starting from the transport header. multiple of 8, default 8. --dpi-desync-ipfrag-pos-tcp=<8..9216> ; ip frag position starting from the transport header. multiple of 8, default 32.
--dpi-desync-ipfrag-pos-udp=<8..9216> ; ip frag position starting from the transport header. multiple of 8, default 32. --dpi-desync-ipfrag-pos-udp=<8..9216> ; ip frag position starting from the transport header. multiple of 8, default 8.
--dpi-desync-ts-increment=<int|0xHEX> ; ts fooling TSval signed increment. default -600000 --dpi-desync-ts-increment=<int|0xHEX> ; ts fooling TSval signed increment. default -600000
--dpi-desync-badseq-increment=<int|0xHEX> ; badseq fooling seq signed increment. default -10000 --dpi-desync-badseq-increment=<int|0xHEX> ; badseq fooling seq signed increment. default -10000
--dpi-desync-badack-increment=<int|0xHEX> ; badseq fooling ackseq signed increment. default -66000 --dpi-desync-badack-increment=<int|0xHEX> ; badseq fooling ackseq signed increment. default -66000
@@ -1702,7 +1702,9 @@ If this is the case then run another script in background and add some delay the
Are welcome here : Are welcome here :
USDT `0x3d52Ce15B7Be734c53fc9526ECbAB8267b63d66E` USDT ERC `0x3d52Ce15B7Be734c53fc9526ECbAB8267b63d66E`
USDT TRC `TEzAAtn4VhndqEaAyuCM78xh5W2gCjwWEo`
BTC `bc1qhqew3mrvp47uk2vevt5sctp7p2x9m7m5kkchve` BTC `bc1qhqew3mrvp47uk2vevt5sctp7p2x9m7m5kkchve`
+11 -1
View File
@@ -4,6 +4,12 @@ zapret является свободным и open source.
Всякий, кто понуждает вас скачивать zapret только с его ресурса, требует удалить ссылки, видео, файлы, обосновывая эти требования авторскими правами, сам нарушает [лицензию](./LICENSE.txt). Всякий, кто понуждает вас скачивать zapret только с его ресурса, требует удалить ссылки, видео, файлы, обосновывая эти требования авторскими правами, сам нарушает [лицензию](./LICENSE.txt).
Однако, это не исключает [добровольные пожертвования](#поддержать-разработчика). Однако, это не исключает [добровольные пожертвования](#поддержать-разработчика).
# zapret2
Эта версия zapret более не развивается и находится в режиме EOL (End-Of-Life). Никаких новых функций больше не будет. Только багфиксы.
[Актуальная версия - zapret 2](https://github.com/bol-van/zapret2)
# Multilanguage README # Multilanguage README
[![en](https://img.shields.io/badge/lang-en-red.svg)](./readme.en.md) [![en](https://img.shields.io/badge/lang-en-red.svg)](./readme.en.md)
@@ -231,6 +237,8 @@ dvtws, собираемый из тех же исходников (см. [док
--dpi-desync-fakedsplit-mod=mod[,mod] ; может быть none, altorder=0|1|2|3 + 0|8|16 --dpi-desync-fakedsplit-mod=mod[,mod] ; может быть none, altorder=0|1|2|3 + 0|8|16
--dpi-desync-hostfakesplit-midhost=marker+N|marker-N ; маркер дополнительного разреза сегмента с оригинальным хостом. должен попадать в пределы хоста. --dpi-desync-hostfakesplit-midhost=marker+N|marker-N ; маркер дополнительного разреза сегмента с оригинальным хостом. должен попадать в пределы хоста.
--dpi-desync-hostfakesplit-mod=mod[,mod] ; может быть none, host=<hostname>, altorder=0|1 --dpi-desync-hostfakesplit-mod=mod[,mod] ; может быть none, host=<hostname>, altorder=0|1
--dpi-desync-ipfrag-pos-tcp=<8..9216> ; позиция ip фрагментации tcp, начиная с транспортного заголовка. должно быть кратно 8, по умолчанию - 32.
--dpi-desync-ipfrag-pos-udp=<8..9216> ; позиция ip фрагментации udp, начиная с транспортного заголовка. должно быть кратно 8, по умолчанию - 8.
--dpi-desync-ts-increment=<int|0xHEX> ; инкремент TSval для ts. по умолчанию -600000 --dpi-desync-ts-increment=<int|0xHEX> ; инкремент TSval для ts. по умолчанию -600000
--dpi-desync-badseq-increment=<int|0xHEX> ; инкремент sequence number для badseq. по умолчанию -10000 --dpi-desync-badseq-increment=<int|0xHEX> ; инкремент sequence number для badseq. по умолчанию -10000
--dpi-desync-badack-increment=<int|0xHEX> ; инкремент ack sequence number для badseq. по умолчанию -66000 --dpi-desync-badack-increment=<int|0xHEX> ; инкремент ack sequence number для badseq. по умолчанию -66000
@@ -2716,7 +2724,9 @@ VPS можно приобрести в множестве мест. Сущест
## Поддержать разработчика ## Поддержать разработчика
USDT `0x3d52Ce15B7Be734c53fc9526ECbAB8267b63d66E` USDT ERC `0x3d52Ce15B7Be734c53fc9526ECbAB8267b63d66E`
USDT TRC `TEzAAtn4VhndqEaAyuCM78xh5W2gCjwWEo`
BTC `bc1qhqew3mrvp47uk2vevt5sctp7p2x9m7m5kkchve` BTC `bc1qhqew3mrvp47uk2vevt5sctp7p2x9m7m5kkchve`
+1 -1
View File
@@ -323,7 +323,7 @@ ask_config_tmpdir()
echo /tmp in openwrt is tmpfs. on low RAM systems there may be not enough RAM to store downloaded files echo /tmp in openwrt is tmpfs. on low RAM systems there may be not enough RAM to store downloaded files
echo default tmpfs has size of 50% RAM echo default tmpfs has size of 50% RAM
echo "RAM : $(get_ram_mb) Mb" echo "RAM : $(get_ram_mb) Mb"
echo "DISK : $(get_free_space_mb) Mb" echo "DISK : $(get_free_space_mb "$EXEDIR/tmp") Mb"
echo select temp file location echo select temp file location
[ -z "$TMPDIR" ] && TMPDIR=/tmp [ -z "$TMPDIR" ] && TMPDIR=/tmp
ask_list TMPDIR "/tmp $EXEDIR/tmp" && { ask_list TMPDIR "/tmp $EXEDIR/tmp" && {
+7 -7
View File
@@ -80,15 +80,15 @@ static bool dom_valid(char *dom)
{ {
if (!dom || *dom=='.') return false; if (!dom || *dom=='.') return false;
for (; *dom; dom++) for (; *dom; dom++)
if (*dom < 0x20 || (*dom & 0x80) || !(*dom == '.' || *dom == '-' || *dom == '_' || (*dom >= '0' && *dom <= '9') || (*dom >= 'a' && *dom <= 'z') || (*dom >= 'A' && *dom <= 'Z'))) if (!(*dom == '.' || *dom == '-' || *dom == '_' || (*dom >= '0' && *dom <= '9') || (*dom >= 'a' && *dom <= 'z') || (*dom >= 'A' && *dom <= 'Z')))
return false; return false;
return true; return true;
} }
static void invalid_domain_beautify(char *dom) static void invalid_domain_beautify(char *dom)
{ {
for (int i = 0; *dom && i < 64; i++, dom++) for (int i = 0; *dom && i < 64; i++, dom++)
if (*dom < 0x20 || *dom<0) *dom = '?'; if (*dom < 0x20 || (*dom & 0x80)) *dom = '?';
if (*dom) *dom = 0; if (*dom) *dom = 0;
} }
@@ -220,7 +220,7 @@ static void *t_resolver(void *arg)
{ {
if ((family == AF_INET && (glob.family & FAMILY4)) || (family == AF_INET6 && (glob.family & FAMILY6))) if ((family == AF_INET && (glob.family & FAMILY4)) || (family == AF_INET6 && (glob.family & FAMILY6)))
{ {
unsigned int mask; unsigned int mask=0;
bool mask_needed = false; bool mask_needed = false;
if (s_mask) if (s_mask)
{ {
@@ -436,7 +436,7 @@ int dns_parse_query()
_setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdin), _O_BINARY);
#endif #endif
l = fread(a,1,sizeof(a),stdin); l = fread(a,1,sizeof(a),stdin);
if (!l || !feof(stdin)) if (!l || ferror(stdin))
{ {
fprintf(stderr, "could not read DNS reply blob from stdin\n"); fprintf(stderr, "could not read DNS reply blob from stdin\n");
return 10; return 10;
@@ -455,8 +455,8 @@ static void exithelp(void)
printf( printf(
" --family=<4|6|46>\t\t; ipv4, ipv6, ipv4+ipv6\n" " --family=<4|6|46>\t\t; ipv4, ipv6, ipv4+ipv6\n"
" --threads=<threads_number>\n" " --threads=<threads_number>\n"
" --eagain=<eagain_retries>\t; how many times to retry if EAGAIN received. default %u\n" " --eagain=<eagain_retries>\t; how many times to retry if EAI_AGAIN received. default %u\n"
" --eagain-delay=<ms>\t\t; time in msec to wait between EAGAIN attempts. default %u\n" " --eagain-delay=<ms>\t\t; time in msec to wait between EAI_AGAIN attempts. default %u\n"
" --verbose\t\t\t; print query progress to stderr\n" " --verbose\t\t\t; print query progress to stderr\n"
" --stats=N\t\t\t; print resolve stats to stderr every N domains\n" " --stats=N\t\t\t; print resolve stats to stderr every N domains\n"
" --log-resolved=<file>\t\t; log successfully resolved domains to a file\n" " --log-resolved=<file>\t\t; log successfully resolved domains to a file\n"
+2
View File
@@ -5,6 +5,8 @@ int aes_gcm_crypt(int mode, uint8_t *output, const uint8_t *input, size_t input_
int ret = 0; int ret = 0;
gcm_context ctx; gcm_context ctx;
gcm_initialize();
if (!(ret = gcm_setkey(&ctx, key, (const uint)key_len))) if (!(ret = gcm_setkey(&ctx, key, (const uint)key_len)))
{ {
ret = gcm_crypt_and_tag(&ctx, mode, iv, iv_len, adata, adata_len, input, output, input_length, atag, atag_len); ret = gcm_crypt_and_tag(&ctx, mode, iv, iv_len, adata, adata_len, input, output, input_length, atag, atag_len);
+18 -9
View File
@@ -391,7 +391,9 @@ int gcm_finish(gcm_context *ctx, // pointer to user-provided GCM context
uint64_t orig_add_len = ctx->add_len * 8; uint64_t orig_add_len = ctx->add_len * 8;
size_t i; size_t i;
if (tag_len != 0) memcpy(tag, ctx->base_ectr, tag_len); if (tag_len>16) return -1;
if (tag_len) memcpy(tag, ctx->base_ectr, tag_len);
if (orig_len || orig_add_len) { if (orig_len || orig_add_len) {
memset(work_buf, 0x00, 16); memset(work_buf, 0x00, 16);
@@ -443,10 +445,12 @@ int gcm_crypt_and_tag(
prepare the gcm context with the keying material, we simply prepare the gcm context with the keying material, we simply
invoke each of the three GCM sub-functions in turn... invoke each of the three GCM sub-functions in turn...
*/ */
gcm_start(ctx, mode, iv, iv_len, add, add_len); if (tag_len>16) return -1;
gcm_update(ctx, length, input, output);
gcm_finish(ctx, tag, tag_len); int ret;
return(0); if ((ret=gcm_start(ctx, mode, iv, iv_len, add, add_len))) return ret;
if ((ret=gcm_update(ctx, length, input, output))) return ret;
return gcm_finish(ctx, tag, tag_len);
} }
@@ -477,23 +481,28 @@ int gcm_auth_decrypt(
uchar check_tag[16]; // the tag generated and returned by decryption uchar check_tag[16]; // the tag generated and returned by decryption
int diff; // an ORed flag to detect authentication errors int diff; // an ORed flag to detect authentication errors
size_t i; // our local iterator size_t i; // our local iterator
int ret;
if (tag_len>16) return -1;
/* /*
we use GCM_DECRYPT_AND_TAG (above) to perform our decryption we use GCM_DECRYPT_AND_TAG (above) to perform our decryption
(which is an identical XORing to reverse the previous one) (which is an identical XORing to reverse the previous one)
and also to re-generate the matching authentication tag and also to re-generate the matching authentication tag
*/ */
gcm_crypt_and_tag(ctx, AES_DECRYPT, iv, iv_len, add, add_len, if ((ret = gcm_crypt_and_tag(ctx, AES_DECRYPT, iv, iv_len, add, add_len, input, output, length, check_tag, tag_len))) return ret;
input, output, length, check_tag, tag_len);
// now we verify the authentication tag in 'constant time' // now we verify the authentication tag in 'constant time'
for (diff = 0, i = 0; i < tag_len; i++) for (diff = 0, i = 0; i < tag_len; i++)
diff |= tag[i] ^ check_tag[i]; diff |= tag[i] ^ check_tag[i];
if (diff != 0) { // see whether any bits differed? if (diff)
{
// see whether any bits differed?
memset(output, 0, length); // if so... wipe the output data memset(output, 0, length); // if so... wipe the output data
return(GCM_AUTH_FAILURE); // return GCM_AUTH_FAILURE return(GCM_AUTH_FAILURE); // return GCM_AUTH_FAILURE
} }
return(0); return 0;
} }
/****************************************************************************** /******************************************************************************
+12 -20
View File
@@ -60,9 +60,9 @@ int hkdf(SHAversion whichSha,
uint8_t okm[], size_t okm_len) uint8_t okm[], size_t okm_len)
{ {
uint8_t prk[USHAMaxHashSize]; uint8_t prk[USHAMaxHashSize];
return hkdfExtract(whichSha, salt, salt_len, ikm, ikm_len, prk) || int ret;
hkdfExpand(whichSha, prk, USHAHashSize(whichSha), info, if ((ret=hkdfExtract(whichSha, salt, salt_len, ikm, ikm_len, prk))) return ret;
info_len, okm, okm_len); return hkdfExpand(whichSha, prk, USHAHashSize(whichSha), info, info_len, okm, okm_len);
} }
/* /*
@@ -103,9 +103,6 @@ int hkdfExtract(SHAversion whichSha,
salt_len = USHAHashSize(whichSha); salt_len = USHAHashSize(whichSha);
memset(nullSalt, '\0', salt_len); memset(nullSalt, '\0', salt_len);
} }
else if (salt_len < 0) {
return shaBadParam;
}
return hmac(whichSha, ikm, ikm_len, salt, salt_len, prk); return hmac(whichSha, ikm, ikm_len, salt, salt_len, prk);
} }
@@ -149,16 +146,13 @@ int hkdfExpand(SHAversion whichSha, const uint8_t prk[], size_t prk_len,
size_t hash_len, N; size_t hash_len, N;
unsigned char T[USHAMaxHashSize]; unsigned char T[USHAMaxHashSize];
size_t Tlen, where, i; size_t Tlen, where, i;
int ret;
if (info == 0) { if (info == 0) {
info = (const unsigned char *)""; info = (const unsigned char *)"";
info_len = 0; info_len = 0;
} }
else if (info_len < 0) { if (!okm || !okm_len) return shaBadParam;
return shaBadParam;
}
if (okm_len <= 0) return shaBadParam;
if (!okm) return shaBadParam;
hash_len = USHAHashSize(whichSha); hash_len = USHAHashSize(whichSha);
if (prk_len < hash_len) return shaBadParam; if (prk_len < hash_len) return shaBadParam;
@@ -171,12 +165,11 @@ int hkdfExpand(SHAversion whichSha, const uint8_t prk[], size_t prk_len,
for (i = 1; i <= N; i++) { for (i = 1; i <= N; i++) {
HMACContext context; HMACContext context;
unsigned char c = i; unsigned char c = i;
int ret = hmacReset(&context, whichSha, prk, prk_len) || if ((ret=hmacReset(&context, whichSha, prk, prk_len))) return ret;
hmacInput(&context, T, Tlen) || if ((ret=hmacInput(&context, T, Tlen))) return ret;
hmacInput(&context, info, info_len) || if ((ret=hmacInput(&context, info, info_len))) return ret;
hmacInput(&context, &c, 1) || if ((ret=hmacInput(&context, &c, 1))) return ret;
hmacResult(&context, T); if ((ret=hmacResult(&context, T))) return ret;
if (ret != shaSuccess) return ret;
memcpy(okm + where, T, memcpy(okm + where, T,
(i != N) ? hash_len : (okm_len - where)); (i != N) ? hash_len : (okm_len - where));
where += hash_len; where += hash_len;
@@ -328,9 +321,8 @@ int hkdfResult(HKDFContext *context,
if (!okm) return context->Corrupted = shaBadParam; if (!okm) return context->Corrupted = shaBadParam;
if (!prk) prk = prkbuf; if (!prk) prk = prkbuf;
ret = hmacResult(&context->hmacContext, prk) || if (!(ret = hmacResult(&context->hmacContext, prk)))
hkdfExpand(context->whichSha, prk, context->hashSize, info, ret = hkdfExpand(context->whichSha, prk, context->hashSize, info, info_len, okm, okm_len);
info_len, okm, okm_len);
context->Computed = 1; context->Computed = 1;
return context->Corrupted = ret; return context->Corrupted = ret;
} }
+14 -21
View File
@@ -49,9 +49,10 @@ int hmac(SHAversion whichSha,
uint8_t digest[USHAMaxHashSize]) uint8_t digest[USHAMaxHashSize])
{ {
HMACContext context; HMACContext context;
return hmacReset(&context, whichSha, key, key_len) || int ret;
hmacInput(&context, message_array, length) || if ((ret=hmacReset(&context, whichSha, key, key_len))) return ret;
hmacResult(&context, digest); if ((ret=hmacInput(&context, message_array, length))) return ret;
return hmacResult(&context, digest);
} }
/* /*
@@ -101,10 +102,8 @@ int hmacReset(HMACContext *context, enum SHAversion whichSha,
*/ */
if (key_len > blocksize) { if (key_len > blocksize) {
USHAContext tcontext; USHAContext tcontext;
int err = USHAReset(&tcontext, whichSha) || if ((ret=USHAReset(&tcontext, whichSha)) || (ret=USHAInput(&tcontext, key, key_len)) || (ret=USHAResult(&tcontext, tempkey)))
USHAInput(&tcontext, key, key_len) || return ret;
USHAResult(&tcontext, tempkey);
if (err != shaSuccess) return err;
key = tempkey; key = tempkey;
key_len = hashsize; key_len = hashsize;
@@ -134,9 +133,9 @@ int hmacReset(HMACContext *context, enum SHAversion whichSha,
/* perform inner hash */ /* perform inner hash */
/* init context for 1st pass */ /* init context for 1st pass */
ret = USHAReset(&context->shaContext, whichSha) || if (!(ret = USHAReset(&context->shaContext, whichSha)))
/* and start with inner pad */ /* and start with inner pad */
USHAInput(&context->shaContext, k_ipad, blocksize); ret = USHAInput(&context->shaContext, k_ipad, blocksize);
return context->Corrupted = ret; return context->Corrupted = ret;
} }
@@ -197,8 +196,7 @@ int hmacFinalBits(HMACContext *context,
if (context->Corrupted) return context->Corrupted; if (context->Corrupted) return context->Corrupted;
if (context->Computed) return context->Corrupted = shaStateError; if (context->Computed) return context->Corrupted = shaStateError;
/* then final bits of datagram */ /* then final bits of datagram */
return context->Corrupted = return context->Corrupted = USHAFinalBits(&context->shaContext, bits, bit_count);
USHAFinalBits(&context->shaContext, bits, bit_count);
} }
/* /*
@@ -229,21 +227,16 @@ int hmacResult(HMACContext *context, uint8_t *digest)
/* finish up 1st pass */ /* finish up 1st pass */
/* (Use digest here as a temporary buffer.) */ /* (Use digest here as a temporary buffer.) */
ret = if (!(ret=USHAResult(&context->shaContext, digest)) &&
USHAResult(&context->shaContext, digest) ||
/* perform outer SHA */ /* perform outer SHA */
/* init context for 2nd pass */ /* init context for 2nd pass */
USHAReset(&context->shaContext, context->whichSha) || !(ret=USHAReset(&context->shaContext, context->whichSha)) &&
/* start with outer pad */ /* start with outer pad */
USHAInput(&context->shaContext, context->k_opad, !(ret=USHAInput(&context->shaContext, context->k_opad, context->blockSize)) &&
context->blockSize) ||
/* then results of 1st hash */ /* then results of 1st hash */
USHAInput(&context->shaContext, digest, context->hashSize) || !(ret=USHAInput(&context->shaContext, digest, context->hashSize)))
/* finish up 2nd pass */ /* finish up 2nd pass */
USHAResult(&context->shaContext, digest); ret=USHAResult(&context->shaContext, digest);
context->Computed = 1; context->Computed = 1;
return context->Corrupted = ret; return context->Corrupted = ret;
+6 -6
View File
@@ -64,12 +64,12 @@
* Add "length" to the length. * Add "length" to the length.
* Set Corrupted when overflow has occurred. * Set Corrupted when overflow has occurred.
*/ */
static uint32_t addTemp; static int SHA224_256AddLength(SHA256Context *context, uint32_t length)
#define SHA224_256AddLength(context, length) \ {
(addTemp = (context)->Length_Low, (context)->Corrupted = \ uint32_t addTemp = context->Length_Low;
(((context)->Length_Low += (length)) < addTemp) && \ if (((context->Length_Low += length) < addTemp) && (++(context)->Length_High == 0)) context->Corrupted = shaInputTooLong;
(++(context)->Length_High == 0) ? shaInputTooLong : \ return context->Corrupted;
(context)->Corrupted ) }
/* Local Function Prototypes */ /* Local Function Prototypes */
static int SHA224_256Reset(SHA256Context *context, uint32_t *H0); static int SHA224_256Reset(SHA256Context *context, uint32_t *H0);
+3 -1
View File
@@ -192,7 +192,7 @@ static uint16_t tcpopt_len(bool sack, bool mss, uint32_t fooling, const uint32_t
if (sack) t+=2; if (sack) t+=2;
if (mss) t+=4; if (mss) t+=4;
if (fooling & FOOL_MD5SIG) t+=18; if (fooling & FOOL_MD5SIG) t+=18;
if ((fooling & FOOL_TS) || timestamps) t+=10; if (timestamps) t+=10;
if (scale_factor!=SCALE_NONE) t+=3; if (scale_factor!=SCALE_NONE) t+=3;
return (t+3)&~3; return (t+3)&~3;
} }
@@ -928,6 +928,7 @@ void proto_skip_ipv6(uint8_t **data, size_t *len, uint8_t *proto_type, uint8_t *
if (proto_type) *proto_type = 0; // put error in advance if (proto_type) *proto_type = 0; // put error in advance
HeaderType = (*data)[6]; // NextHeader field HeaderType = (*data)[6]; // NextHeader field
if (proto_type) *proto_type = HeaderType;
if (last_header_type) *last_header_type = (*data)+6; if (last_header_type) *last_header_type = (*data)+6;
*data += 40; *len -= 40; // skip ipv6 base header *data += 40; *len -= 40; // skip ipv6 base header
while (*len > 0) // need at least one byte for NextHeader field while (*len > 0) // need at least one byte for NextHeader field
@@ -2095,6 +2096,7 @@ static bool scan_info(struct mnl_socket* nl, uint16_t wlan_family_id, struct wla
// wlan_info does not return ssid since kernel 5.19 // wlan_info does not return ssid since kernel 5.19
// it's used to enumerate all wifi interfaces then call scan_info on each // it's used to enumerate all wifi interfaces then call scan_info on each
if (!wlan_info(nl, wlan_family_id, &wc_all, false)) return false; if (!wlan_info(nl, wlan_family_id, &wc_all, false)) return false;
w->count=0;
for(int i=0;i<wc_all.count;i++) for(int i=0;i<wc_all.count;i++)
if (!netlink_genl_simple_transact(nl, wlan_family_id, NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP, NL80211_CMD_GET_SCAN, 0, scan_prepare, (void*)&wc_all.wlan[i].ifindex, scan_info_cb, w)) if (!netlink_genl_simple_transact(nl, wlan_family_id, NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP, NL80211_CMD_GET_SCAN, 0, scan_prepare, (void*)&wc_all.wlan[i].ifindex, scan_info_cb, w))
return false; return false;
+5 -2
View File
@@ -256,6 +256,8 @@ static bool nfq_init(struct nfq_handle **h, struct nfq_q_handle **qh)
// dot not fail. not supported on old linuxes <3.6 // dot not fail. not supported on old linuxes <3.6
} }
nfnl_rcvbufsiz(nfq_nfnlh(*h), Q_RCVBUF);
DLOG_CONDUP("initializing raw sockets bind-fix4=%u bind-fix6=%u\n", params.bind_fix4, params.bind_fix6); DLOG_CONDUP("initializing raw sockets bind-fix4=%u bind-fix6=%u\n", params.bind_fix4, params.bind_fix6);
if (!rawsend_preinit(params.bind_fix4, params.bind_fix6)) if (!rawsend_preinit(params.bind_fix4, params.bind_fix6))
goto exiterr; goto exiterr;
@@ -350,7 +352,7 @@ static int nfq_main(void)
if (rd) if (rd)
{ {
int r = nfq_handle_packet(h, (char *)buf, (int)rd); int r = nfq_handle_packet(h, (char *)buf, (int)rd);
if (r) DLOG_ERR("nfq_handle_packet error %d\n", r); if (r<0) DLOG_ERR("nfq_handle_packet result %d, errno %d : %s\n", r, errno, strerror(errno));
} }
else else
DLOG("recv from nfq returned 0 !\n"); DLOG("recv from nfq returned 0 !\n");
@@ -1883,8 +1885,8 @@ static void exithelp(void)
" --dpi-desync-fakedsplit-mod=mod[,mod]\t\t\t; mods can be none,altorder=0|1|2|3 + 0|8|16\n" " --dpi-desync-fakedsplit-mod=mod[,mod]\t\t\t; mods can be none,altorder=0|1|2|3 + 0|8|16\n"
" --dpi-desync-hostfakesplit-midhost=marker+N|marker-N\t; additionally split real hostname at specified marker. must be within host..endhost or won't be splitted.\n" " --dpi-desync-hostfakesplit-midhost=marker+N|marker-N\t; additionally split real hostname at specified marker. must be within host..endhost or won't be splitted.\n"
" --dpi-desync-hostfakesplit-mod=mod[,mod]\t\t; mods can be none,host=<hostname>,altorder=0|1\n" " --dpi-desync-hostfakesplit-mod=mod[,mod]\t\t; mods can be none,host=<hostname>,altorder=0|1\n"
" --dpi-desync-ipfrag-pos-tcp=<8..%u>\t\t\t; ip frag position starting from the transport header. multiple of 8, default %u.\n"
" --dpi-desync-ipfrag-pos-udp=<8..%u>\t\t\t; ip frag position starting from the transport header. multiple of 8, default %u.\n" " --dpi-desync-ipfrag-pos-udp=<8..%u>\t\t\t; ip frag position starting from the transport header. multiple of 8, default %u.\n"
" --dpi-desync-ipfrag-pos-tcp=<8..%u>\t\t\t; ip frag position starting from the transport header. multiple of 8, default %u.\n"
" --dpi-desync-ts-increment=<int|0xHEX>\t\t\t; ts fooling TSval signed increment. default %d\n" " --dpi-desync-ts-increment=<int|0xHEX>\t\t\t; ts fooling TSval signed increment. default %d\n"
" --dpi-desync-badseq-increment=<int|0xHEX>\t\t; badseq fooling seq signed increment. default %d\n" " --dpi-desync-badseq-increment=<int|0xHEX>\t\t; badseq fooling seq signed increment. default %d\n"
" --dpi-desync-badack-increment=<int|0xHEX>\t\t; badseq fooling ackseq signed increment. default %d\n" " --dpi-desync-badack-increment=<int|0xHEX>\t\t; badseq fooling ackseq signed increment. default %d\n"
@@ -2304,6 +2306,7 @@ int main(int argc, char **argv)
#endif #endif
srandom(time(NULL)); srandom(time(NULL));
aes_init_keygen_tables(); // required for aes
PRINT_VER; PRINT_VER;
+2 -1
View File
@@ -23,7 +23,8 @@
#define RAW_SNDBUF (64*1024) // in bytes #define RAW_SNDBUF (64*1024) // in bytes
#define Q_MAXLEN 1024 // in packets #define Q_MAXLEN 4986 // in packets
#define Q_RCVBUF (1024*1024) // in bytes
#define BADSEQ_INCREMENT_DEFAULT -10000 #define BADSEQ_INCREMENT_DEFAULT -10000
#define BADSEQ_ACK_INCREMENT_DEFAULT -66000 #define BADSEQ_ACK_INCREMENT_DEFAULT -66000
+33 -43
View File
@@ -310,7 +310,7 @@ size_t HttpPos(uint8_t posmarker, int16_t pos, const uint8_t *data, size_t sz)
if (sz<10) break; if (sz<10) break;
if (*method=='\n' || *method=='\r') method++; if (*method=='\n' || *method=='\r') method++;
if (*method=='\n' || *method=='\r') method++; if (*method=='\n' || *method=='\r') method++;
for (p=method,i=0;i<7;i++) if (*p>='A' && *p<='Z') p++; for (p=method,i=0; i<9 && *p>='A' && *p<='Z'; i++,p++);
if (i<3 || *p!=' ') break; if (i<3 || *p!=' ') break;
return CheckPos(sz,method-data+pos); return CheckPos(sz,method-data+pos);
case PM_HOST: case PM_HOST:
@@ -615,24 +615,18 @@ bool IsQUICCryptoHello(const uint8_t *data, size_t len, size_t *hello_offset, si
uint8_t QUICDraftVersion(uint32_t version) uint8_t QUICDraftVersion(uint32_t version)
{ {
/* IETF Draft versions */ /* IETF Draft versions */
if ((version >> 8) == 0xff0000) { if ((version >> 8) == 0xff0000)
return (uint8_t)version; return (uint8_t)version;
}
/* Facebook mvfst, based on draft -22. */ /* Facebook mvfst, based on draft -22. */
if (version == 0xfaceb001) { if (version == 0xfaceb001)
return 22; return 22;
}
/* Facebook mvfst, based on draft -27. */ /* Facebook mvfst, based on draft -27. */
if (version == 0xfaceb002 || version == 0xfaceb00e) { if (version == 0xfaceb002 || version == 0xfaceb00e)
return 27; return 27;
}
/* GQUIC Q050, T050 and T051: they are not really based on any drafts, /* GQUIC Q050, T050 and T051: they are not really based on any drafts,
* but we must return a sensible value */ * but we must return a sensible value */
if (version == 0x51303530 || if (version == 0x51303530 || version == 0x54303530 || version == 0x54303531)
version == 0x54303530 ||
version == 0x54303531) {
return 27; return 27;
}
/* https://tools.ietf.org/html/draft-ietf-quic-transport-32#section-15 /* https://tools.ietf.org/html/draft-ietf-quic-transport-32#section-15
"Versions that follow the pattern 0x?a?a?a?a are reserved for use in "Versions that follow the pattern 0x?a?a?a?a are reserved for use in
forcing version negotiation to be exercised" forcing version negotiation to be exercised"
@@ -640,19 +634,17 @@ uint8_t QUICDraftVersion(uint32_t version)
used to select a proper salt (which depends on the version itself), but used to select a proper salt (which depends on the version itself), but
we don't have a real version here! Let's hope that we need to handle we don't have a real version here! Let's hope that we need to handle
only latest drafts... */ only latest drafts... */
if ((version & 0x0F0F0F0F) == 0x0a0a0a0a) { if ((version & 0x0F0F0F0F) == 0x0a0a0a0a)
return 29; return 29;
}
/* QUIC (final?) constants for v1 are defined in draft-33, but draft-34 is the /* QUIC (final?) constants for v1 are defined in draft-33, but draft-34 is the
final draft version */ final draft version */
if (version == 0x00000001) { if (version == 0x00000001)
return 34; return 34;
}
/* QUIC Version 2 */ /* QUIC Version 2 */
/* TODO: for the time being use 100 as a number for V2 and let see how v2 drafts evolve */ /* TODO: for the time being use 100 as a number for V2 and let see how v2 drafts evolve */
if (version == 0x709A50C4) { if ((version == 0x709A50C4) || (version == 0x6b3343cf))
return 100; return 100;
}
return 0; return 0;
} }
@@ -662,7 +654,7 @@ static bool is_quic_draft_max(uint32_t draft_version, uint8_t max_version)
} }
static bool is_quic_v2(uint32_t version) static bool is_quic_v2(uint32_t version)
{ {
return version == 0x6b3343cf; return (version == 0x709A50C4) || (version == 0x6b3343cf);
} }
static bool quic_hkdf_expand_label(const uint8_t *secret, uint8_t secret_len, const char *label, uint8_t *out, size_t out_len) static bool quic_hkdf_expand_label(const uint8_t *secret, uint8_t secret_len, const char *label, uint8_t *out, size_t out_len)
@@ -803,20 +795,19 @@ bool QUICDecryptInitial(const uint8_t *data, size_t data_len, uint8_t *clean, si
return false; return false;
} }
uint64_t payload_len,token_len; uint64_t payload_len,token_len,pn_offset;
size_t pn_offset;
pn_offset = 1 + 4 + 1 + data[5]; pn_offset = 1 + 4 + 1 + data[5];
if (pn_offset >= data_len) return false; if (pn_offset >= data_len) return false;
// SCID length
pn_offset += 1 + data[pn_offset]; pn_offset += 1 + data[pn_offset];
if ((pn_offset + tvb_get_size(data[pn_offset])) >= data_len) return false; if (pn_offset >= data_len || (pn_offset + tvb_get_size(data[pn_offset])) >= data_len) return false;
// token length
pn_offset += tvb_get_varint(data + pn_offset, &token_len); pn_offset += tvb_get_varint(data + pn_offset, &token_len);
pn_offset += token_len; pn_offset += token_len;
if ((pn_offset + tvb_get_size(data[pn_offset])) >= data_len) return false; if (pn_offset >= data_len || (pn_offset + tvb_get_size(data[pn_offset])) >= data_len) return false;
pn_offset += tvb_get_varint(data + pn_offset, &payload_len); pn_offset += tvb_get_varint(data + pn_offset, &payload_len);
if (payload_len<20 || (pn_offset + payload_len)>data_len) return false; if (payload_len<20 || (pn_offset + payload_len)>data_len) return false;
aes_init_keygen_tables();
uint8_t sample_enc[16]; uint8_t sample_enc[16];
aes_context ctx; aes_context ctx;
if (aes_setkey(&ctx, 1, aeshp, sizeof(aeshp)) || aes_cipher(&ctx, data + pn_offset + 4, sample_enc)) return false; if (aes_setkey(&ctx, 1, aeshp, sizeof(aeshp)) || aes_cipher(&ctx, data + pn_offset + 4, sample_enc)) return false;
@@ -834,13 +825,13 @@ bool QUICDecryptInitial(const uint8_t *data, size_t data_len, uint8_t *clean, si
phton64(aesiv + sizeof(aesiv) - 8, pntoh64(aesiv + sizeof(aesiv) - 8) ^ pkn); phton64(aesiv + sizeof(aesiv) - 8, pntoh64(aesiv + sizeof(aesiv) - 8) ^ pkn);
size_t cryptlen = payload_len - pkn_len - 16; uint64_t cryptlen = payload_len - pkn_len - 16;
if (cryptlen > *clean_len) return false; if (cryptlen > *clean_len) return false;
*clean_len = cryptlen; *clean_len = (size_t)cryptlen;
const uint8_t *decrypt_begin = data + pn_offset + pkn_len; const uint8_t *decrypt_begin = data + pn_offset + pkn_len;
uint8_t atag[16],header[256]; uint8_t atag[16],header[2048];
size_t header_len = pn_offset + pkn_len; uint64_t header_len = pn_offset + pkn_len;
if (header_len > sizeof(header)) return false; // not likely header will be so large if (header_len > sizeof(header)) return false; // not likely header will be so large
memcpy(header, data, header_len); memcpy(header, data, header_len);
header[0] = packet0; header[0] = packet0;
@@ -969,21 +960,19 @@ bool QUICExtractHostFromInitial(const uint8_t *data, size_t data_len, char *host
bool IsQUICInitial(const uint8_t *data, size_t len) bool IsQUICInitial(const uint8_t *data, size_t len)
{ {
// too small packets are not likely to be initials with client hello // too small packets are not likely to be initials
// long header, fixed bit // long header, fixed bit
if (len < 256 || (data[0] & 0xC0)!=0xC0) return false; if (len < 128) return false;
uint32_t ver = QUICExtractVersion(data,len); uint32_t ver = QUICExtractVersion(data,len);
if (QUICDraftVersion(ver) < 11) return false; if (QUICDraftVersion(ver) < 11) return false;
// quic v1 : initial packets are 00b if ((data[0] & 0xF0) != (is_quic_v2(ver) ? 0xD0 : 0xC0)) return false;
// quic v2 : initial packets are 01b
if ((data[0] & 0x30) != (is_quic_v2(ver) ? 0x10 : 0x00)) return false;
uint64_t offset=5, sz; uint64_t offset=5, sz, sz2;
// DCID. must be present // DCID
if (!data[offset] || data[offset] > QUIC_MAX_CID_LENGTH) return false; if (data[offset] > QUIC_MAX_CID_LENGTH) return false;
offset += 1 + data[offset]; offset += 1 + data[offset];
// SCID // SCID
@@ -991,18 +980,19 @@ bool IsQUICInitial(const uint8_t *data, size_t len)
offset += 1 + data[offset]; offset += 1 + data[offset];
// token length // token length
if (offset>=len || (offset + tvb_get_size(data[offset])) > len) return false;
offset += tvb_get_varint(data + offset, &sz); offset += tvb_get_varint(data + offset, &sz);
offset += sz; offset += sz;
if (offset >= len) return false; if (offset >= len) return false;
// payload length // payload length
if ((offset + tvb_get_size(data[offset])) > len) return false; sz2 = tvb_get_size(data[offset]);
if ((offset + sz2) > len) return false;
tvb_get_varint(data + offset, &sz); tvb_get_varint(data + offset, &sz);
offset += sz; offset += sz2 + sz;
if (offset > len) return false; if (offset > len) return false;
// client hello cannot be too small. likely ACK return true;
return sz>=96;
} }
@@ -1027,7 +1017,7 @@ bool IsStunMessage(const uint8_t *data, size_t len)
{ {
return len>=20 && // header size return len>=20 && // header size
(data[0]&0xC0)==0 && // 2 most significant bits must be zeroes (data[0]&0xC0)==0 && // 2 most significant bits must be zeroes
(data[3]&0b11)==0 && // length must be a multiple of 4 (data[3]&3)==0 && // length must be a multiple of 4
ntohl(*(uint32_t*)(&data[4]))==0x2112A442 && // magic cookie pntoh32(data+4)==0x2112A442 && // magic cookie
ntohs(*(uint16_t*)(&data[2]))==len-20; pntoh16(data+2)<=(len-20);
} }
+23
View File
@@ -18,6 +18,25 @@ bool dropcaps(void);
#define arch_nr (offsetof(struct seccomp_data, arch)) #define arch_nr (offsetof(struct seccomp_data, arch))
#define syscall_arg(x) (offsetof(struct seccomp_data, args[x])) #define syscall_arg(x) (offsetof(struct seccomp_data, args[x]))
#ifndef __AUDIT_ARCH_64BIT
#define __AUDIT_ARCH_64BIT 0x80000000
#endif
#ifndef __AUDIT_ARCH_LE
#define __AUDIT_ARCH_LE 0x40000000
#endif
#ifndef EM_RISCV
#define EM_RISCV 243
#endif
#ifndef AUDIT_ARCH_RISCV64
#define AUDIT_ARCH_RISCV64 (EM_RISCV | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
#ifndef EM_LOONGARCH
#define EM_LOONGARCH 258
#endif
#ifndef AUDIT_ARCH_LOONGARCH64
#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
#if defined(__aarch64__) #if defined(__aarch64__)
# define ARCH_NR AUDIT_ARCH_AARCH64 # define ARCH_NR AUDIT_ARCH_AARCH64
@@ -72,6 +91,10 @@ bool dropcaps(void);
# define ARCH_NR AUDIT_ARCH_RISCV64 # define ARCH_NR AUDIT_ARCH_RISCV64
#elif defined(__loongarch__) && __loongarch_grlen == 64
# define ARCH_NR AUDIT_ARCH_LOONGARCH64
#else #else
# error "Platform does not support seccomp filter yet" # error "Platform does not support seccomp filter yet"
+23
View File
@@ -20,6 +20,25 @@ bool dropcaps(void);
#define arch_nr (offsetof(struct seccomp_data, arch)) #define arch_nr (offsetof(struct seccomp_data, arch))
#define syscall_arg(x) (offsetof(struct seccomp_data, args[x])) #define syscall_arg(x) (offsetof(struct seccomp_data, args[x]))
#ifndef __AUDIT_ARCH_64BIT
#define __AUDIT_ARCH_64BIT 0x80000000
#endif
#ifndef __AUDIT_ARCH_LE
#define __AUDIT_ARCH_LE 0x40000000
#endif
#ifndef EM_RISCV
#define EM_RISCV 243
#endif
#ifndef AUDIT_ARCH_RISCV64
#define AUDIT_ARCH_RISCV64 (EM_RISCV | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
#ifndef EM_LOONGARCH
#define EM_LOONGARCH 258
#endif
#ifndef AUDIT_ARCH_LOONGARCH64
#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
#if defined(__aarch64__) #if defined(__aarch64__)
# define ARCH_NR AUDIT_ARCH_AARCH64 # define ARCH_NR AUDIT_ARCH_AARCH64
@@ -74,6 +93,10 @@ bool dropcaps(void);
# define ARCH_NR AUDIT_ARCH_RISCV64 # define ARCH_NR AUDIT_ARCH_RISCV64
#elif defined(__loongarch__) && __loongarch_grlen == 64
# define ARCH_NR AUDIT_ARCH_LOONGARCH64
#else #else
# error "Platform does not support seccomp filter yet" # error "Platform does not support seccomp filter yet"