diff --git a/python/README.md b/python/README.md index 3e652517..eeb91687 100644 --- a/python/README.md +++ b/python/README.md @@ -232,6 +232,8 @@ Contributors names and contact info * Fixed a bug in reading subnets from file with full address in windows * 1.3.16 * Added no-fronting option +* 1.3.17 + * Improved the fronting test method (jafar method) [python]: https://img.shields.io/badge/-Python-3776AB?logo=python&logoColor=white -[version]: https://img.shields.io/badge/Version-1.3.16-blue +[version]: https://img.shields.io/badge/Version-1.3.17-blue diff --git a/python/cfscanner/speedtest/fronting.py b/python/cfscanner/speedtest/fronting.py index 0a150979..2daa5348 100644 --- a/python/cfscanner/speedtest/fronting.py +++ b/python/cfscanner/speedtest/fronting.py @@ -1,3 +1,5 @@ +import re + import requests @@ -16,28 +18,28 @@ def fronting_test( """ s = requests.Session() s.get_adapter( - 'https://').poolmanager.connection_pool_kw['server_hostname'] = "speed.cloudflare.com" + 'https://').poolmanager.connection_pool_kw['server_hostname'] = "jafar.mashallah.gq" s.get_adapter( - 'https://').poolmanager.connection_pool_kw['assert_hostname'] = "speed.cloudflare.com" + 'https://').poolmanager.connection_pool_kw['assert_hostname'] = "jafar.mashallah.gq" try: compatible_ip = f"[{ip}]" if ":" in ip else ip r = s.get( f"https://{compatible_ip}/__down?bytes=10", timeout=timeout, - headers={"Host": "speed.cloudflare.com"} + headers={"Host": "jafar.mashallah.gq"} ) - if r.status_code != 200: - return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting error {r.status_code} [/yellow1]" - elif r.content != b"0" * 10: - return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting error - unexpected response [/yellow1]" - except requests.exceptions.ConnectTimeout as e: - return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting connect timeout[/yellow1]" - except requests.exceptions.ReadTimeout as e: - return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting read timeout[/yellow1]" + except requests.exceptions.Timeout as e: + return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting timeout[/yellow1]" except requests.exceptions.ConnectionError as e: return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting connection error[/yellow1]" + + try: + regex = r"^(.+)<\/title>$" + re_match = re.findall(regex, r.text, re.MULTILINE)[0] + if "CNAME Cross-User Banned" in re_match: + return "OK" + else: + return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting Unknown error[/yellow1]" except Exception as e: return f"[bold red1]NO[/bold red1] [orange3]{ip:15s}[/orange3][yellow1] fronting Unknown error[/yellow1]" - - return "OK" diff --git a/python/pyproject.toml b/python/pyproject.toml index e4934534..b71f97d0 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "cfscanner" -version = "1.3.16" +version = "1.3.17" authors = [ { name="tempookian", email="tempookian@gmail.com" }, { name="Morteza Bashsiz", email="morteza.bashsiz@gmail.com"}