potential bypass cloudflare
Build and Push Docker Images / build-and-push (push) Successful in 2m24s

This commit is contained in:
2025-07-18 11:32:13 +02:00
parent a97392f421
commit 085f447e49
8 changed files with 1022 additions and 61 deletions
@@ -0,0 +1,117 @@
#!/usr/bin/env python3
"""
Test script for Cloudflare bypass functionality
"""
import asyncio
import aiohttp
import json
import sys
from urllib.parse import quote
async def test_cloudflare_bypass(api_url, api_key, test_url):
"""Test Cloudflare bypass on a specific URL"""
headers = {
'X-API-Key': api_key,
'Content-Type': 'application/json'
}
# Test the new Cloudflare bypass endpoint
test_endpoint = f"{api_url}/test-cloudflare?url={quote(test_url)}"
print(f"🔍 Testing Cloudflare bypass for: {test_url}")
print(f"📡 Endpoint: {test_endpoint}")
print("-" * 60)
try:
async with aiohttp.ClientSession() as session:
async with session.get(test_endpoint, headers=headers) as response:
if response.status == 200:
result = await response.json()
print("✅ Request successful!")
print(f"📄 Status: {result.get('status')}")
print(f"🌐 Final URL: {result.get('final_url', 'N/A')}")
print(f"📝 Title: {result.get('title', 'N/A')}")
print(f"🛡️ Cloudflare Bypassed: {result.get('cloudflare_bypassed', False)}")
print(f"📏 Content Length: {result.get('content_length', 0)} characters")
# Show Cloudflare indicators
indicators = result.get('cloudflare_indicators', {})
print("\n🔍 Cloudflare Detection Indicators:")
for indicator, value in indicators.items():
status = "❌ Detected" if value else "✅ Not Detected"
print(f" {indicator}: {status}")
if result.get('cloudflare_bypassed'):
print("\n🎉 SUCCESS: Cloudflare protection was successfully bypassed!")
else:
print("\n⚠️ WARNING: Cloudflare protection may still be active")
else:
error_text = await response.text()
print(f"❌ Request failed with status {response.status}")
print(f"Error: {error_text}")
except Exception as e:
print(f"❌ Error during test: {e}")
async def test_regular_endpoint(api_url, api_key, test_url):
"""Test regular endpoint to compare with Cloudflare bypass"""
headers = {
'X-API-Key': api_key,
'Content-Type': 'application/json'
}
print(f"\n🔍 Testing regular endpoint for: {test_url}")
print("-" * 60)
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"{api_url}/?url={quote(test_url)}", headers=headers) as response:
if response.status == 200:
result = await response.json()
print("✅ Regular endpoint successful!")
print(f"📄 Status: {result.get('status')}")
if 'content' in result:
content_length = len(result['content'])
print(f"📏 Content Length: {content_length} characters")
if content_length < 1000:
print("⚠️ Content seems short - might be blocked")
else:
print("✅ Content length looks normal")
else:
error_text = await response.text()
print(f"❌ Regular endpoint failed: {error_text}")
except Exception as e:
print(f"❌ Error during regular test: {e}")
async def main():
"""Main test function"""
if len(sys.argv) < 4:
print("Usage: python test_cloudflare_bypass.py <api_url> <api_key> <test_url>")
print("Example: python test_cloudflare_bypass.py http://localhost:8000 your-api-key https://example.com")
sys.exit(1)
api_url = sys.argv[1].rstrip('/')
api_key = sys.argv[2]
test_url = sys.argv[3]
print("🛡️ Cloudflare Bypass Test Script")
print("=" * 60)
# Test Cloudflare bypass endpoint
await test_cloudflare_bypass(api_url, api_key, test_url)
# Test regular endpoint for comparison
await test_regular_endpoint(api_url, api_key, test_url)
print("\n" + "=" * 60)
print("🏁 Test completed!")
if __name__ == "__main__":
asyncio.run(main())