import { FormEvent, useState } from 'react'; import { useHints } from '../contexts/HintContext'; export default function FlagSubmit() { const [flag, setFlag] = useState(''); const [message, setMessage] = useState(null); const [loading, setLoading] = useState(false); const [submissionHistory, setSubmissionHistory] = useState<{flag: string, timestamp: string, status: string}[]>([]); const { hintsVisible } = useHints(); const onSubmit = async (e: FormEvent) => { e.preventDefault(); setLoading(true); setMessage(null); try { const res = await fetch('/api/flag', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ flag }), }); const data = await res.json(); const resultMessage = data.message || 'Unknown response'; setMessage(resultMessage); // Add to submission history const newSubmission = { flag: flag, timestamp: new Date().toLocaleString(), status: res.ok ? 'success' : 'failed' }; setSubmissionHistory(prev => [newSubmission, ...prev.slice(0, 4)]); if (res.ok) { setFlag(''); } } catch (err) { setMessage('Something went wrong'); const newSubmission = { flag: flag, timestamp: new Date().toLocaleString(), status: 'error' }; setSubmissionHistory(prev => [newSubmission, ...prev.slice(0, 4)]); } finally { setLoading(false); } }; const knownFlags = [ { name: 'SQL Injection', format: 'FLAG{SQL_*}', hint: 'Check the shop search functionality' }, { name: 'XSS Attack', format: 'FLAG{XSS_*}', hint: 'Profile bio field accepts HTML' }, { name: 'IDOR', format: 'FLAG{IDOR_*}', hint: 'Try accessing item IDs you should not' }, { name: 'LFI', format: 'FLAG{LFI_*}', hint: 'Include page might read local files' }, { name: 'File Upload', format: 'FLAG{UPLOAD_*}', hint: 'Upload restrictions might be bypassable' }, ]; return (
{/* Header */}
◈

Submit CTF Flag

Found a vulnerability? Submit your discovered flag here!

{/* Flag Submission Form */}

Submit Your Flag

setFlag(e.target.value)} placeholder="FLAG{YOUR_DISCOVERED_FLAG_HERE}" className="input-field font-mono" disabled={loading} />

Flags should follow the format: FLAG{VULNERABILITY_TYPE_VALUE}

{/* Result Message */} {message && (
{message}
)}
{/* Submission History */} {submissionHistory.length > 0 && (

Recent Submissions

{submissionHistory.map((submission, index) => (
{submission.flag} {submission.timestamp}
))}
)}
{/* Challenge Information */}
{/* Challenge List */}

Available Challenges

{knownFlags.map((challenge, index) => (

{challenge.name}

{challenge.format}

◉ {challenge.hint}

))}
{/* Security Warning */}

⚠ Educational Notice

This application contains intentional security vulnerabilities for educational purposes only.

Never attempt these techniques on real applications without explicit permission.

); }