|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { useEffect, useState } from 'react'; |
| 4 | +import { useRouter } from 'next/navigation'; |
| 5 | +import { loadProgress } from '@/state/persistence'; |
| 6 | + |
| 7 | +const EXERCISES = [ |
| 8 | + { id: 'rit-01', title: '01: The Stack Frame', desc: 'Watch how the computer organizes memory — like a stack of sticky notes.' }, |
| 9 | + { id: 'rit-02', title: '02: The Overflow', desc: 'Type too much and crash the program. Yes, it\'s that easy.' }, |
| 10 | + { id: 'rit-03', title: '03: Hijack Execution', desc: 'Make the program run a secret function it was never supposed to call.' }, |
| 11 | + { id: 'rit-04', title: '04: Randomized Addresses', desc: 'The computer scrambles its memory — use a leaked hint to beat it.' }, |
| 12 | + { id: 'rit-rop', title: '05: Baby\'s First ROP', desc: 'Bypass the final defense by jumping to code that already exists.' }, |
| 13 | +]; |
| 14 | + |
| 15 | +export default function ImagineRitPage() { |
| 16 | + const router = useRouter(); |
| 17 | + const [completed, setCompleted] = useState<Set<string>>(new Set()); |
| 18 | + const [mounted, setMounted] = useState(false); |
| 19 | + |
| 20 | + useEffect(() => { |
| 21 | + setCompleted(loadProgress()); |
| 22 | + setMounted(true); |
| 23 | + }, []); |
| 24 | + |
| 25 | + if (!mounted) return null; |
| 26 | + |
| 27 | + const doneCount = EXERCISES.filter(ex => completed.has(ex.id)).length; |
| 28 | + |
| 29 | + return ( |
| 30 | + <div style={{ |
| 31 | + maxWidth: '620px', |
| 32 | + margin: '3rem auto', |
| 33 | + padding: '2rem', |
| 34 | + fontFamily: 'var(--font)', |
| 35 | + color: 'var(--text)', |
| 36 | + }}> |
| 37 | + <h1 style={{ color: 'var(--green)', fontSize: '22px', fontWeight: 'normal', marginBottom: '0.25rem' }}> |
| 38 | + 0xVRIG — Imagine RIT |
| 39 | + </h1> |
| 40 | + <p style={{ color: 'var(--text-dim)', fontSize: '13px', marginBottom: '0.5rem' }}> |
| 41 | + Learn how hackers exploit programs — in 5 hands-on exercises |
| 42 | + </p> |
| 43 | + <p style={{ color: 'var(--text-dim)', fontSize: '11px', marginBottom: '2rem' }}> |
| 44 | + No coding experience needed. Each exercise builds on the last. |
| 45 | + </p> |
| 46 | + |
| 47 | + <div style={{ fontSize: '12px', marginBottom: '1.5rem', color: 'var(--text-dim)' }}> |
| 48 | + Progress: {doneCount}/{EXERCISES.length}{' '} |
| 49 | + <span style={{ color: 'var(--green)' }}> |
| 50 | + {'█'.repeat(doneCount)}{'░'.repeat(EXERCISES.length - doneCount)} |
| 51 | + </span> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem' }}> |
| 55 | + {EXERCISES.map((ex, i) => { |
| 56 | + const done = completed.has(ex.id); |
| 57 | + const isNext = !done && EXERCISES.slice(0, i).every(e => completed.has(e.id)); |
| 58 | + return ( |
| 59 | + <div |
| 60 | + key={ex.id} |
| 61 | + onClick={() => router.push(`/imagine-rit/${ex.id}`)} |
| 62 | + style={{ |
| 63 | + padding: '0.75rem 1rem', |
| 64 | + border: `1px solid ${isNext ? 'var(--green)' : 'var(--panel-border)'}`, |
| 65 | + cursor: 'pointer', |
| 66 | + opacity: done ? 0.6 : 1, |
| 67 | + }} |
| 68 | + > |
| 69 | + <div style={{ fontSize: '13px', marginBottom: '0.25rem' }}> |
| 70 | + {done && <span style={{ color: 'var(--green)', marginRight: '0.5rem' }}>✓</span>} |
| 71 | + {isNext && <span style={{ color: 'var(--green)', marginRight: '0.5rem' }}>→</span>} |
| 72 | + {ex.title} |
| 73 | + </div> |
| 74 | + <div style={{ fontSize: '11px', color: 'var(--text-dim)' }}>{ex.desc}</div> |
| 75 | + </div> |
| 76 | + ); |
| 77 | + })} |
| 78 | + </div> |
| 79 | + |
| 80 | + {doneCount === EXERCISES.length && ( |
| 81 | + <div style={{ |
| 82 | + marginTop: '2rem', |
| 83 | + padding: '1rem', |
| 84 | + border: '1px solid var(--green)', |
| 85 | + textAlign: 'center', |
| 86 | + }}> |
| 87 | + <div style={{ color: 'var(--green)', fontSize: '14px', marginBottom: '0.25rem' }}> |
| 88 | + Workshop Complete! |
| 89 | + </div> |
| 90 | + <div style={{ fontSize: '11px', color: 'var(--text-dim)' }}> |
| 91 | + You learned how buffer overflows work, hijacked program execution, bypassed ASLR, and built a ROP chain. Nice work! |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + )} |
| 95 | + </div> |
| 96 | + ); |
| 97 | +} |
0 commit comments