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"^