Uname:Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64

Base Dir : /var/www/moonbloom

User : wp-moonbloom


403WebShell
403Webshell
Server IP : 85.155.190.233  /  Your IP : 216.73.216.103
Web Server : nginx/1.24.0
System : Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User : wp-moonbloom ( 1001)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/thread-self/root/opt/Gemini_Swarm_Core/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/opt/Gemini_Swarm_Core/scripts/test_cors.py
import sys
from pathlib import Path

# Add scripts directory to path to import tg_bridge
sys.path.insert(0, str(Path(__file__).resolve().parent))

from fastapi.testclient import TestClient
import uvicorn

# We need to temporarily mock environment variable to import tg_bridge without error
import os
os.environ["TELEGRAM_BOT_TOKEN"] = "123456:mock_token"
os.environ["TELEGRAM_ALLOWED_USERS"] = "12345"

from tg_bridge import app

client = TestClient(app)

def test_cors():
    print("Testing CORS headers...")
    
    # 1. Test allowed origin
    allowed_origin = "https://proimport-shop.ru"
    response = client.options("/api/settings", headers={
        "Origin": allowed_origin,
        "Access-Control-Request-Method": "GET",
        "Access-Control-Request-Headers": "Authorization"
    })
    print(f"Allowed origin status: {response.status_code}")
    print(f"Allowed origin headers: {dict(response.headers)}")
    
    # 2. Test disallowed origin
    disallowed_origin = "https://evil.com"
    response_evil = client.options("/api/settings", headers={
        "Origin": disallowed_origin,
        "Access-Control-Request-Method": "GET",
        "Access-Control-Request-Headers": "Authorization"
    })
    print(f"Disallowed origin status: {response_evil.status_code}")
    print(f"Disallowed origin headers: {dict(response_evil.headers)}")
    
    allowed_header = response.headers.get("access-control-allow-origin")
    disallowed_header = response_evil.headers.get("access-control-allow-origin")
    
    print(f"Access-Control-Allow-Origin for allowed: {allowed_header}")
    print(f"Access-Control-Allow-Origin for disallowed: {disallowed_header}")
    
    # Check if we are in RED or GREEN state
    if disallowed_header == "https://evil.com" or disallowed_header == "*":
        print("RED State: evil.com is ALLOWED or all (*) are allowed.")
        sys.exit(1)
    else:
        print("GREEN State: evil.com is BLOCKED successfully!")
        sys.exit(0)

if __name__ == "__main__":
    test_cors()

Youez - 2016 - github.com/yon3zu
LinuXploit