import { useRouter } from 'next/router'; import { useState } from 'react'; import Link from 'next/link'; import { useHints } from '../contexts/HintContext'; export default function Tools() { const router = useRouter(); const { id, file } = router.query; const [fileContent, setFileContent] = useState(''); const { hintsVisible } = useHints(); const products = { '1': { name: 'Professional Hammer', price: 89, image: '/assets/hammer.png', description: 'Heavy-duty forging hammer perfect for metalworking and blacksmithing projects. Crafted from high-carbon steel with ergonomic handle.', specs: { 'Weight': '2.5 lbs', 'Handle': 'Hickory wood', 'Head Material': 'High-carbon steel', 'Length': '16 inches' } }, '2': { name: 'Steel Anvil', price: 299, image: '/assets/anvil.png', description: 'Solid steel anvil for precise metalworking. Essential tool for any blacksmith. Features hardened work surface and horn for curved work.', specs: { 'Weight': '55 lbs', 'Material': 'Cast steel', 'Work Surface': '12" x 4"', 'Hardness': 'HRC 58-62' } }, '3': { name: 'Heat-Resistant Gloves', price: 45, image: '/assets/gloves.png', description: 'Premium heat-resistant gloves for safe handling of hot materials and tools. Rated for temperatures up to 932°F (500°C).', specs: { 'Material': 'Kevlar and leather', 'Temperature Rating': '932°F (500°C)', 'Sizes': 'S, M, L, XL', 'Cuff Length': '14 inches' } }, '4': { name: 'Forging Tongs', price: 65, image: '/assets/tongs.png', description: 'Precision forging tongs for gripping and manipulating hot metal pieces. Spring-loaded design with comfortable grip.', specs: { 'Length': '18 inches', 'Material': 'Carbon steel', 'Jaw Width': '2 inches', 'Weight': '1.8 lbs' } }, // IDOR Vulnerability - Hidden/Admin products '999': { name: 'Admin Secret Tool', price: 0, image: '/assets/hammer.png', description: 'FLAG{IDOR_ADMIN_ACCESS} - You found the hidden admin product! This demonstrates Insecure Direct Object Reference vulnerability.', specs: { 'Access Level': 'Admin Only', 'Vulnerability': 'IDOR', 'Flag': 'FLAG{IDOR_ADMIN_ACCESS}', 'Security Risk': 'High' } } } as Record; // LFI Vulnerability - Simulated file inclusion const files = { 'info.txt': 'Product information file loaded successfully.', 'specs.txt': 'Technical specifications document.', '../config.txt': 'FLAG{LFI_CONFIG_ACCESS} - Configuration file accessed via Local File Inclusion!', '../../secret.txt': 'FLAG{LFI_SECRET_FILE} - Secret file accessed through directory traversal!', '/etc/passwd': 'root:x:0:0:root:/root:/bin/bash\nFLAG{LFI_SYSTEM_FILE}', } as Record; const product = products[id as string]; // Handle LFI vulnerability const handleFileLoad = () => { if (file && typeof file === 'string') { const content = files[file] || 'File not found or access denied.'; setFileContent(content); } }; if (id && !product) { return (
❌

Product Not Found

{hintsVisible ? "Try different product IDs (1-4) or check for hidden products (hint: try larger numbers)" : "The requested product could not be found" }

Back to Home
); } // If no ID specified, show tools overview if (!id) { return (

Professional Tools

Explore our collection of premium blacksmithing and metalworking tools

{Object.entries(products) .filter(([key]) => ['1', '2', '3', '4'].includes(key)) .map(([key, prod]) => ( {prod.name}

{prod.name}

{prod.description.substring(0, 100)}...

${prod.price} {hintsVisible && (
⚠ ID: {key}
)} ))}
{/* IDOR Hints */} {hintsVisible && (

🔍 Security Testing

This page contains IDOR vulnerabilities. Try:

  • Changing the ID parameter in the URL
  • Trying different number ranges (1-4 are normal, try others)
  • Looking for admin or hidden products
)}
); } // Product detail view return (
{/* Breadcrumb */}
Home / Tools / {product.name}
{/* Product Image */}
{product.name}
{/* Product Info */}

{product.name}

${product.price}

Description

{product.description}

Specifications

{Object.entries(product.specs).map(([key, value]) => (
{key}: {value as string}
))}
{/* LFI Section */}

📁 Product Files

Load additional product information files:

{ if (e.key === 'Enter') { const target = e.target as HTMLInputElement; router.push(`/tools?id=${id}&file=${target.value}`); } }} /> {file && (

File: {file}

                    {files[file as string] || 'File not found or access denied.'}
                  
)} {hintsVisible && (

⚠ This demonstrates Local File Inclusion (LFI) vulnerability

)} {hintsVisible && (
⚠ File paths not validated
)}
); }