<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UltyScan - Web Interface</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="assets/style.css">
</head>
<body>
    <div class="container">
        <!-- Header -->
        <header class="header">
            <h1>🔍 UltyScan</h1>
            <p class="subtitle">Attack Surface Management Platform</p>
            <div style="margin-top: 1rem;">
                <span id="scan-status" class="status-badge status-idle">Idle</span>
            </div>
        </header>

        <!-- Tabs -->
        <div class="tabs">
            <button class="tab active" data-tab="scan-tab">New Scan</button>
            <button class="tab" data-tab="workspaces-tab">Workspaces</button>
            <button class="tab" data-tab="console-tab">Console</button>
            <button class="tab" data-tab="settings-tab">Settings</button>
        </div>

        <!-- Scan Tab -->
        <div id="scan-tab" class="tab-content active">
            <div class="card">
                <div class="card-header">
                    <svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
                    </svg>
                    <h2>Configure Scan</h2>
                </div>

                <form id="scan-form" onsubmit="submitScan(event)">
                    <div class="form-grid">
                        <!-- Target -->
                        <div class="form-group" id="single-target-group">
                            <label for="target">Target (Domain or IP)</label>
                            <input type="text" id="target" name="target" placeholder="example.com or 192.168.1.1" required>
                        </div>

                        <!-- Target File (for mass scans) -->
                        <div class="form-group" id="target-file-group" style="display: none;">
                            <label for="target_file">Target File (one per line)</label>
                            <textarea id="target_file" name="target_file" rows="4" placeholder="example1.com&#10;example2.com&#10;192.168.1.0/24"></textarea>
                        </div>

                        <!-- Mode -->
                        <div class="form-group">
                            <label for="mode">Scan Mode</label>
                            <select id="mode" name="mode">
                                <option value="normal">Normal - Balanced scan</option>
                                <option value="stealth">Stealth - Low profile</option>
                                <option value="web">Web - Ports 80/443 only</option>
                                <option value="webscan">WebScan - Full web app scan</option>
                                <option value="webporthttp">WebPortHTTP - HTTP on custom port</option>
                                <option value="webporthttps">WebPortHTTPS - HTTPS on custom port</option>
                                <option value="port">Port - Specific port scan</option>
                                <option value="fullportonly">FullPortOnly - All 65535 ports</option>
                                <option value="discover">Discover - Network discovery</option>
                                <option value="flyover">Flyover - Quick multi-target</option>
                                <option value="airstrike">Airstrike - Fast enumeration</option>
                                <option value="nuke">Nuke - Full aggressive audit</option>
                                <option value="massportscan">MassPortScan - Multi-target ports</option>
                                <option value="massweb">MassWeb - Multi-target web</option>
                                <option value="masswebscan">MassWebScan - Multi-target webapp</option>
                                <option value="massvulnscan">MassVulnScan - Multi-target vulns</option>
                            </select>
                        </div>

                        <!-- Workspace -->
                        <div class="form-group">
                            <label for="workspace">Workspace Name</label>
                            <input type="text" id="workspace" name="workspace" placeholder="project-alpha">
                        </div>

                        <!-- Port (for port modes) -->
                        <div class="form-group" id="port-group" style="display: none;">
                            <label for="port">Port Number</label>
                            <input type="number" id="port" name="port" min="1" max="65535" placeholder="8080">
                        </div>
                    </div>

                    <!-- Options -->
                    <div class="form-group full-width" style="margin-top: 1.5rem;">
                        <label>Additional Options</label>
                        <div class="checkbox-grid">
                            <label class="checkbox-item">
                                <input type="checkbox" name="osint" value="1">
                                <span>Enable OSINT</span>
                            </label>
                            <label class="checkbox-item">
                                <input type="checkbox" name="recon" value="1">
                                <span>Enable Recon</span>
                            </label>
                            <label class="checkbox-item">
                                <input type="checkbox" name="bruteforce" value="1">
                                <span>Enable Bruteforce</span>
                            </label>
                            <label class="checkbox-item">
                                <input type="checkbox" name="fullportscan" value="1">
                                <span>Full Port Scan</span>
                            </label>
                        </div>
                    </div>

                    <div class="btn-group">
                        <button type="submit" class="btn btn-primary">
                            <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/>
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
                            </svg>
                            Start Scan
                        </button>
                        <button type="reset" class="btn btn-secondary">Clear Form</button>
                    </div>
                </form>
            </div>
        </div>

        <!-- Workspaces Tab -->
        <div id="workspaces-tab" class="tab-content">
            <div class="card">
                <div class="card-header">
                    <svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"/>
                    </svg>
                    <h2>Workspaces</h2>
                </div>
                
                <div class="btn-group" style="margin-bottom: 1.5rem;">
                    <button class="btn btn-secondary" onclick="loadWorkspaces()">
                        Refresh List
                    </button>
                </div>

                <div id="workspace-list" class="workspace-list">
                    <p style="color: var(--text-secondary);">Loading workspaces...</p>
                </div>
            </div>
        </div>

        <!-- Console Tab -->
        <div id="console-tab" class="tab-content">
            <div class="card">
                <div class="card-header">
                    <svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                    </svg>
                    <h2>Console Output</h2>
                </div>
                
                <div id="console-output" class="console">UltyScan Web Interface v1.0
Ready to scan...</div>
                
                <div class="btn-group">
                    <button class="btn btn-secondary" onclick="document.getElementById('console-output').textContent = 'Console cleared.\n'">
                        Clear Console
                    </button>
                    <button class="btn btn-secondary" onclick="checkScanStatus()">
                        Refresh Status
                    </button>
                </div>
            </div>
        </div>

        <!-- Settings Tab -->
        <div id="settings-tab" class="tab-content">
            <div class="card">
                <div class="card-header">
                    <svg class="icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/>
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
                    </svg>
                    <h2>System Actions</h2>
                </div>

                <div class="btn-group">
                    <button class="btn btn-secondary" onclick="updateScanner()">
                        Update UltyScan
                    </button>
                    <button class="btn btn-danger" onclick="if(confirm('Stop all running scans?')) stopAllScans()">
                        Stop All Scans
                    </button>
                </div>

                <div style="margin-top: 2rem;">
                    <h3 style="margin-bottom: 1rem; font-size: 1rem;">Scanner Info</h3>
                    <p style="color: var(--text-secondary); font-size: 0.9rem;">
                        Install Directory: <code style="color: var(--accent-primary);">/usr/share/sniper</code><br>
                        Loot Directory: <code style="color: var(--accent-primary);">/usr/share/sniper/loot/workspace</code>
                    </p>
                </div>
            </div>
        </div>
    </div>

    <script src="assets/script.js"></script>
    <script>
        // Additional inline functions
        async function updateScanner() {
            if (!confirm('Update UltyScan? This may take a while.')) return;
            showNotification('Starting update...', 'info');
            try {
                const response = await fetch('execute.php', {
                    method: 'POST',
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    body: 'action=update'
                });
                const result = await response.json();
                if (result.success) {
                    showNotification('Update started. Check console for progress.', 'success');
                }
            } catch (e) {
                showNotification('Update failed.', 'error');
            }
        }
        
        async function stopAllScans() {
            try {
                await fetch('execute.php', {
                    method: 'POST',
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    body: 'action=stop'
                });
                showNotification('Stop signal sent.', 'warning');
                checkScanStatus();
            } catch (e) {
                showNotification('Failed to stop scans.', 'error');
            }
        }
    </script>
</body>
</html>
