├── README.md ├── checkers ├── check_instagram.sh ├── ip_quality.sh ├── service_availability.sh └── tiktok_region.sh └── speedtest └── countries └── speedtest_ru.sh /README.md: -------------------------------------------------------------------------------- 1 | # server-scripts 2 | 3 | Speedtest for Russian regions: 4 | ``` 5 | wget -qO- https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/speedtest/countries/speedtest_ru.sh | bash 6 | ``` 7 | 8 | IP quality: 9 | ``` 10 | bash <(curl -sL https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/checkers/ip_quality.sh) 11 | ``` 12 | Check the availability of services: 13 | ``` 14 | bash <(curl -sL https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/checkers/service_availability.sh) 15 | ``` 16 | Check Instagram availability 17 | ``` 18 | bash <(curl -sL https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/checkers/check_instagram.sh) 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /checkers/check_instagram.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | shopt -s expand_aliases 3 | 4 | Font_Red="\033[1;31m" 5 | Font_Green="\033[1;32m" 6 | Font_Yellow="\033[1;33m" 7 | Font_Blue="\e[1;34m" 8 | Font_Purple="\033[1;35m" 9 | Font_SkyBlue="\e[1;34m" 10 | Font_White="\e[1;37m" 11 | Font_Suffix="\033[0m" 12 | 13 | 14 | while getopts ":I:M:EX:P:" optname; do 15 | case "$optname" in 16 | "I") 17 | iface="$OPTARG" 18 | useNIC="--interface $iface" 19 | ;; 20 | "M") 21 | if [[ "$OPTARG" == "4" ]]; then 22 | NetworkType=4 23 | elif [[ "$OPTARG" == "6" ]]; then 24 | NetworkType=6 25 | fi 26 | ;; 27 | "E") 28 | language="e" 29 | ;; 30 | "X") 31 | XIP="$OPTARG" 32 | xForward="--header X-Forwarded-For:$XIP" 33 | ;; 34 | "P") 35 | proxy="$OPTARG" 36 | usePROXY="-x $proxy" 37 | ;; 38 | ":") 39 | echo "Unknown error while processing options" 40 | exit 1 41 | ;; 42 | esac 43 | 44 | done 45 | 46 | if [ -z "$iface" ]; then 47 | useNIC="" 48 | fi 49 | 50 | if [ -z "$XIP" ]; then 51 | xForward="" 52 | fi 53 | 54 | if [ -z "$proxy" ]; then 55 | usePROXY="" 56 | elif [ -n "$proxy" ]; then 57 | NetworkType=4 58 | fi 59 | 60 | if ! mktemp -u --suffix=RRC &>/dev/null; then 61 | is_busybox=1 62 | fi 63 | 64 | UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36" 65 | UA_Dalvik="Dalvik/2.1.0 (Linux; U; Android 9; ALP-AL00 Build/HUAWEIALP-AL00)" 66 | Media_Cookie=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/cookies") 67 | IATACode=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/reference/IATACode.txt") 68 | IATACode2=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/reference/IATACode2.txt" 2>&1) 69 | TVer_Cookie="Accept: application/json;pk=BCpkADawqM0_rzsjsYbC1k1wlJLU4HiAtfzjxdUmfvvLUQB-Ax6VA-p-9wOEZbCEm3u95qq2Y1CQQW1K9tPaMma9iAqUqhpISCmyXrgnlpx9soEmoVNuQpiyGsTpePGumWxSs1YoKziYB6Wz" 70 | 71 | 72 | checkOS() { 73 | ifTermux=$(echo $PWD | grep termux) 74 | ifMacOS=$(uname -a | grep Darwin) 75 | if [ -n "$ifTermux" ]; then 76 | os_version=Termux 77 | is_termux=1 78 | elif [ -n "$ifMacOS" ]; then 79 | os_version=MacOS 80 | is_macos=1 81 | else 82 | os_version=$(grep 'VERSION_ID' /etc/os-release | cut -d '"' -f 2 | tr -d '.') 83 | fi 84 | 85 | if [[ "$os_version" == "2004" ]] || [[ "$os_version" == "10" ]] || [[ "$os_version" == "11" ]]; then 86 | is_windows=1 87 | ssll="-k --ciphers DEFAULT@SECLEVEL=1" 88 | fi 89 | 90 | if [ "$(which apt 2>/dev/null)" ]; then 91 | InstallMethod="apt" 92 | is_debian=1 93 | elif [ "$(which dnf 2>/dev/null)" ] || [ "$(which yum 2>/dev/null)" ]; then 94 | InstallMethod="yum" 95 | is_redhat=1 96 | elif [[ "$os_version" == "Termux" ]]; then 97 | InstallMethod="pkg" 98 | elif [[ "$os_version" == "MacOS" ]]; then 99 | InstallMethod="brew" 100 | fi 101 | } 102 | checkOS 103 | 104 | checkCPU() { 105 | CPUArch=$(uname -m) 106 | if [[ "$CPUArch" == "aarch64" ]]; then 107 | arch=_arm64 108 | elif [[ "$CPUArch" == "i686" ]]; then 109 | arch=_i686 110 | elif [[ "$CPUArch" == "arm" ]]; then 111 | arch=_arm 112 | elif [[ "$CPUArch" == "x86_64" ]] && [ -n "$ifMacOS" ]; then 113 | arch=_darwin 114 | fi 115 | } 116 | checkCPU 117 | 118 | checkDependencies() { 119 | 120 | # os_detail=$(cat /etc/os-release 2> /dev/null) 121 | 122 | if ! command -v python &>/dev/null; then 123 | if command -v python3 &>/dev/null; then 124 | alias python="python3" 125 | else 126 | if [ "$is_debian" == 1 ]; then 127 | echo -e "${Font_Green}Installing python${Font_Suffix}" 128 | $InstallMethod update >/dev/null 2>&1 129 | $InstallMethod install python -y >/dev/null 2>&1 130 | elif [ "$is_redhat" == 1 ]; then 131 | echo -e "${Font_Green}Installing python${Font_Suffix}" 132 | if [[ "$os_version" -gt 7 ]]; then 133 | $InstallMethod makecache >/dev/null 2>&1 134 | $InstallMethod install python3 -y >/dev/null 2>&1 135 | alias python="python3" 136 | else 137 | $InstallMethod makecache >/dev/null 2>&1 138 | $InstallMethod install python -y >/dev/null 2>&1 139 | fi 140 | 141 | elif [ "$is_termux" == 1 ]; then 142 | echo -e "${Font_Green}Installing python${Font_Suffix}" 143 | $InstallMethod update -y >/dev/null 2>&1 144 | $InstallMethod install python -y >/dev/null 2>&1 145 | 146 | elif [ "$is_macos" == 1 ]; then 147 | echo -e "${Font_Green}Installing python${Font_Suffix}" 148 | $InstallMethod install python 149 | fi 150 | fi 151 | fi 152 | 153 | if ! command -v dig &>/dev/null; then 154 | if [ "$is_debian" == 1 ]; then 155 | echo -e "${Font_Green}Installing dnsutils${Font_Suffix}" 156 | $InstallMethod update >/dev/null 2>&1 157 | $InstallMethod install dnsutils -y >/dev/null 2>&1 158 | elif [ "$is_redhat" == 1 ]; then 159 | echo -e "${Font_Green}Installing bind-utils${Font_Suffix}" 160 | $InstallMethod makecache >/dev/null 2>&1 161 | $InstallMethod install bind-utils -y >/dev/null 2>&1 162 | elif [ "$is_termux" == 1 ]; then 163 | echo -e "${Font_Green}Installing dnsutils${Font_Suffix}" 164 | $InstallMethod update -y >/dev/null 2>&1 165 | $InstallMethod install dnsutils -y >/dev/null 2>&1 166 | elif [ "$is_macos" == 1 ]; then 167 | echo -e "${Font_Green}Installing bind${Font_Suffix}" 168 | $InstallMethod install bind 169 | fi 170 | fi 171 | 172 | if [ "$is_macos" == 1 ]; then 173 | if ! command -v md5sum &>/dev/null; then 174 | echo -e "${Font_Green}Installing md5sha1sum${Font_Suffix}" 175 | $InstallMethod install md5sha1sum 176 | fi 177 | fi 178 | 179 | } 180 | 181 | checkDependencies 182 | 183 | local_ipv4=$(curl $useNIC $usePROXY -4 -s --max-time 10 api64.ipify.org) 184 | local_ipv4_asterisk=$(awk -F"." '{print $1"."$2".*.*"}' <<<"${local_ipv4}") 185 | local_ipv6=$(curl $useNIC -6 -s --max-time 20 api64.ipify.org) 186 | local_ipv6_asterisk=$(awk -F":" '{print $1":"$2":"$3":*:*"}' <<<"${local_ipv6}") 187 | local_isp4=$(curl $useNIC -s -4 --max-time 10 --user-agent "${UA_Browser}" "https://api.ip.sb/geoip/${local_ipv4}" | grep organization | cut -f4 -d '"') 188 | local_isp6=$(curl $useNIC -s -6 --max-time 10 --user-agent "${UA_Browser}" "https://api.ip.sb/geoip/${local_ipv6}" | grep organization | cut -f4 -d '"') 189 | 190 | ShowRegion() { 191 | echo -e "${Font_Yellow} ---${1}---${Font_Suffix}" 192 | } 193 | 194 | 195 | function MediaUnlockTest_Instagram.Music() { 196 | local videos=("C2YEAdOh9AB" "Cx_DE0ZI1xc" "CyERUKpIS7Q" "C0Y6l7qrfi-" "CrfV3RxgKYl" "C2u22AltQEu") 197 | 198 | for INST_VIDEO in "${videos[@]}" 199 | do 200 | local result=$(curl $useNIC $usePROXY $xForward -${1} ${ssll} -s --max-time 10 'https://www.instagram.com/api/graphql' \ 201 | --header 'Accept: */*' \ 202 | --header 'Accept-Language: ru-RU,zh;q=0.9' \ 203 | --header 'Connection: keep-alive' \ 204 | --header 'Content-Type: application/x-www-form-urlencoded' \ 205 | --header 'Cookie: csrftoken=mmCtHhtfZRG-K3WgoYMemg; dpr=1.75; _js_ig_did=809EA442-22F7-4844-9470-ABC2AC4DE7AE; _js_datr=rb21ZbL7KR_5DN8m_43oEtgn; mid=ZbW9rgALAAECR590Ukv8bAlT8YQX; ig_did=809EA442-22F7-4844-9470-ABC2AC4DE7AE; ig_nrcb=1; datr=rb21ZbL7KR_5DN8m_43oEtgn; ig_did=809EA442-22F7-4844-9470-ABC2AC4DE7AE; csrftoken=OfOpK-7wFiuOiMPkuVwKzf; datr=rb21ZbL7KR_5DN8m_43oEtgn; ig_did=809EA442-22F7-4844-9470-ABC2AC4DE7AE' \ 206 | --header 'Origin: https://www.instagram.com' \ 207 | --header 'Referer: https://www.instagram.com/p/${INST_VIDEO}/' \ 208 | --header 'Sec-Fetch-Dest: empty' \ 209 | --header 'Sec-Fetch-Mode: cors' \ 210 | --header 'Sec-Fetch-Site: same-origin' \ 211 | --header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \ 212 | --header 'X-ASBD-ID: 129477' \ 213 | --header 'X-CSRFToken: mmCtHhtfZRG-K3WgoYMemg' \ 214 | --header 'X-FB-Friendly-Name: PolarisPostActionLoadPostQueryQuery' \ 215 | --header 'X-FB-LSD: AVrkL73GMdk' \ 216 | --header 'X-IG-App-ID: 936619743392459' \ 217 | --header 'dpr: 1.75' \ 218 | --header 'sec-ch-prefers-color-scheme: light' \ 219 | --header 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \ 220 | --header 'sec-ch-ua-full-version-list: "Not_A Brand";v="8.0.0.0", "Chromium";v="120.0.6099.225", "Google Chrome";v="120.0.6099.225"' \ 221 | --header 'sec-ch-ua-mobile: ?0' \ 222 | --header 'sec-ch-ua-model: ""' \ 223 | --header 'sec-ch-ua-platform: "Windows"' \ 224 | --header 'sec-ch-ua-platform-version: "10.0.0"' \ 225 | --header 'viewport-width: 1640' \ 226 | --data-urlencode 'av=0' \ 227 | --data-urlencode '__d=www' \ 228 | --data-urlencode '__user=0' \ 229 | --data-urlencode '__a=1' \ 230 | --data-urlencode '__req=3' \ 231 | --data-urlencode '__hs=19750.HYP:instagram_web_pkg.2.1..0.0' \ 232 | --data-urlencode 'dpr=1' \ 233 | --data-urlencode '__ccg=UNKNOWN' \ 234 | --data-urlencode '__rev=1011068636' \ 235 | --data-urlencode '__s=drshru:gu4p3s:0d8tzk' \ 236 | --data-urlencode '__hsi=7328972521009111950' \ 237 | --data-urlencode '__dyn=7xeUjG1mxu1syUbFp60DU98nwgU29zEdEc8co2qwJw5ux609vCwjE1xoswIwuo2awlU-cw5Mx62G3i1ywOwv89k2C1Fwc60AEC7U2czXwae4UaEW2G1NwwwNwKwHw8Xxm16wUwtEvw4JwJCwLyES1Twoob82ZwrUdUbGwmk1xwmo6O1FwlE6PhA6bxy4UjK5V8' \ 238 | --data-urlencode '__csr=gtneJ9lGF4HlRX-VHjmipBDGAhGuWV4uEyXyp22u6pU-mcx3BCGjHS-yabGq4rhoWBAAAKamtnBy8PJeUgUymlVF48AGGWxCiUC4E9HG78og01bZqx106Ag0clE0kVwdy0Nx4w2TU0iGDgChwmUrw2wVFQ9Bg3fw4uxfo2ow0asW' \ 239 | --data-urlencode '__comet_req=7' \ 240 | --data-urlencode 'lsd=AVrkL73GMdk' \ 241 | --data-urlencode 'jazoest=2909' \ 242 | --data-urlencode '__spin_r=1011068636' \ 243 | --data-urlencode '__spin_b=trunk' \ 244 | --data-urlencode '__spin_t=1706409389' \ 245 | --data-urlencode 'fb_api_caller_class=RelayModern' \ 246 | --data-urlencode 'fb_api_req_friendly_name=PolarisPostActionLoadPostQueryQuery' \ 247 | --data-urlencode 'variables={"shortcode":"'"$INST_VIDEO"'","fetch_comment_count":40,"fetch_related_profile_media_count":3,"parent_comment_count":24,"child_comment_count":3,"fetch_like_count":10,"fetch_tagged_user_count":null,"fetch_preview_comment_count":2,"has_threaded_comments":true,"hoisted_comment_id":null,"hoisted_reply_id":null}' \ 248 | --data-urlencode 'server_timestamps=true' \ 249 | --data-urlencode 'doc_id=10015901848480474') 250 | 251 | 252 | local should_mute_audio=$(echo "$result" | grep -oP '"should_mute_audio":\K(false|true)') 253 | local mute_reason=$(echo "$result" | grep -o -P '(?<="should_mute_audio_reason":")[^"]*') 254 | 255 | echo -n -e " Instagram Licensed Audio:\t\t->\c" 256 | if [[ "$should_mute_audio" == "false" ]]; then 257 | echo -n -e "\r Instagram Licensed Audio (${INST_VIDEO}):\t${Font_Green}Yes${Font_Suffix}\n" 258 | elif [[ "$should_mute_audio" == "true" ]]; then 259 | if [[ -n "$mute_reason" ]]; then 260 | echo -n -e "\r Instagram Licensed Audio (${INST_VIDEO}):\t${Font_Red}No (${mute_reason})${Font_Suffix}\n" 261 | else 262 | echo -n -e "\r Instagram Licensed Audio (${INST_VIDEO}):\t${Font_Red}No${Font_Suffix}\n" 263 | fi 264 | else 265 | echo -n -e "\r Instagram Licensed Audio (${INST_VIDEO}):\t${Font_Red}Failed${Font_Suffix}\n" 266 | fi 267 | 268 | done 269 | } 270 | 271 | 272 | function echo_Result() { 273 | for((i=0;i<${#array[@]};i++)) 274 | do 275 | echo "$result" | grep "${array[i]}" 276 | sleep 0.03 277 | done; 278 | } 279 | 280 | function Global_UnlockTest() { 281 | echo "" 282 | echo "============[ INSTAGRAM ТЕСТ ]============" 283 | local result=$(MediaUnlockTest_Instagram.Music ${1}) 284 | wait 285 | local array=("Instagram Licensed Audio:") 286 | echo_Result <<< "$result" "${array[@]}" 287 | echo "=======================================" 288 | } 289 | 290 | function CheckV4() { 291 | if [[ "$NetworkType" == "6" ]]; then 292 | isv4=0 293 | else 294 | echo -e " ${Font_Yellow}** Результаты проверки для IPv4${Font_Suffix} " 295 | check4=$(ping 1.1.1.1 -c 1 2>&1) 296 | echo "--------------------------------" 297 | echo -e " ${Font_Yellow}** Ваш хостинг-провайдер: ${local_isp4} (${local_ipv4_asterisk})${Font_Suffix} " 298 | ip_info=$(curl -sS "https://ipinfo.io/json") 299 | country=$(echo "$ip_info" | awk -F'"' '/country/ {print $4}') 300 | city=$(echo "$ip_info" | awk -F'"' '/city/ {print $4}') 301 | asn=$(echo "$ip_info" | awk -F'"' '/org/ {print $4}') 302 | echo -e " ${Font_Yellow}"Страна: $country"${Font_Suffix}" 303 | echo -e " ${Font_Yellow}"Город: $city"${Font_Suffix}" 304 | echo -e " ${Font_Yellow}"ASN: $asn"${Font_Suffix}" 305 | 306 | if [[ "$check4" != *"unreachable"* ]] && [[ "$check4" != *"Unreachable"* ]]; then 307 | isv4=1 308 | else 309 | echo "" 310 | echo -e "${Font_Yellow}IPv4 не обнаружен, отмена IPv4 проверки...${Font_Suffix}" 311 | isv4=0 312 | fi 313 | 314 | echo "" 315 | fi 316 | } 317 | 318 | 319 | function CheckV6() { 320 | if [[ "$NetworkType" == "4" ]]; then 321 | isv6=0 322 | else 323 | check6_1=$(curl $useNIC -fsL --write-out %{http_code} --output /dev/null --max-time 10 ipv6.google.com) 324 | check6_2=$(curl $useNIC -fsL --write-out %{http_code} --output /dev/null --max-time 10 ipv6.ip.sb) 325 | if [[ "$check6_1" -ne "000" ]] || [[ "$check6_2" -ne "000" ]]; then 326 | echo "" 327 | echo "" 328 | echo -e " ${Font_Yellow}** Результаты проверки для IPv6${Font_Suffix} " 329 | echo "--------------------------------" 330 | echo -e " ${Font_Yellow}** Ваш хостинг-провайдер: ${local_isp6} (${local_ipv6_asterisk})${Font_Suffix} " 331 | isv6=1 332 | else 333 | echo "" 334 | echo -e "${Font_Yellow}IPv6 не обнаружен, отмена IPv6 проверки...${Font_Suffix}" 335 | isv6=0 336 | fi 337 | echo -e "" 338 | fi 339 | } 340 | 341 | function Goodbye() { 342 | echo "" 343 | echo -e "${Font_Yellow}Тест завершен! ${Font_Suffix}" 344 | } 345 | 346 | clear 347 | 348 | function ScriptTitle() { 349 | echo -e " ${Font_Purple}[Тест для проверки Instagram]${Font_Suffix} " 350 | echo "" 351 | } 352 | 353 | function RunScript() { 354 | clear 355 | ScriptTitle 356 | CheckV4 357 | if [[ "$isv4" -eq 1 ]]; then 358 | Global_UnlockTest 4 359 | fi 360 | CheckV6 361 | if [[ "$isv6" -eq 1 ]]; then 362 | Global_UnlockTest 6 363 | fi 364 | Goodbye 365 | } 366 | 367 | RunScript 368 | -------------------------------------------------------------------------------- /checkers/ip_quality.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: xykt 3 | # Source of the script: https://ip.check.place 4 | 5 | script_version="v2024-11-09" 6 | ADLines=25 7 | check_bash(){ 8 | current_bash_version=$(bash --version | head -n 1 | awk -F ' ' '{for (i=1; i<=NF; i++) if ($i ~ /^[0-9]+\.[0-9]+\.[0-9]+/) {print $i; exit}}' | cut -d . -f 1) 9 | if [ "$current_bash_version" = "0" ]||[ "$current_bash_version" = "1" ]||[ "$current_bash_version" = "2" ]||[ "$current_bash_version" = "3" ];then 10 | echo "ERROR: Bash version is lower than 4.0!" 11 | echo "Tips: Run the following script to automatically upgrade Bash." 12 | echo "bash <(curl -sL https://raw.githubusercontent.com/xykt/IPQuality/main/ref/upgrade_bash.sh)" 13 | exit 0 14 | fi 15 | } 16 | check_bash 17 | Font_B="\033[1m" 18 | Font_D="\033[2m" 19 | Font_I="\033[3m" 20 | Font_U="\033[4m" 21 | Font_Black="\033[30m" 22 | Font_Red="\033[31m" 23 | Font_Green="\033[32m" 24 | Font_Yellow="\033[33m" 25 | Font_Blue="\033[34m" 26 | Font_Purple="\033[35m" 27 | Font_Cyan="\033[36m" 28 | Font_White="\033[37m" 29 | Back_Black="\033[40m" 30 | Back_Red="\033[41m" 31 | Back_Green="\033[42m" 32 | Back_Yellow="\033[43m" 33 | Back_Blue="\033[44m" 34 | Back_Purple="\033[45m" 35 | Back_Cyan="\033[46m" 36 | Back_White="\033[47m" 37 | Font_Suffix="\033[0m" 38 | Font_LineClear="\033[2K" 39 | Font_LineUp="\033[1A" 40 | declare IP="" 41 | declare IPhide 42 | declare fullIP=0 43 | declare LANG="en" 44 | declare -A maxmind 45 | declare -A ipinfo 46 | declare -A scamalytics 47 | declare -A ipregistry 48 | declare -A ipapi 49 | declare -A abuseipdb 50 | declare -A ip2location 51 | declare -A dbip 52 | declare -A ipwhois 53 | declare -A ipdata 54 | declare -A ipqs 55 | declare -A cloudflare 56 | declare -A tiktok 57 | declare -A disney 58 | declare -A netflix 59 | declare -A youtube 60 | declare -A amazon 61 | declare -A spotify 62 | declare -A chatgpt 63 | declare IPV4 64 | declare IPV6 65 | declare IPV4check=1 66 | declare IPV6check=1 67 | declare IPV4work=0 68 | declare IPV6work=0 69 | declare ERRORcode=0 70 | declare asponsor 71 | declare aad1 72 | declare shelp 73 | declare -A swarn 74 | declare -A sinfo 75 | declare -A shead 76 | declare -A sbasic 77 | declare -A stype 78 | declare -A sscore 79 | declare -A sfactor 80 | declare -A smedia 81 | declare -A smail 82 | declare -A stail 83 | declare ibar=0 84 | declare bar_pid 85 | declare ibar_step=0 86 | declare main_pid=$$ 87 | declare PADDING="" 88 | declare useNIC="" 89 | declare usePROXY="" 90 | declare CurlARG="" 91 | declare UA_Browser 92 | declare Media_Cookie=$(curl $CurlARG -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/xykt/IPQuality/main/ref/cookies.txt") 93 | declare IATA_Database="https://raw.githubusercontent.com/xykt/IPQuality/main/ref/iata-icao.csv" 94 | shelp_lines=( 95 | "IP QUALITY CHECK SCRIPT" 96 | "Usage: bash <(curl -sL https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/checkers/ip_quality.sh) [-4] [-6] [-f] [-h] [-i eth0] [-l cn|en|jp|es|de|fr|ru|pt] [-x http://usr:pwd@proxyurl:p]" 97 | " -4 Test IPv4" 98 | " -6 Test IPv6" 99 | " -f Show full IP on reports" 100 | " -h Help information" 101 | " -i eth0 Specify network interface" 102 | " -l cn|en|jp|es|de|fr|ru|pt Specify script language" 103 | " -x http://usr:pwd@proxyurl:p Specify http proxy" 104 | " -x https://usr:pwd@proxyurl:p Specify https proxy" 105 | " -x socks5://usr:pwd@proxyurl:p Specify socks5 proxy") 106 | shelp=$(printf "%s\n" "${shelp_lines[@]}") 107 | set_language(){ 108 | case "$LANG" in 109 | "en"|"jp"|"es"|"de"|"fr"|"ru"|"pt")swarn[1]="ERROR: Unsupported parameters!" 110 | swarn[2]="ERROR: IP address format error!" 111 | swarn[3]="ERROR: Dependent programs are missing. Please run as root or install sudo!" 112 | swarn[4]="ERROR: Parameter -4 conflicts with -i or -6!" 113 | swarn[6]="ERROR: Parameter -6 conflicts with -i or -4!" 114 | swarn[7]="ERROR: The specified network interface is invalid or does not exist!" 115 | swarn[8]="ERROR: The specified proxy parameter is invalid or not working!" 116 | swarn[40]="ERROR: IPv4 is not available!" 117 | swarn[60]="ERROR: IPv6 is not available!" 118 | sinfo[database]="Checking IP database " 119 | sinfo[media]="Checking stream media " 120 | sinfo[ai]="Checking AI provider " 121 | sinfo[mail]="Connecting Email server " 122 | sinfo[dnsbl]="Checking Blacklist database " 123 | sinfo[ldatabase]=21 124 | sinfo[lmedia]=22 125 | sinfo[lai]=21 126 | sinfo[lmail]=24 127 | sinfo[ldnsbl]=28 128 | shead[title]="IP QUALITY CHECK REPORT: " 129 | shead[ver]="Version: $script_version" 130 | shead[bash]="bash <(curl -sL https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/checkers/ip_quality.sh)" 131 | shead[git]="https://github.com/jomertix/server-scripts" 132 | shead[time]=$(date -u +"Report Time: %Y-%m-%d %H:%M:%S UTC") 133 | shead[ltitle]=25 134 | shead[ptime]=$(printf '%7s' '') 135 | sbasic[title]="1. Basic Information (${Font_I}Maxmind Database$Font_Suffix)" 136 | sbasic[asn]="ASN: " 137 | sbasic[noasn]="Not Assigned" 138 | sbasic[org]="Organization: " 139 | sbasic[location]="Location: " 140 | sbasic[map]="Map: " 141 | sbasic[city]="City: " 142 | sbasic[country]="Actual Region: " 143 | sbasic[regcountry]="Registered Region: " 144 | sbasic[continent]="Continent: " 145 | sbasic[timezone]="Time Zone: " 146 | sbasic[type]="IP Type: " 147 | sbasic[type0]=" Geo-consistent " 148 | sbasic[type1]=" Geo-discrepant " 149 | stype[business]=" $Back_Yellow$Font_White$Font_B Business $Font_Suffix " 150 | stype[isp]=" $Back_Green$Font_White$Font_B ISP $Font_Suffix " 151 | stype[hosting]=" $Back_Red$Font_White$Font_B Hosting $Font_Suffix " 152 | stype[education]="$Back_Yellow$Font_White$Font_B Education $Font_Suffix " 153 | stype[government]="$Back_Yellow$Font_White$Font_B Government $Font_Suffix" 154 | stype[banking]=" $Back_Yellow$Font_White$Font_B Banking $Font_Suffix " 155 | stype[organization]="$Back_Yellow$Font_White${Font_B}Organization$Font_Suffix" 156 | stype[military]=" $Back_Yellow$Font_White$Font_B Military $Font_Suffix " 157 | stype[library]=" $Back_Yellow$Font_White$Font_B Library $Font_Suffix " 158 | stype[cdn]=" $Back_Red$Font_White$Font_B CDN $Font_Suffix " 159 | stype[lineisp]=" $Back_Green$Font_White$Font_B Line ISP $Font_Suffix " 160 | stype[mobile]="$Back_Green$Font_White$Font_B Mobile ISP $Font_Suffix" 161 | stype[spider]="$Back_Red$Font_White$Font_B Web Spider $Font_Suffix" 162 | stype[reserved]=" $Back_Yellow$Font_White$Font_B Reserved $Font_Suffix " 163 | stype[other]=" $Back_Yellow$Font_White$Font_B Other $Font_Suffix " 164 | stype[title]="2. IP Type" 165 | stype[db]="Database: " 166 | stype[usetype]="Usage: " 167 | stype[comtype]="Company: " 168 | sscore[verylow]="$Font_Green${Font_B}VeryLow$Font_Suffix" 169 | sscore[low]="$Font_Green${Font_B}Low$Font_Suffix" 170 | sscore[medium]="$Font_Yellow${Font_B}Medium$Font_Suffix" 171 | sscore[high]="$Font_Red${Font_B}High$Font_Suffix" 172 | sscore[veryhigh]="$Font_Red${Font_B}VeryHigh$Font_Suffix" 173 | sscore[elevated]="$Font_Yellow${Font_B}Elevated$Font_Suffix" 174 | sscore[suspicious]="$Font_Yellow${Font_B}Suspicious$Font_Suffix" 175 | sscore[risky]="$Font_Red${Font_B}Risky$Font_Suffix" 176 | sscore[highrisk]="$Font_Red${Font_B}HighRisk$Font_Suffix" 177 | sscore[dos]="$Font_Red${Font_B}DoS$Font_Suffix" 178 | sscore[colon]=": " 179 | sscore[title]="3. Risk Score" 180 | sscore[range]="${Font_Cyan}Levels: $Font_I$Font_White${Back_Green}VeryLow Low $Back_Yellow Medium $Back_Red High VeryHigh$Font_Suffix" 181 | sfactor[title]="4. Risk Factors" 182 | sfactor[factor]="DB: " 183 | sfactor[countrycode]="Region: " 184 | sfactor[proxy]="Proxy: " 185 | sfactor[tor]="Tor: " 186 | sfactor[vpn]="VPN: " 187 | sfactor[server]="Server: " 188 | sfactor[abuser]="Abuser: " 189 | sfactor[robot]="Robot: " 190 | sfactor[yes]="$Font_Red$Font_B Yes$Font_Suffix" 191 | sfactor[no]="$Font_Green$Font_B No $Font_Suffix" 192 | sfactor[na]="$Font_Green$Font_B N/A$Font_Suffix" 193 | smedia[yes]=" $Back_Green$Font_White Yes $Font_Suffix " 194 | smedia[no]=" $Back_Red$Font_White Block $Font_Suffix " 195 | smedia[bad]="$Back_Red$Font_White Failed $Font_Suffix " 196 | smedia[pending]="$Back_Yellow$Font_White Pending $Font_Suffix" 197 | smedia[cn]=" $Back_Red$Font_White China $Font_Suffix " 198 | smedia[noprem]="$Back_Red$Font_White NoPrem. $Font_Suffix" 199 | smedia[org]="$Back_Yellow$Font_White NF.Only $Font_Suffix" 200 | smedia[web]="$Back_Yellow$Font_White WebOnly $Font_Suffix" 201 | smedia[app]="$Back_Yellow$Font_White APPOnly $Font_Suffix" 202 | smedia[idc]=" $Back_Yellow$Font_White IDC $Font_Suffix " 203 | smedia[native]="$Back_Green$Font_White Native $Font_Suffix " 204 | smedia[dns]="$Back_Yellow$Font_White ViaDNS $Font_Suffix " 205 | smedia[nodata]=" " 206 | smedia[title]="5. Accessibility check for media and AI services" 207 | smedia[meida]="Service: " 208 | smedia[status]="Status: " 209 | smedia[region]="Region: " 210 | smedia[type]="Type: " 211 | smail[title]="6. Email service availability and blacklist detection" 212 | smail[port]="Local Port 25: " 213 | smail[yes]="${Font_Green}Available$Font_Suffix" 214 | smail[no]="${Font_Red}Blocked$Font_Suffix" 215 | smail[provider]="Conn: " 216 | smail[dnsbl]="DNSBL database: " 217 | smail[available]="$Font_Suffix${Font_Cyan}Active $Font_B" 218 | smail[clean]="$Font_Suffix${Font_Green}Clean $Font_B" 219 | smail[marked]="$Font_Suffix${Font_Yellow}Marked $Font_B" 220 | smail[blacklisted]="$Font_Suffix${Font_Red}Blacklisted $Font_B" 221 | stail[stoday]="IP Checks Today: " 222 | stail[stotal]="; Total: " 223 | stail[thanks]=". Thanks for running xy scripts!" 224 | stail[link]="${Font_I}Report Link: $Font_U" 225 | ;; 226 | "cn")swarn[1]="错误:不支持的参数!" 227 | swarn[2]="错误:IP地址格式错误!" 228 | swarn[3]="错误:未安装依赖程序,请以root执行此脚本,或者安装sudo命令!" 229 | swarn[4]="错误:参数-4与-i/-6冲突!" 230 | swarn[6]="错误:参数-6与-i/-4冲突!" 231 | swarn[7]="错误:指定的网卡不存在!" 232 | swarn[8]="错误: 指定的代理服务器不可用!" 233 | swarn[40]="错误:IPV4不可用!" 234 | swarn[60]="错误:IPV6不可用!" 235 | sinfo[database]="正在检测IP数据库 " 236 | sinfo[media]="正在检测流媒体服务商 " 237 | sinfo[ai]="正在检测AI服务商 " 238 | sinfo[mail]="正在连接邮件服务商 " 239 | sinfo[dnsbl]="正在检测黑名单数据库 " 240 | sinfo[ldatabase]=17 241 | sinfo[lmedia]=21 242 | sinfo[lai]=17 243 | sinfo[lmail]=19 244 | sinfo[ldnsbl]=21 245 | shead[title]="IP质量体检报告:" 246 | shead[ver]="脚本版本:$script_version" 247 | shead[bash]="bash <(curl -sL https://raw.githubusercontent.com/jomertix/server-scripts/refs/heads/master/checkers/ip_quality.sh)" 248 | shead[git]="https://github.com/jomertix/server-scripts" 249 | shead[time]=$(TZ="Asia/Shanghai" date +"报告时间:%Y-%m-%d %H:%M:%S CST") 250 | shead[ltitle]=16 251 | shead[ptime]=$(printf '%8s' '') 252 | sbasic[title]="一、基础信息(${Font_I}Maxmind 数据库$Font_Suffix)" 253 | sbasic[asn]="自治系统号: " 254 | sbasic[noasn]="未分配" 255 | sbasic[org]="组织: " 256 | sbasic[location]="坐标: " 257 | sbasic[map]="地图: " 258 | sbasic[city]="城市: " 259 | sbasic[country]="使用地: " 260 | sbasic[regcountry]="注册地: " 261 | sbasic[continent]="洲际: " 262 | sbasic[timezone]="时区: " 263 | sbasic[type]="IP类型: " 264 | sbasic[type0]=" 原生IP " 265 | sbasic[type1]=" 广播IP " 266 | stype[business]=" $Back_Yellow$Font_White$Font_B 商业 $Font_Suffix " 267 | stype[isp]=" $Back_Green$Font_White$Font_B 家宽 $Font_Suffix " 268 | stype[hosting]=" $Back_Red$Font_White$Font_B 机房 $Font_Suffix " 269 | stype[education]=" $Back_Yellow$Font_White$Font_B 教育 $Font_Suffix " 270 | stype[government]=" $Back_Yellow$Font_White$Font_B 政府 $Font_Suffix " 271 | stype[banking]=" $Back_Yellow$Font_White$Font_B 银行 $Font_Suffix " 272 | stype[organization]=" $Back_Yellow$Font_White$Font_B 组织 $Font_Suffix " 273 | stype[military]=" $Back_Yellow$Font_White$Font_B 军队 $Font_Suffix " 274 | stype[library]=" $Back_Yellow$Font_White$Font_B 图书馆 $Font_Suffix " 275 | stype[cdn]=" $Back_Red$Font_White$Font_B CDN $Font_Suffix " 276 | stype[lineisp]=" $Back_Green$Font_White$Font_B 家宽 $Font_Suffix " 277 | stype[mobile]=" $Back_Green$Font_White$Font_B 手机 $Font_Suffix " 278 | stype[spider]=" $Back_Red$Font_White$Font_B 蜘蛛 $Font_Suffix " 279 | stype[reserved]=" $Back_Yellow$Font_White$Font_B 保留 $Font_Suffix " 280 | stype[other]=" $Back_Yellow$Font_White$Font_B 其他 $Font_Suffix " 281 | stype[title]="二、IP类型属性" 282 | stype[db]="数据库: " 283 | stype[usetype]="使用类型: " 284 | stype[comtype]="公司类型: " 285 | sscore[verylow]="$Font_Green$Font_B极低风险$Font_Suffix" 286 | sscore[low]="$Font_Green$Font_B低风险$Font_Suffix" 287 | sscore[medium]="$Font_Yellow$Font_B中风险$Font_Suffix" 288 | sscore[high]="$Font_Red$Font_B高风险$Font_Suffix" 289 | sscore[veryhigh]="$Font_Red$Font_B极高风险$Font_Suffix" 290 | sscore[elevated]="$Font_Yellow$Font_B较高风险$Font_Suffix" 291 | sscore[suspicious]="$Font_Yellow$Font_B可疑IP$Font_Suffix" 292 | sscore[risky]="$Font_Red$Font_B存在风险$Font_Suffix" 293 | sscore[highrisk]="$Font_Red$Font_B高风险$Font_Suffix" 294 | sscore[dos]="$Font_Red$Font_B建议封禁$Font_Suffix" 295 | sscore[colon]=":" 296 | sscore[title]="三、风险评分" 297 | sscore[range]="$Font_Cyan风险等级: $Font_I$Font_White$Back_Green极低 低 $Back_Yellow 中等 $Back_Red 高 极高$Font_Suffix" 298 | sfactor[title]="四、风险因子" 299 | sfactor[factor]="库: " 300 | sfactor[countrycode]="地区: " 301 | sfactor[proxy]="代理: " 302 | sfactor[tor]="Tor: " 303 | sfactor[vpn]="VPN: " 304 | sfactor[server]="服务器:" 305 | sfactor[abuser]="滥用: " 306 | sfactor[robot]="机器人:" 307 | sfactor[yes]="$Font_Red$Font_B 是 $Font_Suffix" 308 | sfactor[no]="$Font_Green$Font_B 否 $Font_Suffix" 309 | sfactor[na]="$Font_Green$Font_B 无 $Font_Suffix" 310 | smedia[yes]=" $Back_Green$Font_White 解锁 $Font_Suffix " 311 | smedia[no]=" $Back_Red$Font_White 屏蔽 $Font_Suffix " 312 | smedia[bad]=" $Back_Red$Font_White 失败 $Font_Suffix " 313 | smedia[pending]="$Back_Yellow$Font_White 待支持 $Font_Suffix " 314 | smedia[cn]=" $Back_Red$Font_White 中国 $Font_Suffix " 315 | smedia[noprem]="$Back_Red$Font_White 禁会员 $Font_Suffix " 316 | smedia[org]="$Back_Yellow$Font_White 仅自制 $Font_Suffix " 317 | smedia[web]="$Back_Yellow$Font_White 仅网页 $Font_Suffix " 318 | smedia[app]=" $Back_Yellow$Font_White 仅APP $Font_Suffix " 319 | smedia[idc]=" $Back_Yellow$Font_White 机房 $Font_Suffix " 320 | smedia[native]=" $Back_Green$Font_White 原生 $Font_Suffix " 321 | smedia[dns]=" $Back_Yellow$Font_White DNS $Font_Suffix " 322 | smedia[nodata]=" " 323 | smedia[title]="五、流媒体及AI服务解锁检测" 324 | smedia[meida]="服务商: " 325 | smedia[status]="状态: " 326 | smedia[region]="地区: " 327 | smedia[type]="方式: " 328 | smail[title]="六、邮局连通性及黑名单检测" 329 | smail[port]="本地25端口:" 330 | smail[yes]="$Font_Green可用$Font_Suffix" 331 | smail[no]="$Font_Red阻断$Font_Suffix" 332 | smail[provider]="通信:" 333 | smail[dnsbl]="IP地址黑名单数据库:" 334 | smail[available]="$Font_Suffix$Font_Cyan有效 $Font_B" 335 | smail[clean]="$Font_Suffix$Font_Green正常 $Font_B" 336 | smail[marked]="$Font_Suffix$Font_Yellow已标记 $Font_B" 337 | smail[blacklisted]="$Font_Suffix$Font_Red黑名单 $Font_B" 338 | stail[stoday]="今日IP检测量:" 339 | stail[stotal]=";总检测量:" 340 | stail[thanks]="。感谢使用xy系列脚本!" 341 | stail[link]="$Font_I报告链接:$Font_U" 342 | ;; 343 | *)echo -ne "ERROR: Language not supported!" 344 | esac 345 | } 346 | show_progress_bar(){ 347 | local bar="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏" 348 | local n="${#bar}" 349 | while sleep 0.1;do 350 | if ! kill -0 $main_pid 2>/dev/null;then 351 | echo -ne "" 352 | exit 353 | fi 354 | echo -ne "\r$Font_Cyan$Font_B[$IP]# $1$Font_Cyan$Font_B$(printf '%*s' "$2" ''|tr ' ' '.') ${bar:ibar++%n:1} $(printf '%02d%%' $ibar_step) $Font_Suffix" 355 | done 356 | } 357 | kill_progress_bar(){ 358 | kill "$bar_pid" 2>/dev/null&&echo -ne "\r" 359 | } 360 | install_dependencies(){ 361 | if ! jq --version >/dev/null 2>&1||! curl --version >/dev/null 2>&1||! bc --version >/dev/null 2>&1||! nc -h >/dev/null 2>&1||! dig -v >/dev/null 2>&1;then 362 | echo "Detecting operating system..." 363 | if [ "$(uname)" == "Darwin" ];then 364 | install_packages "brew" "brew install" "no_sudo" 365 | elif [ -f /etc/os-release ];then 366 | . /etc/os-release 367 | if [ $(id -u) -ne 0 ]&&! command -v sudo >/dev/null 2>&1;then 368 | ERRORcode=3 369 | fi 370 | case $ID in 371 | ubuntu|debian|linuxmint)install_packages "apt" "apt-get install -y" 372 | ;; 373 | rhel|centos|almalinux|rocky|anolis)if 374 | [ "$(echo $VERSION_ID|cut -d '.' -f1)" -ge 8 ] 375 | then 376 | install_packages "dnf" "dnf install -y" 377 | else 378 | install_packages "yum" "yum install -y" 379 | fi 380 | ;; 381 | arch|manjaro)install_packages "pacman" "pacman -S --noconfirm" 382 | ;; 383 | alpine)install_packages "apk" "apk add" 384 | ;; 385 | fedora)install_packages "dnf" "dnf install -y" 386 | ;; 387 | alinux)install_packages "yum" "yum install -y" 388 | ;; 389 | suse|opensuse*)install_packages "zypper" "zypper install -y" 390 | ;; 391 | void)install_packages "xbps" "xbps-install -Sy" 392 | ;; 393 | *)echo "Unsupported distribution: $ID" 394 | exit 1 395 | esac 396 | elif [ -n "$PREFIX" ];then 397 | install_packages "pkg" "pkg install" 398 | else 399 | echo "Cannot detect distribution because /etc/os-release is missing." 400 | exit 1 401 | fi 402 | fi 403 | } 404 | install_packages(){ 405 | local package_manager=$1 406 | local install_command=$2 407 | local no_sudo=$3 408 | echo "Using package manager: $package_manager" 409 | echo -e "Lacking necessary dependencies, $Font_I${Font_Cyan}jq curl bc netcat dnsutils iproute$Font_Suffix will be installed using $Font_I$Font_Cyan$package_manager$Font_Suffix." 410 | prompt=$(printf "Continue? (${Font_Green}y$Font_Suffix/${Font_Red}n$Font_Suffix): ") 411 | read -p "$prompt" choice 412 | case "$choice" in 413 | y|Y|yes|Yes|YES)echo "Continue to execute script..." 414 | ;; 415 | n|N|no|No|NO)echo "Script exited." 416 | exit 0 417 | ;; 418 | *)echo "Invalid input, script exited." 419 | exit 1 420 | esac 421 | if [ "$no_sudo" == "no_sudo" ]||[ $(id -u) -eq 0 ];then 422 | local usesudo="" 423 | else 424 | local usesudo="sudo" 425 | fi 426 | case $package_manager in 427 | apt)$usesudo apt update 428 | $usesudo $install_command jq curl bc netcat-openbsd dnsutils iproute2 429 | ;; 430 | dnf)$usesudo dnf install epel-release -y 431 | $usesudo $package_manager makecache 432 | $usesudo $install_command jq curl bc nmap-ncat bind-utils iproute 433 | ;; 434 | yum)$usesudo yum install epel-release -y 435 | $usesudo $package_manager makecache 436 | $usesudo $install_command jq curl bc nmap-ncat bind-utils iproute 437 | ;; 438 | pacman)$usesudo pacman -Sy 439 | $usesudo $install_command jq curl bc gnu-netcat bind-tools iproute2 440 | ;; 441 | apk)$usesudo apk update 442 | $usesudo $install_command jq curl bc netcat-openbsd grep bind-tools iproute2 443 | ;; 444 | pkg)$usesudo $package_manager update 445 | $usesudo $package_manager $install_command jq curl bc netcat dnsutils iproute 446 | ;; 447 | brew)eval "$(/opt/homebrew/bin/brew shellenv)" 448 | $install_command jq curl bc netcat bind 449 | ;; 450 | zypper)$usesudo zypper refresh 451 | $usesudo $install_command jq curl bc netcat bind-utils iproute2 452 | ;; 453 | xbps)$usesudo xbps-install -Sy 454 | $usesudo $install_command jq curl bc netcat bind-utils iproute2 455 | esac 456 | } 457 | declare -A browsers=( 458 | [Chrome]="87.0.4280.66 88.0.4324.150 89.0.4389.82" 459 | [Firefox]="83.0 84.0 85.0" 460 | [Edge]="88.0.705.50 89.0.774.57") 461 | generate_random_user_agent(){ 462 | local browsers_keys=(${!browsers[@]}) 463 | local random_browser_index=$((RANDOM%${#browsers_keys[@]})) 464 | local browser=${browsers_keys[random_browser_index]} 465 | local versions=(${browsers[$browser]}) 466 | local random_version_index=$((RANDOM%${#versions[@]})) 467 | local version=${versions[random_version_index]} 468 | case $browser in 469 | Chrome)UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$version Safari/537.36" 470 | ;; 471 | Firefox)UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:${version%%.*}) Gecko/20100101 Firefox/$version" 472 | ;; 473 | Edge)UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version%.*}.0.0 Safari/537.36 Edg/$version" 474 | esac 475 | } 476 | is_valid_ipv4(){ 477 | local ip=$1 478 | if [[ $ip =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]];then 479 | IFS='.' read -r -a octets <<<"$ip" 480 | for octet in "${octets[@]}";do 481 | if ((octet<0||octet>255));then 482 | IPV4work=0 483 | return 1 484 | fi 485 | done 486 | IPV4work=1 487 | return 0 488 | else 489 | IPV4work=0 490 | return 1 491 | fi 492 | } 493 | is_private_ipv4(){ 494 | local ip_address=$1 495 | if [[ -z $ip_address ]];then 496 | return 0 497 | fi 498 | if [[ $ip_address =~ ^10\. ]]||[[ $ip_address =~ ^172\.(1[6-9]|2[0-9]|3[0-1])\. ]]||[[ $ip_address =~ ^192\.168\. ]]||[[ $ip_address =~ ^127\. ]]||[[ $ip_address =~ ^0\. ]]||[[ $ip_address =~ ^22[4-9]\. ]]||[[ $ip_address =~ ^23[0-9]\. ]];then 499 | return 0 500 | fi 501 | return 1 502 | } 503 | get_ipv4(){ 504 | local response 505 | local API_NET=("ip.sb" "ping0.cc" "icanhazip.com" "api64.ipify.org" "ifconfig.co" "ident.me") 506 | for p in "${API_NET[@]}";do 507 | response=$(curl $CurlARG -s4 --max-time 8 "$p") 508 | if [[ $? -eq 0 && ! $response =~ error ]];then 509 | IPV4="$response" 510 | break 511 | fi 512 | done 513 | } 514 | hide_ipv4(){ 515 | if [[ -n $1 ]];then 516 | IFS='.' read -r -a ip_parts <<<"$1" 517 | IPhide="${ip_parts[0]}.${ip_parts[1]}.*.*" 518 | else 519 | IPhide="" 520 | fi 521 | } 522 | is_valid_ipv6(){ 523 | local ip=$1 524 | if [[ $ip =~ ^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,7}:$ || $ip =~ ^:([0-9a-fA-F]{1,4}:){1,7}$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}$ || $ip =~ ^[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})$ || $ip =~ ^:((:[0-9a-fA-F]{1,4}){1,7}|:)$ || $ip =~ ^fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}$ || $ip =~ ^::(ffff(:0{1,4}){0,1}:){0,1}(([0-9]{1,3}\.){3}[0-9]{1,3})$ || $ip =~ ^([0-9a-fA-F]{1,4}:){1,4}:(([0-9]{1,3}\.){3}[0-9]{1,3})$ ]];then 525 | IPV6work=1 526 | return 0 527 | else 528 | IPV6work=0 529 | return 1 530 | fi 531 | } 532 | is_private_ipv6(){ 533 | local address=$1 534 | if [[ -z $address ]];then 535 | return 0 536 | fi 537 | if [[ $address =~ ^fe80: ]]||[[ $address =~ ^fc00: ]]||[[ $address =~ ^fd00: ]]||[[ $address =~ ^2001:db8: ]]||[[ $address == ::1 ]]||[[ $address =~ ^::ffff: ]]||[[ $address =~ ^2002: ]]||[[ $address =~ ^2001: ]];then 538 | return 0 539 | fi 540 | return 1 541 | } 542 | get_ipv6(){ 543 | local response 544 | local API_NET=("ip.sb" "ping0.cc" "icanhazip.com" "api64.ipify.org" "ifconfig.co" "ident.me") 545 | for p in "${API_NET[@]}";do 546 | response=$(curl $CurlARG -s6k --max-time 8 "$p") 547 | if [[ $? -eq 0 && ! $response =~ error ]];then 548 | IPV6="$response" 549 | break 550 | fi 551 | done 552 | } 553 | hide_ipv6(){ 554 | if [[ -n $1 ]];then 555 | local expanded_ip=$(echo "$1"|sed 's/::/:0000:0000:0000:0000:0000:0000:0000:0000:/g'|cut -d ':' -f1-8) 556 | IFS=':' read -r -a ip_parts <<<"$expanded_ip" 557 | while [ ${#ip_parts[@]} -lt 8 ];do 558 | ip_parts+=(0000) 559 | done 560 | IPhide="${ip_parts[0]:-0}:${ip_parts[1]:-0}:${ip_parts[2]:-0}:*:*:*:*:*" 561 | IPhide=$(echo "$IPhide"|sed 's/:0\{1,\}/:/g'|sed 's/::\+/:/g') 562 | else 563 | IPhide="" 564 | fi 565 | } 566 | calculate_display_width(){ 567 | local string="$1" 568 | local length=0 569 | local char 570 | for ((i=0; i<${#string}; i++));do 571 | char=$(echo "$string"|od -An -N1 -tx1 -j $((i))|tr -d ' ') 572 | if [ "$(printf '%d\n' 0x$char)" -gt 127 ];then 573 | length=$((length+2)) 574 | i=$((i+1)) 575 | else 576 | length=$((length+1)) 577 | fi 578 | done 579 | echo "$length" 580 | } 581 | calc_padding(){ 582 | local input_text="$1" 583 | local total_width=$2 584 | local title_length=$(calculate_display_width "$input_text") 585 | local left_padding=$(((total_width-title_length)/2)) 586 | if [[ $left_padding -gt 0 ]];then 587 | PADDING=$(printf '%*s' $left_padding) 588 | else 589 | PADDING="" 590 | fi 591 | } 592 | generate_dms(){ 593 | local lat=$1 594 | local lon=$2 595 | if [[ -z $lat || $lat == "null" || -z $lon || $lon == "null" ]];then 596 | echo "" 597 | return 598 | fi 599 | convert_single(){ 600 | local coord=$1 601 | local direction=$2 602 | local fixed_coord=$(echo "$coord"|sed 's/\.$/.0/') 603 | local degrees=$(echo "$fixed_coord"|cut -d'.' -f1) 604 | local fractional="0.$(echo "$fixed_coord"|cut -d'.' -f2)" 605 | local minutes=$(echo "$fractional * 60"|bc -l|cut -d'.' -f1) 606 | local seconds_fractional="0.$(echo "$fractional * 60"|bc -l|cut -d'.' -f2)" 607 | local seconds=$(echo "$seconds_fractional * 60"|bc -l|awk '{printf "%.0f", $1}') 608 | echo "$degrees°$minutes′$seconds″$direction" 609 | } 610 | local lat_dir='N' 611 | if [[ $(echo "$lat < 0"|bc -l) -eq 1 ]];then 612 | lat_dir='S' 613 | lat=$(echo "$lat * -1"|bc -l) 614 | fi 615 | local lon_dir='E' 616 | if [[ $(echo "$lon < 0"|bc -l) -eq 1 ]];then 617 | lon_dir='W' 618 | lon=$(echo "$lon * -1"|bc -l) 619 | fi 620 | local lat_dms=$(convert_single $lat $lat_dir) 621 | local lon_dms=$(convert_single $lon $lon_dir) 622 | echo "$lon_dms, $lat_dms" 623 | } 624 | 625 | generate_googlemap_url() { 626 | local lat="$1" 627 | local lon="$2" 628 | 629 | if [[ -z "$lat" || -z "$lon" ]]; then 630 | echo "null" 631 | else 632 | echo "https://maps.google.com/?q=${lat},${lon}" 633 | fi 634 | } 635 | 636 | db_maxmind() { 637 | local temp_info="$Font_Cyan$Font_B${sinfo[database]}${Font_I}IPWhois $Font_Suffix" 638 | ((ibar_step += 3)) 639 | show_progress_bar "$temp_info" $((40 - 8 - ${sinfo[ldatabase]})) & 640 | bar_pid="$!" && disown "$bar_pid" 641 | trap "kill_progress_bar" RETURN 642 | 643 | maxmind=() 644 | local RESPONSE=$(curl -s "http://ipwho.is/$IP") 645 | echo "$RESPONSE" | jq . >/dev/null 2>&1 || RESPONSE="" 646 | 647 | local success=$(echo "$RESPONSE" | jq -r '.success // false') 648 | if [[ "$success" != "true" ]]; then 649 | echo "Failed to get response for IP $IP" 650 | return 1 651 | fi 652 | 653 | maxmind[ip]=$(echo "$RESPONSE" | jq -r '.ip // "N/A"') 654 | maxmind[city]=$(echo "$RESPONSE" | jq -r '.city // "N/A"') 655 | maxmind[region]=$(echo "$RESPONSE" | jq -r '.region // "N/A"') 656 | maxmind[regioncode]=$(echo "$RESPONSE" | jq -r '.region_code // "N/A"') 657 | maxmind[country]=$(echo "$RESPONSE" | jq -r '.country // "N/A"') 658 | maxmind[countrycode]=$(echo "$RESPONSE" | jq -r '.country_code // "N/A"') 659 | maxmind[continent]=$(echo "$RESPONSE" | jq -r '.continent // "N/A"') 660 | maxmind[continentcode]=$(echo "$RESPONSE" | jq -r '.continent_code // "N/A"') 661 | maxmind[lat]=$(echo "$RESPONSE" | jq -r '.latitude // "null"') 662 | maxmind[lon]=$(echo "$RESPONSE" | jq -r '.longitude // "null"') 663 | maxmind[postal]=$(echo "$RESPONSE" | jq -r '.postal // "N/A"') 664 | maxmind[timezone]=$(echo "$RESPONSE" | jq -r '.timezone.id // "N/A"') 665 | maxmind[asn]=$(echo "$RESPONSE" | jq -r '.connection.asn // "N/A"') 666 | maxmind[org]=$(echo "$RESPONSE" | jq -r '.connection.org // "N/A"') 667 | maxmind[isp]=$(echo "$RESPONSE" | jq -r '.connection.isp // "N/A"') 668 | maxmind[domain]=$(echo "$RESPONSE" | jq -r '.connection.domain // "N/A"') 669 | 670 | if [[ ${maxmind[lat]} != "null" && ${maxmind[lon]} != "null" ]]; then 671 | maxmind[dms]=$(generate_dms "${maxmind[lat]}" "${maxmind[lon]}") 672 | maxmind[map]=$(generate_googlemap_url "${maxmind[lat]}" "${maxmind[lon]}" "") 673 | else 674 | maxmind[dms]="null" 675 | maxmind[map]="null" 676 | fi 677 | } 678 | 679 | 680 | 681 | 682 | db_ipinfo(){ 683 | local temp_info="$Font_Cyan$Font_B${sinfo[database]}${Font_I}IPinfo $Font_Suffix" 684 | ((ibar_step+=3)) 685 | show_progress_bar "$temp_info" $((40-7-${sinfo[ldatabase]}))& 686 | bar_pid="$!"&&disown "$bar_pid" 687 | trap "kill_progress_bar" RETURN 688 | ipinfo=() 689 | local RESPONSE=$(curl $CurlARG -Ls -m 10 "https://ipinfo.io/widget/demo/$IP") 690 | echo "$RESPONSE"|jq . >/dev/null 2>&1||RESPONSE="" 691 | ipinfo[usetype]=$(echo "$RESPONSE"|jq -r '.data.asn.type') 692 | ipinfo[comtype]=$(echo "$RESPONSE"|jq -r '.data.company.type') 693 | shopt -s nocasematch 694 | case ${ipinfo[usetype]} in 695 | "business")ipinfo[susetype]="${stype[business]}" 696 | ;; 697 | "isp")ipinfo[susetype]="${stype[isp]}" 698 | ;; 699 | "hosting")ipinfo[susetype]="${stype[hosting]}" 700 | ;; 701 | "education")ipinfo[susetype]="${stype[education]}" 702 | ;; 703 | *)ipinfo[susetype]="${stype[other]}" 704 | esac 705 | case ${ipinfo[comtype]} in 706 | "business")ipinfo[scomtype]="${stype[business]}" 707 | ;; 708 | "isp")ipinfo[scomtype]="${stype[isp]}" 709 | ;; 710 | "hosting")ipinfo[scomtype]="${stype[hosting]}" 711 | ;; 712 | "education")ipinfo[scomtype]="${stype[education]}" 713 | ;; 714 | *)ipinfo[scomtype]="${stype[other]}" 715 | esac 716 | shopt -u nocasematch 717 | ipinfo[countrycode]=$(echo "$RESPONSE"|jq -r '.data.country') 718 | ipinfo[proxy]=$(echo "$RESPONSE"|jq -r '.data.privacy.proxy') 719 | ipinfo[tor]=$(echo "$RESPONSE"|jq -r '.data.privacy.tor') 720 | ipinfo[vpn]=$(echo "$RESPONSE"|jq -r '.data.privacy.vpn') 721 | ipinfo[server]=$(echo "$RESPONSE"|jq -r '.data.privacy.hosting') 722 | } 723 | db_scamalytics(){ 724 | local temp_info="$Font_Cyan$Font_B${sinfo[database]}${Font_I}SCAMALYTICS $Font_Suffix" 725 | ((ibar_step+=3)) 726 | show_progress_bar "$temp_info" $((40-12-${sinfo[ldatabase]}))& 727 | bar_pid="$!"&&disown "$bar_pid" 728 | trap "kill_progress_bar" RETURN 729 | scamalytics=() 730 | local RESPONSE=$(curl $CurlARG -sL -H "Referer: https://scamalytics.com" -m 10 "https://scamalytics.com/ip/$IP") 731 | [[ -z $RESPONSE ]]&&return 1 732 | local tmpscore=$(echo "$RESPONSE"|grep -oE 'Fraud Score: [0-9]+'|awk -F': ' '{print $2}') 733 | scamalytics[score]=$(echo "$tmpscore"|bc) 734 | if [[ ${scamalytics[score]} -lt 25 ]];then 735 | scamalytics[risk]="${sscore[low]}" 736 | elif [[ ${scamalytics[score]} -lt 50 ]];then 737 | scamalytics[risk]="${sscore[medium]}" 738 | elif [[ ${scamalytics[score]} -lt 75 ]];then 739 | scamalytics[risk]="${sscore[high]}" 740 | elif [[ ${scamalytics[score]} -ge 75 ]];then 741 | scamalytics[risk]="${sscore[veryhigh]}" 742 | fi 743 | scamalytics[countrycode]=$(echo "$RESPONSE"|awk -F'?td>' '/
/p'|sed -e 's/<[^>]*>//g'|sed 's/^[\t]*//')
828 | echo "$RESPONSE"|jq . >/dev/null 2>&1||RESPONSE=""
829 | ip2location[usetype]=$(echo "$RESPONSE"|jq -r '.usage_type')
830 | shopt -s nocasematch
831 | local first_use="${ip2location[usetype]%%/*}"
832 | case $first_use in
833 | "COM")ip2location[susetype]="${stype[business]}"
834 | ;;
835 | "DCH")ip2location[susetype]="${stype[hosting]}"
836 | ;;
837 | "EDU")ip2location[susetype]="${stype[education]}"
838 | ;;
839 | "GOV")ip2location[susetype]="${stype[government]}"
840 | ;;
841 | "ORG")ip2location[susetype]="${stype[organization]}"
842 | ;;
843 | "MIL")ip2location[susetype]="${stype[military]}"
844 | ;;
845 | "LIB")ip2location[susetype]="${stype[library]}"
846 | ;;
847 | "CDN")ip2location[susetype]="${stype[cdn]}"
848 | ;;
849 | "ISP")ip2location[susetype]="${stype[lineisp]}"
850 | ;;
851 | "MOB")ip2location[susetype]="${stype[mobile]}"
852 | ;;
853 | "SES")ip2location[susetype]="${stype[spider]}"
854 | ;;
855 | "RSV")ip2location[susetype]="${stype[reserved]}"
856 | ;;
857 | *)ip2location[susetype]="${stype[other]}"
858 | esac
859 | shopt -u nocasematch
860 | ip2location[countrycode]=$(echo "$RESPONSE"|jq -r '.country_code')
861 | ip2location[proxy1]=$(echo "$RESPONSE"|jq -r '.proxy.is_public_proxy')
862 | ip2location[proxy2]=$(echo "$RESPONSE"|jq -r '.proxy.is_web_proxy')
863 | ip2location[proxy]="true"
864 | [[ ${ip2location[proxy1]} == "false" && ${ip2location[proxy2]} == "false" ]]&&ip2location[proxy]="false"
865 | ip2location[tor]=$(echo "$RESPONSE"|jq -r '.proxy.is_tor')
866 | ip2location[vpn]=$(echo "$RESPONSE"|jq -r '.proxy.is_vpn')
867 | ip2location[server]=$(echo "$RESPONSE"|jq -r '.proxy.is_data_center')
868 | ip2location[abuser]=$(echo "$RESPONSE"|jq -r '.proxy.is_spammer')
869 | ip2location[robot1]=$(echo "$RESPONSE"|jq -r '.proxy.is_web_crawler')
870 | ip2location[robot2]=$(echo "$RESPONSE"|jq -r '.proxy.is_scanner')
871 | ip2location[robot3]=$(echo "$RESPONSE"|jq -r '.proxy.is_botnet')
872 | ip2location[robot]="true"
873 | [[ ${ip2location[robot1]} == "false" && ${ip2location[robot2]} == "false" && ${ip2location[robot3]} == "false" ]]&&ip2location[robot]="false"
874 | }
875 | db_dbip(){
876 | local temp_info="$Font_Cyan$Font_B${sinfo[database]}${Font_I}DB-IP $Font_Suffix"
877 | ((ibar_step+=3))
878 | show_progress_bar "$temp_info" $((40-6-${sinfo[ldatabase]}))&
879 | bar_pid="$!"&&disown "$bar_pid"
880 | trap "kill_progress_bar" RETURN
881 | dbip=()
882 | local RESPONSE=$(curl $CurlARG -sL -m 10 "https://db-ip.com/demo/home.php?s=$IP")
883 | echo "$RESPONSE"|jq . >/dev/null 2>&1||RESPONSE=""
884 | dbip[risktext]=$(echo "$RESPONSE"|jq -r '.demoInfo.threatLevel')
885 | shopt -s nocasematch
886 | case ${dbip[risktext]} in
887 | "low")dbip[risk]="${sscore[low]}"
888 | dbip[score]=0
889 | ;;
890 | "medium")dbip[risk]="${sscore[medium]}"
891 | dbip[score]=50
892 | ;;
893 | "high")dbip[risk]="${sscore[high]}"
894 | dbip[score]=100
895 | esac
896 | shopt -u nocasematch
897 | }
898 | db_ipwhois(){
899 | local temp_info="$Font_Cyan$Font_B${sinfo[database]}${Font_I}IPWHOIS $Font_Suffix"
900 | ((ibar_step+=3))
901 | show_progress_bar "$temp_info" $((40-8-${sinfo[ldatabase]}))&
902 | bar_pid="$!"&&disown "$bar_pid"
903 | trap "kill_progress_bar" RETURN
904 | ipwhois=()
905 | local RESPONSE=$(curl $CurlARG -sL -m 10 "https://ipwhois.io/widget?ip=$IP&lang=en" --compressed \
906 | -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0" \
907 | -H "Accept: */*" \
908 | -H "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2" \
909 | -H "Connection: keep-alive" \
910 | -H "Referer: https://ipwhois.io/" \
911 | -H "Sec-Fetch-Dest: empty" \
912 | -H "Sec-Fetch-Mode: cors" \
913 | -H "Sec-Fetch-Site: same-origin" \
914 | -H "TE: trailers")
915 | echo "$RESPONSE"|jq . >/dev/null 2>&1||RESPONSE=""
916 | ipwhois[countrycode]=$(echo "$RESPONSE"|jq -r '.country_code')
917 | ipwhois[proxy]=$(echo "$RESPONSE"|jq -r '.security.proxy')
918 | ipwhois[tor]=$(echo "$RESPONSE"|jq -r '.security.tor')
919 | ipwhois[vpn]=$(echo "$RESPONSE"|jq -r '.security.vpn')
920 | ipwhois[server]=$(echo "$RESPONSE"|jq -r '.security.hosting')
921 | }
922 | db_cloudflare(){
923 | local temp_info="$Font_Cyan$Font_B${sinfo[database]}${Font_I}Cloudflare $Font_Suffix"
924 | ((ibar_step+=3))
925 | show_progress_bar "$temp_info" $((40-11-${sinfo[ldatabase]}))&
926 | bar_pid="$!"&&disown "$bar_pid"
927 | trap "kill_progress_bar" RETURN
928 | cloudflare=()
929 | local RESPONSE=$(curl $CurlARG -sL -$1 -m 10 "https://ip.nodeget.com/json")
930 | echo "$RESPONSE"|jq . >/dev/null 2>&1||RESPONSE=""
931 | cloudflare[score]=$(echo "$RESPONSE"|jq -r '.ip.riskScore')
932 | if [[ ${cloudflare[score]} -lt 10 ]];then
933 | cloudflare[risk]="${sscore[low]}"
934 | elif [[ ${cloudflare[score]} -lt 15 ]];then
935 | cloudflare[risk]="${sscore[medium]}"
936 | elif [[ ${cloudflare[score]} -lt 25 ]];then
937 | cloudflare[risk]="${sscore[risky]}"
938 | elif [[ ${cloudflare[score]} -ge 50 ]];then
939 | cloudflare[risk]="${sscore[veryhigh]}"
940 | fi
941 | }
942 | function check_ip_valide(){
943 | local IPPattern='^(\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>\.){3}\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>$'
944 | IP="$1"
945 | if [[ $IP =~ $IPPattern ]];then
946 | return 0
947 | else
948 | return 1
949 | fi
950 | }
951 | function calc_ip_net(){
952 | sip="$1"
953 | snetmask="$2"
954 | check_ip_valide "$sip"
955 | if [ $? -ne 0 ];then
956 | echo ""
957 | return 1
958 | fi
959 | local ipFIELD1=$(echo "$sip"|cut -d. -f1)
960 | local ipFIELD2=$(echo "$sip"|cut -d. -f2)
961 | local ipFIELD3=$(echo "$sip"|cut -d. -f3)
962 | local ipFIELD4=$(echo "$sip"|cut -d. -f4)
963 | local netmaskFIELD1=$(echo "$snetmask"|cut -d. -f1)
964 | local netmaskFIELD2=$(echo "$snetmask"|cut -d. -f2)
965 | local netmaskFIELD3=$(echo "$snetmask"|cut -d. -f3)
966 | local netmaskFIELD4=$(echo "$snetmask"|cut -d. -f4)
967 | local tmpret1=$((ipFIELD1&netmaskFIELD1))
968 | local tmpret2=$((ipFIELD2&netmaskFIELD2))
969 | local tmpret3=$((ipFIELD3&netmaskFIELD3))
970 | local tmpret4=$((ipFIELD4&netmaskFIELD4))
971 | echo "$tmpret1.$tmpret2.$tmpret3.$tmpret4"
972 | }
973 | function Check_DNS_IP(){
974 | if [ "$1" != "${1#*[0-9].[0-9]}" ];then
975 | if [ "$(calc_ip_net "$1" 255.0.0.0)" == "10.0.0.0" ];then
976 | echo 0
977 | elif [ "$(calc_ip_net "$1" 255.240.0.0)" == "172.16.0.0" ];then
978 | echo 0
979 | elif [ "$(calc_ip_net "$1" 255.255.0.0)" == "169.254.0.0" ];then
980 | echo 0
981 | elif [ "$(calc_ip_net "$1" 255.255.0.0)" == "192.168.0.0" ];then
982 | echo 0
983 | elif [ "$(calc_ip_net "$1" 255.255.255.0)" == "$(calc_ip_net "$2" 255.255.255.0)" ];then
984 | echo 0
985 | else
986 | echo 1
987 | fi
988 | elif [ "$1" != "${1#*[0-9a-fA-F]:*}" ];then
989 | if [ "${1:0:3}" == "fe8" ];then
990 | echo 0
991 | elif [ "${1:0:3}" == "FE8" ];then
992 | echo 0
993 | elif [ "${1:0:2}" == "fc" ];then
994 | echo 0
995 | elif [ "${1:0:2}" == "FC" ];then
996 | echo 0
997 | elif [ "${1:0:2}" == "fd" ];then
998 | echo 0
999 | elif [ "${1:0:2}" == "FD" ];then
1000 | echo 0
1001 | elif [ "${1:0:2}" == "ff" ];then
1002 | echo 0
1003 | elif [ "${1:0:2}" == "FF" ];then
1004 | echo 0
1005 | else
1006 | echo 1
1007 | fi
1008 | else
1009 | echo 0
1010 | fi
1011 | }
1012 | function Check_DNS_1(){
1013 | local resultdns=$(nslookup $1)
1014 | local resultinlines=(${resultdns//$'\n'/ })
1015 | for i in ${resultinlines[*]};do
1016 | if [[ $i == "Name:" ]];then
1017 | local resultdnsindex=$((resultindex+3))
1018 | break
1019 | fi
1020 | local resultindex=$((resultindex+1))
1021 | done
1022 | echo $(Check_DNS_IP ${resultinlines[$resultdnsindex]} ${resultinlines[1]})
1023 | }
1024 | function Check_DNS_2(){
1025 | local resultdnstext=$(dig $1|grep "ANSWER:")
1026 | local resultdnstext=${resultdnstext#*"ANSWER: "}
1027 | local resultdnstext=${resultdnstext%", AUTHORITY:"*}
1028 | if [ "$resultdnstext" == "0" ]||[ "$resultdnstext" == "1" ]||[ "$resultdnstext" == "2" ];then
1029 | echo 0
1030 | else
1031 | echo 1
1032 | fi
1033 | }
1034 | function Check_DNS_3(){
1035 | local resultdnstext=$(dig "test$RANDOM$RANDOM.$1"|grep "ANSWER:")
1036 | echo "test$RANDOM$RANDOM.$1"
1037 | local resultdnstext=${resultdnstext#*"ANSWER: "}
1038 | local resultdnstext=${resultdnstext%", AUTHORITY:"*}
1039 | if [ "$resultdnstext" == "0" ];then
1040 | echo 1
1041 | else
1042 | echo 0
1043 | fi
1044 | }
1045 | function Get_Unlock_Type(){
1046 | while [ $# -ne 0 ];do
1047 | if [ "$1" = "0" ];then
1048 | echo "${smedia[dns]}"
1049 | return
1050 | fi
1051 | shift
1052 | done
1053 | echo "${smedia[native]}"
1054 | }
1055 | function MediaUnlockTest_TikTok(){
1056 | local temp_info="$Font_Cyan$Font_B${sinfo[media]}${Font_I}TikTok $Font_Suffix"
1057 | ((ibar_step+=3))
1058 | show_progress_bar "$temp_info" $((40-7-${sinfo[lmedia]}))&
1059 | bar_pid="$!"&&disown "$bar_pid"
1060 | trap "kill_progress_bar" RETURN
1061 | tiktok=()
1062 | local checkunlockurl="tiktok.com"
1063 | local result1=$(Check_DNS_1 $checkunlockurl)
1064 | local result3=$(Check_DNS_3 $checkunlockurl)
1065 | local resultunlocktype=$(Get_Unlock_Type $result1 $result3)
1066 | local Ftmpresult=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -sL -m 10 "https://www.tiktok.com/")
1067 | if [[ $Ftmpresult == "curl"* ]];then
1068 | tiktok[ustatus]="${smedia[no]}"
1069 | tiktok[uregion]="${smedia[nodata]}"
1070 | tiktok[utype]="${smedia[nodata]}"
1071 | return
1072 | fi
1073 | local FRegion=$(echo $Ftmpresult|grep '"region":'|sed 's/.*"region"//'|cut -f2 -d'"')
1074 | if [ -n "$FRegion" ];then
1075 | tiktok[ustatus]="${smedia[yes]}"
1076 | tiktok[uregion]=" [$FRegion] "
1077 | tiktok[utype]="$resultunlocktype"
1078 | return
1079 | fi
1080 | local STmpresult=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -sL -m 10 -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" -H "Accept-Encoding: gzip" -H "Accept-Language: en" "https://www.tiktok.com"|gunzip 2>/dev/null)
1081 | local SRegion=$(echo $STmpresult|grep '"region":'|sed 's/.*"region"//'|cut -f2 -d'"')
1082 | if [ -n "$SRegion" ];then
1083 | tiktok[ustatus]="${smedia[idc]}"
1084 | tiktok[uregion]=" [$SRegion] "
1085 | tiktok[utype]="$resultunlocktype"
1086 | return
1087 | else
1088 | tiktok[ustatus]="${smedia[bad]}"
1089 | tiktok[uregion]="${smedia[nodata]}"
1090 | tiktok[utype]="${smedia[nodata]}"
1091 | return
1092 | fi
1093 | }
1094 | function MediaUnlockTest_DisneyPlus(){
1095 | local temp_info="$Font_Cyan$Font_B${sinfo[media]}${Font_I}Disney+ $Font_Suffix"
1096 | ((ibar_step+=3))
1097 | show_progress_bar "$temp_info" $((40-8-${sinfo[lmedia]}))&
1098 | bar_pid="$!"&&disown "$bar_pid"
1099 | trap "kill_progress_bar" RETURN
1100 | disney=()
1101 | local checkunlockurl="disneyplus.com"
1102 | local result1=$(Check_DNS_1 $checkunlockurl)
1103 | local result3=$(Check_DNS_3 $checkunlockurl)
1104 | local resultunlocktype=$(Get_Unlock_Type $result1 $result3)
1105 | local PreAssertion=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -s --max-time 10 -X POST "https://disney.api.edge.bamgrid.com/devices" -H "authorization: Bearer ZGlzbmV5JmJyb3dzZXImMS4wLjA.Cu56AgSfBTDag5NiRA81oLHkDZfu5L3CKadnefEAY84" -H "content-type: application/json; charset=UTF-8" -d '{"deviceFamily":"browser","applicationRuntime":"chrome","deviceProfile":"windows","attributes":{}}' 2>&1)
1106 | if [[ $PreAssertion == "curl"* ]]&&[[ $1 == "6" ]];then
1107 | disney[ustatus]="${smedia[bad]}"
1108 | disney[uregion]="${smedia[nodata]}"
1109 | disney[utype]="${smedia[nodata]}"
1110 | return
1111 | elif [[ $PreAssertion == "curl"* ]];then
1112 | disney[ustatus]="${smedia[bad]}"
1113 | disney[uregion]="${smedia[nodata]}"
1114 | disney[utype]="${smedia[nodata]}"
1115 | return
1116 | fi
1117 | if ! (echo "$PreAssertion"|jq . >/dev/null 2>&1&&echo "$TokenContent"|jq . >/dev/null 2>&1);then
1118 | disney[ustatus]="${smedia[bad]}"
1119 | disney[uregion]="${smedia[nodata]}"
1120 | disney[utype]="${smedia[nodata]}"
1121 | return
1122 | fi
1123 | local assertion=$(echo $PreAssertion|jq -r '.assertion')
1124 | local PreDisneyCookie=$(echo "$Media_Cookie"|sed -n '1p')
1125 | local disneycookie=$(echo $PreDisneyCookie|sed "s/DISNEYASSERTION/$assertion/g")
1126 | local TokenContent=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -s --max-time 10 -X POST "https://disney.api.edge.bamgrid.com/token" -H "authorization: Bearer ZGlzbmV5JmJyb3dzZXImMS4wLjA.Cu56AgSfBTDag5NiRA81oLHkDZfu5L3CKadnefEAY84" -d "$disneycookie" 2>&1)
1127 | local isBanned=$(echo $TokenContent|jq -r 'select(.error_description == "forbidden-location") | .error_description')
1128 | local is403=$(echo $TokenContent|grep '403 ERROR')
1129 | if [ -n "$isBanned" ]||[ -n "$is403" ];then
1130 | disney[ustatus]="${smedia[no]}"
1131 | disney[uregion]="${smedia[nodata]}"
1132 | disney[utype]="${smedia[nodata]}"
1133 | return
1134 | fi
1135 | local fakecontent=$(echo "$Media_Cookie"|sed -n '8p')
1136 | local refreshToken=$(echo $TokenContent|jq -r '.refresh_token')
1137 | local disneycontent=$(echo $fakecontent|sed "s/ILOVEDISNEY/$refreshToken/g")
1138 | local tmpresult=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -X POST -sSL --max-time 10 "https://disney.api.edge.bamgrid.com/graph/v1/device/graphql" -H "authorization: ZGlzbmV5JmJyb3dzZXImMS4wLjA.Cu56AgSfBTDag5NiRA81oLHkDZfu5L3CKadnefEAY84" -d "$disneycontent" 2>&1)
1139 | if ! (echo "$tmpresult"|jq . >/dev/null 2>&1);then
1140 | disney[ustatus]="${smedia[bad]}"
1141 | disney[uregion]="${smedia[nodata]}"
1142 | disney[utype]="${smedia[nodata]}"
1143 | return
1144 | fi
1145 | local previewcheck=$(curl $CurlARG -$1 -s -o /dev/null -L --max-time 10 -w '%{url_effective}\n' "https://disneyplus.com"|grep preview)
1146 | local isUnabailable=$(echo $previewcheck|grep 'unavailable')
1147 | local region=$(echo $tmpresult|jq -r '.extensions.sdk.session.location.countryCode')
1148 | local inSupportedLocation=$(echo $tmpresult|jq -r '.extensions.sdk.session.inSupportedLocation')
1149 | if [[ $region == "JP" ]];then
1150 | disney[ustatus]="${smedia[yes]}"
1151 | disney[uregion]=" [JP] "
1152 | disney[utype]="$resultunlocktype"
1153 | return
1154 | elif [ -n "$region" ]&&[[ $inSupportedLocation == "false" ]]&&[ -z "$isUnabailable" ];then
1155 | disney[ustatus]="${smedia[pending]}"
1156 | disney[uregion]=" [$region] "
1157 | disney[utype]="$resultunlocktype"
1158 | return
1159 | elif [ -n "$region" ]&&[ -n "$isUnavailable" ];then
1160 | disney[ustatus]="${smedia[no]}"
1161 | disney[uregion]="${smedia[nodata]}"
1162 | disney[utype]="${smedia[nodata]}"
1163 | return
1164 | elif [ -n "$region" ]&&[[ $inSupportedLocation == "true" ]];then
1165 | disney[ustatus]="${smedia[yes]}"
1166 | disney[uregion]=" [$region] "
1167 | disney[utype]="$resultunlocktype"
1168 | return
1169 | elif [ -z "$region" ];then
1170 | disney[ustatus]="${smedia[no]}"
1171 | disney[uregion]="${smedia[nodata]}"
1172 | disney[utype]="${smedia[nodata]}"
1173 | return
1174 | else
1175 | disney[ustatus]="${smedia[bad]}"
1176 | disney[uregion]="${smedia[nodata]}"
1177 | disney[utype]="${smedia[nodata]}"
1178 | return
1179 | fi
1180 | }
1181 | function MediaUnlockTest_Netflix(){
1182 | local temp_info="$Font_Cyan$Font_B${sinfo[media]}${Font_I}Netflix $Font_Suffix"
1183 | ((ibar_step+=3))
1184 | show_progress_bar "$temp_info" $((40-8-${sinfo[lmedia]}))&
1185 | bar_pid="$!"&&disown "$bar_pid"
1186 | trap "kill_progress_bar" RETURN
1187 | netflix=()
1188 | local checkunlockurl="netflix.com"
1189 | local result1=$(Check_DNS_1 $checkunlockurl)
1190 | local result2=$(Check_DNS_2 $checkunlockurl)
1191 | local result3=$(Check_DNS_3 $checkunlockurl)
1192 | local resultunlocktype=$(Get_Unlock_Type $result1 $result2 $result3)
1193 | local result1=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -fsLI -X GET --write-out %{http_code} --output /dev/null --max-time 10 --tlsv1.3 "https://www.netflix.com/title/81280792" 2>&1)
1194 | local result2=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -fsLI -X GET --write-out %{http_code} --output /dev/null --max-time 10 --tlsv1.3 "https://www.netflix.com/title/70143836" 2>&1)
1195 | local regiontmp=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -fSsI -X GET --max-time 10 --write-out %{redirect_url} --output /dev/null --tlsv1.3 "https://www.netflix.com/login" 2>&1)
1196 | if [[ $regiontmp == "curl"* ]];then
1197 | netflix[ustatus]="${smedia[bad]}"
1198 | netflix[uregion]="${smedia[nodata]}"
1199 | netflix[utype]="${smedia[nodata]}"
1200 | return
1201 | fi
1202 | local region=$(echo $regiontmp|cut -d '/' -f4|cut -d '-' -f1|tr [:lower:] [:upper:])
1203 | if [[ -z $region ]];then
1204 | region="US"
1205 | fi
1206 | if [[ $result1 == "404" ]]&&[[ $result2 == "404" ]];then
1207 | netflix[ustatus]="${smedia[org]}"
1208 | netflix[uregion]=" [$region] "
1209 | netflix[utype]="$resultunlocktype"
1210 | return
1211 | elif [[ $result1 == "403" ]]&&[[ $result2 == "403" ]];then
1212 | netflix[ustatus]="${smedia[no]}"
1213 | netflix[uregion]="${smedia[nodata]}"
1214 | netflix[utype]="${smedia[nodata]}"
1215 | return
1216 | elif [[ $result1 == "200" ]]||[[ $result2 == "200" ]];then
1217 | netflix[ustatus]="${smedia[yes]}"
1218 | netflix[uregion]=" [$region] "
1219 | netflix[utype]="$resultunlocktype"
1220 | return
1221 | elif [[ $result1 == "000" ]];then
1222 | netflix[ustatus]="${smedia[bad]}"
1223 | netflix[uregion]="${smedia[nodata]}"
1224 | netflix[utype]="${smedia[nodata]}"
1225 | return
1226 | fi
1227 | netflix[ustatus]="${smedia[bad]}"
1228 | netflix[uregion]="${smedia[nodata]}"
1229 | netflix[utype]="${smedia[nodata]}"
1230 | }
1231 | function MediaUnlockTest_YouTube_Premium(){
1232 | local temp_info="$Font_Cyan$Font_B${sinfo[media]}${Font_I}Youtube $Font_Suffix"
1233 | ((ibar_step+=3))
1234 | show_progress_bar "$temp_info" $((40-8-${sinfo[lmedia]}))&
1235 | bar_pid="$!"&&disown "$bar_pid"
1236 | trap "kill_progress_bar" RETURN
1237 | youtube=()
1238 | local checkunlockurl="www.youtube.com"
1239 | local result1=$(Check_DNS_1 $checkunlockurl)
1240 | local result3=$(Check_DNS_3 $checkunlockurl)
1241 | local resultunlocktype=$(Get_Unlock_Type $result1 $result3)
1242 | local tmpresult=$(curl $CurlARG -$1 --max-time 10 -sSL -H "Accept-Language: en" -b "YSC=BiCUU3-5Gdk; CONSENT=YES+cb.20220301-11-p0.en+FX+700; GPS=1; VISITOR_INFO1_LIVE=4VwPMkB7W5A; PREF=tz=Asia.Shanghai; _gcl_au=1.1.1809531354.1646633279" "https://www.youtube.com/premium" 2>&1)
1243 | if [[ $tmpresult == "curl"* ]];then
1244 | youtube[ustatus]="${smedia[bad]}"
1245 | youtube[uregion]="${smedia[nodata]}"
1246 | youtube[utype]="${smedia[nodata]}"
1247 | return
1248 | fi
1249 | local isCN=$(echo $tmpresult|grep 'www.google.cn')
1250 | if [ -n "$isCN" ];then
1251 | youtube[ustatus]="${smedia[cn]}"
1252 | youtube[uregion]=" $Font_Red[CN]$Font_Green "
1253 | youtube[utype]="${smedia[nodata]}"
1254 | return
1255 | fi
1256 | local isNotAvailable=$(echo $tmpresult|grep 'Premium is not available in your country')
1257 | local region=$(echo $tmpresult|sed -n 's/.*"contentRegion":"\([^"]*\)".*/\1/p')
1258 | local isAvailable=$(echo $tmpresult|grep 'ad-free')
1259 | if [ -n "$isNotAvailable" ];then
1260 | youtube[ustatus]="${smedia[noprem]}"
1261 | youtube[uregion]="${smedia[nodata]}"
1262 | youtube[utype]="${smedia[nodata]}"
1263 | return
1264 | elif [ -n "$isAvailable" ]&&[ -n "$region" ];then
1265 | youtube[ustatus]="${smedia[yes]}"
1266 | youtube[uregion]=" [$region] "
1267 | youtube[utype]="$resultunlocktype"
1268 | return
1269 | elif [ -z "$region" ]&&[ -n "$isAvailable" ];then
1270 | youtube[ustatus]="${smedia[yes]}"
1271 | youtube[uregion]="${smedia[nodata]}"
1272 | youtube[utype]="$resultunlocktype"
1273 | return
1274 | else
1275 | youtube[ustatus]="${smedia[bad]}"
1276 | youtube[uregion]="${smedia[nodata]}"
1277 | youtube[utype]="${smedia[nodata]}"
1278 | fi
1279 | }
1280 | function MediaUnlockTest_PrimeVideo_Region(){
1281 | local temp_info="$Font_Cyan$Font_B${sinfo[media]}${Font_I}Amazon $Font_Suffix"
1282 | ((ibar_step+=3))
1283 | show_progress_bar "$temp_info" $((40-7-${sinfo[lmedia]}))&
1284 | bar_pid="$!"&&disown "$bar_pid"
1285 | trap "kill_progress_bar" RETURN
1286 | amazon=()
1287 | local checkunlockurl="www.primevideo.com"
1288 | local result1=$(Check_DNS_1 $checkunlockurl)
1289 | local result3=$(Check_DNS_3 $checkunlockurl)
1290 | local resultunlocktype=$(Get_Unlock_Type $result1 $result3)
1291 | local tmpresult=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -sL --max-time 10 "https://www.primevideo.com" 2>&1)
1292 | if [[ $tmpresult == "curl"* ]];then
1293 | amazon[ustatus]="${smedia[bad]}"
1294 | amazon[uregion]="${smedia[nodata]}"
1295 | amazon[utype]="${smedia[nodata]}"
1296 | return
1297 | fi
1298 | local result=$(echo $tmpresult|grep '"currentTerritory":'|sed 's/.*currentTerritory//'|cut -f3 -d'"'|head -n 1)
1299 | if [ -n "$result" ];then
1300 | amazon[ustatus]="${smedia[yes]}"
1301 | amazon[uregion]=" [$result] "
1302 | amazon[utype]="$resultunlocktype"
1303 | return
1304 | else
1305 | amazon[ustatus]="${smedia[no]}"
1306 | amazon[uregion]="${smedia[nodata]}"
1307 | amazon[utype]="${smedia[nodata]}"
1308 | return
1309 | fi
1310 | }
1311 | function MediaUnlockTest_Spotify(){
1312 | local temp_info="$Font_Cyan$Font_B${sinfo[media]}${Font_I}Spotify $Font_Suffix"
1313 | ((ibar_step+=3))
1314 | show_progress_bar "$temp_info" $((40-8-${sinfo[lmedia]}))&
1315 | bar_pid="$!"&&disown "$bar_pid"
1316 | trap "kill_progress_bar" RETURN
1317 | spotify=()
1318 | local checkunlockurl="spclient.wg.spotify.com"
1319 | local result1=$(Check_DNS_1 $checkunlockurl)
1320 | local result3=$(Check_DNS_3 $checkunlockurl)
1321 | local resultunlocktype=$(Get_Unlock_Type $result1 $result3)
1322 | local tmpresult=$(curl $CurlARG -$1 --user-agent "$UA_Browser" -s --max-time 10 -X POST "https://spclient.wg.spotify.com/signup/public/v1/account" -d "birth_day=11&birth_month=11&birth_year=2000&collect_personal_info=undefined&creation_flow=&creation_point=https%3A%2F%2Fwww.spotify.com%2Fhk-en%2F&displayname=Gay%20Lord&gender=male&iagree=1&key=a1e486e2729f46d6bb368d6b2bcda326&platform=www&referrer=&send-email=0&thirdpartyemail=0&identifier_token=AgE6YTvEzkReHNfJpO114514" -H "Accept-Language: en" 2>&1)
1323 | if echo "$tmpresult"|jq . >/dev/null 2>&1;then
1324 | local region=$(echo $tmpresult|jq -r '.country')
1325 | local isLaunched=$(echo $tmpresult|jq -r '.is_country_launched')
1326 | local StatusCode=$(echo $tmpresult|jq -r '.status')
1327 | if [ "$tmpresult" = "000" ];then
1328 | spotify[ustatus]="${smedia[bad]}"
1329 | spotify[uregion]="${smedia[nodata]}"
1330 | spotify[utype]="${smedia[nodata]}"
1331 | return
1332 | elif [ "$StatusCode" = "320" ]||[ "$StatusCode" = "120" ];then
1333 | spotify[ustatus]="${smedia[no]}"
1334 | spotify[uregion]="${smedia[nodata]}"
1335 | spotify[utype]="${smedia[nodata]}"
1336 | return
1337 | elif [ "$StatusCode" = "311" ]&&[ "$isLaunched" = "true" ];then
1338 | spotify[ustatus]="${smedia[yes]}"
1339 | spotify[uregion]=" [$region] "
1340 | spotify[utype]="$resultunlocktype"
1341 | return
1342 | else
1343 | spotify[ustatus]="${smedia[bad]}"
1344 | spotify[uregion]="${smedia[nodata]}"
1345 | spotify[utype]="${smedia[nodata]}"
1346 | return
1347 | fi
1348 | else
1349 | spotify[ustatus]="${smedia[bad]}"
1350 | spotify[uregion]="${smedia[nodata]}"
1351 | spotify[utype]="${smedia[nodata]}"
1352 | return
1353 | fi
1354 | }
1355 | function OpenAITest(){
1356 | local temp_info="$Font_Cyan$Font_B${sinfo[ai]}${Font_I}ChatGPT $Font_Suffix"
1357 | ((ibar_step+=3))
1358 | show_progress_bar "$temp_info" $((40-8-${sinfo[lai]}))&
1359 | bar_pid="$!"&&disown "$bar_pid"
1360 | trap "kill_progress_bar" RETURN
1361 | chatgpt=()
1362 | local checkunlockurl="chat.openai.com"
1363 | local result1=$(Check_DNS_1 $checkunlockurl)
1364 | local result2=$(Check_DNS_2 $checkunlockurl)
1365 | local result3=$(Check_DNS_3 $checkunlockurl)
1366 | local checkunlockurl="ios.chat.openai.com"
1367 | local result4=$(Check_DNS_1 $checkunlockurl)
1368 | local result5=$(Check_DNS_2 $checkunlockurl)
1369 | local result6=$(Check_DNS_3 $checkunlockurl)
1370 | local checkunlockurl="api.openai.com"
1371 | local result7=$(Check_DNS_1 $checkunlockurl)
1372 | local result8=$(Check_DNS_3 $checkunlockurl)
1373 | local resultunlocktype=$(Get_Unlock_Type $result1 $result2 $result3 $result4 $result5 $result6 $result7 $result8)
1374 | local tmpresult1=$(curl $CurlARG -$1 -sS --max-time 10 'https://api.openai.com/compliance/cookie_requirements' -H 'authority: api.openai.com' -H 'accept: */*' -H 'accept-language: zh-CN,zh;q=0.9' -H 'authorization: Bearer null' -H 'content-type: application/json' -H 'origin: https://platform.openai.com' -H 'referer: https://platform.openai.com/' -H 'sec-ch-ua: "Microsoft Edge";v="119", "Chromium";v="119", "Not?A_Brand";v="24"' -H 'sec-ch-ua-mobile: ?0' -H 'sec-ch-ua-platform: "Windows"' -H 'sec-fetch-dest: empty' -H 'sec-fetch-mode: cors' -H 'sec-fetch-site: same-site' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0' 2>&1)
1375 | local tmpresult2=$(curl $CurlARG -$1 -sS --max-time 10 'https://ios.chat.openai.com/' -H 'authority: ios.chat.openai.com' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' -H 'accept-language: zh-CN,zh;q=0.9' -H 'sec-ch-ua: "Microsoft Edge";v="119", "Chromium";v="119", "Not?A_Brand";v="24"' -H 'sec-ch-ua-mobile: ?0' -H 'sec-ch-ua-platform: "Windows"' -H 'sec-fetch-dest: document' -H 'sec-fetch-mode: navigate' -H 'sec-fetch-site: none' -H 'sec-fetch-user: ?1' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0' 2>&1)
1376 | local result1=$(echo $tmpresult1|grep unsupported_country)
1377 | local result2=$(echo $tmpresult2|grep VPN)
1378 | local countryCode="$(curl $CurlARG --max-time 10 -sS https://chat.openai.com/cdn-cgi/trace 2>&1|grep "loc="|awk -F= '{print $2}')"
1379 | if [ -z "$result2" ]&&[ -z "$result1" ]&&[[ $tmpresult1 != "curl"* ]]&&[[ $tmpresult2 != "curl"* ]];then
1380 | chatgpt[ustatus]="${smedia[yes]}"
1381 | chatgpt[uregion]=" [$countryCode] "
1382 | chatgpt[utype]="$resultunlocktype"
1383 | return
1384 | elif [ -n "$result2" ]&&[ -n "$result1" ];then
1385 | chatgpt[ustatus]="${smedia[no]}"
1386 | chatgpt[uregion]="${smedia[nodata]}"
1387 | chatgpt[utype]="${smedia[nodata]}"
1388 | return
1389 | elif [ -z "$result1" ]&&[ -n "$result2" ]&&[[ $tmpresult1 != "curl"* ]];then
1390 | chatgpt[ustatus]="${smedia[web]}"
1391 | chatgpt[uregion]=" [$countryCode] "
1392 | chatgpt[utype]="$resultunlocktype"
1393 | return
1394 | elif [ -n "$result1" ]&&[ -z "$result2" ];then
1395 | chatgpt[ustatus]="${smedia[app]}"
1396 | chatgpt[uregion]=" [$countryCode] "
1397 | chatgpt[utype]="$resultunlocktype"
1398 | return
1399 | elif [[ $tmpresult1 == "curl"* ]]&&[ -n "$result2" ];then
1400 | chatgpt[ustatus]="${smedia[no]}"
1401 | chatgpt[uregion]="${smedia[nodata]}"
1402 | chatgpt[utype]="${smedia[nodata]}"
1403 | return
1404 | else
1405 | chatgpt[ustatus]="${smedia[bad]}"
1406 | chatgpt[uregion]="${smedia[nodata]}"
1407 | chatgpt[utype]="${smedia[nodata]}"
1408 | return
1409 | fi
1410 | }
1411 | check_local_port_25(){
1412 | local host=$1
1413 | local port=$2
1414 | nc -s "$IP" -z -w5 $host $port >/dev/null 2>&1
1415 | if [ $? -eq 0 ]&&[ -z "$usePROXY" ];then
1416 | smail[local]=1
1417 | else
1418 | smail[local]=0
1419 | fi
1420 | }
1421 | get_sorted_mx_records(){
1422 | local domain=$1
1423 | dig +short MX $domain|sort -n|head -1|awk '{print $2}'
1424 | }
1425 | check_email_service(){
1426 | local service=$1
1427 | local port=25
1428 | local expected_response="220"
1429 | local domain=""
1430 | local host=""
1431 | local response=""
1432 | local success="false"
1433 | case $service in
1434 | "Gmail")domain="gmail.com";;
1435 | "Outlook")domain="outlook.com";;
1436 | "Yahoo")domain="yahoo.com";;
1437 | "Apple")domain="me.com";;
1438 | "QQ")domain="qq.com";;
1439 | "MailRU")domain="mail.ru";;
1440 | "AOL")domain="aol.com";;
1441 | "GMX")domain="gmx.com";;
1442 | "MailCOM")domain="mail.com";;
1443 | "163")domain="163.com";;
1444 | "Sohu")domain="sohu.com";;
1445 | "Sina")domain="sina.com";;
1446 | *)return
1447 | esac
1448 | if [[ -z $host ]];then
1449 | local mx_hosts=($(get_sorted_mx_records $domain))
1450 | for host in "${mx_hosts[@]}";do
1451 | response=$(timeout 4 bash -c "echo -e 'QUIT\r\n' | nc -s $IP -w4 $host $port 2>&1")
1452 | smail_response[$service]=$response
1453 | if [[ $response == *"$expected_response"* ]];then
1454 | success="true"
1455 | smail[$service]="$Back_Green$Font_White$Font_B$service$Font_Suffix"
1456 | break
1457 | fi
1458 | done
1459 | else
1460 | response=$(timeout 4 bash -c "echo -e 'QUIT\r\n' | nc -s $IP -w4 $host $port 2>&1")
1461 | if [[ $response == *"$expected_response"* ]];then
1462 | success="true"
1463 | smail[$service]="$Back_Green$Font_White$Font_B$service$Font_Suffix"
1464 | fi
1465 | fi
1466 | if [[ $success == "false" ]];then
1467 | smail[$service]="$Back_Red$Font_White$Font_B$service$Font_Suffix"
1468 | fi
1469 | }
1470 | check_mail(){
1471 | check_local_port_25 "localhost" 25
1472 | if [ ${smail[local]} -eq 1 ];then
1473 | services=("Gmail" "Outlook" "Yahoo" "Apple" "QQ" "MailRU" "AOL" "GMX" "MailCOM" "163" "Sohu" "Sina")
1474 | for service in "${services[@]}";do
1475 | local temp_info="$Font_Cyan$Font_B${sinfo[mail]}$Font_I$service $Font_Suffix"
1476 | ((ibar_step+=3))
1477 | show_progress_bar "$temp_info" $((40-1-${#service}-${sinfo[lmail]}))&
1478 | bar_pid="$!"&&disown "$bar_pid"
1479 | check_email_service $service
1480 | kill_progress_bar
1481 | done
1482 | fi
1483 | }
1484 | check_dnsbl_parallel(){
1485 | ip_to_check=$1
1486 | parallel_jobs=$2
1487 | smail[t]=0
1488 | smail[c]=0
1489 | smail[m]=0
1490 | smail[b]=0
1491 | reversed_ip=$(echo "$ip_to_check"|awk -F. '{print $4"."$3"."$2"."$1}')
1492 | local total=0
1493 | local clean=0
1494 | local blacklisted=0
1495 | local other=0
1496 | curl $CurlARG -s "https://raw.githubusercontent.com/xykt/IPQuality/main/ref/dnsbl.list"|sort -u|xargs -P "$parallel_jobs" -I {} bash -c "result=\$(dig +short \"$reversed_ip.{}\" A); if [[ -z \"\$result\" ]]; then echo 'Clean'; elif [[ \"\$result\" == '127.0.0.2' ]]; then echo 'Blacklisted'; else echo 'Other'; fi"|{
1497 | while IFS= read -r line;do
1498 | ((total++))
1499 | case "$line" in
1500 | "Clean")((clean++));;
1501 | "Blacklisted")((blacklisted++));;
1502 | *)((other++))
1503 | esac
1504 | done
1505 | smail[t]="$total"
1506 | smail[c]="$clean"
1507 | smail[m]="$other"
1508 | smail[b]="$blacklisted"
1509 | echo "$Font_Cyan${smail[dnsbl]} ${smail[available]}${smail[t]} ${smail[clean]}${smail[c]} ${smail[marked]}${smail[m]} ${smail[blacklisted]}${smail[b]}$Font_Suffix"
1510 | }
1511 | }
1512 | check_dnsbl(){
1513 | local temp_info="$Font_Cyan$Font_B${sinfo[dnsbl]} $Font_Suffix"
1514 | ((ibar_step=95))
1515 | show_progress_bar "$temp_info" $((40-1-${sinfo[ldnsbl]}))&
1516 | bar_pid="$!"&&disown "$bar_pid"
1517 | trap "kill_progress_bar" RETURN
1518 | smail[sdnsbl]=$(check_dnsbl_parallel "$IP" 50)
1519 | }
1520 | show_head(){
1521 | echo -ne "\r$(printf '%72s'|tr ' ' '#')\n"
1522 | if [ $fullIP -eq 1 ];then
1523 | calc_padding "$(printf '%*s' "${shead[ltitle]}" '')$IP" 72
1524 | echo -ne "\r$PADDING$Font_B${shead[title]}$Font_Cyan$IP$Font_Suffix\n"
1525 | else
1526 | calc_padding "$(printf '%*s' "${shead[ltitle]}" '')$IPhide" 72
1527 | echo -ne "\r$PADDING$Font_B${shead[title]}$Font_Cyan$IPhide$Font_Suffix\n"
1528 | fi
1529 | calc_padding "${shead[bash]}" 72
1530 | echo -ne "\r$PADDING${shead[bash]}\n"
1531 | calc_padding "${shead[git]}" 72
1532 | echo -ne "\r$PADDING$Font_U${shead[git]}$Font_Suffix\n"
1533 | echo -ne "\r${shead[ptime]}${shead[time]} ${shead[ver]}\n"
1534 | echo -ne "\r$(printf '%72s'|tr ' ' '#')\n"
1535 | }
1536 | show_basic(){
1537 | echo -ne "\r${sbasic[title]}\n"
1538 | if [[ -n ${maxmind[asn]} && ${maxmind[asn]} != "null" ]];then
1539 | echo -ne "\r$Font_Cyan${sbasic[asn]}${Font_Green}AS${maxmind[asn]}$Font_Suffix\n"
1540 | echo -ne "\r$Font_Cyan${sbasic[org]}$Font_Green${maxmind[org]}$Font_Suffix\n"
1541 | else
1542 | echo -ne "\r$Font_Cyan${sbasic[asn]}${sbasic[noasn]}$Font_Suffix\n"
1543 | fi
1544 | if [[ ${maxmind[dms]} != "null" && ${maxmind[map]} != "null" ]];then
1545 | echo -ne "\r$Font_Cyan${sbasic[location]}$Font_Green${maxmind[dms]}$Font_Suffix\n"
1546 | echo -ne "\r$Font_Cyan${sbasic[map]}$Font_U$Font_Green${maxmind[map]}$Font_Suffix\n"
1547 | fi
1548 | local city_info=""
1549 | if [[ -n ${maxmind[sub]} && ${maxmind[sub]} != "null" ]];then
1550 | city_info+="${maxmind[sub]}"
1551 | fi
1552 | if [[ -n ${maxmind[city]} && ${maxmind[city]} != "null" ]];then
1553 | [[ -n $city_info ]]&&city_info+=", "
1554 | city_info+="${maxmind[city]}"
1555 | fi
1556 | if [[ -n ${maxmind[post]} && ${maxmind[post]} != "null" ]];then
1557 | [[ -n $city_info ]]&&city_info+=", "
1558 | city_info+="${maxmind[post]}"
1559 | fi
1560 | if [[ -n $city_info ]];then
1561 | echo -ne "\r$Font_Cyan${sbasic[city]}$Font_Green$city_info$Font_Suffix\n"
1562 | fi
1563 | if [[ -n ${maxmind[countrycode]} && ${maxmind[countrycode]} != "null" ]];then
1564 | echo -ne "\r$Font_Cyan${sbasic[country]}$Font_Green[${maxmind[countrycode]}]${maxmind[country]}$Font_Suffix"
1565 | if [[ -n ${maxmind[continentcode]} && ${maxmind[continentcode]} != "null" ]];then
1566 | echo -ne "$Font_Green, [${maxmind[continentcode]}]${maxmind[continent]}$Font_Suffix\n"
1567 | else
1568 | echo -ne "\n"
1569 | fi
1570 | elif [[ -n ${maxmind[continentcode]} && ${maxmind[continentcode]} != "null" ]];then
1571 | echo -ne "\r$Font_Cyan${sbasic[continent]}$Font_Green[${maxmind[continentcode]}]${maxmind[continent]}$Font_Suffix\n"
1572 | fi
1573 | if [[ -n ${maxmind[regcountrycode]} && ${maxmind[regcountrycode]} != "null" ]];then
1574 | echo -ne "\r$Font_Cyan${sbasic[regcountry]}$Font_Green[${maxmind[regcountrycode]}]${maxmind[regcountry]}$Font_Suffix\n"
1575 | fi
1576 | if [[ -n ${maxmind[timezone]} && ${maxmind[timezone]} != "null" ]];then
1577 | echo -ne "\r$Font_Cyan${sbasic[timezone]}$Font_Green${maxmind[timezone]}$Font_Suffix\n"
1578 | fi
1579 | if [[ -n ${maxmind[countrycode]} && ${maxmind[countrycode]} != "null" ]];then
1580 | if [ "${maxmind[countrycode]}" == "${maxmind[regcountrycode]}" ];then
1581 | echo -ne "\r$Font_Cyan${sbasic[type]}$Back_Green$Font_B$Font_White${sbasic[type0]}$Font_Suffix\n"
1582 | else
1583 | echo -ne "\r$Font_Cyan${sbasic[type]}$Back_Red$Font_B$Font_White${sbasic[type1]}$Font_Suffix\n"
1584 | fi
1585 | fi
1586 | }
1587 | show_type(){
1588 | echo -ne "\r${stype[title]}\n"
1589 | echo -ne "\r$Font_Cyan${stype[db]}$Font_I IPinfo ipregistry ipapi AbuseIPDB IP2LOCATION $Font_Suffix\n"
1590 | echo -ne "\r$Font_Cyan${stype[usetype]}$Font_Suffix${ipinfo[susetype]}${ipregistry[susetype]}${ipapi[susetype]}${abuseipdb[susetype]}${ip2location[susetype]}\n"
1591 | echo -ne "\r$Font_Cyan${stype[comtype]}$Font_Suffix${ipinfo[scomtype]}${ipregistry[susetype]}${ipapi[susetype]}\n"
1592 | }
1593 | sscore_text(){
1594 | local text="$1"
1595 | local p2=$2
1596 | local p3=$3
1597 | local p4=$4
1598 | local p5=$5
1599 | local p6=$6
1600 | local tmplen
1601 | local tmp
1602 | if ((p2>=p4));then
1603 | tmplen=$((49+15*(p2-p4)/(p5-p4)-p6))
1604 | elif ((p2>=p3));then
1605 | tmplen=$((33+16*(p2-p3)/(p4-p3)-p6))
1606 | elif ((p2>=0));then
1607 | tmplen=$((17+16*p2/p3-p6))
1608 | else
1609 | tmplen=0
1610 | fi
1611 | tmp=$(printf '%*s' $tmplen '')
1612 | local total_length=${#tmp}
1613 | local text_length=${#text}
1614 | local tmp1="${tmp:1:total_length-text_length}$text|"
1615 | sscore[text1]="${tmp1:1:16-p6}"
1616 | sscore[text2]="${tmp1:17-p6:16}"
1617 | sscore[text3]="${tmp1:33-p6:16}"
1618 | sscore[text4]="${tmp1:49-p6}"
1619 | }
1620 | show_score(){
1621 | echo -ne "\r${sscore[title]}\n"
1622 | echo -ne "\r${sscore[range]}\n"
1623 | if [[ -n ${scamalytics[score]} ]];then
1624 | sscore_text "${scamalytics[score]}" ${scamalytics[score]} 25 50 100 13
1625 | echo -ne "\r${Font_Cyan}SCAMALYTICS${sscore[colon]}$Font_White$Font_B${sscore[text1]}$Back_Green${sscore[text2]}$Back_Yellow${sscore[text3]}$Back_Red${sscore[text4]}$Font_Suffix${scamalytics[risk]}\n"
1626 | fi
1627 | if [[ -n ${ipapi[score]} ]];then
1628 | local tmp_score=$(echo "${ipapi[scorenum]} * 10000 / 1"|bc)
1629 | sscore_text "${ipapi[score]}" $tmp_score 85 300 10000 7
1630 | echo -ne "\r${Font_Cyan}ipapi${sscore[colon]}$Font_White$Font_B${sscore[text1]}$Back_Green${sscore[text2]}$Back_Yellow${sscore[text3]}$Back_Red${sscore[text4]}$Font_Suffix${ipapi[risk]}\n"
1631 | fi
1632 | sscore_text "${abuseipdb[score]}" ${abuseipdb[score]} 25 25 100 11
1633 | echo -ne "\r${Font_Cyan}AbuseIPDB${sscore[colon]}$Font_White$Font_B${sscore[text1]}$Back_Green${sscore[text2]}$Back_Yellow${sscore[text3]}$Back_Red${sscore[text4]}$Font_Suffix${abuseipdb[risk]}\n"
1634 | if [ -n "${ipqs[score]}" ]&&[ "${ipqs[score]}" != "null" ];then
1635 | sscore_text "${ipqs[score]}" ${ipqs[score]} 75 85 100 6
1636 | echo -ne "\r${Font_Cyan}IPQS${sscore[colon]}$Font_White$Font_B${sscore[text1]}$Back_Green${sscore[text2]}$Back_Yellow${sscore[text3]}$Back_Red${sscore[text4]}$Font_Suffix${ipqs[risk]}\n"
1637 | fi
1638 | if [ -n "${cloudflare[score]}" ]&&[ "${cloudflare[score]}" != "null" ];then
1639 | sscore_text "${cloudflare[score]}" ${cloudflare[score]} 75 85 100 12
1640 | echo -ne "\r${Font_Cyan}Cloudflare${sscore[colon]}$Font_White$Font_B${sscore[text1]}$Back_Green${sscore[text2]}$Back_Yellow${sscore[text3]}$Back_Red${sscore[text4]}$Font_Suffix${cloudflare[risk]}\n"
1641 | fi
1642 | sscore_text " " ${dbip[score]} 33 66 100 7
1643 | [[ -n ${dbip[risk]} ]]&&echo -ne "\r${Font_Cyan}DB-IP${sscore[colon]}$Font_White$Font_B${sscore[text1]}$Back_Green${sscore[text2]}$Back_Yellow${sscore[text3]}$Back_Red${sscore[text4]}$Font_Suffix${dbip[risk]}\n"
1644 | }
1645 | format_factor(){
1646 | local tmp_txt=" "
1647 | if [[ $1 == "true" ]];then
1648 | tmp_txt+="${sfactor[yes]}"
1649 | elif [[ $1 == "false" ]];then
1650 | tmp_txt+="${sfactor[no]}"
1651 | elif [ ${#1} -eq 2 ];then
1652 | tmp_txt+="$Font_Green[$1]$Font_Suffix"
1653 | else
1654 | tmp_txt+="${sfactor[na]}"
1655 | fi
1656 | tmp_txt+=" "
1657 | if [[ $2 == "true" ]];then
1658 | tmp_txt+="${sfactor[yes]}"
1659 | elif [[ $2 == "false" ]];then
1660 | tmp_txt+="${sfactor[no]}"
1661 | elif [ ${#2} -eq 2 ];then
1662 | tmp_txt+="$Font_Green[$2]$Font_Suffix"
1663 | else
1664 | tmp_txt+="${sfactor[na]}"
1665 | fi
1666 | tmp_txt+=" "
1667 | if [[ $3 == "true" ]];then
1668 | tmp_txt+="${sfactor[yes]}"
1669 | elif [[ $3 == "false" ]];then
1670 | tmp_txt+="${sfactor[no]}"
1671 | elif [ ${#3} -eq 2 ];then
1672 | tmp_txt+="$Font_Green[$3]$Font_Suffix"
1673 | else
1674 | tmp_txt+="${sfactor[na]}"
1675 | fi
1676 | tmp_txt+=" "
1677 | if [[ $4 == "true" ]];then
1678 | tmp_txt+="${sfactor[yes]}"
1679 | elif [[ $4 == "false" ]];then
1680 | tmp_txt+="${sfactor[no]}"
1681 | elif [ ${#4} -eq 2 ];then
1682 | tmp_txt+="$Font_Green[$4]$Font_Suffix"
1683 | else
1684 | tmp_txt+="${sfactor[na]}"
1685 | fi
1686 | tmp_txt+=" "
1687 | if [[ $5 == "true" ]];then
1688 | tmp_txt+="${sfactor[yes]}"
1689 | elif [[ $5 == "false" ]];then
1690 | tmp_txt+="${sfactor[no]}"
1691 | elif [ ${#5} -eq 2 ];then
1692 | tmp_txt+="$Font_Green[$5]$Font_Suffix"
1693 | else
1694 | tmp_txt+="${sfactor[na]}"
1695 | fi
1696 | tmp_txt+=" "
1697 | if [[ $6 == "true" ]];then
1698 | tmp_txt+="${sfactor[yes]}"
1699 | elif [[ $6 == "false" ]];then
1700 | tmp_txt+="${sfactor[no]}"
1701 | elif [ ${#6} -eq 2 ];then
1702 | tmp_txt+="$Font_Green[$6]$Font_Suffix"
1703 | else
1704 | tmp_txt+="${sfactor[na]}"
1705 | fi
1706 | tmp_txt+=" "
1707 | if [[ $7 == "true" ]];then
1708 | tmp_txt+="${sfactor[yes]}"
1709 | elif [[ $7 == "false" ]];then
1710 | tmp_txt+="${sfactor[no]}"
1711 | elif [ ${#7} -eq 2 ];then
1712 | tmp_txt+="$Font_Green[$7]$Font_Suffix"
1713 | else
1714 | tmp_txt+="${sfactor[na]}"
1715 | fi
1716 | tmp_txt+=" "
1717 | if [[ $8 == "true" ]];then
1718 | tmp_txt+="${sfactor[yes]}"
1719 | elif [[ $8 == "false" ]];then
1720 | tmp_txt+="${sfactor[no]}"
1721 | elif [ ${#8} -eq 2 ];then
1722 | tmp_txt+="$Font_Green[$8]$Font_Suffix"
1723 | else
1724 | tmp_txt+="${sfactor[na]}"
1725 | fi
1726 | echo "$tmp_txt"
1727 | }
1728 | show_factor(){
1729 | local tmp_factor=""
1730 | echo -ne "\r${sfactor[title]}\n"
1731 | echo -ne "\r$Font_Cyan${sfactor[factor]}${Font_I}IP2LOCATION ipapi ipregistry IPQS SCAMALYTICS ipdata IPinfo IPWHOIS$Font_Suffix\n"
1732 | tmp_factor=$(format_factor "${ip2location[countrycode]}" "${ipapi[countrycode]}" "${ipregistry[countrycode]}" "${ipqs[countrycode]}" "${scamalytics[countrycode]}" "${ipdata[countrycode]}" "${ipinfo[countrycode]}" "${ipwhois[countrycode]}")
1733 | echo -ne "\r$Font_Cyan${sfactor[countrycode]}$Font_Suffix$tmp_factor\n"
1734 | tmp_factor=$(format_factor "${ip2location[proxy]}" "${ipapi[proxy]}" "${ipregistry[proxy]}" "${ipqs[proxy]}" "${scamalytics[proxy]}" "${ipdata[proxy]}" "${ipinfo[proxy]}" "${ipwhois[proxy]}")
1735 | echo -ne "\r$Font_Cyan${sfactor[proxy]}$Font_Suffix$tmp_factor\n"
1736 | tmp_factor=$(format_factor "${ip2location[tor]}" "${ipapi[tor]}" "${ipregistry[tor]}" "${ipqs[tor]}" "${scamalytics[tor]}" "${ipdata[tor]}" "${ipinfo[tor]}" "${ipwhois[tor]}")
1737 | echo -ne "\r$Font_Cyan${sfactor[tor]}$Font_Suffix$tmp_factor\n"
1738 | tmp_factor=$(format_factor "${ip2location[vpn]}" "${ipapi[vpn]}" "${ipregistry[vpn]}" "${ipqs[vpn]}" "${scamalytics[vpn]}" "${ipdata[vpn]}" "${ipinfo[vpn]}" "${ipwhois[vpn]}")
1739 | echo -ne "\r$Font_Cyan${sfactor[vpn]}$Font_Suffix$tmp_factor\n"
1740 | tmp_factor=$(format_factor "${ip2location[server]}" "${ipapi[server]}" "${ipregistry[server]}" "${ipqs[server]}" "${scamalytics[server]}" "${ipdata[server]}" "${ipinfo[server]}" "${ipwhois[server]}")
1741 | echo -ne "\r$Font_Cyan${sfactor[server]}$Font_Suffix$tmp_factor\n"
1742 | tmp_factor=$(format_factor "${ip2location[abuser]}" "${ipapi[abuser]}" "${ipregistry[abuser]}" "${ipqs[abuser]}" "${scamalytics[abuser]}" "${ipdata[abuser]}" "${ipinfo[abuser]}" "${ipwhois[abuser]}")
1743 | echo -ne "\r$Font_Cyan${sfactor[abuser]}$Font_Suffix$tmp_factor\n"
1744 | tmp_factor=$(format_factor "${ip2location[robot]}" "${ipapi[robot]}" "${ipregistry[robot]}" "${ipqs[robot]}" "${scamalytics[robot]}" "${ipdata[robot]}" "${ipinfo[robot]}" "${ipwhois[robot]}")
1745 | echo -ne "\r$Font_Cyan${sfactor[robot]}$Font_Suffix$tmp_factor\n"
1746 | }
1747 | show_media(){
1748 | echo -ne "\r${smedia[title]}\n"
1749 | echo -ne "\r$Font_Cyan${smedia[meida]}$Font_I TikTok Disney+ Netflix Youtube AmazonPV Spotify ChatGPT $Font_Suffix\n"
1750 | echo -ne "\r$Font_Cyan${smedia[status]}${tiktok[ustatus]}${disney[ustatus]}${netflix[ustatus]}${youtube[ustatus]}${amazon[ustatus]}${spotify[ustatus]}${chatgpt[ustatus]}$Font_Suffix\n"
1751 | echo -ne "\r$Font_Cyan${smedia[region]}$Font_Green${tiktok[uregion]}${disney[uregion]}${netflix[uregion]}${youtube[uregion]}${amazon[uregion]}${spotify[uregion]}${chatgpt[uregion]}$Font_Suffix\n"
1752 | echo -ne "\r$Font_Cyan${smedia[type]}${tiktok[utype]}${disney[utype]}${netflix[utype]}${youtube[utype]}${amazon[utype]}${spotify[utype]}${chatgpt[utype]}$Font_Suffix\n"
1753 | }
1754 | show_mail(){
1755 | echo -ne "\r${smail[title]}\n"
1756 | if [ ${smail[local]} -eq 1 ];then
1757 | echo -ne "\r$Font_Cyan${smail[port]}$Font_Suffix${smail[yes]}\n"
1758 | echo -ne "\r$Font_Cyan${smail[provider]}$Font_Suffix"
1759 | for service in "${services[@]}";do
1760 | echo -ne "${smail[$service]} "
1761 | done
1762 | echo ""
1763 | else
1764 | echo -ne "\r$Font_Cyan${smail[port]}$Font_Suffix${smail[no]}\n"
1765 | fi
1766 | [[ $1 -eq 4 ]]&&echo -ne "\r${smail[sdnsbl]}\n"
1767 | }
1768 | show_tail(){
1769 | echo -ne "\r$(printf '%72s'|tr ' ' '=')\n"
1770 | echo -e ""
1771 | }
1772 | show_help(){
1773 | echo -ne "\r$shelp\n"
1774 | exit 0
1775 | }
1776 | check_IP(){
1777 | IP=$1
1778 | ibar_step=0
1779 | [[ $2 -eq 4 ]]&&hide_ipv4 $IP
1780 | [[ $2 -eq 6 ]]&&hide_ipv6 $IP
1781 | db_maxmind $2
1782 | db_ipinfo
1783 | db_scamalytics
1784 | db_ipapi
1785 | db_ip2location
1786 | db_dbip
1787 | db_ipwhois
1788 | db_cloudflare $2
1789 | MediaUnlockTest_TikTok $2
1790 | MediaUnlockTest_DisneyPlus $2
1791 | MediaUnlockTest_Netflix $2
1792 | MediaUnlockTest_YouTube_Premium $2
1793 | MediaUnlockTest_PrimeVideo_Region $2
1794 | MediaUnlockTest_Spotify $2
1795 | OpenAITest $2
1796 | check_mail
1797 | [[ $2 -eq 4 ]]&&check_dnsbl "$IP" 50
1798 | echo -ne "$Font_LineClear"
1799 | if [ $2 -eq 4 ]||[[ $IPV4work -eq 0 || $IPV4check -eq 0 ]];then
1800 | for ((i=0; i/dev/null; then
63 | is_busybox=1
64 | fi
65 |
66 | UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
67 | UA_Dalvik="Dalvik/2.1.0 (Linux; U; Android 9; ALP-AL00 Build/HUAWEIALP-AL00)"
68 | Media_Cookie=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/cookies")
69 | IATACode=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/reference/IATACode.txt")
70 | IATACode2=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/reference/IATACode2.txt" 2>&1)
71 | TVer_Cookie="Accept: application/json;pk=BCpkADawqM0_rzsjsYbC1k1wlJLU4HiAtfzjxdUmfvvLUQB-Ax6VA-p-9wOEZbCEm3u95qq2Y1CQQW1K9tPaMma9iAqUqhpISCmyXrgnlpx9soEmoVNuQpiyGsTpePGumWxSs1YoKziYB6Wz"
72 |
73 |
74 | checkOS() {
75 | ifTermux=$(echo $PWD | grep termux)
76 | ifMacOS=$(uname -a | grep Darwin)
77 | if [ -n "$ifTermux" ]; then
78 | os_version=Termux
79 | is_termux=1
80 | elif [ -n "$ifMacOS" ]; then
81 | os_version=MacOS
82 | is_macos=1
83 | else
84 | os_version=$(grep 'VERSION_ID' /etc/os-release | cut -d '"' -f 2 | tr -d '.')
85 | fi
86 |
87 | if [[ "$os_version" == "2004" ]] || [[ "$os_version" == "10" ]] || [[ "$os_version" == "11" ]]; then
88 | is_windows=1
89 | ssll="-k --ciphers DEFAULT@SECLEVEL=1"
90 | fi
91 |
92 | if [ "$(which apt 2>/dev/null)" ]; then
93 | InstallMethod="apt"
94 | is_debian=1
95 | elif [ "$(which dnf 2>/dev/null)" ] || [ "$(which yum 2>/dev/null)" ]; then
96 | InstallMethod="yum"
97 | is_redhat=1
98 | elif [[ "$os_version" == "Termux" ]]; then
99 | InstallMethod="pkg"
100 | elif [[ "$os_version" == "MacOS" ]]; then
101 | InstallMethod="brew"
102 | fi
103 | }
104 | checkOS
105 |
106 | checkCPU() {
107 | CPUArch=$(uname -m)
108 | if [[ "$CPUArch" == "aarch64" ]]; then
109 | arch=_arm64
110 | elif [[ "$CPUArch" == "i686" ]]; then
111 | arch=_i686
112 | elif [[ "$CPUArch" == "arm" ]]; then
113 | arch=_arm
114 | elif [[ "$CPUArch" == "x86_64" ]] && [ -n "$ifMacOS" ]; then
115 | arch=_darwin
116 | fi
117 | }
118 | checkCPU
119 |
120 | checkDependencies() {
121 |
122 | # os_detail=$(cat /etc/os-release 2> /dev/null)
123 |
124 | if ! command -v python &>/dev/null; then
125 | if command -v python3 &>/dev/null; then
126 | alias python="python3"
127 | else
128 | if [ "$is_debian" == 1 ]; then
129 | echo -e "${Font_Green}Installing python${Font_Suffix}"
130 | $InstallMethod update >/dev/null 2>&1
131 | $InstallMethod install python -y >/dev/null 2>&1
132 | elif [ "$is_redhat" == 1 ]; then
133 | echo -e "${Font_Green}Installing python${Font_Suffix}"
134 | if [[ "$os_version" -gt 7 ]]; then
135 | $InstallMethod makecache >/dev/null 2>&1
136 | $InstallMethod install python3 -y >/dev/null 2>&1
137 | alias python="python3"
138 | else
139 | $InstallMethod makecache >/dev/null 2>&1
140 | $InstallMethod install python -y >/dev/null 2>&1
141 | fi
142 |
143 | elif [ "$is_termux" == 1 ]; then
144 | echo -e "${Font_Green}Installing python${Font_Suffix}"
145 | $InstallMethod update -y >/dev/null 2>&1
146 | $InstallMethod install python -y >/dev/null 2>&1
147 |
148 | elif [ "$is_macos" == 1 ]; then
149 | echo -e "${Font_Green}Installing python${Font_Suffix}"
150 | $InstallMethod install python
151 | fi
152 | fi
153 | fi
154 |
155 | if ! command -v dig &>/dev/null; then
156 | if [ "$is_debian" == 1 ]; then
157 | echo -e "${Font_Green}Installing dnsutils${Font_Suffix}"
158 | $InstallMethod update >/dev/null 2>&1
159 | $InstallMethod install dnsutils -y >/dev/null 2>&1
160 | elif [ "$is_redhat" == 1 ]; then
161 | echo -e "${Font_Green}Installing bind-utils${Font_Suffix}"
162 | $InstallMethod makecache >/dev/null 2>&1
163 | $InstallMethod install bind-utils -y >/dev/null 2>&1
164 | elif [ "$is_termux" == 1 ]; then
165 | echo -e "${Font_Green}Installing dnsutils${Font_Suffix}"
166 | $InstallMethod update -y >/dev/null 2>&1
167 | $InstallMethod install dnsutils -y >/dev/null 2>&1
168 | elif [ "$is_macos" == 1 ]; then
169 | echo -e "${Font_Green}Installing bind${Font_Suffix}"
170 | $InstallMethod install bind
171 | fi
172 | fi
173 |
174 | if [ "$is_macos" == 1 ]; then
175 | if ! command -v md5sum &>/dev/null; then
176 | echo -e "${Font_Green}Installing md5sha1sum${Font_Suffix}"
177 | $InstallMethod install md5sha1sum
178 | fi
179 | fi
180 |
181 | }
182 | checkDependencies
183 |
184 | local_ipv4=$(curl $useNIC $usePROXY -4 -s --max-time 10 api64.ipify.org)
185 | local_ipv4_asterisk=$(awk -F"." '{print $1"."$2".*.*"}' <<<"${local_ipv4}")
186 | local_ipv6=$(curl $useNIC -6 -s --max-time 20 api64.ipify.org)
187 | local_ipv6_asterisk=$(awk -F":" '{print $1":"$2":"$3":*:*"}' <<<"${local_ipv6}")
188 | local_isp4=$(curl $useNIC -s -4 --max-time 10 --user-agent "${UA_Browser}" "https://api.ip.sb/geoip/${local_ipv4}" | grep organization | cut -f4 -d '"')
189 | local_isp6=$(curl $useNIC -s -6 --max-time 10 --user-agent "${UA_Browser}" "https://api.ip.sb/geoip/${local_ipv6}" | grep organization | cut -f4 -d '"')
190 |
191 | ShowRegion() {
192 | echo -e "${Font_Yellow} ---${1}---${Font_Suffix}"
193 | }
194 |
195 |
196 | function MediaUnlockTest_Netflix() {
197 | local tmpresult1=$(curl $useNIC $usePROXY $xForward -${1} --user-agent "${UA_Browser}" -fsL --max-time 10 "https://www.netflix.com/title/81280792" 2>&1)
198 | local tmpresult2=$(curl $useNIC $usePROXY $xForward -${1} --user-agent "${UA_Browser}" -fsL --max-time 10 "https://www.netflix.com/title/70143836" 2>&1)
199 | local result1=$(echo $tmpresult1 | grep -oP '"isPlayable":\K(true|false)')
200 | local result2=$(echo $tmpresult2 | grep -oP '"isPlayable":\K(true|false)')
201 |
202 | if [[ "$result1" == "false" ]] && [[ "$result2" == "false" ]]; then
203 | echo -n -e "\r Netflix:\t\t\t\t${Font_Yellow}Originals Only${Font_Suffix}\n"
204 | return
205 | elif [ -z "$result1" ] && [ -z "$result2" ]; then
206 | echo -n -e "\r Netflix:\t\t\t\t${Font_Red}No${Font_Suffix}\n"
207 | return
208 | elif [[ "$result1" == "true" ]] || [[ "$result2" == "true" ]]; then
209 | local region=$(echo $tmpresult1 | grep -oP '"requestCountry":{"id":"\K\w\w' | head -n 1)
210 | echo -n -e "\r Netflix:\t\t\t\t${Font_Green}Yes (Region: ${region})${Font_Suffix}\n"
211 | return
212 | else
213 | echo -n -e "\r Netflix:\t\t\t\t${Font_Red}Failed${Font_Suffix}\n"
214 | return
215 | fi
216 | }
217 |
218 | function MediaUnlockTest_YouTube_Premium() {
219 | local tmpresult=$(curl $useNIC $usePROXY $xForward -${1} --max-time 10 -sSL -H "Accept-Language: en" -b "YSC=BiCUU3-5Gdk; CONSENT=YES+cb.20220301-11-p0.en+FX+700; GPS=1; VISITOR_INFO1_LIVE=4VwPMkB7W5A; PREF=tz=Asia.Shanghai; _gcl_au=1.1.1809531354.1646633279" "https://www.youtube.com/premium" 2>&1)
220 |
221 | if [[ "$tmpresult" == "curl"* ]]; then
222 | echo -n -e "\r YouTube Premium:\t\t\t${Font_Red}Failed (Network Connection)${Font_Suffix}\n"
223 | return
224 | fi
225 |
226 | local isCN=$(echo $tmpresult | grep 'www.google.cn')
227 | if [ -n "$isCN" ]; then
228 | echo -n -e "\r YouTube Premium:\t\t\t${Font_Red}No${Font_Suffix} ${Font_Green} (Region: CN)${Font_Suffix} \n"
229 | return
230 | fi
231 | local isNotAvailable=$(echo $tmpresult | grep 'Premium is not available in your country')
232 | local region=$(echo $tmpresult | grep "countryCode" | sed 's/.*"countryCode"//' | cut -f2 -d'"')
233 | local isAvailable=$(echo $tmpresult | grep 'ad-free')
234 |
235 | if [ -n "$isNotAvailable" ]; then
236 | echo -n -e "\r YouTube Premium:\t\t\t${Font_Red}No${Font_Suffix} \n"
237 | return
238 | elif [ -n "$isAvailable" ] && [ -n "$region" ]; then
239 | echo -n -e "\r YouTube Premium:\t\t\t${Font_Green}Yes (Region: $region)${Font_Suffix}\n"
240 | return
241 | elif [ -z "$region" ] && [ -n "$isAvailable" ]; then
242 | echo -n -e "\r YouTube Premium:\t\t\t${Font_Green}Yes${Font_Suffix}\n"
243 | return
244 | else
245 | echo -n -e "\r YouTube Premium:\t\t\t${Font_Red}Failed${Font_Suffix}\n"
246 | fi
247 |
248 | }
249 |
250 |
251 | function MediaUnlockTest_YouTube_CDN() {
252 | local tmpresult=$(curl $useNIC $usePROXY $xForward -${1} ${ssll} -sS --max-time 10 "https://redirector.googlevideo.com/report_mapping" 2>&1)
253 |
254 | if [[ "$tmpresult" == "curl"* ]]; then
255 | echo -n -e "\r YouTube Region:\t\t\t${Font_Red}Check Failed (Network Connection)${Font_Suffix}\n"
256 | return
257 | fi
258 |
259 | local iata=$(echo $tmpresult | grep '=>'| awk "NR==1" | awk '{print $3}' | cut -f2 -d'-' | cut -c 1-3 | tr [:lower:] [:upper:])
260 |
261 | local isIataFound1=$(echo "$IATACode" | grep $iata)
262 | local isIataFound2=$(echo "$IATACode2" | grep $iata)
263 | if [ -n "$isIataFound1" ]; then
264 | local lineNo=$(echo "$IATACode" | cut -f3 -d"|" | sed -n "/${iata}/=")
265 | local location=$(echo "$IATACode" | awk "NR==${lineNo}" | cut -f1 -d"|" | sed -e 's/^[[:space:]]*//')
266 | elif [ -z "$isIataFound1" ] && [ -n "$isIataFound2" ]; then
267 | local lineNo=$(echo "$IATACode2" | awk '{print $1}' | sed -n "/${iata}/=")
268 | local location=$(echo "$IATACode2" | awk "NR==${lineNo}" | cut -f2 -d"," | sed -e 's/^[[:space:]]*//' | tr [:upper:] [:lower:] | sed 's/\b[a-z]/\U&/g')
269 | fi
270 |
271 | local isIDC=$(echo $tmpresult | grep "router")
272 | if [ -n "$iata" ] && [ -z "$isIDC" ]; then
273 | local CDN_ISP=$(echo $tmpresult | awk "NR==1" | awk '{print $3}' | cut -f1 -d"-" | tr [:lower:] [:upper:])
274 | echo -n -e "\r YouTube CDN:\t\t\t\t${Font_Yellow}$CDN_ISP in $location${Font_Suffix}\n"
275 | return
276 | elif [ -n "$iata" ] && [ -n "$isIDC" ]; then
277 | echo -n -e "\r YouTube CDN:\t\t\t\t${Font_Green}$location${Font_Suffix}\n"
278 | return
279 | else
280 | echo -n -e "\r YouTube CDN:\t\t\t\t${Font_Red}Undetectable${Font_Suffix}\n"
281 | return
282 | fi
283 |
284 | }
285 |
286 |
287 | function MediaUnlockTest_NetflixCDN() {
288 | local tmpresult=$(curl $useNIC $usePROXY $xForward -${1} ${ssll} -s --max-time 10 "https://api.fast.com/netflix/speedtest/v2?https=true&token=YXNkZmFzZGxmbnNkYWZoYXNkZmhrYWxm&urlCount=1" 2>&1)
289 | if [ -z "$tmpresult" ]; then
290 | echo -n -e "\r Netflix Preferred CDN:\t\t\t${Font_Red}Failed${Font_Suffix}\n"
291 | return
292 | elif [ -n "$(echo $tmpresult | grep '>403<')" ]; then
293 | echo -n -e "\r Netflix Preferred CDN:\t\t\t${Font_Red}Failed (IP Banned By Netflix)${Font_Suffix}\n"
294 | return
295 | fi
296 |
297 | local CDNAddr=$(echo $tmpresult | sed 's/.*"url":"//' | cut -f3 -d"/")
298 | if [[ "$1" == "6" ]]; then
299 | nslookup -q=AAAA $CDNAddr >~/v6_addr.txt
300 | ifAAAA=$(cat ~/v6_addr.txt | grep 'AAAA address' | awk '{print $NF}')
301 | if [ -z "$ifAAAA" ]; then
302 | CDNIP=$(cat ~/v6_addr.txt | grep Address | sed -n '$p' | awk '{print $NF}')
303 | else
304 | CDNIP=${ifAAAA}
305 | fi
306 | else
307 | CDNIP=$(nslookup $CDNAddr | sed '/^\s*$/d' | awk 'END {print}' | awk '{print $2}')
308 | fi
309 |
310 | if [ -z "$CDNIP" ]; then
311 | echo -n -e "\r Netflix Preferred CDN:\t\t\t${Font_Red}Failed (CDN IP Not Found)${Font_Suffix}\n"
312 | rm -rf ~/v6_addr.txt
313 | return
314 | fi
315 |
316 | local CDN_ISP=$(curl $useNIC $xForward --user-agent "${UA_Browser}" -s --max-time 20 "https://api.ip.sb/geoip/$CDNIP" 2>&1 | python -m json.tool 2>/dev/null | grep 'isp' | cut -f4 -d'"')
317 | local iata=$(echo $CDNAddr | cut -f3 -d"-" | sed 's/.\{3\}$//' | tr [:lower:] [:upper:])
318 |
319 | #local IATACode2=$(curl -s --retry 3 --max-time 10 "https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/reference/IATACode2.txt" 2>&1)
320 |
321 | local isIataFound1=$(echo "$IATACode" | grep $iata)
322 | local isIataFound2=$(echo "$IATACode2" | grep $iata)
323 |
324 | if [ -n "$isIataFound1" ]; then
325 | local lineNo=$(echo "$IATACode" | cut -f3 -d"|" | sed -n "/${iata}/=")
326 | local location=$(echo "$IATACode" | awk "NR==${lineNo}" | cut -f1 -d"|" | sed -e 's/^[[:space:]]*//')
327 | elif [ -z "$isIataFound1" ] && [ -n "$isIataFound2" ]; then
328 | local lineNo=$(echo "$IATACode2" | awk '{print $1}' | sed -n "/${iata}/=")
329 | local location=$(echo "$IATACode2" | awk "NR==${lineNo}" | cut -f2 -d"," | sed -e 's/^[[:space:]]*//' | tr [:upper:] [:lower:] | sed 's/\b[a-z]/\U&/g')
330 | fi
331 |
332 | if [ -n "$location" ] && [[ "$CDN_ISP" == "Netflix Streaming Services" ]]; then
333 | echo -n -e "\r Netflix Preferred CDN:\t\t\t${Font_Green}$location ${Font_Suffix}\n"
334 | rm -rf ~/v6_addr.txt
335 | return
336 | elif [ -n "$location" ] && [[ "$CDN_ISP" != "Netflix Streaming Services" ]]; then
337 | echo -n -e "\r Netflix Preferred CDN:\t\t\t${Font_Yellow}Associated with [$CDN_ISP] in [$location]${Font_Suffix}\n"
338 | rm -rf ~/v6_addr.txt
339 | return
340 | elif [ -n "$location" ] && [ -z "$CDN_ISP" ]; then
341 | echo -n -e "\r Netflix Preferred CDN:\t\t\t${Font_Red}No ISP Info Founded${Font_Suffix}\n"
342 | rm -rf ~/v6_addr.txt
343 | return
344 | fi
345 | }
346 |
347 |
348 | function MediaUnlockTest_Spotify() {
349 | local tmpresult=$(curl $useNIC $usePROXY $xForward -${1} ${ssll} --user-agent "${UA_Browser}" -s --max-time 10 -X POST "https://spclient.wg.spotify.com/signup/public/v1/account" -d "birth_day=11&birth_month=11&birth_year=2000&collect_personal_info=undefined&creation_flow=&creation_point=https%3A%2F%2Fwww.spotify.com%2Fhk-en%2F&displayname=Gay%20Lord&gender=male&iagree=1&key=a1e486e2729f46d6bb368d6b2bcda326&platform=www&referrer=&send-email=0&thirdpartyemail=0&identifier_token=AgE6YTvEzkReHNfJpO114514" -H "Accept-Language: en" 2>&1)
350 | local region=$(echo $tmpresult | python -m json.tool 2>/dev/null | grep '"country":' | cut -f4 -d'"')
351 | local isLaunched=$(echo $tmpresult | python -m json.tool 2>/dev/null | grep is_country_launched | cut -f1 -d',' | awk '{print $2}')
352 | local StatusCode=$(echo $tmpresult | python -m json.tool 2>/dev/null | grep status | cut -f1 -d',' | awk '{print $2}')
353 |
354 | if [ "$tmpresult" = "000" ]; then
355 | echo -n -e "\r Spotify Registration:\t\t\t${Font_Red}Failed (Network Connection)${Font_Suffix}\n"
356 | return
357 | elif [ "$StatusCode" = "320" ] || [ "$StatusCode" = "120" ]; then
358 | echo -n -e "\r Spotify Registration:\t\t\t${Font_Red}No${Font_Suffix}\n"
359 | return
360 | elif [ "$StatusCode" = "311" ] && [ "$isLaunched" = "true" ]; then
361 | echo -n -e "\r Spotify Registration:\t\t\t${Font_Green}Yes (Region: $region)${Font_Suffix}\n"
362 | return
363 | fi
364 | }
365 |
366 |
367 | function MediaUnlockTest_Instagram.Music() {
368 | local result=$(curl $useNIC $usePROXY $xForward -${1} ${ssll} -s --max-time 10 'https://www.instagram.com/api/graphql' -H 'Accept: */*' -H 'Accept-Language: zh-CN,zh;q=0.9' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: csrftoken=mmCtHhtfZRG-K3WgoYMemg; dpr=1.75; _js_ig_did=809EA442-22F7-4844-9470-ABC2AC4DE7AE; _js_datr=rb21ZbL7KR_5DN8m_43oEtgn; mid=ZbW9rgALAAECR590Ukv8bAlT8YQX; ig_did=809EA442-22F7-4844-9470-ABC2AC4DE7AE; ig_nrcb=1' -H 'Origin: https://www.instagram.com' -H 'Referer: https://www.instagram.com/p/C2YEAdOh9AB/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' -H 'X-ASBD-ID: 129477' -H 'X-CSRFToken: mmCtHhtfZRG-K3WgoYMemg' -H 'X-FB-Friendly-Name: PolarisPostActionLoadPostQueryQuery' -H 'X-FB-LSD: AVrkL73GMdk' -H 'X-IG-App-ID: 936619743392459' -H 'dpr: 1.75' -H 'sec-ch-prefers-color-scheme: light' -H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' -H 'sec-ch-ua-full-version-list: "Not_A Brand";v="8.0.0.0", "Chromium";v="120.0.6099.225", "Google Chrome";v="120.0.6099.225"' -H 'sec-ch-ua-mobile: ?0' -H 'sec-ch-ua-model: ""' -H 'sec-ch-ua-platform: "Windows"' -H 'sec-ch-ua-platform-version: "10.0.0"' -H 'viewport-width: 1640' --data-raw 'av=0&__d=www&__user=0&__a=1&__req=3&__hs=19750.HYP%3Ainstagram_web_pkg.2.1..0.0&dpr=1&__ccg=UNKNOWN&__rev=1011068636&__s=drshru%3Agu4p3s%3A0d8tzk&__hsi=7328972521009111950&__dyn=7xeUjG1mxu1syUbFp60DU98nwgU29zEdEc8co2qwJw5ux609vCwjE1xoswIwuo2awlU-cw5Mx62G3i1ywOwv89k2C1Fwc60AEC7U2czXwae4UaEW2G1NwwwNwKwHw8Xxm16wUwtEvw4JwJCwLyES1Twoob82ZwrUdUbGwmk1xwmo6O1FwlE6PhA6bxy4UjK5V8&__csr=gtneJ9lGF4HlRX-VHjmipBDGAhGuWV4uEyXyp22u6pU-mcx3BCGjHS-yabGq4rhoWBAAAKamtnBy8PJeUgUymlVF48AGGWxCiUC4E9HG78og01bZqx106Ag0clE0kVwdy0Nx4w2TU0iGDgChwmUrw2wVFQ9Bg3fw4uxfo2ow0asW&__comet_req=7&lsd=AVrkL73GMdk&jazoest=2909&__spin_r=1011068636&__spin_b=trunk&__spin_t=1706409389&fb_api_caller_class=RelayModern&fb_api_req_friendly_name=PolarisPostActionLoadPostQueryQuery&variables=%7B%22shortcode%22%3A%22C2YEAdOh9AB%22%2C%22fetch_comment_count%22%3A40%2C%22fetch_related_profile_media_count%22%3A3%2C%22parent_comment_count%22%3A24%2C%22child_comment_count%22%3A3%2C%22fetch_like_count%22%3A10%2C%22fetch_tagged_user_count%22%3Anull%2C%22fetch_preview_comment_count%22%3A2%2C%22has_threaded_comments%22%3Atrue%2C%22hoisted_comment_id%22%3Anull%2C%22hoisted_reply_id%22%3Anull%7D&server_timestamps=true&doc_id=10015901848480474' | grep -oP '"should_mute_audio":\K(false|true)')
369 | echo -n -e " Instagram Licensed Audio:\t\t->\c"
370 | if [[ "$result" == "false" ]]; then
371 | echo -n -e "\r Instagram Licensed Audio:\t\t${Font_Green}Yes${Font_Suffix}\n"
372 | elif [[ "$result" == "true" ]]; then
373 | echo -n -e "\r Instagram Licensed Audio:\t\t${Font_Red}No${Font_Suffix}\n"
374 | else
375 | echo -n -e "\r Instagram Licensed Audio:\t\t${Font_Red}Failed${Font_Suffix}\n"
376 | fi
377 |
378 | }
379 |
380 |
381 | function OpenAITest() {
382 | local location=$(curl -sS "https://chat.openai.com/cdn-cgi/trace" | grep -oP '(?<=loc=)[A-Z]{2}')
383 | local SUPPORT_COUNTRY=("AL" "DZ" "AD" "AO" "AG" "AR" "AM" "AU" "AT" "AZ" "BS" "BD" "BB" "BE" "BZ" "BJ" "BT" "BO" "BA" "BW" "BR" "BN" "BG" "BF" "CV" "CA" "CL" "CO" "KM" "CG" "CR" "CI" "HR" "CY" "CZ" "DK" "DJ" "DM" "DO" "EC" "SV" "EE" "FJ" "FI" "FR" "GA" "GM" "GE" "DE" "GH" "GR" "GD" "GT" "GN" "GW" "GY" "HT" "VA" "HN" "HU" "IS" "IN" "ID" "IQ" "IE" "IL" "IT" "JM" "JP" "JO" "KZ" "KE" "KI" "KW" "KG" "LV" "LB" "LS" "LR" "LI" "LT" "LU" "MG" "MW" "MY" "MV" "ML" "MT" "MH" "MR" "MU" "MX" "FM" "MD" "MC" "MN" "ME" "MA" "MZ" "MM" "NA" "NR" "NP" "NL" "NZ" "NI" "NE" "NG" "MK" "NO" "OM" "PK" "PW" "PS" "PA" "PG" "PY" "PE" "PH" "PL" "PT" "QA" "RO" "RW" "KN" "LC" "VC" "WS" "SM" "ST" "SN" "RS" "SC" "SL" "SG" "SK" "SI" "SB" "ZA" "KR" "ES" "LK" "SR" "SE" "CH" "TW" "TZ" "TH" "TL" "TG" "TO" "TT" "TN" "TR" "TV" "UG" "UA" "AE" "GB" "US" "UY" "VU" "ZM")
384 |
385 | if [[ " ${SUPPORT_COUNTRY[@]} " =~ " ${location} " ]]; then
386 | echo -n -e "\r ChatGPT:\t\t\t\t${Font_Green}Yes (Region: ${location})${Font_Suffix}\n"
387 | return
388 | else
389 | echo -n -e "\r ChatGPT:\t\t\t\t${Font_Red}No (Region: ${location})${Font_Suffix}\n"
390 | return
391 | fi
392 | }
393 |
394 |
395 |
396 | function Bing_Region(){
397 | local tmpresult=$(curl $useNIC $usePROXY $xForward -${1} ${ssll} -s --max-time 10 "https://www.bing.com/search?q=curl")
398 | local isCN=$(echo $tmpresult | grep 'cn.bing.com')
399 | local Region=$(echo $tmpresult | sed -n 's/.*Region:"\([^"]*\)".*/\1/p')
400 | if [ -n "$isCN" ]; then
401 | echo -n -e "\r Bing Region:\t\t\t\t${Font_Yellow}CN${Font_Suffix}\n"
402 | return
403 | else
404 | echo -n -e "\r Bing Region:\t\t\t\t${Font_Yellow}${Region}${Font_Suffix}\n"
405 | return
406 | fi
407 | }
408 |
409 |
410 | function echo_Result() {
411 | for((i=0;i<${#array[@]};i++))
412 | do
413 | echo "$result" | grep "${array[i]}"
414 | sleep 0.03
415 | done;
416 | }
417 |
418 |
419 | function Global_UnlockTest() {
420 | echo ""
421 | echo -e "${Font_Yellow}============[ Глобальный тест ]============${Font_Suffix}"
422 | echo ""
423 | local result=$(
424 | MediaUnlockTest_Netflix ${1} &
425 | MediaUnlockTest_YouTube_Premium ${1} &
426 | MediaUnlockTest_YouTube_CDN ${1} &
427 | MediaUnlockTest_NetflixCDN ${1} &
428 | MediaUnlockTest_Spotify ${1} &
429 | OpenAITest ${1} &
430 | Bing_Region ${1} &
431 | MediaUnlockTest_Instagram.Music ${1} &
432 | )
433 | wait
434 | local array=("Netflix:" "YouTube Premium:" "YouTube CDN:" "Netflix Preferred CDN:" "Spotify Registration:" "ChatGPT:" "Bing Region:" "Instagram Licensed Audio:")
435 | echo_Result ${result} ${array}
436 | echo "======================================="
437 | }
438 |
439 |
440 | function CheckPROXY() {
441 | if [ -n "$usePROXY" ]; then
442 | local proxy=$(echo $usePROXY | tr A-Z a-z)
443 | if [[ "$proxy" == *"socks:"* ]] ; then
444 | proxyType=Socks
445 | elif [[ "$proxy" == *"socks4:"* ]]; then
446 | proxyType=Socks4
447 | elif [[ "$proxy" == *"socks5:"* ]]; then
448 | proxyType=Socks5
449 | elif [[ "$proxy" == *"http"* ]]; then
450 | proxyType=http
451 | else
452 | proxyType=""
453 | fi
454 | local result1=$(curl $useNIC $usePROXY -sS --user-agent "${UA_Browser}" ip.sb 2>&1)
455 | local result2=$(curl $useNIC $usePROXY -sS --user-agent "${UA_Browser}" https://1.0.0.1/cdn-cgi/trace 2>&1)
456 | if [[ "$result1" == "curl"* ]] && [[ "$result2" == "curl"* ]] || [ -z "$proxyType" ]; then
457 | isproxy=0
458 | else
459 | isproxy=1
460 | fi
461 | else
462 | isproxy=0
463 | fi
464 | }
465 |
466 |
467 |
468 | function CheckV4() {
469 | CheckPROXY
470 | if [[ "$NetworkType" == "6" ]]; then
471 | isv4=0
472 | echo -e "${Font_SkyBlue}User Choose to Test Only IPv6 Results, Skipping IPv4 Testing...${Font_Suffix}"
473 | else
474 | if [ -n "$usePROXY" ] && [[ "$isproxy" -eq 1 ]]; then
475 | echo -e " ${Font_SkyBlue}** Checking Results Under Proxy${Font_Suffix} "
476 | isv6=0
477 | elif [ -n "$usePROXY" ] && [[ "$isproxy" -eq 0 ]]; then
478 | echo -e " ${Font_SkyBlue}** Unable to connect to this proxy${Font_Suffix} "
479 | isv6=0
480 | return
481 | else
482 | echo -e " ${Font_Yellow}** Проверяем результаты для IPv4${Font_Suffix} "
483 | check4=$(ping 1.1.1.1 -c 1 2>&1)
484 | fi
485 | echo "--------------------------------"
486 | echo -e " ${Font_Yellow}** Ваш хостинг-провайдер: ${local_isp4} (${local_ipv4_asterisk})${Font_Suffix} "
487 | ip_info=$(curl -sS "https://ipinfo.io/json")
488 | country=$(echo "$ip_info" | awk -F'"' '/country/ {print $4}')
489 | city=$(echo "$ip_info" | awk -F'"' '/city/ {print $4}')
490 | asn=$(echo "$ip_info" | awk -F'"' '/org/ {print $4}')
491 | echo -e " ${Font_Yellow}"Страна: $country"${Font_Suffix}"
492 | echo -e " ${Font_Yellow}"Город: $city"${Font_Suffix}"
493 | echo -e " ${Font_Yellow}"ASN: $asn"${Font_Suffix}"
494 |
495 | if [[ "$check4" != *"unreachable"* ]] && [[ "$check4" != *"Unreachable"* ]]; then
496 | isv4=1
497 | else
498 | echo ""
499 | echo -e "${Font_Yellow}IPv4 не обнаружен, отмена IPv4 проверки...${Font_Suffix}"
500 | isv4=0
501 | fi
502 |
503 | echo ""
504 | fi
505 | }
506 |
507 |
508 | function CheckV6() {
509 | if [[ "$NetworkType" == "4" ]]; then
510 | isv6=0
511 | if [ -z "$usePROXY" ]; then
512 | echo -e "${Font_SkyBlue}User Choose to Test Only IPv4 Results, Skipping IPv6 Testing...${Font_Suffix}"
513 | fi
514 | else
515 | check6_1=$(curl $useNIC -fsL --write-out %{http_code} --output /dev/null --max-time 10 ipv6.google.com)
516 | check6_2=$(curl $useNIC -fsL --write-out %{http_code} --output /dev/null --max-time 10 ipv6.ip.sb)
517 | if [[ "$check6_1" -ne "000" ]] || [[ "$check6_2" -ne "000" ]]; then
518 | echo ""
519 | echo ""
520 | echo -e " ${Font_yellow}** Проверяем результаты для IPv6${Font_Suffix} "
521 | echo "--------------------------------"
522 | echo -e " ${Font_Yellow}** Ваш хостинг-провайдер: ${local_isp6} (${local_ipv6_asterisk})${Font_Suffix} "
523 | isv6=1
524 | else
525 | echo ""
526 | echo -e "${Font_Yellow}IPv6 не обнаружен, отмена IPv6 проверки...${Font_Suffix}"
527 | isv6=0
528 | fi
529 | echo -e ""
530 | fi
531 | }
532 |
533 |
534 | function Goodbye() {
535 | echo -e "${Font_Yellow}Тест завершен! ${Font_Suffix}"
536 | }
537 |
538 | clear
539 |
540 |
541 | function ScriptTitle() {
542 | echo -e " ${Font_Purple}[Тест для проверки доступности сервисов на сервере]${Font_Suffix} "
543 | echo ""
544 | }
545 | ScriptTitle
546 |
547 |
548 | function RunScript() {
549 | clear
550 | ScriptTitle
551 | CheckV4
552 | if [[ "$isv4" -eq 1 ]]; then
553 | Global_UnlockTest 4
554 | fi
555 | CheckV6
556 | if [[ "$isv6" -eq 1 ]]; then
557 | Global_UnlockTest 6
558 | fi
559 | Goodbye
560 | }
561 |
562 | RunScript
563 |
--------------------------------------------------------------------------------
/checkers/tiktok_region.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | shopt -s expand_aliases
3 | Font_Black="\033[30m"
4 | Font_Red="\033[31m"
5 | Font_Green="\033[32m"
6 | Font_Yellow="\033[33m"
7 | Font_Blue="\033[34m"
8 | Font_Purple="\033[35m"
9 | Font_SkyBlue="\033[36m"
10 | Font_White="\033[37m"
11 | Font_Suffix="\033[0m"
12 |
13 | while getopts ":I:" optname; do
14 | case "$optname" in
15 | "I")
16 | iface="$OPTARG"
17 | useNIC="--interface $iface"
18 | ;;
19 | ":")
20 | echo "Unknown error while processing options"
21 | exit 1
22 | ;;
23 | esac
24 |
25 | done
26 |
27 | checkOS(){
28 | ifCentOS=$(cat /etc/os-release | grep CentOS)
29 | if [ -n "$ifCentOS" ];then
30 | OS_Version=$(cat /etc/os-release | grep REDHAT_SUPPORT_PRODUCT_VERSION | cut -f2 -d'"')
31 | if [[ "$OS_Version" -lt "8" ]];then
32 | echo -e "${Font_Red}此脚本不支持CentOS${OS_Version},请升级至CentOS8或更换其他操作系统${Font_Suffix}"
33 | echo -e "${Font_Red}3秒后退出脚本...${Font_Suffix}"
34 | sleep 3
35 | exit 1
36 | fi
37 | fi
38 | }
39 | checkOS
40 |
41 | if [ -z "$iface" ]; then
42 | useNIC=""
43 | fi
44 |
45 | if ! mktemp -u --suffix=RRC &>/dev/null; then
46 | is_busybox=1
47 | fi
48 |
49 | UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
50 |
51 | local_ipv4=$(curl $useNIC -4 -s --max-time 10 api64.ipify.org)
52 | local_ipv4_asterisk=$(awk -F"." '{print $1"."$2".*.*"}' <<<"${local_ipv4}")
53 | local_isp4=$(curl $useNIC -s -4 -A $UA_Browser --max-time 10 https://api.ip.sb/geoip/${local_ipv4} | grep organization | cut -f4 -d '"')
54 |
55 | function MediaUnlockTest_Tiktok_Region() {
56 | echo -n -e " Tiktok Region:\t\t\c"
57 | local Ftmpresult=$(curl $useNIC --user-agent "${UA_Browser}" -s --max-time 10 "https://www.tiktok.com/")
58 |
59 | if [[ "$Ftmpresult" = "curl"* ]]; then
60 | echo -n -e "\r Tiktok Region:\t\t${Font_Red}Failed (Network Connection)${Font_Suffix}\n"
61 | return
62 | fi
63 |
64 | local FRegion=$(echo $Ftmpresult | grep '"region":' | sed 's/.*"region"//' | cut -f2 -d'"')
65 | if [ -n "$FRegion" ]; then
66 | echo -n -e "\r Tiktok Region:\t\t${Font_Green}【${FRegion}】${Font_Suffix}\n"
67 | return
68 | fi
69 |
70 | local STmpresult=$(curl $useNIC --user-agent "${UA_Browser}" -sL --max-time 10 -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" -H "Accept-Encoding: gzip" -H "Accept-Language: en" "https://www.tiktok.com" | gunzip 2>/dev/null)
71 | local SRegion=$(echo $STmpresult | grep '"region":' | sed 's/.*"region"//' | cut -f2 -d'"')
72 | if [ -n "$SRegion" ]; then
73 | echo -n -e "\r Tiktok Region:\t\t${Font_Yellow}【${SRegion}】(Possibly IDC IP)${Font_Suffix}\n"
74 | return
75 | else
76 | echo -n -e "\r Tiktok Region:\t\t${Font_Red}Failed${Font_Suffix}\n"
77 | return
78 | fi
79 |
80 | }
81 |
82 | function Heading() {
83 | echo -e " ${Font_SkyBlue}** Your Network: ${local_isp4} (${local_ipv4_asterisk})${Font_Suffix} "
84 | echo "******************************************"
85 | echo ""
86 |
87 | }
88 |
89 | clear
90 |
91 | function ScriptTitle() {
92 | echo -e "${Font_SkyBlue}【TikTok Region Detection】${Font_Suffix}"
93 | echo ""
94 | echo -e " ** Test Time: $(date)"
95 | echo ""
96 | }
97 | ScriptTitle
98 |
99 | function RunScript() {
100 | Heading
101 | MediaUnlockTest_Tiktok_Region
102 | }
103 |
104 | RunScript
105 |
--------------------------------------------------------------------------------
/speedtest/countries/speedtest_ru.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Description: A Bench Script by Teddysun
4 | #
5 | # Copyright (C) 2015 - 2023 Teddysun
6 | # Thanks: LookBack
7 | # URL: https://teddysun.com/444.html
8 | # https://github.com/teddysun/across/blob/master/bench.sh
9 | #
10 | trap _exit INT QUIT TERM
11 |
12 | _red() {
13 | printf '\033[0;31;31m%b\033[0m' "$1"
14 | }
15 |
16 | _green() {
17 | printf '\033[0;31;32m%b\033[0m' "$1"
18 | }
19 |
20 | _yellow() {
21 | printf '\033[0;31;33m%b\033[0m' "$1"
22 | }
23 |
24 | _blue() {
25 | printf '\033[0;31;36m%b\033[0m' "$1"
26 | }
27 |
28 | _exists() {
29 | local cmd="$1"
30 | if eval type type >/dev/null 2>&1; then
31 | eval type "$cmd" >/dev/null 2>&1
32 | elif command >/dev/null 2>&1; then
33 | command -v "$cmd" >/dev/null 2>&1
34 | else
35 | which "$cmd" >/dev/null 2>&1
36 | fi
37 | local rt=$?
38 | return ${rt}
39 | }
40 |
41 | _exit() {
42 | _red "\nThe script has been terminated. Cleaning up files...\n"
43 | # clean up
44 | rm -fr speedtest.tgz speedtest-cli benchtest_*
45 | exit 1
46 | }
47 |
48 | get_opsy() {
49 | [ -f /etc/redhat-release ] && awk '{print $0}' /etc/redhat-release && return
50 | [ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
51 | [ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
52 | }
53 |
54 | next() {
55 | printf "%-70s\n" "-" | sed 's/\s/-/g'
56 | }
57 |
58 | speed_test() {
59 | local nodeName="$2"
60 | if [ -z "$1" ];then
61 | ./speedtest-cli/speedtest --progress=no --accept-license --accept-gdpr >./speedtest-cli/speedtest.log 2>&1
62 | else
63 | ./speedtest-cli/speedtest --progress=no --server-id="$1" --accept-license --accept-gdpr >./speedtest-cli/speedtest.log 2>&1
64 | fi
65 | if [ $? -eq 0 ]; then
66 | local dl_speed up_speed latency
67 | dl_speed=$(awk '/Download/{print $3" "$4}' ./speedtest-cli/speedtest.log)
68 | up_speed=$(awk '/Upload/{print $3" "$4}' ./speedtest-cli/speedtest.log)
69 | latency=$(awk '/Latency/{print $3" "$4}' ./speedtest-cli/speedtest.log)
70 | if [[ -n "${dl_speed}" && -n "${up_speed}" && -n "${latency}" ]]; then
71 | printf "\033[0;33m%-18s\033[0;32m%-18s\033[0;31m%-20s\033[0;36m%-12s\033[0m\n" " ${nodeName}" "${up_speed}" "${dl_speed}" "${latency}"
72 | fi
73 | fi
74 | }
75 |
76 | speed() {
77 | # Длина строки не более 15 символов
78 | speed_test '' 'Speedtest.net'
79 |
80 | speed_test '1907' 'MTS, Moscow'
81 | speed_test '2699' 'MTS, SPb'
82 |
83 | speed_test '4744' 'Beeline, Kaluga'
84 | speed_test '4903' 'Beeline, AST'
85 |
86 | speed_test '4483' 'RCom, Penza'
87 | speed_test '3310' 'RCom, AST'
88 |
89 | speed_test '2660' 'DOM.RU, Perm'
90 |
91 | speed_test '6388' 'Megafon, KRD'
92 | # Краснодар
93 | speed_test '6389' 'Megafon, NVS'
94 | # Новосибирск
95 |
96 | speed_test '6616' 'Tele2, EKB'
97 | speed_test '6563' 'Tele2, NIZH'
98 | speed_test '6430' 'Tele2, NVS'
99 |
100 | speed_test '3805' 'ACom, VLD'
101 | # Альянс Телеком
102 | # Владивосток
103 | speed_test '1325' 'Tatcom, Kazan'
104 | # Tattelecom
105 | }
106 |
107 | io_test() {
108 | (LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count="$1" conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F '[,,]' '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
109 | }
110 |
111 | calc_size() {
112 | local raw=$1
113 | local total_size=0
114 | local num=1
115 | local unit="KB"
116 | if ! [[ ${raw} =~ ^[0-9]+$ ]]; then
117 | echo ""
118 | return
119 | fi
120 | if [ "${raw}" -ge 1073741824 ]; then
121 | num=1073741824
122 | unit="TB"
123 | elif [ "${raw}" -ge 1048576 ]; then
124 | num=1048576
125 | unit="GB"
126 | elif [ "${raw}" -ge 1024 ]; then
127 | num=1024
128 | unit="MB"
129 | elif [ "${raw}" -eq 0 ]; then
130 | echo "${total_size}"
131 | return
132 | fi
133 | total_size=$(awk 'BEGIN{printf "%.1f", '"$raw"' / '$num'}')
134 | echo "${total_size} ${unit}"
135 | }
136 |
137 | # since calc_size converts kilobyte to MB, GB and TB
138 | # to_kibyte converts zfs size from bytes to kilobyte
139 | to_kibyte() {
140 | local raw=$1
141 | awk 'BEGIN{printf "%.0f", '"$raw"' / 1024}'
142 | }
143 |
144 | calc_sum() {
145 | local arr=("$@")
146 | local s
147 | s=0
148 | for i in "${arr[@]}"; do
149 | s=$((s + i))
150 | done
151 | echo ${s}
152 | }
153 |
154 | check_virt() {
155 | _exists "dmesg" && virtualx="$(dmesg 2>/dev/null)"
156 | if _exists "dmidecode"; then
157 | sys_manu="$(dmidecode -s system-manufacturer 2>/dev/null)"
158 | sys_product="$(dmidecode -s system-product-name 2>/dev/null)"
159 | sys_ver="$(dmidecode -s system-version 2>/dev/null)"
160 | else
161 | sys_manu=""
162 | sys_product=""
163 | sys_ver=""
164 | fi
165 | if grep -qa docker /proc/1/cgroup; then
166 | virt="Docker"
167 | elif grep -qa lxc /proc/1/cgroup; then
168 | virt="LXC"
169 | elif grep -qa container=lxc /proc/1/environ; then
170 | virt="LXC"
171 | elif [[ -f /proc/user_beancounters ]]; then
172 | virt="OpenVZ"
173 | elif [[ "${virtualx}" == *kvm-clock* ]]; then
174 | virt="KVM"
175 | elif [[ "${sys_product}" == *KVM* ]]; then
176 | virt="KVM"
177 | elif [[ "${sys_manu}" == *QEMU* ]]; then
178 | virt="KVM"
179 | elif [[ "${cname}" == *KVM* ]]; then
180 | virt="KVM"
181 | elif [[ "${cname}" == *QEMU* ]]; then
182 | virt="KVM"
183 | elif [[ "${virtualx}" == *"VMware Virtual Platform"* ]]; then
184 | virt="VMware"
185 | elif [[ "${sys_product}" == *"VMware Virtual Platform"* ]]; then
186 | virt="VMware"
187 | elif [[ "${virtualx}" == *"Parallels Software International"* ]]; then
188 | virt="Parallels"
189 | elif [[ "${virtualx}" == *VirtualBox* ]]; then
190 | virt="VirtualBox"
191 | elif [[ -e /proc/xen ]]; then
192 | if grep -q "control_d" "/proc/xen/capabilities" 2>/dev/null; then
193 | virt="Xen-Dom0"
194 | else
195 | virt="Xen-DomU"
196 | fi
197 | elif [ -f "/sys/hypervisor/type" ] && grep -q "xen" "/sys/hypervisor/type"; then
198 | virt="Xen"
199 | elif [[ "${sys_manu}" == *"Microsoft Corporation"* ]]; then
200 | if [[ "${sys_product}" == *"Virtual Machine"* ]]; then
201 | if [[ "${sys_ver}" == *"7.0"* || "${sys_ver}" == *"Hyper-V" ]]; then
202 | virt="Hyper-V"
203 | else
204 | virt="Microsoft Virtual Machine"
205 | fi
206 | fi
207 | else
208 | virt="Dedicated"
209 | fi
210 | }
211 |
212 | ipv4_info() {
213 | local org city country region
214 | org="$(wget -q -T10 -O- ipinfo.io/org)"
215 | city="$(wget -q -T10 -O- ipinfo.io/city)"
216 | country="$(wget -q -T10 -O- ipinfo.io/country)"
217 | region="$(wget -q -T10 -O- ipinfo.io/region)"
218 | if [[ -n "${org}" ]]; then
219 | echo " Organization : $(_blue "${org}")"
220 | fi
221 | if [[ -n "${city}" && -n "${country}" ]]; then
222 | echo " Location : $(_blue "${city} / ${country}")"
223 | fi
224 | if [[ -n "${region}" ]]; then
225 | echo " Region : $(_yellow "${region}")"
226 | fi
227 | if [[ -z "${org}" ]]; then
228 | echo " Region : $(_red "No ISP detected")"
229 | fi
230 | }
231 |
232 | install_speedtest() {
233 | if [ ! -e "./speedtest-cli/speedtest" ]; then
234 | sys_bit=""
235 | local sysarch
236 | sysarch="$(uname -m)"
237 | if [ "${sysarch}" = "unknown" ] || [ "${sysarch}" = "" ]; then
238 | sysarch="$(arch)"
239 | fi
240 | if [ "${sysarch}" = "x86_64" ]; then
241 | sys_bit="x86_64"
242 | fi
243 | if [ "${sysarch}" = "i386" ] || [ "${sysarch}" = "i686" ]; then
244 | sys_bit="i386"
245 | fi
246 | if [ "${sysarch}" = "armv8" ] || [ "${sysarch}" = "armv8l" ] || [ "${sysarch}" = "aarch64" ] || [ "${sysarch}" = "arm64" ]; then
247 | sys_bit="aarch64"
248 | fi
249 | if [ "${sysarch}" = "armv7" ] || [ "${sysarch}" = "armv7l" ]; then
250 | sys_bit="armhf"
251 | fi
252 | if [ "${sysarch}" = "armv6" ]; then
253 | sys_bit="armel"
254 | fi
255 | [ -z "${sys_bit}" ] && _red "Error: Unsupported system architecture (${sysarch}).\n" && exit 1
256 | url1="https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-${sys_bit}.tgz"
257 | url2="https://dl.lamp.sh/files/ookla-speedtest-1.2.0-linux-${sys_bit}.tgz"
258 | if ! wget --no-check-certificate -q -T10 -O speedtest.tgz ${url1}; then
259 | if ! wget --no-check-certificate -q -T10 -O speedtest.tgz ${url2}; then
260 | _red "Error: Failed to download speedtest-cli.\n" && exit 1
261 | fi
262 | fi
263 | mkdir -p speedtest-cli && tar zxf speedtest.tgz -C ./speedtest-cli && chmod +x ./speedtest-cli/speedtest
264 | rm -f speedtest.tgz
265 | fi
266 | printf "%-18s%-18s%-20s%-12s\n" " Node Name" "Upload Speed" "Download Speed" "Latency"
267 | }
268 |
269 | print_intro() {
270 | echo "----------- A Bench.sh Script By Teddysun | Russian Regions ----------"
271 | echo " Version : $(_green v2024-11-05)"
272 | echo " More scripts : $(_green "https://github.com/jomertix/server-scripts")"
273 | }
274 |
275 | # Get System information
276 | get_system_info() {
277 | cname=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
278 | cores=$(awk -F: '/^processor/ {core++} END {print core}' /proc/cpuinfo)
279 | freq=$(awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo)
280 | ccache=$(awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
281 | cpu_aes=$(grep -i 'aes' /proc/cpuinfo)
282 | cpu_virt=$(grep -Ei 'vmx|svm' /proc/cpuinfo)
283 | tram=$(
284 | LANG=C
285 | free | awk '/Mem/ {print $2}'
286 | )
287 | tram=$(calc_size "$tram")
288 | uram=$(
289 | LANG=C
290 | free | awk '/Mem/ {print $3}'
291 | )
292 | uram=$(calc_size "$uram")
293 | swap=$(
294 | LANG=C
295 | free | awk '/Swap/ {print $2}'
296 | )
297 | swap=$(calc_size "$swap")
298 | uswap=$(
299 | LANG=C
300 | free | awk '/Swap/ {print $3}'
301 | )
302 | uswap=$(calc_size "$uswap")
303 | up=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime)
304 | if _exists "w"; then
305 | load=$(
306 | LANG=C
307 | w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
308 | )
309 | elif _exists "uptime"; then
310 | load=$(
311 | LANG=C
312 | uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
313 | )
314 | fi
315 | opsy=$(get_opsy)
316 | arch=$(uname -m)
317 | if _exists "getconf"; then
318 | lbit=$(getconf LONG_BIT)
319 | else
320 | echo "${arch}" | grep -q "64" && lbit="64" || lbit="32"
321 | fi
322 | kern=$(uname -r)
323 | in_kernel_no_swap_total_size=$(
324 | LANG=C
325 | df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $2 }'
326 | )
327 | swap_total_size=$(free -k | grep Swap | awk '{print $2}')
328 | zfs_total_size=$(to_kibyte "$(calc_sum "$(zpool list -o size -Hp 2> /dev/null)")")
329 | disk_total_size=$(calc_size $((swap_total_size + in_kernel_no_swap_total_size + zfs_total_size)))
330 | in_kernel_no_swap_used_size=$(
331 | LANG=C
332 | df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs --total 2>/dev/null | grep total | awk '{ print $3 }'
333 | )
334 | swap_used_size=$(free -k | grep Swap | awk '{print $3}')
335 | zfs_used_size=$(to_kibyte "$(calc_sum "$(zpool list -o allocated -Hp 2> /dev/null)")")
336 | disk_used_size=$(calc_size $((swap_used_size + in_kernel_no_swap_used_size + zfs_used_size)))
337 | tcpctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
338 | }
339 | # Print System information
340 | print_system_info() {
341 | if [ -n "$cname" ]; then
342 | echo " CPU Model : $(_blue "$cname")"
343 | else
344 | echo " CPU Model : $(_blue "CPU model not detected")"
345 | fi
346 | if [ -n "$freq" ]; then
347 | echo " CPU Cores : $(_blue "$cores @ $freq MHz")"
348 | else
349 | echo " CPU Cores : $(_blue "$cores")"
350 | fi
351 | if [ -n "$ccache" ]; then
352 | echo " CPU Cache : $(_blue "$ccache")"
353 | fi
354 | if [ -n "$cpu_aes" ]; then
355 | echo " AES-NI : $(_green "\xe2\x9c\x93 Enabled")"
356 | else
357 | echo " AES-NI : $(_red "\xe2\x9c\x97 Disabled")"
358 | fi
359 | if [ -n "$cpu_virt" ]; then
360 | echo " VM-x/AMD-V : $(_green "\xe2\x9c\x93 Enabled")"
361 | else
362 | echo " VM-x/AMD-V : $(_red "\xe2\x9c\x97 Disabled")"
363 | fi
364 | echo " Total Disk : $(_yellow "$disk_total_size") $(_blue "($disk_used_size Used)")"
365 | echo " Total Mem : $(_yellow "$tram") $(_blue "($uram Used)")"
366 | if [ "$swap" != "0" ]; then
367 | echo " Total Swap : $(_blue "$swap ($uswap Used)")"
368 | fi
369 | echo " System uptime : $(_blue "$up")"
370 | echo " Load average : $(_blue "$load")"
371 | echo " OS : $(_blue "$opsy")"
372 | echo " Arch : $(_blue "$arch ($lbit Bit)")"
373 | echo " Kernel : $(_blue "$kern")"
374 | echo " TCP CC : $(_yellow "$tcpctrl")"
375 | echo " Virtualization : $(_blue "$virt")"
376 | echo " IPv4/IPv6 : $online"
377 | }
378 |
379 | print_io_test() {
380 | freespace=$(df -m . | awk 'NR==2 {print $4}')
381 | if [ -z "${freespace}" ]; then
382 | freespace=$(df -m . | awk 'NR==3 {print $3}')
383 | fi
384 | if [ "${freespace}" -gt 1024 ]; then
385 | writemb=2048
386 | io1=$(io_test ${writemb})
387 | echo " I/O Speed(1st run) : $(_yellow "$io1")"
388 | io2=$(io_test ${writemb})
389 | echo " I/O Speed(2nd run) : $(_yellow "$io2")"
390 | io3=$(io_test ${writemb})
391 | echo " I/O Speed(3rd run) : $(_yellow "$io3")"
392 | ioraw1=$(echo "$io1" | awk 'NR==1 {print $1}')
393 | [[ "$(echo "$io1" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw1=$(awk 'BEGIN{print '"$ioraw1"' * 1024}')
394 | ioraw2=$(echo "$io2" | awk 'NR==1 {print $1}')
395 | [[ "$(echo "$io2" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw2=$(awk 'BEGIN{print '"$ioraw2"' * 1024}')
396 | ioraw3=$(echo "$io3" | awk 'NR==1 {print $1}')
397 | [[ "$(echo "$io3" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw3=$(awk 'BEGIN{print '"$ioraw3"' * 1024}')
398 | ioall=$(awk 'BEGIN{print '"$ioraw1"' + '"$ioraw2"' + '"$ioraw3"'}')
399 | ioavg=$(awk 'BEGIN{printf "%.1f", '"$ioall"' / 3}')
400 | echo " I/O Speed(average) : $(_yellow "$ioavg MB/s")"
401 | else
402 | echo " $(_red "Not enough space for I/O Speed test!")"
403 | fi
404 | }
405 |
406 | print_end_time() {
407 | end_time=$(date +%s)
408 | time=$((end_time - start_time))
409 | if [ ${time} -gt 60 ]; then
410 | min=$((time / 60))
411 | sec=$((time % 60))
412 | echo " Finished in : ${min} min ${sec} sec"
413 | else
414 | echo " Finished in : ${time} sec"
415 | fi
416 | date_time=$(date '+%Y-%m-%d %H:%M:%S %Z')
417 | echo " Timestamp : $date_time"
418 | }
419 |
420 | ! _exists "wget" && _red "Error: wget command not found.\n" && exit 1
421 | ! _exists "free" && _red "Error: free command not found.\n" && exit 1
422 | # check for curl/wget
423 | _exists "curl" && local_curl=true
424 | # test if the host has IPv4/IPv6 connectivity
425 | [[ -n ${local_curl} ]] && ip_check_cmd="curl -s -m 4" || ip_check_cmd="wget -qO- -T 4"
426 | ipv4_check=$( (ping -4 -c 1 -W 4 ipv4.google.com >/dev/null 2>&1 && echo true) || ${ip_check_cmd} -4 icanhazip.com 2> /dev/null)
427 | ipv6_check=$( (ping -6 -c 1 -W 4 ipv6.google.com >/dev/null 2>&1 && echo true) || ${ip_check_cmd} -6 icanhazip.com 2> /dev/null)
428 | if [[ -z "$ipv4_check" && -z "$ipv6_check" ]]; then
429 | _yellow "Warning: Both IPv4 and IPv6 connectivity were not detected.\n"
430 | fi
431 | [[ -z "$ipv4_check" ]] && online="$(_red "\xe2\x9c\x97 Offline")" || online="$(_green "\xe2\x9c\x93 Online")"
432 | [[ -z "$ipv6_check" ]] && online+=" / $(_red "\xe2\x9c\x97 Offline")" || online+=" / $(_green "\xe2\x9c\x93 Online")"
433 | start_time=$(date +%s)
434 | get_system_info
435 | check_virt
436 | clear
437 | print_intro
438 | next
439 | print_system_info
440 | ipv4_info
441 | next
442 | print_io_test
443 | next
444 | install_speedtest && speed && rm -fr speedtest-cli
445 | next
446 | print_end_time
447 | next
448 |
--------------------------------------------------------------------------------