// SPDX-License-Identifier: GPL-2.0-or-later // Copyright (C) 2026 Bryan Joshua Pedini import http from 'node:http'; const port = Number(process.env.ORIGIN2_PORT || 8081); const hits = []; const attackScript = ` const params = new URLSearchParams(location.search); const target = params.get('target'); const results = {}; async function probe(name, url, init) { try { const res = await fetch(url, init); results[name] = { type: res.type, status: res.status }; } catch (err) { results[name] = { error: String(err && err.message ? err.message : err) }; } } async function main() { await probe('create_zone_simple', target + '/api/v1/zones', { method: 'POST', mode: 'no-cors', credentials: 'include', headers: { 'Content-Type': 'text/plain' }, body: JSON.stringify({ name: params.get('zone'), ns: 'ns1.' + params.get('zone'), mbox: 'hostmaster@' + params.get('zone'), extra_ns: [], refresh: 3600, retry: 600, expire: 604800, minttl: 300, ttl: 3600 }) }); await probe('create_zone_cors', target + '/api/v1/zones', { method: 'POST', mode: 'cors', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: params.get('zone') }) }); await probe('read_zones', target + '/api/v1/zones', { method: 'GET', mode: 'cors', credentials: 'include' }); await probe('delete_user', target + '/api/v1/users/' + encodeURIComponent(params.get('victim') || 'nobody'), { method: 'DELETE', mode: 'no-cors', credentials: 'include', headers: { 'Content-Type': 'text/plain' }, body: JSON.stringify({ confirm: params.get('victim') }) }); document.getElementById('results').textContent = JSON.stringify(results); document.body.dataset.done = '1'; if (params.get('form') === 'logout') document.getElementById('logout').submit(); } main(); `; function attackPage(query) { const target = new URLSearchParams(query).get('target') || ''; const safeTarget = /^http:\/\/[a-z0-9-]+:[0-9]+$/.test(target) ? target : 'http://invalid.invalid'; return `