Browse Source

blockcheck: working strategies intersection print for multiple domains

master
bol-van 5 days ago
parent
commit
aa4982a526
  1. 71
      blockcheck.sh
  2. 9
      common/base.sh
  3. 1
      docs/changes.txt

71
blockcheck.sh

@ -1097,7 +1097,7 @@ tpws_curl_test()
shift; shift; shift; shift;
strategy="$@" strategy="$@"
strategy_append_extra_tpws strategy_append_extra_tpws
report_append "ipv${IPV} $dom $testf : tpws ${WF:+$WF }$strategy" report_append "$dom" "$testf ipv${IPV}" "tpws ${WF:+$WF }$strategy"
} }
return $code return $code
} }
@ -1116,7 +1116,7 @@ pktws_curl_test()
[ "$code" = 0 ] && { [ "$code" = 0 ] && {
strategy="$@" strategy="$@"
strategy_append_extra_pktws strategy_append_extra_pktws
report_append "ipv${IPV} $dom $testf : $PKTWSD ${WF:+$WF }$strategy" report_append "$dom" "$testf ipv${IPV}" "$PKTWSD ${WF:+$WF }$strategy"
} }
return $code return $code
} }
@ -1156,8 +1156,35 @@ tpws_curl_test_update()
report_append() report_append()
{ {
# $1 - domain
# $2 - test function + ipver
# $3 - value
local hashstr hash hashvar hashcountvar val ct
# save resources if only one domain
[ "$DOMAINS_COUNT" -gt 1 ] && {
hashstr="$2 : $3"
hash="$(echo -n "$hashstr" | md5)"
hashvar=RESHASH_${hash}
hashcountvar=${hashvar}_COUNTER
NRESHASH=${NRESHASH:-0}
eval val="\$$hashvar"
if [ -n "$val" ]; then
eval ct="\$$hashcountvar"
ct=$(($ct + 1))
eval $hashcountvar="\$ct"
else
eval $hashvar=\"$hashstr\"
eval $hashcountvar=1
eval RES_$NRESHASH="\$hash"
NRESHASH=$(($NRESHASH+1))
fi
}
NREPORT=${NREPORT:-0} NREPORT=${NREPORT:-0}
eval REPORT_${NREPORT}=\"$@\" eval REPORT_${NREPORT}=\"$2 $1 : $3\"
NREPORT=$(($NREPORT+1)) NREPORT=$(($NREPORT+1))
} }
report_print() report_print()
@ -1170,6 +1197,22 @@ report_print()
n=$(($n+1)) n=$(($n+1))
done done
} }
result_intersection_print()
{
local n=0 hash hashvar hashcountvar ct val
while : ; do
eval hash=\"\$RES_$n\"
[ -n "$hash" ] || break
hashvar=RESHASH_${hash}
hashcountvar=${hashvar}_COUNTER
eval ct=\"\$$hashcountvar\"
[ "$ct" = "$DOMAINS_COUNT" ] && {
eval val=\"\$$hashvar\"
echo "$val"
}
n=$(($n + 1))
done
}
report_strategy() report_strategy()
{ {
# $1 - test function # $1 - test function
@ -1181,12 +1224,11 @@ report_strategy()
strategy="$(echo "$strategy" | xargs)" strategy="$(echo "$strategy" | xargs)"
echo "!!!!! $1: working strategy found for ipv${IPV} $2 : $3 $strategy !!!!!" echo "!!!!! $1: working strategy found for ipv${IPV} $2 : $3 $strategy !!!!!"
echo echo
# report_append "ipv${IPV} $2 $1 : $3 ${WF:+$WF }$strategy"
return 0 return 0
else else
echo "$1: $3 strategy for ipv${IPV} $2 not found" echo "$1: $3 strategy for ipv${IPV} $2 not found"
echo echo
report_append "ipv${IPV} $2 $1 : $3 not working" report_append "$2" "$1 ipv${IPV}" "$3 not working"
return 1 return 1
fi fi
} }
@ -1675,17 +1717,19 @@ check_domain_prolog()
local code local code
[ "$SIMULATE" = 1 ] && return 0
echo echo
echo \* $1 ipv$IPV $3 echo \* $1 ipv$IPV $3
echo "- checking without DPI bypass" echo "- checking without DPI bypass"
curl_test $1 $3 && { curl_test $1 $3 && {
report_append "ipv${IPV} $3 $1 : working without bypass" report_append "$3" "$1 ipv${IPV}" "working without bypass"
[ "$SCANLEVEL" = force ] || return 1 [ "$SCANLEVEL" = force ] || return 1
} }
code=$? code=$?
curl_has_reason_to_continue $code || { curl_has_reason_to_continue $code || {
report_append "ipv${IPV} $3 $1 : test aborted, no reason to continue. curl code $(curl_translate_code $code)" report_append "$3" "$1 ipv${IPV}" "test aborted, no reason to continue. curl code $(curl_translate_code $code)"
return 1 return 1
} }
return 0 return 0
@ -1869,6 +1913,7 @@ ask_params()
[ -n "$dom" ] && DOMAINS="$dom" [ -n "$dom" ] && DOMAINS="$dom"
} }
} }
DOMAINS_COUNT="$(echo "$DOMAINS" | wc -w | trim)"
local IPVS_def=4 local IPVS_def=4
[ -n "$IPVS" ] || { [ -n "$IPVS" ] || {
@ -2248,6 +2293,18 @@ cleanup
echo echo
echo \* SUMMARY echo \* SUMMARY
report_print report_print
[ "$DOMAINS_COUNT" -gt 1 ] && {
echo
echo \* COMMON
result_intersection_print
echo
[ "$SCANLEVEL" = force ] || {
echo "blockcheck optimizes test sequence. To save time some strategies can be skipped if their test is considered useless."
echo "That's why COMMON intersection can miss strategies that would work for all domains."
echo "Use \"force\" scan level to test all strategies and generate trustable intersection."
echo "Current scan level was \"$SCANLEVEL\"".
}
}
echo echo
echo "Please note this SUMMARY does not guarantee a magic pill for you to copy/paste and be happy." echo "Please note this SUMMARY does not guarantee a magic pill for you to copy/paste and be happy."
echo "Understanding how strategies work is very desirable." echo "Understanding how strategies work is very desirable."

9
common/base.sh

@ -318,6 +318,12 @@ setup_md5()
exists $MD5 || MD5=md5 exists $MD5 || MD5=md5
} }
md5()
{
setup_md5
$MD5 | cut -d ' ' -f1
}
setup_random() setup_random()
{ {
[ -n "$RCUT" ] && return [ -n "$RCUT" ] && return
@ -330,7 +336,6 @@ random()
{ {
# $1 - min, $2 - max # $1 - min, $2 - max
local r rs local r rs
setup_md5
setup_random setup_random
if [ -c /dev/urandom ]; then if [ -c /dev/urandom ]; then
read rs </dev/urandom read rs </dev/urandom
@ -338,7 +343,7 @@ random()
rs="$RANDOM$RANDOM$(date)" rs="$RANDOM$RANDOM$(date)"
fi fi
# shells use signed int64 # shells use signed int64
r=1$(echo $rs | $MD5 | sed 's/[^0-9]//g' | $RCUT) r=1$(echo $rs | md5 | sed 's/[^0-9]//g' | $RCUT)
echo $(( ($r % ($2-$1+1)) + $1 )) echo $(( ($r % ($2-$1+1)) + $1 ))
} }

1
docs/changes.txt

@ -548,3 +548,4 @@ winws: --wf-raw-part
nfqws: --dpi-desync=hostfakesplit nfqws: --dpi-desync=hostfakesplit
blockcheck: new strategies blockcheck: new strategies
blockcheck: curl test simulation : SIMULATE=1 blockcheck: curl test simulation : SIMULATE=1
blockcheck: print strategies that work for all tested domains. can be trusted only if SCANLEVEL=force.

Loading…
Cancel
Save