import { FormEvent, useState } from 'react'; 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 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)]); // Keep last 5 if (res.ok) { setFlag(''); // Clear on success } } 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: 'Command Injection', format: 'FLAG{CMD_*}', hint: 'Execute page might run system commands' }, { name: 'File Upload', format: 'FLAG{UPLOAD_*}', hint: 'Upload restrictions might be bypassable' }, { name: 'IDOR', format: 'FLAG{IDOR_*}', hint: 'Try accessing item IDs you shouldn\'t' }, { name: 'LFI', format: 'FLAG{LFI_*}', hint: 'Include page might read local files' }, ]; 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.includes('Correct') || message.includes('Valid') || message.includes('Success') ? '✅' : '❌'} {message}
)}
{/* Submission History */} {submissionHistory.length > 0 && (

Recent Submissions

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

Available Challenges

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

{challenge.name}

{challenge.format}

💡 {challenge.hint}

))}
{/* CTF Rules */}

CTF Rules

1. Each vulnerability contains exactly one flag
2. Flags follow the format FLAG{CONTENT}
3. Explore all pages and functionalities
4. Use only the provided web interface
5. This is for educational purposes only
{/* Security Warning */}

⚠️ Educational Notice

This application contains intentional security vulnerabilities for educational purposes only.

Never attempt these techniques on real applications without explicit permission.

); }